25 QPalette systemPalette;
31 QColor placeholderText;
33 QColor disabledButton;
39 bool isDarkSystemTheme = QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark;
41 UIUserInterfaceStyle style = isDarkSystemTheme ? UIUserInterfaceStyleDark : UIUserInterfaceStyleLight;
42 UITraitCollection *traitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:style];
44 window = qt_mac_toQColor([UIColor.systemGroupedBackgroundColor resolvedColorWithTraitCollection:traitCollection].CGColor);
45 base = qt_mac_toQColor([UIColor.secondarySystemGroupedBackgroundColor resolvedColorWithTraitCollection:traitCollection].CGColor);
46 text = qt_mac_toQColor([UIColor.labelColor resolvedColorWithTraitCollection:traitCollection].CGColor);
47 disabledText = qt_mac_toQColor([UIColor.tertiaryLabelColor resolvedColorWithTraitCollection:traitCollection].CGColor);
48 placeholderText = qt_mac_toQColor([UIColor.placeholderTextColor resolvedColorWithTraitCollection:traitCollection].CGColor);
49 button = qt_mac_toQColor([UIColor.systemBlueColor resolvedColorWithTraitCollection:traitCollection].CGColor);
50 disabledButton = qt_mac_toQColor([UIColor.tertiarySystemFillColor resolvedColorWithTraitCollection:traitCollection].CGColor);
51 white = qt_mac_toQColor([UIColor.whiteColor resolvedColorWithTraitCollection:traitCollection].CGColor);
52 lightGray = qt_mac_toQColor([UIColor.systemGray6Color resolvedColorWithTraitCollection:traitCollection].CGColor);
53 gray = qt_mac_toQColor([UIColor.opaqueSeparatorColor resolvedColorWithTraitCollection:traitCollection].CGColor);
54 darkGray = qt_mac_toQColor([UIColor.systemGrayColor resolvedColorWithTraitCollection:traitCollection].CGColor);
56 window = isDarkSystemTheme ? QColor(qRgba(0, 0, 0, 255)) : QColor(qRgba(242, 242, 247, 255));
57 base = isDarkSystemTheme ? QColor(qRgba(28, 28, 30, 255)) : QColor(Qt::white);
58 text = isDarkSystemTheme ? QColor(Qt::white) : QColor(Qt::black);
59 disabledText = isDarkSystemTheme ? QColor(qRgba(60, 60, 67, 76)) : QColor(qRgba(235, 235, 245, 76));
60 placeholderText = isDarkSystemTheme ? QColor(qRgba(235, 235, 245, 76)) : QColor(qRgba(60, 60, 67, 77));
61 button = isDarkSystemTheme ? QColor(qRgba(10, 132, 255, 255)) : QColor(qRgba(0, 122, 255, 255));
62 disabledButton = isDarkSystemTheme ? QColor(qRgba(118, 118, 128, 61)) : QColor(qRgba(118, 118, 128, 31));
63 white = QColor(Qt::white);
64 lightGray = isDarkSystemTheme ? QColor(qRgba(28, 28, 30, 255)) : QColor(qRgba(242, 242, 247, 255));
65 gray = isDarkSystemTheme ? QColor(qRgba(56, 56, 58, 255)) : QColor(qRgba(198, 198, 200, 2555));
66 darkGray = QColor(qRgba(142, 142, 147, 255));
68 systemPalette.setColor(QPalette::Window, window);
69 systemPalette.setColor(QPalette::Base, base);
71 systemPalette.setColor(QPalette::WindowText, text);
72 systemPalette.setColor(QPalette::Disabled, QPalette::WindowText, disabledText);
73 systemPalette.setColor(QPalette::Text, text);
74 systemPalette.setColor(QPalette::Disabled, QPalette::Text, disabledText);
75 systemPalette.setColor(QPalette::PlaceholderText, placeholderText);
77 systemPalette.setColor(QPalette::Button, button);
78 systemPalette.setColor(QPalette::Disabled, QPalette::Button, disabledButton);
79 systemPalette.setColor(QPalette::ButtonText, white);
80 systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText, disabledText);
82 systemPalette.setColor(QPalette::ToolTipText, text);
83 systemPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, disabledText);
85 systemPalette.setColor(QPalette::Highlight, button.lighter(115));
87 systemPalette.setColor(QPalette::Light, lightGray);
88 systemPalette.setColor(QPalette::Mid, gray);
89 systemPalette.setColor(QPalette::Dark, darkGray);
91 theme->setPalette(QQuickTheme::System, systemPalette);