aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/imports/imports.pro1
-rw-r--r--src/imports/platform/doc/qtlabsplatform.qdocconf37
-rw-r--r--src/imports/platform/doc/src/qtlabsplatform-index.qdoc50
-rw-r--r--src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc58
-rw-r--r--src/imports/platform/platform.pri5
-rw-r--r--src/imports/platform/platform.pro21
-rw-r--r--src/imports/platform/qmldir3
-rw-r--r--src/imports/platform/qquickplatformiconloader.cpp111
-rw-r--r--src/imports/platform/qquickplatformiconloader_p.h89
-rw-r--r--src/imports/platform/qtlabsplatformplugin.cpp71
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/platform/platform.pro12
-rw-r--r--tests/auto/platform/tst_platform.cpp38
14 files changed, 498 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 5597a2f7..091c7390 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@
/tests/auto/drawer/tst_drawer
/tests/auto/focus/tst_focus
/tests/auto/menu/tst_menu
+/tests/auto/platform/tst_platform
/tests/auto/popup/tst_popup
/tests/auto/pressandhold/tst_pressandhold
/tests/auto/qquickmaterialstyle/tst_qquickmaterialstyle
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 3227cb99..e1da66c9 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS += \
controls \
calendar \
+ platform \
templates
SUBDIRS += \
diff --git a/src/imports/platform/doc/qtlabsplatform.qdocconf b/src/imports/platform/doc/qtlabsplatform.qdocconf
new file mode 100644
index 00000000..e7afb662
--- /dev/null
+++ b/src/imports/platform/doc/qtlabsplatform.qdocconf
@@ -0,0 +1,37 @@
+include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
+
+project = QtLabsPlatform
+description = Qt Labs Platform Reference Documentation
+version = $QT_VERSION
+
+qhp.projects = QtLabsPlatform
+
+qhp.QtLabsPlatform.file = qtlabsplatform.qhp
+qhp.QtLabsPlatform.namespace = org.qt-project.qtlabsplatform.$QT_VERSION_TAG
+qhp.QtLabsPlatform.virtualFolder = qtlabsplatform
+qhp.QtLabsPlatform.indexTitle = Qt Labs Platform
+qhp.QtLabsPlatform.indexRoot =
+
+qhp.QtLabsPlatform.filterAttributes = qtlabsplatform $QT_VERSION qtrefdoc
+qhp.QtLabsPlatform.customFilters.Qt.name = QtLabsPlatform $QT_VERSION
+qhp.QtLabsPlatform.customFilters.Qt.filterAttributes = qtlabsplatform $QT_VERSION
+
+qhp.QtLabsPlatform.subprojects = qmltypes
+qhp.QtLabsPlatform.subprojects.qmltypes.title = QML Types
+qhp.QtLabsPlatform.subprojects.qmltypes.indexTitle = Qt Labs Platform QML Types
+qhp.QtLabsPlatform.subprojects.qmltypes.selectors = qmlclass
+qhp.QtLabsPlatform.subprojects.qmltypes.sortPages = true
+
+depends = qtcore qtgui qtdoc qtqml qtquick qtquickcontrols2
+
+headerdirs += ../
+sourcedirs += ../
+
+imagedirs += images
+
+navigation.landingpage = "Qt Labs Platform"
+navigation.qmltypespage = "Qt Labs Platform QML Types"
+
+tagfile = qtlabsplatform.tags
+
+macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}"
diff --git a/src/imports/platform/doc/src/qtlabsplatform-index.qdoc b/src/imports/platform/doc/src/qtlabsplatform-index.qdoc
new file mode 100644
index 00000000..aec2a923
--- /dev/null
+++ b/src/imports/platform/doc/src/qtlabsplatform-index.qdoc
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtlabsplatform-index.html
+ \title Qt Labs Platform
+
+ \brief The experimental Qt Labs Platform module provides QML types for
+ native platform extensions.
+
+ The experimental Qt Labs Platform module provides QML types for native
+ platform extensions. The module was introduced in Qt 5.8.
+
+ \section1 QML Types
+
+ \generatelist {qmltypesbymodule Qt.labs.platform}
+
+ \labs
+
+ \section1 Related Information
+
+ \list
+ \li \l{Qt Quick}
+ \li \l{Qt Quick Controls 2}
+ \endlist
+*/
diff --git a/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc
new file mode 100644
index 00000000..470b93c4
--- /dev/null
+++ b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule Qt.labs.platform 1.0
+ \title Qt Labs Platform QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for native platform extensions.
+
+ The experimental \l{Qt Labs Platform} module provides QML types for native
+ platform extensions. These QML types work in conjunction with \l{Qt Quick}
+ and \l{Qt Quick Controls 2}.
+
+ The QML types can be imported into your application using the
+ following import statement in your .qml file:
+
+ \badcode
+ import Qt.labs.platform 1.0
+ \endcode
+
+ \section1 QML Types
+
+ \generatelist {qmltypesbymodule Qt.labs.platform}
+
+ \labs
+
+ \section1 Related Information
+
+ \list
+ \li \l {Qt Quick Controls 2 QML Types}
+ \endlist
+
+ \noautolist
+*/
diff --git a/src/imports/platform/platform.pri b/src/imports/platform/platform.pri
new file mode 100644
index 00000000..453ed447
--- /dev/null
+++ b/src/imports/platform/platform.pri
@@ -0,0 +1,5 @@
+HEADERS += \
+ $$PWD/qquickplatformiconloader_p.h
+
+SOURCES += \
+ $$PWD/qquickplatformiconloader.cpp
diff --git a/src/imports/platform/platform.pro b/src/imports/platform/platform.pro
new file mode 100644
index 00000000..8126860b
--- /dev/null
+++ b/src/imports/platform/platform.pro
@@ -0,0 +1,21 @@
+TARGET = qtlabsplatformplugin
+TARGETPATH = Qt/labs/platform
+IMPORT_VERSION = 1.0
+
+QT += qml quick
+QT_PRIVATE += core-private gui-private qml-private quick-private
+
+DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
+
+QMAKE_DOCS = $$PWD/doc/qtlabsplatform.qdocconf
+
+OTHER_FILES += \
+ qmldir
+
+SOURCES += \
+ $$PWD/qtlabsplatformplugin.cpp
+
+include(platform.pri)
+
+CONFIG += no_cxx_module
+load(qml_plugin)
diff --git a/src/imports/platform/qmldir b/src/imports/platform/qmldir
new file mode 100644
index 00000000..9653b7d3
--- /dev/null
+++ b/src/imports/platform/qmldir
@@ -0,0 +1,3 @@
+module Qt.labs.platform
+plugin qtlabsplatformplugin
+classname QtLabsPlatformPlugin
diff --git a/src/imports/platform/qquickplatformiconloader.cpp b/src/imports/platform/qquickplatformiconloader.cpp
new file mode 100644
index 00000000..08df44d9
--- /dev/null
+++ b/src/imports/platform/qquickplatformiconloader.cpp
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform 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 "qquickplatformiconloader_p.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qmetaobject.h>
+#include <QtQml/qqml.h>
+
+QT_BEGIN_NAMESPACE
+
+QQuickPlatformIconLoader::QQuickPlatformIconLoader(int slot, QObject *parent)
+ : m_parent(parent),
+ m_slot(slot),
+ m_enabled(false)
+{
+ Q_ASSERT(slot != -1 && parent);
+}
+
+bool QQuickPlatformIconLoader::isEnabled() const
+{
+ return m_enabled;
+}
+
+void QQuickPlatformIconLoader::setEnabled(bool enabled)
+{
+ m_enabled = enabled;
+ if (m_enabled)
+ loadIcon();
+}
+
+QIcon QQuickPlatformIconLoader::icon() const
+{
+ QIcon fallback = QPixmap::fromImage(image());
+ return QIcon::fromTheme(m_iconName, fallback);
+}
+
+QUrl QQuickPlatformIconLoader::iconSource() const
+{
+ return m_iconSource;
+}
+
+void QQuickPlatformIconLoader::setIconSource(const QUrl& source)
+{
+ m_iconSource = source;
+ if (m_enabled)
+ loadIcon();
+}
+
+QString QQuickPlatformIconLoader::iconName() const
+{
+ return m_iconName;
+}
+
+void QQuickPlatformIconLoader::setIconName(const QString& name)
+{
+ m_iconName = name;
+ if (m_enabled)
+ loadIcon();
+}
+
+void QQuickPlatformIconLoader::loadIcon()
+{
+ if (m_iconSource.isEmpty()) {
+ clear(m_parent);
+ } else {
+ load(qmlEngine(m_parent), m_iconSource);
+ if (m_slot != -1 && isLoading()) {
+ connectFinished(m_parent, m_slot);
+ m_slot = -1;
+ }
+ }
+
+ if (!isLoading())
+ m_parent->metaObject()->method(m_slot).invoke(m_parent);
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/platform/qquickplatformiconloader_p.h b/src/imports/platform/qquickplatformiconloader_p.h
new file mode 100644
index 00000000..5ddb625f
--- /dev/null
+++ b/src/imports/platform/qquickplatformiconloader_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Platform 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 QQUICKPLATFORMICONLOADER_P_H
+#define QQUICKPLATFORMICONLOADER_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/qurl.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qicon.h>
+#include <QtQuick/private/qquickpixmapcache_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+
+class QQuickPlatformIconLoader : public QQuickPixmap
+{
+public:
+ QQuickPlatformIconLoader(int slot, QObject *parent);
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+ QIcon icon() const;
+
+ QUrl iconSource() const;
+ void setIconSource(const QUrl &source);
+
+ QString iconName() const;
+ void setIconName(const QString &name);
+
+private:
+ void loadIcon();
+
+ QObject *m_parent;
+ int m_slot;
+ bool m_enabled;
+ QIcon m_icon;
+ QUrl m_iconSource;
+ QString m_iconName;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKPLATFORMICONLOADER_P_H
diff --git a/src/imports/platform/qtlabsplatformplugin.cpp b/src/imports/platform/qtlabsplatformplugin.cpp
new file mode 100644
index 00000000..c691e1cf
--- /dev/null
+++ b/src/imports/platform/qtlabsplatformplugin.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Labs Templates 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 <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+
+static inline void initResources()
+{
+#ifdef QT_STATIC
+ Q_INIT_RESOURCE(qmake_Qt_labs_platform);
+#endif
+}
+
+QT_BEGIN_NAMESPACE
+
+class QtLabsPlatformPlugin: public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
+
+public:
+ QtLabsPlatformPlugin(QObject *parent = nullptr);
+ void registerTypes(const char *uri) override;
+};
+
+QtLabsPlatformPlugin::QtLabsPlatformPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
+{
+ initResources();
+}
+
+void QtLabsPlatformPlugin::registerTypes(const char *uri)
+{
+ Q_UNUSED(uri)
+}
+
+QT_END_NAMESPACE
+
+#include "qtlabsplatformplugin.moc"
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index b17aa77a..437bfd71 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -6,6 +6,7 @@ SUBDIRS += \
controls \
drawer \
menu \
+ platform \
popup \
pressandhold \
qquickmaterialstyle \
diff --git a/tests/auto/platform/platform.pro b/tests/auto/platform/platform.pro
new file mode 100644
index 00000000..e8f66d13
--- /dev/null
+++ b/tests/auto/platform/platform.pro
@@ -0,0 +1,12 @@
+TEMPLATE = app
+TARGET = tst_platform
+CONFIG += qmltestcase
+
+SOURCES += \
+ $$PWD/tst_platform.cpp
+
+OTHER_FILES += \
+ $$PWD/data/*
+
+TESTDATA += \
+ $$PWD/data/tst_*
diff --git a/tests/auto/platform/tst_platform.cpp b/tests/auto/platform/tst_platform.cpp
new file mode 100644
index 00000000..3866f7c2
--- /dev/null
+++ b/tests/auto/platform/tst_platform.cpp
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite 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 <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(tst_platform)