| 1 | // Copyright (C) 2017 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qquickbasictheme_p.h" |
| 5 | |
| 6 | #include <QtQuickTemplates2/private/qquicktheme_p.h> |
| 7 | #include <QtQuickControls2/private/qquickstyle_p.h> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | void QQuickBasicTheme::initialize(QQuickTheme *theme) |
| 12 | { |
| 13 | QPalette systemPalette; |
| 14 | |
| 15 | const bool isDarkSystemTheme = QQuickStylePrivate::isDarkSystemTheme(); |
| 16 | |
| 17 | const QRgb base(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF); |
| 18 | const QRgb disabledBase(isDarkSystemTheme ? 0xFF292929 : 0xFFD6D6D6); |
| 19 | const QRgb button(isDarkSystemTheme ? 0xFF2F2F2F : 0xFFE0E0E0); |
| 20 | const QRgb buttonText(isDarkSystemTheme ? 0xFFD4D6D8 : 0xFF26282A); |
| 21 | const QRgb disabledButtonText(isDarkSystemTheme ? 0x4DD4D6D8 : 0x4D26282A); |
| 22 | const QRgb brightText(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF); |
| 23 | const QRgb disabledBrightText(isDarkSystemTheme ? 0x4D000000 : 0x4DFFFFFF); |
| 24 | const QRgb dark(isDarkSystemTheme ? 0xFFC8C9CB : 0xFF353637); |
| 25 | const QRgb highlight(isDarkSystemTheme ? 0xFF0D69F2 : 0xFF0066FF); |
| 26 | const QRgb disabledHighlight(isDarkSystemTheme ? 0xFF01060F : 0xFFF0F6FF); |
| 27 | const QRgb highlightedText(isDarkSystemTheme ? 0xFFFDFDFD : 0xFF090909); |
| 28 | const QRgb light(isDarkSystemTheme ? 0xFF1A1A1A : 0xFFF6F6F6); |
| 29 | const QRgb link(isDarkSystemTheme ? 0xFF2F86B1 : 0xFF45A7D7); |
| 30 | const QRgb mid(isDarkSystemTheme ? 0xFF626262 : 0xFFBDBDBD); |
| 31 | const QRgb midlight(isDarkSystemTheme ? 0xFF2C2C2C : 0xFFE4E4E4); |
| 32 | const QRgb text(isDarkSystemTheme ? 0xFFEFF0F2 : 0xFF353637); |
| 33 | const QRgb disabledText(isDarkSystemTheme ? 0x7FC8C9CB : 0x7F353637); |
| 34 | const QRgb shadow(0xFF28282A); // using the same color for dark and light |
| 35 | const QRgb toolTipBase(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF); |
| 36 | const QRgb toolTipText(isDarkSystemTheme ? 0xFFFFFFFF : 0xFF000000); |
| 37 | const QRgb window(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF); |
| 38 | const QRgb windowText(isDarkSystemTheme ? 0xFFD4D6D8 : 0xFF26282A); |
| 39 | const QRgb disabledWindowText(isDarkSystemTheme ? 0xFF3F4040 : 0xFFBDBEBF); |
| 40 | const QRgb placeholderText(isDarkSystemTheme ? 0x88C8C9CB : 0x88353637); |
| 41 | |
| 42 | systemPalette.setColor(acr: QPalette::Base, acolor: QColor::fromRgba(rgba: base)); |
| 43 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::Base, acolor: QColor::fromRgba(rgba: disabledBase)); |
| 44 | |
| 45 | systemPalette.setColor(acr: QPalette::Button, acolor: QColor::fromRgba(rgba: button)); |
| 46 | |
| 47 | systemPalette.setColor(acr: QPalette::ButtonText, acolor: QColor::fromRgba(rgba: buttonText)); |
| 48 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::ButtonText, |
| 49 | acolor: QColor::fromRgba(rgba: disabledButtonText)); |
| 50 | |
| 51 | systemPalette.setColor(acr: QPalette::BrightText, acolor: QColor::fromRgba(rgba: brightText)); |
| 52 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::BrightText, |
| 53 | acolor: QColor::fromRgba(rgba: disabledBrightText)); |
| 54 | |
| 55 | systemPalette.setColor(acr: QPalette::Dark, acolor: QColor::fromRgba(rgba: dark)); |
| 56 | |
| 57 | systemPalette.setColor(acr: QPalette::Highlight, acolor: QColor::fromRgba(rgba: highlight)); |
| 58 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::Highlight, |
| 59 | acolor: QColor::fromRgba(rgba: disabledHighlight)); |
| 60 | |
| 61 | systemPalette.setColor(acr: QPalette::HighlightedText, acolor: QColor::fromRgba(rgba: highlightedText)); |
| 62 | |
| 63 | systemPalette.setColor(acr: QPalette::Light, acolor: QColor::fromRgba(rgba: light)); |
| 64 | |
| 65 | systemPalette.setColor(acr: QPalette::Link, acolor: QColor::fromRgba(rgba: link)); |
| 66 | |
| 67 | systemPalette.setColor(acr: QPalette::Mid, acolor: QColor::fromRgba(rgba: mid)); |
| 68 | |
| 69 | systemPalette.setColor(acr: QPalette::Midlight, acolor: QColor::fromRgba(rgba: midlight)); |
| 70 | |
| 71 | systemPalette.setColor(acr: QPalette::Text, acolor: QColor::fromRgba(rgba: text)); |
| 72 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::Text, acolor: QColor::fromRgba(rgba: disabledText)); |
| 73 | |
| 74 | systemPalette.setColor(acr: QPalette::Shadow, acolor: QColor::fromRgba(rgba: shadow)); |
| 75 | |
| 76 | systemPalette.setColor(acr: QPalette::ToolTipBase, acolor: QColor::fromRgba(rgba: toolTipBase)); |
| 77 | systemPalette.setColor(acr: QPalette::ToolTipText, acolor: QColor::fromRgba(rgba: toolTipText)); |
| 78 | |
| 79 | systemPalette.setColor(acr: QPalette::Window, acolor: QColor::fromRgba(rgba: window)); |
| 80 | |
| 81 | systemPalette.setColor(acr: QPalette::WindowText, acolor: QColor::fromRgba(rgba: windowText)); |
| 82 | systemPalette.setColor(acg: QPalette::Disabled, acr: QPalette::WindowText, |
| 83 | acolor: QColor::fromRgba(rgba: disabledWindowText)); |
| 84 | |
| 85 | systemPalette.setColor(acr: QPalette::PlaceholderText, acolor: QColor::fromRgba(rgba: placeholderText)); |
| 86 | |
| 87 | theme->setPalette(scope: QQuickTheme::System, palette: systemPalette); |
| 88 | } |
| 89 | |
| 90 | void QQuickBasicTheme::updateTheme() |
| 91 | { |
| 92 | QQuickTheme *theme = QQuickTheme::instance(); |
| 93 | if (!theme) |
| 94 | return; |
| 95 | initialize(theme); |
| 96 | } |
| 97 | |
| 98 | QT_END_NAMESPACE |
| 99 | |