diff options
Diffstat (limited to 'src/dialogs/plugin.cpp')
| -rw-r--r-- | src/dialogs/plugin.cpp | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/src/dialogs/plugin.cpp b/src/dialogs/plugin.cpp index 21284697d..23eeac388 100644 --- a/src/dialogs/plugin.cpp +++ b/src/dialogs/plugin.cpp @@ -1,34 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Dialogs module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL3$ +** $QT_BEGIN_LICENSE:LGPL$ ** 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. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 +** Foundation and appearing in the file LICENSE.LGPL3 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. +** will be met: https://www.gnu.org/licenses/lgpl-3.0.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. +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -61,7 +64,11 @@ Q_LOGGING_CATEGORY(lcRegistration, "qt.quick.dialogs.registration") static void initResources() { +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Dialogs); +#else Q_INIT_RESOURCE(dialogs); +#endif } QT_BEGIN_NAMESPACE @@ -87,7 +94,7 @@ class QtQuick2DialogsPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - QtQuick2DialogsPlugin() : QQmlExtensionPlugin(), m_useResources(true) { } + QtQuick2DialogsPlugin() : QQmlExtensionPlugin(), m_useResources(true) { initResources(); } virtual void initializeEngine(QQmlEngine *engine, const char * uri) { qCDebug(lcRegistration) << uri << m_decorationComponentUrl; @@ -96,16 +103,18 @@ public: } virtual void registerTypes(const char *uri) { - initResources(); - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs")); bool hasTopLevelWindows = QGuiApplicationPrivate::platformIntegration()-> hasCapability(QPlatformIntegration::MultipleWindows); qCDebug(lcRegistration) << uri << "can use top-level windows?" << hasTopLevelWindows; QDir qmlDir(baseUrl().toLocalFile()); QDir widgetsDir(baseUrl().toLocalFile()); +#ifndef QT_STATIC widgetsDir.cd("../PrivateWidgets"); - +#endif +#ifdef QT_STATIC + m_useResources = false; +#else #ifndef ALWAYS_LOAD_FROM_RESOURCES // If at least one file was actually installed, then use installed qml files instead of resources. // This makes debugging and incremental development easier, whereas the "normal" installation @@ -113,10 +122,14 @@ public: if (qmlDir.exists(QString("DefaultFileDialog.qml"))) m_useResources = false; #endif +#endif m_decorationComponentUrl = m_useResources ? QUrl("qrc:/QtQuick/Dialogs/qml/DefaultWindowDecoration.qml") : +#ifndef QT_STATIC QUrl::fromLocalFile(qmlDir.filePath(QString("qml/DefaultWindowDecoration.qml"))); - +#else + QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/qml/DefaultWindowDecoration.qml"); +#endif // Prefer the QPA dialog helpers if the platform supports them. // Else if there is a QWidget-based implementation, check whether it's // possible to instantiate it from Qt Quick. @@ -167,7 +180,11 @@ public: qmlRegisterType<QQuickDialog>(uri, 1, 2, "AbstractDialog"); // implementation wrapper QUrl dialogQmlPath = m_useResources ? QUrl("qrc:/QtQuick/Dialogs/DefaultDialogWrapper.qml") : +#ifndef QT_STATIC QUrl::fromLocalFile(qmlDir.filePath("DefaultDialogWrapper.qml")); +#else + QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/DefaultDialogWrapper.qml"); +#endif qCDebug(lcRegistration) << " registering" << dialogQmlPath << "as Dialog"; qmlRegisterType(dialogQmlPath, uri, 1, 2, "Dialog"); } @@ -199,7 +216,8 @@ protected: #if defined(Q_OS_IOS) mobileTouchPlatform = true; #elif defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_QNX) || defined(Q_OS_WINRT) - foreach (const QTouchDevice *dev, QTouchDevice::devices()) + const auto devices = QTouchDevice::devices(); + for (const QTouchDevice *dev : devices) if (dev->type() == QTouchDevice::TouchScreen) mobileTouchPlatform = true; #endif @@ -213,7 +231,12 @@ protected: QCoreApplication::instance()->inherits("QApplication")) { QUrl dialogQmlPath = m_useResources ? QUrl(QString("qrc:/QtQuick/Dialogs/Widget%1.qml").arg(qmlName)) : - QUrl::fromLocalFile(qmlDir.filePath(QString("Widget%1.qml").arg(qmlName))); +#ifndef QT_STATIC + QUrl::fromLocalFile(qmlDir.filePath(QString("Widget%1.qml").arg(qmlName))); +#else + QUrl(QString("qrc:/qt-project.org/imports/QtQuick/Dialogs/Widget%1.qml").arg(qmlName)); + Q_UNUSED(qmlDir); +#endif if (qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName) >= 0) { qCDebug(lcRegistration) << " registering" << qmlName << " as " << dialogQmlPath; return true; @@ -231,7 +254,12 @@ protected: qmlRegisterType<WrapperType>(uri, versionMajor, versionMinor, abstractTypeName); QUrl dialogQmlPath = m_useResources ? QUrl(QString("qrc:/QtQuick/Dialogs/Default%1.qml").arg(qmlName)) : +#ifndef QT_STATIC QUrl::fromLocalFile(qmlDir.filePath(QString("Default%1.qml").arg(qmlName))); +#else + QUrl(QString("qrc:/qt-project.org/imports/QtQuick/Dialogs/Default%1.qml").arg(qmlName)); + Q_UNUSED(qmlDir); +#endif qCDebug(lcRegistration) << " registering" << qmlName << " as " << dialogQmlPath; qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName); } |
