Change button colors to be palette aware.

Took 13 minutes


Took 41 seconds

Took 15 seconds
This commit is contained in:
Lukas Brübach 2026-04-19 10:12:08 +02:00
parent 58a8c7d3df
commit f21d61237a
5 changed files with 75 additions and 10 deletions

View file

@ -80,8 +80,21 @@ void VisualDatabaseDisplayFormatLegalityFilterWidget::createFormatButtons()
for (auto it = allFormatsWithCount.begin(); it != allFormatsWithCount.end(); ++it) {
auto *button = new QPushButton(it.key(), flowWidget);
button->setCheckable(true);
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
"QPushButton:checked { background-color: green; color: white; }");
QPalette pal = button->palette();
QString base = pal.button().color().name();
QString highlight = pal.highlight().color().name();
button->setStyleSheet(QString(R"(
QPushButton {
background-color: %1;
padding: 5px;
}
QPushButton:checked {
background-color: %2;
color: white;
}
)")
.arg(base, highlight));
flowWidget->addWidget(button);
formatButtons[it.key()] = button;

View file

@ -75,8 +75,21 @@ void VisualDatabaseDisplayMainTypeFilterWidget::createMainTypeButtons()
for (auto it = allMainCardTypesWithCount.begin(); it != allMainCardTypesWithCount.end(); ++it) {
auto *button = new QPushButton(it.key(), flowWidget);
button->setCheckable(true);
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
"QPushButton:checked { background-color: green; color: white; }");
QPalette pal = button->palette();
QString base = pal.button().color().name();
QString highlight = pal.highlight().color().name();
button->setStyleSheet(QString(R"(
QPushButton {
background-color: %1;
padding: 5px;
}
QPushButton:checked {
background-color: %2;
color: white;
}
)")
.arg(base, highlight));
flowWidget->addWidget(button);
typeButtons[it.key()] = button;

View file

@ -95,8 +95,21 @@ void VisualDatabaseDisplayNameFilterWidget::createNameFilter(const QString &name
// Create a button for the filter
auto *button = new QPushButton(name, flowWidget);
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
"QPushButton:hover { background-color: red; color: white; }");
QPalette pal = button->palette();
QString base = pal.button().color().name();
QString highlight = pal.highlight().color().name();
button->setStyleSheet(QString(R"(
QPushButton {
background-color: %1;
padding: 5px;
}
QPushButton:checked {
background-color: %2;
color: white;
}
)")
.arg(base, highlight));
connect(button, &QPushButton::clicked, this, [this, name]() {
removeNameFilter(name);

View file

@ -101,8 +101,21 @@ void VisualDatabaseDisplaySetFilterWidget::createSetButtons()
auto *button = new QPushButton(longName + " (" + shortName + ")", flowWidget);
button->setCheckable(true);
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
"QPushButton:checked { background-color: green; color: white; }");
QPalette pal = button->palette();
QString base = pal.button().color().name();
QString highlight = pal.highlight().color().name();
button->setStyleSheet(QString(R"(
QPushButton {
background-color: %1;
padding: 5px;
}
QPushButton:checked {
background-color: %2;
color: white;
}
)")
.arg(base, highlight));
flowWidget->addWidget(button);
setButtons[shortName] = button;

View file

@ -80,8 +80,21 @@ void VisualDatabaseDisplaySubTypeFilterWidget::createSubTypeButtons()
for (auto it = allSubCardTypesWithCount.begin(); it != allSubCardTypesWithCount.end(); ++it) {
auto *button = new QPushButton(it.key(), flowWidget);
button->setCheckable(true);
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
"QPushButton:checked { background-color: green; color: white; }");
QPalette pal = button->palette();
QString base = pal.button().color().name();
QString highlight = pal.highlight().color().name();
button->setStyleSheet(QString(R"(
QPushButton {
background-color: %1;
padding: 5px;
}
QPushButton:checked {
background-color: %2;
color: white;
}
)")
.arg(base, highlight));
flowWidget->addWidget(button);
typeButtons[it.key()] = button;