mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Reduce allocations required for the palette
This commit is contained in:
parent
d8ead9573b
commit
812e3b5f03
1 changed files with 40 additions and 34 deletions
|
@ -12,42 +12,48 @@ Theme::paletteFromTheme(std::string_view theme)
|
||||||
[[maybe_unused]] static auto meta = qRegisterMetaType<Theme>("Theme");
|
[[maybe_unused]] static auto meta = qRegisterMetaType<Theme>("Theme");
|
||||||
static QPalette original;
|
static QPalette original;
|
||||||
if (theme == "light") {
|
if (theme == "light") {
|
||||||
QPalette lightActive(
|
static QPalette lightActive = [] {
|
||||||
/*windowText*/ QColor(0x33, 0x33, 0x33),
|
QPalette lightActive(
|
||||||
/*button*/ QColor(Qt::GlobalColor::white),
|
/*windowText*/ QColor(0x33, 0x33, 0x33),
|
||||||
/*light*/ QColor(0xef, 0xef, 0xef),
|
/*button*/ QColor(Qt::GlobalColor::white),
|
||||||
/*dark*/ QColor(70, 77, 93),
|
/*light*/ QColor(0xef, 0xef, 0xef),
|
||||||
/*mid*/ QColor(220, 220, 220),
|
/*dark*/ QColor(70, 77, 93),
|
||||||
/*text*/ QColor(0x33, 0x33, 0x33),
|
/*mid*/ QColor(220, 220, 220),
|
||||||
/*bright_text*/ QColor(0xf2, 0xf5, 0xf8),
|
/*text*/ QColor(0x33, 0x33, 0x33),
|
||||||
/*base*/ QColor(Qt::GlobalColor::white),
|
/*bright_text*/ QColor(0xf2, 0xf5, 0xf8),
|
||||||
/*window*/ QColor(Qt::GlobalColor::white));
|
/*base*/ QColor(Qt::GlobalColor::white),
|
||||||
lightActive.setColor(QPalette::AlternateBase, QColor(0xee, 0xee, 0xee));
|
/*window*/ QColor(Qt::GlobalColor::white));
|
||||||
lightActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
lightActive.setColor(QPalette::AlternateBase, QColor(0xee, 0xee, 0xee));
|
||||||
lightActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf4, 0xf5));
|
lightActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
||||||
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
|
lightActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf4, 0xf5));
|
||||||
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
|
lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color());
|
||||||
lightActive.setColor(QPalette::Link, QColor(0x00, 0x77, 0xb5));
|
lightActive.setColor(QPalette::ToolTipText, lightActive.text().color());
|
||||||
lightActive.setColor(QPalette::ButtonText, QColor(0x55, 0x54, 0x59));
|
lightActive.setColor(QPalette::Link, QColor(0x00, 0x77, 0xb5));
|
||||||
|
lightActive.setColor(QPalette::ButtonText, QColor(0x55, 0x54, 0x59));
|
||||||
|
return lightActive;
|
||||||
|
}();
|
||||||
return lightActive;
|
return lightActive;
|
||||||
} else if (theme == "dark") {
|
} else if (theme == "dark") {
|
||||||
QPalette darkActive(
|
static QPalette darkActive = [] {
|
||||||
/*windowText*/ QColor(0xca, 0xcc, 0xd1),
|
QPalette darkActive(
|
||||||
/*button*/ QColor(Qt::GlobalColor::white),
|
/*windowText*/ QColor(0xca, 0xcc, 0xd1),
|
||||||
/*light*/ QColor(0xca, 0xcc, 0xd1),
|
/*button*/ QColor(Qt::GlobalColor::white),
|
||||||
/*dark*/ QColor(60, 70, 77),
|
/*light*/ QColor(0xca, 0xcc, 0xd1),
|
||||||
/*mid*/ QColor(0x20, 0x22, 0x28),
|
/*dark*/ QColor(60, 70, 77),
|
||||||
/*text*/ QColor(0xca, 0xcc, 0xd1),
|
/*mid*/ QColor(0x20, 0x22, 0x28),
|
||||||
/*bright_text*/ QColor(0xf4, 0xf5, 0xf8),
|
/*text*/ QColor(0xca, 0xcc, 0xd1),
|
||||||
/*base*/ QColor(0x20, 0x22, 0x28),
|
/*bright_text*/ QColor(0xf4, 0xf5, 0xf8),
|
||||||
/*window*/ QColor(0x2d, 0x31, 0x39));
|
/*base*/ QColor(0x20, 0x22, 0x28),
|
||||||
darkActive.setColor(QPalette::AlternateBase, QColor(0x2d, 0x31, 0x39));
|
/*window*/ QColor(0x2d, 0x31, 0x39));
|
||||||
darkActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
darkActive.setColor(QPalette::AlternateBase, QColor(0x2d, 0x31, 0x39));
|
||||||
darkActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf5, 0xf8));
|
darkActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8));
|
||||||
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
|
darkActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf5, 0xf8));
|
||||||
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
|
darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color());
|
||||||
darkActive.setColor(QPalette::Link, QColor(0x38, 0xa3, 0xd8));
|
darkActive.setColor(QPalette::ToolTipText, darkActive.text().color());
|
||||||
darkActive.setColor(QPalette::ButtonText, QColor(0x82, 0x82, 0x84));
|
darkActive.setColor(QPalette::Link, QColor(0x38, 0xa3, 0xd8));
|
||||||
|
darkActive.setColor(QPalette::ButtonText, QColor(0x82, 0x82, 0x84));
|
||||||
|
return darkActive;
|
||||||
|
}();
|
||||||
return darkActive;
|
return darkActive;
|
||||||
} else {
|
} else {
|
||||||
return original;
|
return original;
|
||||||
|
|
Loading…
Reference in a new issue