mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
Clean up filter layout, use mana symbols.
This commit is contained in:
parent
57edb03dc8
commit
33092e1406
2 changed files with 74 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "tab_archidekt.h"
|
#include "tab_archidekt.h"
|
||||||
|
|
||||||
|
#include "../../../cards/additional_info/mana_symbol_widget.h"
|
||||||
#include "../../tab_supervisor.h"
|
#include "../../tab_supervisor.h"
|
||||||
#include "api_response/archidekt_deck_listing_api_response.h"
|
#include "api_response/archidekt_deck_listing_api_response.h"
|
||||||
#include "display/archidekt_api_response_deck_display_widget.h"
|
#include "display/archidekt_api_response_deck_display_widget.h"
|
||||||
|
|
@ -82,21 +83,23 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
searchOptionsLayout = new QHBoxLayout(searchOptionsContainer);
|
searchOptionsLayout = new QHBoxLayout(searchOptionsContainer);
|
||||||
mainLayout->addWidget(searchOptionsContainer);
|
mainLayout->addWidget(searchOptionsContainer);
|
||||||
|
|
||||||
nameField = new QLineEdit(searchOptionsContainer);
|
// Colors
|
||||||
nameField->setPlaceholderText(tr("Deck name contains..."));
|
|
||||||
searchOptionsLayout->addWidget(nameField);
|
|
||||||
|
|
||||||
ownerField = new QLineEdit(searchOptionsContainer);
|
|
||||||
ownerField->setPlaceholderText(tr("Owner name contains..."));
|
|
||||||
searchOptionsLayout->addWidget(ownerField);
|
|
||||||
|
|
||||||
QHBoxLayout *colorLayout = new QHBoxLayout();
|
QHBoxLayout *colorLayout = new QHBoxLayout();
|
||||||
QStringList colors = {"White", "Blue", "Black", "Green", "Red", "Colorless"};
|
QString colorIdentity = "WUBRG"; // Optionally include "C" for colorless once we have a symbol for it
|
||||||
|
|
||||||
for (const auto &c : colors) {
|
for (const QChar &color : colorIdentity) {
|
||||||
QCheckBox *chk = new QCheckBox(c, searchOptionsContainer);
|
auto *manaSymbol = new ManaSymbolWidget(searchOptionsContainer, color, false, true);
|
||||||
colorChecks << chk;
|
manaSymbol->setFixedWidth(25);
|
||||||
colorLayout->addWidget(chk);
|
colorLayout->addWidget(manaSymbol);
|
||||||
|
|
||||||
|
connect(manaSymbol, &ManaSymbolWidget::colorToggled, this, [=](QChar c, bool active) {
|
||||||
|
if (active) {
|
||||||
|
activeColors.insert(c);
|
||||||
|
} else {
|
||||||
|
activeColors.remove(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
searchOptionsLayout->addLayout(colorLayout);
|
searchOptionsLayout->addLayout(colorLayout);
|
||||||
|
|
@ -104,7 +107,10 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
logicalAndCheck = new QCheckBox("Require ALL colors", searchOptionsContainer);
|
logicalAndCheck = new QCheckBox("Require ALL colors", searchOptionsContainer);
|
||||||
searchOptionsLayout->addWidget(logicalAndCheck);
|
searchOptionsLayout->addWidget(logicalAndCheck);
|
||||||
|
|
||||||
QHBoxLayout *formatLayout = new QHBoxLayout();
|
// Formats
|
||||||
|
|
||||||
|
auto formatSettingsWidget = new SettingsButtonWidget(this);
|
||||||
|
|
||||||
QStringList formatNames = {"Standard", "Modern", "Commander", "Legacy", "Vintage",
|
QStringList formatNames = {"Standard", "Modern", "Commander", "Legacy", "Vintage",
|
||||||
"Pauper", "Custom", "Frontier", "Future Std", "Penny Dreadful",
|
"Pauper", "Custom", "Frontier", "Future Std", "Penny Dreadful",
|
||||||
"1v1 Commander", "Dual Commander", "Brawl"};
|
"1v1 Commander", "Dual Commander", "Brawl"};
|
||||||
|
|
@ -112,24 +118,45 @@ TabArchidekt::TabArchidekt(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor)
|
||||||
for (int i = 0; i < formatNames.size(); ++i) {
|
for (int i = 0; i < formatNames.size(); ++i) {
|
||||||
QCheckBox *formatCheckBox = new QCheckBox(formatNames[i], searchOptionsContainer);
|
QCheckBox *formatCheckBox = new QCheckBox(formatNames[i], searchOptionsContainer);
|
||||||
formatChecks << formatCheckBox;
|
formatChecks << formatCheckBox;
|
||||||
formatLayout->addWidget(formatCheckBox);
|
formatSettingsWidget->addSettingsWidget(formatCheckBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
searchOptionsLayout->addLayout(formatLayout);
|
searchOptionsLayout->addWidget(formatSettingsWidget);
|
||||||
|
|
||||||
pageSizeSpin = new QSpinBox(searchOptionsContainer);
|
// Deck Name
|
||||||
pageSizeSpin->setRange(1, 500);
|
|
||||||
pageSizeSpin->setValue(50);
|
nameField = new QLineEdit(searchOptionsContainer);
|
||||||
searchOptionsLayout->addWidget(pageSizeSpin);
|
nameField->setPlaceholderText(tr("Deck name contains..."));
|
||||||
|
searchOptionsLayout->addWidget(nameField);
|
||||||
|
|
||||||
|
// Owner Name
|
||||||
|
|
||||||
|
ownerField = new QLineEdit(searchOptionsContainer);
|
||||||
|
ownerField->setPlaceholderText(tr("Owner name contains..."));
|
||||||
|
searchOptionsLayout->addWidget(ownerField);
|
||||||
|
|
||||||
|
// Contained cards
|
||||||
|
|
||||||
cardsField = new QLineEdit(searchOptionsContainer);
|
cardsField = new QLineEdit(searchOptionsContainer);
|
||||||
cardsField->setPlaceholderText("Cards (comma separated)");
|
cardsField->setPlaceholderText("Cards (comma separated)");
|
||||||
searchOptionsLayout->addWidget(cardsField);
|
searchOptionsLayout->addWidget(cardsField);
|
||||||
|
|
||||||
|
// Commanders
|
||||||
|
|
||||||
commandersField = new QLineEdit(searchOptionsContainer);
|
commandersField = new QLineEdit(searchOptionsContainer);
|
||||||
commandersField->setPlaceholderText("Commanders (comma separated)");
|
commandersField->setPlaceholderText("Commanders (comma separated)");
|
||||||
searchOptionsLayout->addWidget(commandersField);
|
searchOptionsLayout->addWidget(commandersField);
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
|
||||||
|
pageSizeLabel = new QLabel(searchOptionsContainer);
|
||||||
|
searchOptionsLayout->addWidget(pageSizeLabel);
|
||||||
|
|
||||||
|
pageSizeSpin = new QSpinBox(searchOptionsContainer);
|
||||||
|
pageSizeSpin->setRange(1, 200);
|
||||||
|
pageSizeSpin->setValue(50);
|
||||||
|
searchOptionsLayout->addWidget(pageSizeSpin);
|
||||||
|
|
||||||
settingsButton = new SettingsButtonWidget(this);
|
settingsButton = new SettingsButtonWidget(this);
|
||||||
|
|
||||||
cardSizeSlider = new CardSizeWidget(this);
|
cardSizeSlider = new CardSizeWidget(this);
|
||||||
|
|
@ -165,6 +192,7 @@ void TabArchidekt::retranslateUi()
|
||||||
decksPushButton->setText(tr("&Decks"));
|
decksPushButton->setText(tr("&Decks"));
|
||||||
searchBar->setPlaceholderText(tr("Search for a card ..."));
|
searchBar->setPlaceholderText(tr("Search for a card ..."));
|
||||||
searchPushButton->setText(tr("Search"));
|
searchPushButton->setText(tr("Search"));
|
||||||
|
pageSizeLabel->setText(tr("Max. Results:"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TabArchidekt::buildSearchUrl()
|
QString TabArchidekt::buildSearchUrl()
|
||||||
|
|
@ -176,9 +204,31 @@ QString TabArchidekt::buildSearchUrl()
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
QStringList selectedColors;
|
QStringList selectedColors;
|
||||||
for (auto *chk : colorChecks)
|
for (QChar c : activeColors) {
|
||||||
if (chk->isChecked())
|
switch (c.unicode()) {
|
||||||
selectedColors << chk->text();
|
case 'W':
|
||||||
|
selectedColors << "White";
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
selectedColors << "Blue";
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
selectedColors << "Black";
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
selectedColors << "Green";
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
selectedColors << "Red";
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
selectedColors << "Colorless";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!selectedColors.isEmpty())
|
if (!selectedColors.isEmpty())
|
||||||
query.addQueryItem("colors", selectedColors.join(","));
|
query.addQueryItem("colors", selectedColors.join(","));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,14 @@ private:
|
||||||
QLineEdit *ownerField; // Owner substring
|
QLineEdit *ownerField; // Owner substring
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
QVector<QCheckBox *> colorChecks; // White, Blue, Black, Green, Red, Colorless
|
QSet<QChar> activeColors;
|
||||||
QCheckBox *logicalAndCheck; // Require ALL colors instead of ANY
|
QCheckBox *logicalAndCheck; // Require ALL colors instead of ANY
|
||||||
|
|
||||||
// Formats
|
// Formats
|
||||||
QVector<QCheckBox *> formatChecks; // Format checkboxes (13 total)
|
QVector<QCheckBox *> formatChecks; // Format checkboxes (13 total)
|
||||||
|
|
||||||
// Page size
|
// Page size
|
||||||
|
QLabel *pageSizeLabel;
|
||||||
QSpinBox *pageSizeSpin;
|
QSpinBox *pageSizeSpin;
|
||||||
|
|
||||||
// Cards and Commanders
|
// Cards and Commanders
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue