aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-10 15:33:05 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-11 09:00:18 +0000
commit7172c212faf73b6f4ab80b025e4cd45ecc7d6a86 (patch)
treee70286def8ffcb04e9a179c2bde7977f4f468749 /src/controls
parent7946ce46e5ec42b4a1510b9dc6a33a28d8febe4e (diff)
Add internal QQuickStylePlugin
This is a common base class for QtQuickMaterialStylePlugin and QtQuickUniversalStylePlugin that takes care of the proxy theme installation and manages its life time by using a scoped pointer. Change-Id: I2cbe38287565d284b18fab4265456a41a2dbd8d4 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/controls.pri2
-rw-r--r--src/controls/qquickstyleplugin.cpp81
-rw-r--r--src/controls/qquickstyleplugin_p.h79
3 files changed, 162 insertions, 0 deletions
diff --git a/src/controls/controls.pri b/src/controls/controls.pri
index dc1920fb..5424c5c7 100644
--- a/src/controls/controls.pri
+++ b/src/controls/controls.pri
@@ -4,6 +4,7 @@ HEADERS += \
$$PWD/qquickproxytheme_p.h \
$$PWD/qquickstyle.h \
$$PWD/qquickstyleattached_p.h \
+ $$PWD/qquickstyleplugin_p.h \
$$PWD/qquickstyleselector_p.h \
$$PWD/qquickstyleselector_p_p.h \
$$PWD/qquickpaddedrectangle_p.h
@@ -14,5 +15,6 @@ SOURCES += \
$$PWD/qquickproxytheme.cpp \
$$PWD/qquickstyle.cpp \
$$PWD/qquickstyleattached.cpp \
+ $$PWD/qquickstyleplugin.cpp \
$$PWD/qquickstyleselector.cpp \
$$PWD/qquickpaddedrectangle.cpp
diff --git a/src/controls/qquickstyleplugin.cpp b/src/controls/qquickstyleplugin.cpp
new file mode 100644
index 00000000..ceb6531e
--- /dev/null
+++ b/src/controls/qquickstyleplugin.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Controls 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 "qquickstyleplugin_p.h"
+#include "qquickproxytheme_p.h"
+#include "qquickstyle.h"
+
+#include <QtGui/private/qguiapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickStylePlugin::QQuickStylePlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+}
+
+QQuickStylePlugin::~QQuickStylePlugin()
+{
+}
+
+void QQuickStylePlugin::registerTypes(const char *uri)
+{
+ Q_UNUSED(uri);
+}
+
+void QQuickStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ Q_UNUSED(engine);
+ Q_UNUSED(uri);
+
+ const QString style = name();
+ if (!style.isEmpty() && style.compare(QQuickStyle::name(), Qt::CaseInsensitive) == 0) {
+ m_theme.reset(createTheme());
+ if (m_theme)
+ QGuiApplicationPrivate::platform_theme = m_theme.data();
+ }
+}
+
+QString QQuickStylePlugin::name() const
+{
+ return QString();
+}
+
+QQuickProxyTheme *QQuickStylePlugin::createTheme() const
+{
+ return nullptr;
+}
+
+QT_END_NAMESPACE
diff --git a/src/controls/qquickstyleplugin_p.h b/src/controls/qquickstyleplugin_p.h
new file mode 100644
index 00000000..93be0aa8
--- /dev/null
+++ b/src/controls/qquickstyleplugin_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Controls 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 <QtCore/qscopedpointer.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQuickControls/private/qtquickcontrolsglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickProxyTheme;
+
+class Q_QUICKCONTROLS_PRIVATE_EXPORT QQuickStylePlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+
+public:
+ explicit QQuickStylePlugin(QObject *parent = nullptr);
+ ~QQuickStylePlugin();
+
+ void registerTypes(const char *uri) override;
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
+
+ virtual QString name() const;
+ virtual QQuickProxyTheme *createTheme() const;
+
+private:
+ QScopedPointer<QQuickProxyTheme> m_theme;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSTYLEPLUGIN_P_H