diff options
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/CMakeLists.txt | 44 | ||||
-rw-r--r-- | src/quickcontrols2/configure.cmake | 62 | ||||
-rw-r--r-- | src/quickcontrols2/configure.json | 76 | ||||
-rw-r--r-- | src/quickcontrols2/qquickdummyregistration_p.h | 71 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 505 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyle.h | 56 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyle_p.h | 80 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 151 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin_p.h | 80 | ||||
-rw-r--r-- | src/quickcontrols2/qt_cmdline.cmake | 6 | ||||
-rw-r--r-- | src/quickcontrols2/qtquickcontrols2global.h | 58 |
11 files changed, 0 insertions, 1189 deletions
diff --git a/src/quickcontrols2/CMakeLists.txt b/src/quickcontrols2/CMakeLists.txt deleted file mode 100644 index fb3bf748..00000000 --- a/src/quickcontrols2/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Generated from quickcontrols2.pro. - -##################################################################### -## QuickControls2 Module: -##################################################################### - -qt_internal_add_module(QuickControls2 - GENERATE_METATYPES - SOURCES - qquickdummyregistration_p.h - qquickstyle.cpp qquickstyle.h qquickstyle_p.h - qquickstyleplugin.cpp qquickstyleplugin_p.h - qtquickcontrols2global.h - DEFINES - QT_NO_CAST_FROM_ASCII - QT_NO_CAST_TO_ASCII - LIBRARIES - Qt::CorePrivate - Qt::GuiPrivate - Qt::QmlPrivate - Qt::QuickPrivate - Qt::QuickTemplates2Private - PUBLIC_LIBRARIES - Qt::Core - Qt::Gui - Qt::Quick -) - -#### Keys ignored in scope 1:.:.:quickcontrols2.pro:<TRUE>: -# MODULE = "quickcontrols2" -# QMLTYPES_FILENAME = "plugins.qmltypes" -# QMLTYPES_INSTALL_DIR = "$$[QT_INSTALL_QML]/QtQuick/Controls" -# QML_IMPORT_NAME = "QtQuick.Controls" -# QML_IMPORT_VERSION = "$$QT_VERSION" - -set_target_properties(QuickControls2 PROPERTIES - QT_QML_MODULE_INSTALL_QMLTYPES TRUE - QT_QML_MODULE_VERSION ${PROJECT_VERSION} - QT_QML_MODULE_URI QtQuick.Controls - QT_QMLTYPES_FILENAME plugins.qmltypes - QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtQuick/Controls" -) - -qt6_qml_type_registration(QuickControls2) diff --git a/src/quickcontrols2/configure.cmake b/src/quickcontrols2/configure.cmake deleted file mode 100644 index f996cf28..00000000 --- a/src/quickcontrols2/configure.cmake +++ /dev/null @@ -1,62 +0,0 @@ - - -#### Inputs - - - -#### Libraries - - - -#### Tests - - - -#### Features - -qt_feature("quickcontrols2-basic" PRIVATE - LABEL "Basic" -) -qt_feature("quickcontrols2-fusion" PRIVATE - SECTION "Quick Controls 2" - LABEL "Fusion" - PURPOSE "Provides the platform agnostic desktop-oriented Fusion style." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_feature("quickcontrols2-imagine" PRIVATE - SECTION "Quick Controls 2" - LABEL "Imagine" - PURPOSE "Provides a style based on configurable image assets." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_feature("quickcontrols2-material" PRIVATE - SECTION "Quick Controls 2" - LABEL "Material" - PURPOSE "Provides a style based on the Material Design guidelines." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_feature("quickcontrols2-universal" PRIVATE - SECTION "Quick Controls 2" - LABEL "Universal" - PURPOSE "Provides a style based on the Universal Design guidelines." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_feature("quickcontrols2-macos" PRIVATE - SECTION "Quick Controls 2" - LABEL "macOS" - PURPOSE "Provides a native macOS desktop style." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_feature("quickcontrols2-windows" PRIVATE - SECTION "Quick Controls 2" - LABEL "Windows" - PURPOSE "Provides a native Windows desktop style." - CONDITION QT_FEATURE_quickcontrols2_basic -) -qt_configure_add_summary_section(NAME "Qt Quick Controls 2") -qt_configure_add_summary_entry( - TYPE "featureList" - ARGS "quickcontrols2-basic quickcontrols2-fusion quickcontrols2-imagine quickcontrols2-material quickcontrols2-universal quickcontrols2-macos quickcontrols2-windows" - MESSAGE "Styles" -) -qt_configure_end_summary_section() # end of "Qt Quick Controls 2" section diff --git a/src/quickcontrols2/configure.json b/src/quickcontrols2/configure.json deleted file mode 100644 index ffefe17a..00000000 --- a/src/quickcontrols2/configure.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "module": "quickcontrols2", - - "commandline": { - "options": { - "style-fusion": { "type": "boolean", "name": "quickcontrols2-fusion" }, - "style-imagine": { "type": "boolean", "name": "quickcontrols2-imagine" }, - "style-material": { "type": "boolean", "name": "quickcontrols2-material" }, - "style-universal": { "type": "boolean", "name": "quickcontrols2-universal" }, - "style-macos": { "type": "boolean", "name": "quickcontrols2-macos" }, - "style-windows": { "type": "boolean", "name": "quickcontrols2-windows" } - } - }, - - "features": { - "quickcontrols2-basic": { - "label": "Basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-fusion": { - "label": "Fusion", - "purpose": "Provides the platform agnostic desktop-oriented Fusion style.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-imagine": { - "label": "Imagine", - "purpose": "Provides a style based on configurable image assets.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-material": { - "label": "Material", - "purpose": "Provides a style based on the Material Design guidelines.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-universal": { - "label": "Universal", - "purpose": "Provides a style based on the Universal Design guidelines.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-macos": { - "label": "macOS", - "purpose": "Provides a native macOS desktop style.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - }, - "quickcontrols2-windows": { - "label": "Windows", - "purpose": "Provides a native Windows desktop style.", - "section": "Quick Controls 2", - "condition": "features.quickcontrols2-basic", - "output": [ "privateFeature" ] - } - }, - - "summary": [ - { - "section": "Qt Quick Controls 2", - "entries": [ - { - "message": "Styles", - "type": "featureList", - "args": "quickcontrols2-basic quickcontrols2-fusion quickcontrols2-imagine quickcontrols2-material quickcontrols2-universal quickcontrols2-macos quickcontrols2-windows" - } - ] - } - ] -} diff --git a/src/quickcontrols2/qquickdummyregistration_p.h b/src/quickcontrols2/qquickdummyregistration_p.h deleted file mode 100644 index 0d3b34a8..00000000 --- a/src/quickcontrols2/qquickdummyregistration_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKDUMMYREGISTRATION_H -#define QQUICKDUMMYREGISTRATION_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQml/qqml.h> -// Ensure that the generated qmltyperegistrations .cpp file includes this header -// by including it here. Otherwise, the qtquickcontrols2plugin will fail to load -// due to the type registration function's symbol being undefined. -#include <QtQuickControls2/qtquickcontrols2global.h> - -QT_BEGIN_NAMESPACE - -// QtQuick.Controls has no types, so if we didn't have this dummy type, -// we'd have no way of specifying the version when the module was added, -// and 6.0 would be the only version that gets registered: QTBUG-85151 -struct QQuickDummyType -{ - Q_GADGET - QML_ANONYMOUS - QML_ADDED_IN_VERSION(2, 0) -}; - -QT_END_NAMESPACE - -#endif // QQUICKDUMMYREGISTRATION_H diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp deleted file mode 100644 index 7c403529..00000000 --- a/src/quickcontrols2/qquickstyle.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickstyle.h" -#include "qquickstyle_p.h" - -#include <QtCore/qdir.h> -#include <QtCore/qfile.h> -#include <QtCore/qdebug.h> -#include <QtCore/qsettings.h> -#include <QtCore/qfileselector.h> -#include <QtCore/qlibraryinfo.h> -#include <QtCore/qloggingcategory.h> -#include <QtCore/qmetaobject.h> -#include <QtGui/qcolor.h> -#include <QtGui/qfont.h> -#include <QtGui/qpalette.h> -#include <QtGui/private/qguiapplication_p.h> -#include <QtGui/qpa/qplatformtheme.h> -#include <QtQml/private/qqmlmetatype_p.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlfile.h> - -#include <functional> - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcQtQuickControlsStyle, "qt.quick.controls.style") - -/*! - \class QQuickStyle - \brief The QQuickStyle class allows configuring the application style. - \inmodule QtQuickControls2 - \since 5.7 - - QQuickStyle provides API for querying and configuring the application - \l {Styling Qt Quick Controls}{styles} of Qt Quick Controls. - - \code - #include <QGuiApplication> - #include <QQmlApplicationEngine> - #include <QQuickStyle> - - int main(int argc, char *argv[]) - { - QGuiApplication app(argc, argv); - - QQuickStyle::setStyle("Material"); - - QQmlApplicationEngine engine; - engine.load(QUrl("qrc:/main.qml")); - - return app.exec(); - } - \endcode - - \note The style must be configured \b before loading QML that imports - Qt Quick Controls. It is not possible to change the style after the QML - types have been registered. - - \note QQuickStyle is not supported when using - \l {Compile-Time Style Selection}{compile-time style selection}. - - To create your own custom style, see \l {Creating a Custom Style}. Custom - styles do not need to implement all controls. By default, the styling - system uses the \l {Basic style} as a fallback for controls that a custom - style does not provide. It is possible to specify a different fallback - style to customize or extend one of the built-in styles. - - \code - QQuickStyle::setStyle("MyStyle"); - QQuickStyle::setFallbackStyle("Material"); - \endcode - - \sa {Styling Qt Quick Controls} -*/ - -struct QQuickStyleSpec -{ - QQuickStyleSpec() { } - - QString name() - { - if (!resolved) - resolve(); - return style.mid(style.lastIndexOf(QLatin1Char('/')) + 1); - } - - QString path() - { - if (!resolved) - resolve(); - QString s = style; - if (QQmlFile::isLocalFile(s)) - s = QQmlFile::urlToLocalFileOrQrc(s); - return s.left(s.lastIndexOf(QLatin1Char('/')) + 1); - } - - void setStyle(const QString &s) - { - qCDebug(lcQtQuickControlsStyle) << "style" << s << "set on QQuickStyleSpec"; - if (s.contains(QLatin1Char('/'))) { - qWarning() << "Style names must not contain paths; see the \"Definition of a Style\" documentation for more information"; - return; - } - - qCDebug(lcQtQuickControlsStyle) << "clearing resolved flag and resolving"; - style = s; - resolved = false; - resolve(); - } - - void setFallbackStyle(const QString &fallback, const QByteArray &method) - { - if (!fallback.isEmpty()) - qCDebug(lcQtQuickControlsStyle) << "fallback style" << fallback << "set on QQuickStyleSpec via" << method; - - fallbackStyle = fallback; - fallbackMethod = method; - } - - void resolve() - { - qCDebug(lcQtQuickControlsStyle) << "resolving style"; - - if (style.isEmpty()) - style = QGuiApplicationPrivate::styleOverride; - if (style.isEmpty()) - style = QString::fromLocal8Bit(qgetenv("QT_QUICK_CONTROLS_STYLE")); - if (fallbackStyle.isEmpty()) - setFallbackStyle(QString::fromLocal8Bit(qgetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE")), "QT_QUICK_CONTROLS_FALLBACK_STYLE"); -#if QT_CONFIG(settings) - if (style.isEmpty() || fallbackStyle.isEmpty()) { - QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(QStringLiteral("Controls")); - if (settings) { - if (style.isEmpty()) - style = settings->value(QStringLiteral("Style")).toString(); - if (fallbackStyle.isEmpty()) - setFallbackStyle(settings->value(QStringLiteral("FallbackStyle")).toString(), ":/qtquickcontrols2.conf"); - } - } -#endif - - auto builtInStyleList = QQuickStylePrivate::builtInStyles(); - if (!fallbackStyle.isEmpty() && !builtInStyleList.contains(fallbackStyle)) { - qWarning().nospace().noquote() << fallbackMethod << ": the specified fallback style \"" << - fallbackStyle << "\" is not one of the built-in Qt Quick Controls 2 styles"; - fallbackStyle.clear(); - } - - // Find the config file. - resolveConfigFilePath(); - - usingDefaultStyle = false; - - if (style.isEmpty() || style.toLower() == QStringLiteral("default")) { - usingDefaultStyle = true; - style.clear(); - - qCDebug(lcQtQuickControlsStyle) << "no style (or Default) was specified;" - << "checking if we have an appropriate style for this platform"; -#if defined(Q_OS_MACOS) - style = QLatin1String("macOS"); -#elif defined(Q_OS_WINDOWS) - style = QLatin1String("Windows"); -#elif defined(Q_OS_ANDROID) - style = QLatin1String("Material"); -#elif defined(Q_OS_LINUX) - style = QLatin1String("Fusion"); -#endif - if (!style.isEmpty()) - qCDebug(lcQtQuickControlsStyle) << "using" << style << "as a default"; - else - qCDebug(lcQtQuickControlsStyle) << "no appropriate style found; using Basic as a default"; - } - - // If it's still empty by this point, then it means we have no native style available for this platform, - // as is the case on e.g. embedded. In that case, we want to default to the Basic style, - // which is what effectiveStyleName() returns when "style" is empty. - custom = !builtInStyleList.contains(QQuickStylePrivate::effectiveStyleName(style)); - - resolved = true; - - qCDebug(lcQtQuickControlsStyle).nospace() << "done resolving:" - << "\n style=" << style - << "\n custom=" << custom - << "\n resolved=" << resolved - << "\n fallbackStyle=" << fallbackStyle - << "\n fallbackMethod=" << fallbackMethod - << "\n configFilePath=" << configFilePath; - } - - void reset() - { - qCDebug(lcQtQuickControlsStyle) << "resetting values to their defaults"; - - custom = false; - resolved = false; - usingDefaultStyle = false; - style.clear(); - fallbackStyle.clear(); - fallbackMethod.clear(); - configFilePath.clear(); - } - - QString resolveConfigFilePath() - { - if (configFilePath.isEmpty()) { - configFilePath = QFile::decodeName(qgetenv("QT_QUICK_CONTROLS_CONF")); - if (configFilePath.isEmpty() || !QFile::exists(configFilePath)) { - if (!configFilePath.isEmpty()) - qWarning("QT_QUICK_CONTROLS_CONF=%s: No such file", qPrintable(configFilePath)); - - configFilePath = QStringLiteral(":/qtquickcontrols2.conf"); - } - } - return configFilePath; - } - - // Is this a custom style defined by the user and not "built-in" style? - bool custom = false; - // Have we resolved the style yet? - bool resolved = false; - // Are we using the default style for this platform (because no style was specified)? - bool usingDefaultStyle = false; - // The name of the style. - QString style; - // The built-in style to use if the requested style cannot be found. - QString fallbackStyle; - // A description of the way in which fallbackStyle was set, used in e.g. warning messages shown to the user. - QByteArray fallbackMethod; - // The path to the qtquickcontrols2.conf file. - QString configFilePath; -}; - -Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec) - -/* - Note that most of these functions (with the exception of e.g. isResolved()) - should not be called before the style has been resolved, as it's only after - that happens that they will have been set. -*/ -QString QQuickStylePrivate::style() -{ - return styleSpec()->style; -} - -QString QQuickStylePrivate::effectiveStyleName(const QString &styleName) -{ - return !styleName.isEmpty() ? styleName : QLatin1String("Basic"); -} - -QString QQuickStylePrivate::fallbackStyle() -{ - return styleSpec()->fallbackStyle; -} - -bool QQuickStylePrivate::isCustomStyle() -{ - return styleSpec()->custom; -} - -bool QQuickStylePrivate::isResolved() -{ - return styleSpec()->resolved; -} - -bool QQuickStylePrivate::isUsingDefaultStyle() -{ - return styleSpec()->usingDefaultStyle; -} - -void QQuickStylePrivate::init() -{ - QQuickStyleSpec *spec = styleSpec(); - spec->resolve(); -} - -void QQuickStylePrivate::reset() -{ - if (styleSpec()) - styleSpec()->reset(); -} - -QString QQuickStylePrivate::configFilePath() -{ - return styleSpec()->resolveConfigFilePath(); -} - -QSharedPointer<QSettings> QQuickStylePrivate::settings(const QString &group) -{ -#ifndef QT_NO_SETTINGS - const QString filePath = QQuickStylePrivate::configFilePath(); - if (QFile::exists(filePath)) { - QFileSelector selector; - QSettings *settings = new QSettings(selector.select(filePath), QSettings::IniFormat); - if (!group.isEmpty()) - settings->beginGroup(group); - return QSharedPointer<QSettings>(settings); - } -#endif // QT_NO_SETTINGS - return QSharedPointer<QSettings>(); -} - -#if QT_CONFIG(settings) -static void readValue(const QSharedPointer<QSettings> &settings, const QString &name, std::function<void(const QVariant &)> setValue) -{ - const QVariant var = settings->value(name); - if (var.isValid()) - setValue(var); -} - -template <typename Enum> -static Enum toEnumValue(const QVariant &var) -{ - // ### TODO: expose QFont enums to the meta object system using Q_ENUM - //QMetaEnum enumeration = QMetaEnum::fromType<Enum>(); - //bool ok = false; - //int value = enumeration.keyToValue(var.toByteArray(), &ok); - //if (!ok) - // value = var.toInt(); - //return static_cast<Enum>(value); - - return static_cast<Enum>(var.toInt()); -} - -const QFont *QQuickStylePrivate::readFont(const QSharedPointer<QSettings> &settings) -{ - const QVariant var = settings->value(QStringLiteral("Font")); - if (var.isValid()) - return new QFont(var.value<QFont>()); - - QFont f; - settings->beginGroup(QStringLiteral("Font")); - readValue(settings, QStringLiteral("Family"), [&f](const QVariant &var) { f.setFamilies(QStringList{var.toString()}); }); - readValue(settings, QStringLiteral("PointSize"), [&f](const QVariant &var) { f.setPointSizeF(var.toReal()); }); - readValue(settings, QStringLiteral("PixelSize"), [&f](const QVariant &var) { f.setPixelSize(var.toInt()); }); - readValue(settings, QStringLiteral("StyleHint"), [&f](const QVariant &var) { f.setStyleHint(toEnumValue<QFont::StyleHint>(var.toInt())); }); - readValue(settings, QStringLiteral("Weight"), [&f](const QVariant &var) { f.setWeight(toEnumValue<QFont::Weight>(var)); }); - readValue(settings, QStringLiteral("Style"), [&f](const QVariant &var) { f.setStyle(toEnumValue<QFont::Style>(var.toInt())); }); - settings->endGroup(); - return new QFont(f); -} - -static void readColorGroup(const QSharedPointer<QSettings> &settings, QPalette::ColorGroup group, QPalette *palette) -{ - const QStringList keys = settings->childKeys(); - if (keys.isEmpty()) - return; - - static const int index = QPalette::staticMetaObject.indexOfEnumerator("ColorRole"); - Q_ASSERT(index != -1); - QMetaEnum metaEnum = QPalette::staticMetaObject.enumerator(index); - - for (const QString &key : keys) { - bool ok = false; - int role = metaEnum.keyToValue(key.toUtf8(), &ok); - if (ok) - palette->setColor(group, static_cast<QPalette::ColorRole>(role), settings->value(key).value<QColor>()); - } -} - -const QPalette *QQuickStylePrivate::readPalette(const QSharedPointer<QSettings> &settings) -{ - QPalette p; - settings->beginGroup(QStringLiteral("Palette")); - readColorGroup(settings, QPalette::All, &p); - - settings->beginGroup(QStringLiteral("Normal")); - readColorGroup(settings, QPalette::Normal, &p); - settings->endGroup(); - - settings->beginGroup(QStringLiteral("Disabled")); - readColorGroup(settings, QPalette::Disabled, &p); - settings->endGroup(); - return new QPalette(p); -} -#endif // QT_CONFIG(settings) - -static bool qt_is_dark_system_theme() -{ - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { - if (const QPalette *systemPalette = theme->palette(QPlatformTheme::SystemPalette)) { - const QColor &textColor = systemPalette->color(QPalette::WindowText); - return textColor.red() > 128 && textColor.blue() > 128 && textColor.green() > 128; - } - } - return false; -} - -bool QQuickStylePrivate::isDarkSystemTheme() -{ - static bool dark = qt_is_dark_system_theme(); - return dark; -} - -QStringList QQuickStylePrivate::builtInStyles() -{ - return { - QLatin1String("Basic"), - QLatin1String("Fusion"), - QLatin1String("Imagine"), -#ifdef Q_OS_MACOS - QLatin1String("macOS"), -#endif - QLatin1String("Material"), - QLatin1String("Universal"), -#ifdef Q_OS_WINDOWS - QLatin1String("Windows") -#endif - }; -} - -/*! - Returns the name of the application style. - - \note The application style can be specified by passing a \c -style command - line argument. Therefore \c name() may not return a fully resolved - value if called before constructing a QGuiApplication. -*/ -QString QQuickStyle::name() -{ - return styleSpec()->name(); -} - -/*! - Sets the application style to \a style. - - \note The style must be configured \b before loading QML that imports Qt Quick Controls. - It is not possible to change the style after the QML types have been registered. - - \sa setFallbackStyle(), {Using Styles in Qt Quick Controls} -*/ -void QQuickStyle::setStyle(const QString &style) -{ - qCDebug(lcQtQuickControlsStyle) << "setStyle called with" << style; - - if (QQmlMetaType::matchingModuleVersion( - QStringLiteral("QtQuick.Controls"), QTypeRevision::fromVersion(2, 0)).isValid()) { - qWarning() << "ERROR: QQuickStyle::setStyle() must be called before loading QML that imports Qt Quick Controls 2."; - return; - } - - styleSpec()->setStyle(style); -} - -/*! - \since 5.8 - Sets the application fallback style to \a style. - - \note The fallback style must be the name of one of the built-in Qt Quick Controls styles, e.g. "Material". - - \note The style must be configured \b before loading QML that imports Qt Quick Controls. - It is not possible to change the style after the QML types have been registered. - - The fallback style can be also specified by setting the \c QT_QUICK_CONTROLS_FALLBACK_STYLE - \l {Supported Environment Variables in Qt Quick Controls}{environment variable}. - - \sa setStyle(), {Using Styles in Qt Quick Controls} -*/ -void QQuickStyle::setFallbackStyle(const QString &style) -{ - if (QQmlMetaType::matchingModuleVersion( - QStringLiteral("QtQuick.Controls"), QTypeRevision::fromVersion(2, 0)).isValid()) { - qWarning() << "ERROR: QQuickStyle::setFallbackStyle() must be called before loading QML that imports Qt Quick Controls 2."; - return; - } - - styleSpec()->setFallbackStyle(style, "QQuickStyle::setFallbackStyle()"); -} - -QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickstyle.h b/src/quickcontrols2/qquickstyle.h deleted file mode 100644 index e26ec90b..00000000 --- a/src/quickcontrols2/qquickstyle.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSTYLE_H -#define QQUICKSTYLE_H - -#include <QtCore/qurl.h> -#include <QtCore/qstring.h> -#include <QtQuickControls2/qtquickcontrols2global.h> - -QT_BEGIN_NAMESPACE - -class Q_QUICKCONTROLS2_EXPORT QQuickStyle -{ -public: - static QString name(); - static void setStyle(const QString &style); - static void setFallbackStyle(const QString &style); -}; - -QT_END_NAMESPACE - -#endif // QQUICKSTYLE_H diff --git a/src/quickcontrols2/qquickstyle_p.h b/src/quickcontrols2/qquickstyle_p.h deleted file mode 100644 index 31c70893..00000000 --- a/src/quickcontrols2/qquickstyle_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSTYLE_P_H -#define QQUICKSTYLE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/qsharedpointer.h> -#include <QtQuickControls2/qtquickcontrols2global.h> - -QT_BEGIN_NAMESPACE - -class QSettings; - -class Q_QUICKCONTROLS2_EXPORT QQuickStylePrivate -{ -public: - static QString style(); - static QString effectiveStyleName(const QString &styleName); - static QString fallbackStyle(); - static bool isCustomStyle(); - static bool isResolved(); - static bool isUsingDefaultStyle(); - static bool exists(); - static void init(); - static void reset(); - static QString configFilePath(); - static QSharedPointer<QSettings> settings(const QString &group = QString()); - static const QFont *readFont(const QSharedPointer<QSettings> &settings); - static const QPalette *readPalette(const QSharedPointer<QSettings> &settings); - static bool isDarkSystemTheme(); - static QStringList builtInStyles(); -}; - -QT_END_NAMESPACE - -#endif // QQUICKSTYLE_P_H diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp deleted file mode 100644 index 27299b21..00000000 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickstyle.h" -#include "qquickstyle_p.h" -#include "qquickstyleplugin_p.h" - -#include <QtCore/private/qfileselector_p.h> -#include <QtCore/qloggingcategory.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlfile.h> -#include <QtQml/private/qqmlmetatype_p.h> -#include <QtQuickTemplates2/private/qquicktheme_p_p.h> - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcStylePlugin, "qt.quick.controls.styleplugin") - -QQuickStylePlugin::QQuickStylePlugin(QObject *parent) - : QQmlExtensionPlugin(parent) -{ -} - -QQuickStylePlugin::~QQuickStylePlugin() -{ -} - -void QQuickStylePlugin::registerTypes(const char *uri) -{ - qCDebug(lcStylePlugin).nospace() << "registerTypes called with uri " << uri << "; plugin name is " << name(); - - const QTypeRevision latestControlsRevision = QQmlMetaType::latestModuleVersion(QLatin1String("QtQuick.Controls")); - // Use the private function because we don't want to cause resolve() to be called, - // as the logic that assigns a default style if one wasn't set would interfere with compile-time style selection. - QString styleName = QQuickStylePrivate::style(); - if (!latestControlsRevision.isValid() && styleName.isEmpty()) { - // The user hasn't imported QtQuick.Controls, nor set a style via the runtime methods. - qCDebug(lcStylePlugin).nospace() << uri << " imported before QtQuick.Controls; using compile-time style selection"; - QQuickStyle::setStyle(name()); - styleName = name(); - } - - // Even if this style plugin isn't for the style set by the user, - // we still want to create the theme object, because that function - // is also responsible for reading values from qtquickcontrols2.conf. - // So, even if a style doesn't have a QQuickTheme, it can still have - // values set for (e.g. fonts and palettes) in qtquickcontrols2.conf. - const QString effectiveCurrentStyleName = QQuickStylePrivate::effectiveStyleName(styleName); - auto theme = QQuickTheme::instance(); - if (!theme) { - qCDebug(lcStylePlugin) << "creating theme"; - theme = createTheme(effectiveCurrentStyleName); - } - - if (name() != effectiveCurrentStyleName) { - qCDebug(lcStylePlugin).nospace() << "theme does not belong to current style (" - << effectiveCurrentStyleName << "); not calling initializeTheme()"; - return; - } - - qCDebug(lcStylePlugin) << "theme has not yet been initialized; calling initializeTheme()"; - initializeTheme(theme); - - if (!styleName.isEmpty()) - QFileSelectorPrivate::addStatics(QStringList() << styleName); -} - -void QQuickStylePlugin::unregisterTypes() -{ - qCDebug(lcStylePlugin) << "unregisterTypes called; plugin name is" << name(); - if (!QQuickThemePrivate::instance) - return; - - // Not every style has a plugin - some styles are QML-only. So, we clean this - // stuff up when the first style plugin is unregistered rather than when the - // plugin for the current style is unregistered. - QQuickThemePrivate::instance.reset(); - QQuickStylePrivate::reset(); -} - -/*! - \internal - - Responsible for setting the font and palette settings that were specified in the - qtquickcontrols2.conf file. - - Style-specific settings (e.g. Variant=Dense) are read in the constructor of the - appropriate style plugin (e.g. QtQuickControls2MaterialStylePlugin). - - Implicit style-specific font and palette values are assigned in the relevant theme - (e.g. QQuickMaterialTheme). -*/ -QQuickTheme *QQuickStylePlugin::createTheme(const QString &name) -{ - qCDebug(lcStylePlugin) << "creating QQuickTheme instance to be initialized by style-specific theme of" << name; - - QQuickTheme *theme = new QQuickTheme; -#if QT_CONFIG(settings) - QQuickThemePrivate *p = QQuickThemePrivate::get(theme); - QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(name); - if (settings) { - p->defaultFont.reset(QQuickStylePrivate::readFont(settings)); - // Set the default font as the System scope, because that's what - // QQuickControlPrivate::parentFont() uses as its fallback if no - // parent item has a font explicitly set. QQuickControlPrivate::parentFont() - // is used as the starting point for font inheritance/resolution. - // The same goes for palettes below. - theme->setFont(QQuickTheme::System, *p->defaultFont); - - p->defaultPalette.reset(QQuickStylePrivate::readPalette(settings)); - theme->setPalette(QQuickTheme::System, *p->defaultPalette); - } -#endif - QQuickThemePrivate::instance.reset(theme); - return theme; -} - -QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h deleted file mode 100644 index 0cc793a2..00000000 --- a/src/quickcontrols2/qquickstyleplugin_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSTYLEPLUGIN_P_H -#define QQUICKSTYLEPLUGIN_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQuickControls2/qtquickcontrols2global.h> - -QT_BEGIN_NAMESPACE - -class QQuickTheme; - -class Q_QUICKCONTROLS2_EXPORT QQuickStylePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - -public: - explicit QQuickStylePlugin(QObject *parent = nullptr); - ~QQuickStylePlugin(); - - virtual QString name() const = 0; - virtual void initializeTheme(QQuickTheme *theme) = 0; - - void registerTypes(const char *uri) override; - void unregisterTypes() override; - -private: - QQuickTheme *createTheme(const QString &name); - - Q_DISABLE_COPY(QQuickStylePlugin) -}; - -QT_END_NAMESPACE - -#endif // QQUICKSTYLEPLUGIN_P_H diff --git a/src/quickcontrols2/qt_cmdline.cmake b/src/quickcontrols2/qt_cmdline.cmake deleted file mode 100644 index b1e98c9a..00000000 --- a/src/quickcontrols2/qt_cmdline.cmake +++ /dev/null @@ -1,6 +0,0 @@ -qt_commandline_option(style-fusion TYPE boolean NAME quickcontrols2-fusion) -qt_commandline_option(style-imagine TYPE boolean NAME quickcontrols2-imagine) -qt_commandline_option(style-material TYPE boolean NAME quickcontrols2-material) -qt_commandline_option(style-universal TYPE boolean NAME quickcontrols2-universal) -qt_commandline_option(style-macos TYPE boolean NAME quickcontrols2-macos) -qt_commandline_option(style-windows TYPE boolean NAME quickcontrols2-windows) diff --git a/src/quickcontrols2/qtquickcontrols2global.h b/src/quickcontrols2/qtquickcontrols2global.h deleted file mode 100644 index e5f050ce..00000000 --- a/src/quickcontrols2/qtquickcontrols2global.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTQUICKCONTROLS2GLOBAL_H -#define QTQUICKCONTROLS2GLOBAL_H - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_QUICKCONTROLS2_LIB) -# define Q_QUICKCONTROLS2_EXPORT Q_DECL_EXPORT -# else -# define Q_QUICKCONTROLS2_EXPORT Q_DECL_IMPORT -# endif -#else -# define Q_QUICKCONTROLS2_EXPORT -#endif - -QT_END_NAMESPACE - -Q_QUICKCONTROLS2_EXPORT void qml_register_types_QtQuick_Controls(); - -#endif // QTQUICKCONTROLS2GLOBAL_H |