Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickbasictheme.cpp
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
6
7#include <QtQuickTemplates2/private/qquicktheme_p.h>
8#include <QtQuickControls2/private/qquickstyle_p.h>
9
11
12void QQuickBasicTheme::initialize(QQuickTheme *theme)
13{
14 QPalette systemPalette;
15
16 const bool isDarkSystemTheme = QQuickStylePrivate::isDarkSystemTheme();
17
18 const QRgb base(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF);
19 const QRgb disabledBase(isDarkSystemTheme ? 0xFF292929 : 0xFFD6D6D6);
20 const QRgb button(isDarkSystemTheme ? 0xFF2F2F2F : 0xFFE0E0E0);
21 const QRgb buttonText(isDarkSystemTheme ? 0xFFD4D6D8 : 0xFF26282A);
22 const QRgb disabledButtonText(isDarkSystemTheme ? 0x4DD4D6D8 : 0x4D26282A);
23 const QRgb brightText(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF);
24 const QRgb disabledBrightText(isDarkSystemTheme ? 0x4D000000 : 0x4DFFFFFF);
25 const QRgb dark(isDarkSystemTheme ? 0xFFC8C9CB : 0xFF353637);
26 const QRgb highlight(isDarkSystemTheme ? 0xFF0D69F2 : 0xFF0066FF);
27 const QRgb disabledHighlight(isDarkSystemTheme ? 0xFF01060F : 0xFFF0F6FF);
28 const QRgb highlightedText(isDarkSystemTheme ? 0xFFFDFDFD : 0xFF090909);
29 const QRgb light(isDarkSystemTheme ? 0xFF1A1A1A : 0xFFF6F6F6);
30 const QRgb link(isDarkSystemTheme ? 0xFF2F86B1 : 0xFF45A7D7);
31 const QRgb mid(isDarkSystemTheme ? 0xFF626262 : 0xFFBDBDBD);
32 const QRgb midlight(isDarkSystemTheme ? 0xFF2C2C2C : 0xFFE4E4E4);
33 const QRgb text(isDarkSystemTheme ? 0xFFEFF0F2 : 0xFF353637);
34 const QRgb disabledText(isDarkSystemTheme ? 0x7FC8C9CB : 0x7F353637);
35 const QRgb shadow(0xFF28282A); // using the same color for dark and light
36 const QRgb toolTipBase(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF);
37 const QRgb toolTipText(isDarkSystemTheme ? 0xFFFFFFFF : 0xFF000000);
38 const QRgb window(isDarkSystemTheme ? 0xFF000000 : 0xFFFFFFFF);
39 const QRgb windowText(isDarkSystemTheme ? 0xFFD4D6D8 : 0xFF26282A);
40 const QRgb disabledWindowText(isDarkSystemTheme ? 0xFF3F4040 : 0xFFBDBEBF);
41 const QRgb placeholderText(isDarkSystemTheme ? 0x88C8C9CB : 0x88353637);
42
43 systemPalette.setColor(QPalette::Base, QColor::fromRgba(base));
44 systemPalette.setColor(QPalette::Disabled, QPalette::Base, QColor::fromRgba(disabledBase));
45
46 systemPalette.setColor(QPalette::Button, QColor::fromRgba(button));
47
48 systemPalette.setColor(QPalette::ButtonText, QColor::fromRgba(buttonText));
49 systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText,
50 QColor::fromRgba(disabledButtonText));
51
52 systemPalette.setColor(QPalette::BrightText, QColor::fromRgba(brightText));
53 systemPalette.setColor(QPalette::Disabled, QPalette::BrightText,
54 QColor::fromRgba(disabledBrightText));
55
56 systemPalette.setColor(QPalette::Dark, QColor::fromRgba(dark));
57
58 systemPalette.setColor(QPalette::Highlight, QColor::fromRgba(highlight));
59 systemPalette.setColor(QPalette::Disabled, QPalette::Highlight,
60 QColor::fromRgba(disabledHighlight));
61
62 systemPalette.setColor(QPalette::HighlightedText, QColor::fromRgba(highlightedText));
63
64 systemPalette.setColor(QPalette::Light, QColor::fromRgba(light));
65
66 systemPalette.setColor(QPalette::Link, QColor::fromRgba(link));
67
68 systemPalette.setColor(QPalette::Mid, QColor::fromRgba(mid));
69
70 systemPalette.setColor(QPalette::Midlight, QColor::fromRgba(midlight));
71
72 systemPalette.setColor(QPalette::Text, QColor::fromRgba(text));
73 systemPalette.setColor(QPalette::Disabled, QPalette::Text, QColor::fromRgba(disabledText));
74
75 systemPalette.setColor(QPalette::Shadow, QColor::fromRgba(shadow));
76
77 systemPalette.setColor(QPalette::ToolTipBase, QColor::fromRgba(toolTipBase));
78 systemPalette.setColor(QPalette::ToolTipText, QColor::fromRgba(toolTipText));
79
80 systemPalette.setColor(QPalette::Window, QColor::fromRgba(window));
81
82 systemPalette.setColor(QPalette::WindowText, QColor::fromRgba(windowText));
83 systemPalette.setColor(QPalette::Disabled, QPalette::WindowText,
84 QColor::fromRgba(disabledWindowText));
85
86 systemPalette.setColor(QPalette::PlaceholderText, QColor::fromRgba(placeholderText));
87
88 theme->setPalette(QQuickTheme::System, systemPalette);
89}
90
91void QQuickBasicTheme::updateTheme()
92{
93 QQuickTheme *theme = QQuickTheme::instance();
94 if (!theme)
95 return;
96 initialize(theme);
97}
98
99QT_END_NAMESPACE