mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Change button colors to be palette aware.
Took 13 minutes Took 41 seconds Took 15 seconds
This commit is contained in:
parent
58a8c7d3df
commit
f21d61237a
5 changed files with 75 additions and 10 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue