aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/ios/qquickiostheme.mm
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-11-18 15:15:16 +0800
committerMitch Curtis <mitch.curtis@qt.io>2022-12-01 10:26:20 +0800
commit4bd87b903b355b53e3105ba1ae7c154c4e55cdaf (patch)
treecc2edb597f0d5871302eb86e9dda78217384a5aa /src/quickcontrols/ios/qquickiostheme.mm
parent786e1748d4469c135a922a221024f3f9c421c0de (diff)
Remove "2" from Qt Quick Controls directories
Qt Quick Controls 2 was named that way because it was a follow-up to Qt Quick Controls 1.x. Now that Qt Quick Controls 1 is no longer supported, we don't need to have "2" in the name. Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. By doing this renaming a few weeks before feature freeze, it won't affect the release but still results in as little time possible spent manually fixing conflicts in cherry-picks from non-LTS releases as a result of the renaming. This patch does the following: - Renames directories. - Adapts CMakeLists.txt and other files to account for the new paths. A follow-up patch will handle documentation. It does not touch library names or other user-facing stuff, as that will have to be done in Qt 7. Task-number: QTBUG-95413 Change-Id: I170d8db19033ee71e495ff0c5c1a517a41ed7634 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols/ios/qquickiostheme.mm')
-rw-r--r--src/quickcontrols/ios/qquickiostheme.mm82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/quickcontrols/ios/qquickiostheme.mm b/src/quickcontrols/ios/qquickiostheme.mm
new file mode 100644
index 0000000000..9c58e68d9d
--- /dev/null
+++ b/src/quickcontrols/ios/qquickiostheme.mm
@@ -0,0 +1,82 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qquickiostheme_p.h"
+
+#include <QtGui/private/qcoregraphics_p.h>
+
+#ifdef Q_OS_IOS
+#include <UIKit/UIInterface.h>
+#endif
+
+#include <QtQuickTemplates2/private/qquicktheme_p.h>
+#include <QtQuickControls2/private/qquickstyle_p.h>
+
+QT_BEGIN_NAMESPACE
+
+void QQuickIOSTheme::initialize(QQuickTheme *theme)
+{
+ QPalette systemPalette;
+
+ QColor window;
+ QColor windowText;
+ QColor background;
+ QColor placeholderText;
+ QColor button;
+ QColor disabledButton;
+ QColor white;
+ QColor lightGray;
+ QColor gray;
+ QColor darkGray;
+#ifdef Q_OS_IOS
+ window = qt_mac_toQColor(UIColor.systemGroupedBackgroundColor.CGColor);
+ windowText = qt_mac_toQColor(UIColor.labelColor.CGColor);
+ background = qt_mac_toQColor(UIColor.systemBackgroundColor.CGColor);
+ placeholderText = qt_mac_toQColor(UIColor.placeholderTextColor.CGColor);
+ button = qt_mac_toQColor(UIColor.systemBlueColor.CGColor);
+ disabledButton = qt_mac_toQColor(UIColor.tertiarySystemFillColor.CGColor);
+ white = qt_mac_toQColor(UIColor.whiteColor.CGColor);
+ lightGray = qt_mac_toQColor(UIColor.systemGray6Color.CGColor);
+ gray = qt_mac_toQColor(UIColor.opaqueSeparatorColor.CGColor);
+ darkGray = qt_mac_toQColor(UIColor.systemGrayColor.CGColor);
+#else
+ bool isDarkSystemTheme = QQuickStylePrivate::isDarkSystemTheme();
+ window = isDarkSystemTheme ? QColor(qRgba(0, 0, 0, 255)) : QColor(qRgba(242, 242, 247, 255));
+ windowText = isDarkSystemTheme ? QColor(Qt::white) : QColor(Qt::black);
+ background = isDarkSystemTheme ? QColor(Qt::black) : QColor(Qt::white);
+ placeholderText = isDarkSystemTheme ? QColor(qRgba(235, 235, 245, 77)) : QColor(qRgba(60, 60, 67, 77));
+ button = isDarkSystemTheme ? QColor(qRgba(10, 132, 255, 255)) : QColor(qRgba(0, 122, 255, 255));
+ disabledButton = isDarkSystemTheme ? QColor(qRgba(118, 118, 128, 61)) : QColor(qRgba(118, 118, 128, 31));
+ white = QColor(Qt::white);
+ lightGray = isDarkSystemTheme ? QColor(qRgba(28, 28, 30, 255)) : QColor(qRgba(242, 242, 247, 255));
+ gray = isDarkSystemTheme ? QColor(qRgba(56, 56, 58, 255)) : QColor(qRgba(198, 198, 200, 2555));
+ darkGray = QColor(qRgba(142, 142, 147, 255));
+#endif
+ systemPalette.setColor(QPalette::Window, window);
+
+ systemPalette.setColor(QPalette::Active, QPalette::WindowText, windowText);
+ systemPalette.setColor(QPalette::Disabled, QPalette::WindowText, darkGray);
+
+ systemPalette.setColor(QPalette::Base, background);
+
+ systemPalette.setColor(QPalette::PlaceholderText, placeholderText);
+
+ systemPalette.setColor(QPalette::Button, button);
+ systemPalette.setColor(QPalette::Disabled, QPalette::Button, disabledButton);
+
+ systemPalette.setColor(QPalette::ButtonText, white);
+ white.setAlphaF(0.5);
+ systemPalette.setColor(QPalette::Disabled, QPalette::ButtonText, white);
+
+ button.setAlphaF(0.8);
+ systemPalette.setColor(QPalette::Highlight, button);
+
+ systemPalette.setColor(QPalette::Light, lightGray);
+ systemPalette.setColor(QPalette::Mid, gray);
+ systemPalette.setColor(QPalette::Dark, darkGray);
+
+ theme->setPalette(QQuickTheme::System, systemPalette);
+}
+
+QT_END_NAMESPACE
+