| 1 | // SPDX-FileCopyrightText: Nheko Contributors |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "Theme.h" |
| 6 | |
| 7 | QPalette |
| 8 | Theme::paletteFromTheme(QStringView theme) |
| 9 | { |
| 10 | static QPalette original; |
| 11 | if (theme == u"light") { |
| 12 | static QPalette lightActive = [] { |
| 13 | QPalette lightActive( |
| 14 | /*windowText*/ QColor(0x33, 0x33, 0x33), |
| 15 | /*button*/ QColor(Qt::GlobalColor::white), |
| 16 | /*light*/ QColor(0xef, 0xef, 0xef), |
| 17 | /*dark*/ QColor(70, 77, 93), |
| 18 | /*mid*/ QColor(220, 220, 220), |
| 19 | /*text*/ QColor(0x33, 0x33, 0x33), |
| 20 | /*bright_text*/ QColor(0xf2, 0xf5, 0xf8), |
| 21 | /*base*/ QColor(Qt::GlobalColor::white), |
| 22 | /*window*/ QColor(Qt::GlobalColor::white)); |
| 23 | lightActive.setColor(QPalette::AlternateBase, QColor(0xee, 0xee, 0xee)); |
| 24 | lightActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8)); |
| 25 | lightActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf4, 0xf5)); |
| 26 | lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color()); |
| 27 | lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); |
| 28 | lightActive.setColor(QPalette::Link, QColor(0x00, 0x77, 0xb5)); |
| 29 | lightActive.setColor(QPalette::ButtonText, QColor(0x55, 0x54, 0x59)); |
| 30 | return lightActive; |
| 31 | }(); |
| 32 | return lightActive; |
| 33 | } else if (theme == u"dark") { |
| 34 | static QPalette darkActive = [] { |
| 35 | QPalette darkActive( |
| 36 | /*windowText*/ QColor(0xca, 0xcc, 0xd1), |
| 37 | /*button*/ QColor(Qt::GlobalColor::white), |
| 38 | /*light*/ QColor(0xca, 0xcc, 0xd1), |
| 39 | /*dark*/ QColor(60, 70, 77), |
| 40 | /*mid*/ QColor(0x20, 0x22, 0x28), |
| 41 | /*text*/ QColor(0xca, 0xcc, 0xd1), |
| 42 | /*bright_text*/ QColor(0xf4, 0xf5, 0xf8), |
| 43 | /*base*/ QColor(0x20, 0x22, 0x28), |
| 44 | /*window*/ QColor(0x2d, 0x31, 0x39)); |
| 45 | darkActive.setColor(QPalette::AlternateBase, QColor(0x2d, 0x31, 0x39)); |
| 46 | darkActive.setColor(QPalette::Highlight, QColor(0x38, 0xa3, 0xd8)); |
| 47 | darkActive.setColor(QPalette::HighlightedText, QColor(0xf4, 0xf5, 0xf8)); |
| 48 | darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color()); |
| 49 | darkActive.setColor(QPalette::ToolTipText, darkActive.text().color()); |
| 50 | darkActive.setColor(QPalette::Link, QColor(0x38, 0xa3, 0xd8)); |
| 51 | darkActive.setColor(QPalette::ButtonText, QColor(0x82, 0x82, 0x84)); |
| 52 | return darkActive; |
| 53 | }(); |
| 54 | return darkActive; |
| 55 | } else { |
| 56 | return original; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | Theme::Theme(QStringView theme) |
| 61 | { |
| 62 | auto p = paletteFromTheme(theme); |
| 63 | separator_ = p.mid().color(); |
| 64 | if (theme == u"light") { |
| 65 | sidebarBackground_ = QColor(0x23, 0x36, 0x49); |
| 66 | alternateButton_ = QColor(0xcc, 0xcc, 0xcc); |
| 67 | red_ = QColor(0xa8, 0x23, 0x53); |
| 68 | green_ = QColor(QColorConstants::Svg::green); |
| 69 | orange_ = QColor(0xfc, 0xbe, 0x05); |
| 70 | error_ = QColor(0xdd, 0x3d, 0x3d); |
| 71 | } else if (theme == u"dark") { |
| 72 | sidebarBackground_ = QColor(0x2d, 0x31, 0x39); |
| 73 | alternateButton_ = QColor(0x41, 0x4A, 0x59); |
| 74 | red_ = QColor(0xa8, 0x23, 0x53); |
| 75 | green_ = QColor(QColorConstants::Svg::green); |
| 76 | orange_ = QColor(0xfc, 0xc5, 0x3a); |
| 77 | error_ = QColor(0xdd, 0x3d, 0x3d); |
| 78 | } else { |
| 79 | sidebarBackground_ = p.window().color(); |
| 80 | alternateButton_ = p.dark().color(); |
| 81 | red_ = QColor(QColorConstants::Svg::red); |
| 82 | green_ = QColor(QColorConstants::Svg::green); |
| 83 | orange_ = QColor(QColorConstants::Svg::orange); // SVG orange |
| 84 | error_ = QColor(0xdd, 0x3d, 0x3d); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | #include "moc_Theme.cpp" |