mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add a style for disabled buttons (#6134)
* Disable view card database button until card db is loaded, add a new style for disabled buttons. Took 4 minutes Took 21 seconds * Lint. Took 8 minutes * Rename variables, don't disable DB button anymore. Took 4 minutes Took 4 seconds --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
ce6cad5dfe
commit
46285a499e
1 changed files with 29 additions and 13 deletions
|
|
@ -20,14 +20,22 @@ void HomeStyledButton::updateStylesheet(const QPair<QColor, QColor> &colors)
|
|||
|
||||
QString HomeStyledButton::generateButtonStylesheet(const QPair<QColor, QColor> &colors)
|
||||
{
|
||||
QColor base1 = colors.first;
|
||||
QColor base2 = colors.second;
|
||||
QColor baseGradientStart = colors.first;
|
||||
QColor baseGradientEnd = colors.second;
|
||||
|
||||
QColor hover1 = base1.lighter(120); // 20% lighter
|
||||
QColor hover2 = base2.lighter(120);
|
||||
QColor hoverGradientStart = baseGradientStart.lighter(120); // 20% lighter
|
||||
QColor hoverGradientEnd = baseGradientEnd.lighter(120);
|
||||
|
||||
QColor pressed1 = base1.darker(130); // 30% darker
|
||||
QColor pressed2 = base2.darker(130);
|
||||
QColor pressedGradientStart = baseGradientStart.darker(130); // 30% darker
|
||||
QColor pressedGradientEnd = baseGradientEnd.darker(130);
|
||||
|
||||
// Disabled: more gray, less saturated
|
||||
QColor disabledGradientStart = baseGradientStart.toHsv();
|
||||
disabledGradientStart.setHsv(disabledGradientStart.hue(), disabledGradientStart.saturation() * 0.2,
|
||||
disabledGradientStart.value() * 0.6);
|
||||
QColor disabledGradientEnd = baseGradientEnd.toHsv();
|
||||
disabledGradientEnd.setHsv(disabledGradientEnd.hue(), disabledGradientEnd.saturation() * 0.2,
|
||||
disabledGradientEnd.value() * 0.6);
|
||||
|
||||
return QString(R"(
|
||||
QPushButton {
|
||||
|
|
@ -47,14 +55,22 @@ QString HomeStyledButton::generateButtonStylesheet(const QPair<QColor, QColor> &
|
|||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
|
||||
stop:0 %6, stop:1 %7);
|
||||
}
|
||||
QPushButton:disabled {
|
||||
color: #aaaaaa;
|
||||
border: 2px solid #888888;
|
||||
background: qlineargradient(x1:0, y1:1, x2:0, y2:0,
|
||||
stop:0 %8, stop:1 %9);
|
||||
}
|
||||
)")
|
||||
.arg(base1.name()) // border color
|
||||
.arg(base1.name()) // normal gradient start
|
||||
.arg(base2.name()) // normal gradient end
|
||||
.arg(hover1.name()) // hover start
|
||||
.arg(hover2.name()) // hover end
|
||||
.arg(pressed1.name()) // pressed start
|
||||
.arg(pressed2.name()); // pressed end
|
||||
.arg(baseGradientStart.name())
|
||||
.arg(baseGradientStart.name())
|
||||
.arg(baseGradientEnd.name())
|
||||
.arg(hoverGradientStart.name())
|
||||
.arg(hoverGradientEnd.name())
|
||||
.arg(pressedGradientStart.name())
|
||||
.arg(pressedGradientEnd.name())
|
||||
.arg(disabledGradientStart.name())
|
||||
.arg(disabledGradientEnd.name());
|
||||
}
|
||||
|
||||
void HomeStyledButton::paintEvent(QPaintEvent *event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue