Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickiostheme.mm
Go to the documentation of this file.
1// Copyright (C) 2022 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 "qquickiostheme_p.h"
5
6#if defined(Q_OS_APPLE)
7#include <QtGui/private/qcoregraphics_p.h>
8#endif
9
10#ifdef Q_OS_IOS
11#include <UIKit/UIInterface.h>
12#endif
13
14#include <QtQuickTemplates2/private/qquicktheme_p.h>
15#include <QtQuickControls2/private/qquickstyle_p.h>
16
18
20{
21 QPalette systemPalette;
22
26 QColor disabledText;
27 QColor placeholderText;
29 QColor disabledButton;
30 QColor white;
31 QColor lightGray;
32 QColor gray;
33 QColor darkGray;
34#ifdef Q_OS_IOS
35 window = qt_mac_toQColor(UIColor.systemGroupedBackgroundColor.CGColor);
36 base = qt_mac_toQColor(UIColor.secondarySystemGroupedBackgroundColor.CGColor);
37 text = qt_mac_toQColor(UIColor.labelColor.CGColor);
38 disabledText = qt_mac_toQColor(UIColor.tertiaryLabelColor.CGColor);
39 placeholderText = qt_mac_toQColor(UIColor.placeholderTextColor.CGColor);
40 button = qt_mac_toQColor(UIColor.systemBlueColor.CGColor);
41 disabledButton = qt_mac_toQColor(UIColor.tertiarySystemFillColor.CGColor);
42 white = qt_mac_toQColor(UIColor.whiteColor.CGColor);
43 lightGray = qt_mac_toQColor(UIColor.systemGray6Color.CGColor);
44 gray = qt_mac_toQColor(UIColor.opaqueSeparatorColor.CGColor);
45 darkGray = qt_mac_toQColor(UIColor.systemGrayColor.CGColor);
46#else
47 bool isDarkSystemTheme = QQuickStylePrivate::isDarkSystemTheme();
48 window = isDarkSystemTheme ? QColor(qRgba(0, 0, 0, 255)) : QColor(qRgba(242, 242, 247, 255));
49 base = isDarkSystemTheme ? QColor(qRgba(28, 28, 30, 255)) : QColor(Qt::white);
50 text = isDarkSystemTheme ? QColor(Qt::white) : QColor(Qt::black);
51 disabledText = isDarkSystemTheme ? QColor(qRgba(60, 60, 67, 76)) : QColor(qRgba(235, 235, 245, 76));
52 placeholderText = isDarkSystemTheme ? QColor(qRgba(235, 235, 245, 76)) : QColor(qRgba(60, 60, 67, 77));
53 button = isDarkSystemTheme ? QColor(qRgba(10, 132, 255, 255)) : QColor(qRgba(0, 122, 255, 255));
54 disabledButton = isDarkSystemTheme ? QColor(qRgba(118, 118, 128, 61)) : QColor(qRgba(118, 118, 128, 31));
55 white = QColor(Qt::white);
56 lightGray = isDarkSystemTheme ? QColor(qRgba(28, 28, 30, 255)) : QColor(qRgba(242, 242, 247, 255));
57 gray = isDarkSystemTheme ? QColor(qRgba(56, 56, 58, 255)) : QColor(qRgba(198, 198, 200, 2555));
58 darkGray = QColor(qRgba(142, 142, 147, 255));
59#endif
60 systemPalette.setColor(QPalette::Window, window);
61 systemPalette.setColor(QPalette::Base, base);
62
63 systemPalette.setColor(QPalette::WindowText, text);
64 systemPalette.setColor(QPalette::Disabled, QPalette::WindowText, disabledText);
65 systemPalette.setColor(QPalette::Text, text);
66 systemPalette.setColor(QPalette::Disabled, QPalette::Text, disabledText);
67 systemPalette.setColor(QPalette::PlaceholderText, placeholderText);
68
69 systemPalette.setColor(QPalette::Button, button);
70 systemPalette.setColor(QPalette::Disabled, QPalette::Button, disabledButton);
71 systemPalette.setColor(QPalette::ButtonText, white);
72 systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledText);
73
74 systemPalette.setColor(QPalette::ToolTipText, text);
75 systemPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, disabledText);
76
77 systemPalette.setColor(QPalette::Highlight, button.lighter(115));
78
79 systemPalette.setColor(QPalette::Light, lightGray);
80 systemPalette.setColor(QPalette::Mid, gray);
81 systemPalette.setColor(QPalette::Dark, darkGray);
82
83 theme->setPalette(QQuickTheme::System, systemPalette);
84}
85
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
@ Disabled
Definition qpalette.h:49
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition qpalette.h:146
@ ButtonText
Definition qpalette.h:52
@ WindowText
Definition qpalette.h:51
@ Highlight
Definition qpalette.h:53
@ ToolTipText
Definition qpalette.h:57
@ PlaceholderText
Definition qpalette.h:58
static void initialize(QQuickTheme *theme)
static bool isDarkSystemTheme()
void setPalette(Scope scope, const QPalette &palette)
QString text
QPushButton * button
[2]
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:31
@ black
Definition qnamespace.h:30
QColor qt_mac_toQColor(CGColorRef color)
constexpr QRgb qRgba(int r, int g, int b, int a)
Definition qrgb.h:33
static const uint base
Definition qurlidna.cpp:20
aWidget window() -> setWindowTitle("New Window Title")
[2]