Included an Exclude button (ironic) on the Visual Deck Storage. (#7086)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run

This commit is contained in:
Galaxy 2026-08-08 20:20:47 -05:00 committed by GitHub
parent e65fcbfa7d
commit 46bdb6df32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 79 additions and 33 deletions

View file

@ -28,11 +28,10 @@ DeckPreviewColorIdentityFilterWidget::DeckPreviewColorIdentityFilterWidget(Visua
} }
toggleButton = new QPushButton(this); toggleButton = new QPushButton(this);
toggleButton->setCheckable(true);
layout->addWidget(toggleButton); layout->addWidget(toggleButton);
// Connect the button's toggled signal // Connect the button's clicked signal
connect(toggleButton, &QPushButton::toggled, this, &DeckPreviewColorIdentityFilterWidget::updateFilterMode); connect(toggleButton, &QPushButton::clicked, this, &DeckPreviewColorIdentityFilterWidget::updateFilterMode);
connect(this, &DeckPreviewColorIdentityFilterWidget::activeColorsChanged, parent, connect(this, &DeckPreviewColorIdentityFilterWidget::activeColorsChanged, parent,
&VisualDeckStorageWidget::updateColorFilter); &VisualDeckStorageWidget::updateColorFilter);
connect(this, &DeckPreviewColorIdentityFilterWidget::filterModeChanged, parent, connect(this, &DeckPreviewColorIdentityFilterWidget::filterModeChanged, parent,
@ -45,7 +44,17 @@ DeckPreviewColorIdentityFilterWidget::DeckPreviewColorIdentityFilterWidget(Visua
void DeckPreviewColorIdentityFilterWidget::retranslateUi() void DeckPreviewColorIdentityFilterWidget::retranslateUi()
{ {
// Set the toggle button text based on the current mode // Set the toggle button text based on the current mode
toggleButton->setText(exactMatchMode ? tr("Mode: Exact Match") : tr("Mode: Includes")); switch (filterMode) {
case ExactMatch:
toggleButton->setText(tr("Mode: Exact Match"));
break;
case Includes:
toggleButton->setText(tr("Mode: Includes"));
break;
case Excludes:
toggleButton->setText(tr("Mode: Excludes"));
break;
}
toggleButton->setToolTip(tr("Color identity filter mode (AND/OR/NOT conjunctions of filters)")); toggleButton->setToolTip(tr("Color identity filter mode (AND/OR/NOT conjunctions of filters)"));
} }
@ -55,11 +64,23 @@ void DeckPreviewColorIdentityFilterWidget::handleColorToggled(QChar color, bool
emit activeColorsChanged(); emit activeColorsChanged();
} }
void DeckPreviewColorIdentityFilterWidget::updateFilterMode(bool checked) void DeckPreviewColorIdentityFilterWidget::updateFilterMode()
{ {
exactMatchMode = checked; // Toggle between modes // Cycle through the modes
retranslateUi(); // Update the button text switch (filterMode) {
emit filterModeChanged(exactMatchMode); case ExactMatch:
filterMode = Includes;
break;
case Includes:
filterMode = Excludes;
break;
case Excludes:
filterMode = ExactMatch;
break;
}
retranslateUi(); // Update the button text
emit filterModeChanged(filterMode);
} }
void DeckPreviewColorIdentityFilterWidget::filterWidgets(QList<DeckPreviewWidget *> widgets) void DeckPreviewColorIdentityFilterWidget::filterWidgets(QList<DeckPreviewWidget *> widgets)
@ -78,41 +99,55 @@ void DeckPreviewColorIdentityFilterWidget::filterWidgets(QList<DeckPreviewWidget
for (DeckPreviewWidget *previewWidget : widgets) { for (DeckPreviewWidget *previewWidget : widgets) {
previewWidget->filteredByColor = false; previewWidget->filteredByColor = false;
} }
return;
} }
for (const auto &widget : widgets) { for (const auto &widget : widgets) {
QString colorIdentity = widget->getColorIdentity(); QString colorIdentity = widget->getColorIdentity();
bool matchesFilter = true; bool matchesFilter = true;
if (exactMatchMode) { switch (filterMode) {
// Exact match mode: active colors must exactly match colorIdentity case ExactMatch: {
// Exact match mode: active colors must exactly match colorIdentity
// Create a set of active colors // Create a set of active colors
QSet<QChar> activeColorSet; QSet<QChar> activeColorSet;
for (auto it = activeColors.constBegin(); it != activeColors.constEnd(); ++it) { for (auto it = activeColors.constBegin(); it != activeColors.constEnd(); ++it) {
if (it.value()) { if (it.value()) {
activeColorSet.insert(it.key().toUpper()); // Use uppercase for uniformity activeColorSet.insert(it.key().toUpper()); // Use uppercase for uniformity
}
} }
}
// Create a set of colors from the color identity string // Create a set of colors from the color identity string
QSet<QChar> colorIdentitySet; QSet<QChar> colorIdentitySet;
for (const QChar &color : colorIdentity) { for (const QChar &color : colorIdentity) {
colorIdentitySet.insert(color.toUpper()); // Ensure case uniformity colorIdentitySet.insert(color.toUpper()); // Ensure case uniformity
} }
// Compare the sets: the sets must match exactly // Compare the sets: the sets must match exactly
if (activeColorSet != colorIdentitySet) { if (activeColorSet != colorIdentitySet) {
matchesFilter = false;
}
} else {
// Includes mode: colorIdentity must contain all active colors
for (auto it = activeColors.constBegin(); it != activeColors.constEnd(); ++it) {
if (it.value() && !colorIdentity.contains(it.key())) {
matchesFilter = false; matchesFilter = false;
break;
} }
break;
} }
case Includes:
// Includes mode: colorIdentity must contain all active colors
for (auto it = activeColors.constBegin(); it != activeColors.constEnd(); ++it) {
if (it.value() && !colorIdentity.contains(it.key())) {
matchesFilter = false;
break;
}
}
break;
case Excludes:
// Excludes mode: colorIdentity must contain none of the active colors
for (auto it = activeColors.constBegin(); it != activeColors.constEnd(); ++it) {
if (it.value() && colorIdentity.contains(it.key())) {
matchesFilter = false;
break;
}
}
break;
} }
widget->filteredByColor = !matchesFilter; widget->filteredByColor = !matchesFilter;

View file

@ -21,23 +21,34 @@ class DeckPreviewColorIdentityFilterWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
/**
* How the active colors are matched against a deck's color identity.
*/
enum FilterMode
{
ExactMatch, ///< The color identity consists of exactly the active colors.
Includes, ///< The color identity contains all of the active colors.
Excludes ///< The color identity contains none of the active colors.
};
Q_ENUM(FilterMode)
explicit DeckPreviewColorIdentityFilterWidget(VisualDeckStorageWidget *parent); explicit DeckPreviewColorIdentityFilterWidget(VisualDeckStorageWidget *parent);
void retranslateUi(); void retranslateUi();
void filterWidgets(QList<DeckPreviewWidget *> widgets); void filterWidgets(QList<DeckPreviewWidget *> widgets);
signals: signals:
void filterModeChanged(bool exactMatchMode); void filterModeChanged(FilterMode mode);
void activeColorsChanged(); void activeColorsChanged();
private slots: private slots:
void handleColorToggled(QChar color, bool active); void handleColorToggled(QChar color, bool active);
void updateFilterMode(bool checked); void updateFilterMode();
private: private:
QHBoxLayout *layout; QHBoxLayout *layout;
QPushButton *toggleButton; QPushButton *toggleButton;
QMap<QChar, bool> activeColors; QMap<QChar, bool> activeColors;
bool exactMatchMode = false; // Default to "includes" mode FilterMode filterMode = Includes; // Default to "includes" mode
}; };
#endif // DECK_PREVIEW_COLOR_IDENTITY_FILTER_WIDGET_H #endif // DECK_PREVIEW_COLOR_IDENTITY_FILTER_WIDGET_H