aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-19 11:44:12 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-04-19 20:08:23 +0000
commitc2fdb4ecf3644015fa16e417c0939dd30f8b5a27 (patch)
tree13d691d97816b12fc49f2e5289f9855728c41719
parente91e832f4a0a3ad820c07efd13e761881eeee790 (diff)
Merge QQuickPluginUtils to QQuickStylePlugin
Now that we have a common base class for the plugins, we don't need a separate utils namespace. QQuickStylePlugin::typeUrl() is based on the former QQuickPluginUtils::pluginBasePath(). It returns a URL to the internal composite types that must be explicitly registered for static builds. Change-Id: Icf28c27c84f6b58b1e7b34203dad39c852f0d362 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/imports/controls/material/qtquickmaterialstyleplugin.cpp11
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp15
-rw-r--r--src/imports/controls/universal/qtquickuniversalstyleplugin.cpp6
-rw-r--r--src/quickcontrols2/qquickpluginutils.cpp65
-rw-r--r--src/quickcontrols2/qquickpluginutils_p.h66
-rw-r--r--src/quickcontrols2/qquickstyleplugin.cpp16
-rw-r--r--src/quickcontrols2/qquickstyleplugin_p.h2
-rw-r--r--src/quickcontrols2/quickcontrols2.pri2
8 files changed, 31 insertions, 152 deletions
diff --git a/src/imports/controls/material/qtquickmaterialstyleplugin.cpp b/src/imports/controls/material/qtquickmaterialstyleplugin.cpp
index 28a880cb..96ffbb56 100644
--- a/src/imports/controls/material/qtquickmaterialstyleplugin.cpp
+++ b/src/imports/controls/material/qtquickmaterialstyleplugin.cpp
@@ -42,7 +42,6 @@
#include "qquickmaterialprogressstrip_p.h"
#include <QtQuickControls2/private/qquickstyleselector_p.h>
-#include <QtQuickControls2/private/qquickpluginutils_p.h>
static inline void initResources()
{
@@ -83,17 +82,15 @@ void QtQuickMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char
{
QQuickStylePlugin::initializeEngine(engine, uri);
- const QString pluginBasePath = QQuickPluginUtils::pluginBasePath(*this);
-
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickMaterialProgressRing>(import, 1, 0, "ProgressRing");
qmlRegisterType<QQuickMaterialProgressStrip>(import, 1, 0, "ProgressStrip");
qmlRegisterType<QQuickMaterialRingAnimator>(import, 1, 0, "RingAnimator");
qmlRegisterType<QQuickMaterialStripAnimator>(import, 1, 0, "StripAnimator");
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/CheckIndicator.qml")), import, 1, 0, "CheckIndicator");
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/Ripple.qml")), import, 1, 0, "Ripple");
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/SliderHandle.qml")), import, 1, 0, "SliderHandle");
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/SwitchIndicator.qml")), import, 1, 0, "SwitchIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 1, 0, "CheckIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("Ripple.qml")), import, 1, 0, "Ripple");
+ qmlRegisterType(typeUrl(QStringLiteral("SliderHandle.qml")), import, 1, 0, "SliderHandle");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 1, 0, "SwitchIndicator");
}
QString QtQuickMaterialStylePlugin::name() const
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index c23e3707..d3ae1905 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -46,7 +46,7 @@
#include <QtQuickTemplates2/private/qquickcontainer_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
-#include <QtQuickControls2/private/qquickpluginutils_p.h>
+#include <QtQuickControls2/private/qquickstyleplugin_p.h>
#include <QtQuickControls2/private/qquickstyleselector_p.h>
#include "qquickbusyindicatorring_p.h"
@@ -62,7 +62,7 @@ static inline void initResources()
QT_BEGIN_NAMESPACE
-class QtQuickControls2Plugin: public QQmlExtensionPlugin
+class QtQuickControls2Plugin: public QQuickStylePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
@@ -73,7 +73,7 @@ public:
void initializeEngine(QQmlEngine *engine, const char *uri);
};
-QtQuickControls2Plugin::QtQuickControls2Plugin(QObject *parent) : QQmlExtensionPlugin(parent)
+QtQuickControls2Plugin::QtQuickControls2Plugin(QObject *parent) : QQuickStylePlugin(parent)
{
initResources();
}
@@ -87,7 +87,7 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickControl>(uri, 1, 0, "Control");
QQuickStyleSelector selector;
- selector.setBaseUrl(QQuickPluginUtils::pluginBaseUrl(*this));
+ selector.setBaseUrl(typeUrl());
const QString style = QQuickStyle::name();
if (!style.isEmpty())
@@ -145,10 +145,9 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur
qmlRegisterType<QQuickProgressStrip>(import, 1, 0, "ProgressStrip");
qmlRegisterType<QQuickProgressAnimator>(import, 1, 0, "ProgressStripAnimator");
- const QString pluginBasePath = QQuickPluginUtils::pluginBasePath(*this);
- qmlRegisterType(pluginBasePath + QStringLiteral("/CheckIndicator.qml"), import, 1, 0, "CheckIndicator");
- qmlRegisterType(pluginBasePath + QStringLiteral("/RadioIndicator.qml"), import, 1, 0, "RadioIndicator");
- qmlRegisterType(pluginBasePath + QStringLiteral("/SwitchIndicator.qml"), import, 1, 0, "SwitchIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 1, 0, "CheckIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 1, 0, "RadioIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 1, 0, "SwitchIndicator");
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/universal/qtquickuniversalstyleplugin.cpp b/src/imports/controls/universal/qtquickuniversalstyleplugin.cpp
index 20d964f3..41cebeda 100644
--- a/src/imports/controls/universal/qtquickuniversalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtquickuniversalstyleplugin.cpp
@@ -43,7 +43,6 @@
#include "qquickuniversaltheme_p.h"
#include <QtQuickControls2/private/qquickcolorimageprovider_p.h>
-#include <QtQuickControls2/private/qquickpluginutils_p.h>
static inline void initResources()
{
@@ -93,9 +92,8 @@ void QtQuickUniversalStylePlugin::initializeEngine(QQmlEngine *engine, const cha
qmlRegisterType<QQuickUniversalProgressStrip>(import, 1, 0, "ProgressStrip");
qmlRegisterType<QQuickUniversalProgressStripAnimator>(import, 1, 0, "ProgressStripAnimator");
- const QString pluginBasePath = QQuickPluginUtils::pluginBasePath(*this);
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/RadioIndicator.qml")), import, 1, 0, "RadioIndicator");
- qmlRegisterType(QUrl(pluginBasePath + QStringLiteral("/SwitchIndicator.qml")), import, 1, 0, "SwitchIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 1, 0, "RadioIndicator");
+ qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 1, 0, "SwitchIndicator");
}
QString QtQuickUniversalStylePlugin::name() const
diff --git a/src/quickcontrols2/qquickpluginutils.cpp b/src/quickcontrols2/qquickpluginutils.cpp
deleted file mode 100644
index e4e336f2..00000000
--- a/src/quickcontrols2/qquickpluginutils.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 "qquickpluginutils_p.h"
-
-#include "qquickstyle.h"
-
-QT_BEGIN_NAMESPACE
-
-/*
- Returns either a file system path if Qt was built as shared libraries,
- or a QRC path if Qt was built statically.
-*/
-QString QQuickPluginUtils::pluginBasePath(const QQmlExtensionPlugin &plugin)
-{
-#ifdef QT_STATIC
- return QLatin1String("qrc") + plugin.baseUrl().path();
-#else
- return plugin.baseUrl().toString();
-#endif
-}
-
-/*
- Returns either a file system URL if Qt was built as shared libraries,
- or a QRC URL if Qt was built statically.
-*/
-QUrl QQuickPluginUtils::pluginBaseUrl(const QQmlExtensionPlugin &plugin)
-{
- return QUrl(pluginBasePath(plugin));
-}
-
-QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickpluginutils_p.h b/src/quickcontrols2/qquickpluginutils_p.h
deleted file mode 100644
index 9c439977..00000000
--- a/src/quickcontrols2/qquickpluginutils_p.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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 QQUICKPLUGINUTILS_H
-#define QQUICKPLUGINUTILS_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/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtQml/qqmlextensionplugin.h>
-#include <QtQuickControls2/private/qtquickcontrols2global_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QQuickPluginUtils
-{
- Q_QUICKCONTROLS2_PRIVATE_EXPORT QString pluginBasePath(const QQmlExtensionPlugin &plugin);
- Q_QUICKCONTROLS2_PRIVATE_EXPORT QUrl pluginBaseUrl(const QQmlExtensionPlugin &plugin);
-}
-
-QT_END_NAMESPACE
-
-#endif // QQUICKPLUGINUTILS_H
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp
index 1235b34c..7f6e1323 100644
--- a/src/quickcontrols2/qquickstyleplugin.cpp
+++ b/src/quickcontrols2/qquickstyleplugin.cpp
@@ -78,4 +78,20 @@ QQuickProxyTheme *QQuickStylePlugin::createTheme() const
return nullptr;
}
+/*
+ Returns either a file system path if Qt was built as shared libraries,
+ or a QRC path if Qt was built statically.
+*/
+QUrl QQuickStylePlugin::typeUrl(const QString &name) const
+{
+#ifdef QT_STATIC
+ QString url = QLatin1String("qrc") + baseUrl().path();
+#else
+ QString url = baseUrl().toString();
+#endif
+ if (!name.isEmpty())
+ url += QLatin1Char('/') + name;
+ return QUrl(url);
+}
+
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h
index 525a3b75..34e262e1 100644
--- a/src/quickcontrols2/qquickstyleplugin_p.h
+++ b/src/quickcontrols2/qquickstyleplugin_p.h
@@ -70,6 +70,8 @@ public:
virtual QString name() const;
virtual QQuickProxyTheme *createTheme() const;
+ QUrl typeUrl(const QString &name = QString()) const;
+
private:
QScopedPointer<QQuickProxyTheme> m_theme;
};
diff --git a/src/quickcontrols2/quickcontrols2.pri b/src/quickcontrols2/quickcontrols2.pri
index 5424c5c7..aaf01ed6 100644
--- a/src/quickcontrols2/quickcontrols2.pri
+++ b/src/quickcontrols2/quickcontrols2.pri
@@ -1,6 +1,5 @@
HEADERS += \
$$PWD/qquickcolorimageprovider_p.h \
- $$PWD/qquickpluginutils_p.h \
$$PWD/qquickproxytheme_p.h \
$$PWD/qquickstyle.h \
$$PWD/qquickstyleattached_p.h \
@@ -11,7 +10,6 @@ HEADERS += \
SOURCES += \
$$PWD/qquickcolorimageprovider.cpp \
- $$PWD/qquickpluginutils.cpp \
$$PWD/qquickproxytheme.cpp \
$$PWD/qquickstyle.cpp \
$$PWD/qquickstyleattached.cpp \