diff options
author | Craig Scott <craig.scott@qt.io> | 2021-05-31 16:40:54 +1000 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-05 12:52:00 +0200 |
commit | 5e8feb64d6a3cf50360c066e4595e41021bd0f9c (patch) | |
tree | c7901024f6c082dab14c97d109853ab5a64db1e1 /src/quicktemplates2 | |
parent | 284936db8327f030473c0533041ee850f5369bdd (diff) |
Update to latest qml CMake API
The new qml CMake API places a closer relationship between
the backing target and the plugin target. Both are typically
created together and they share a lot of common details.
Instead of creating them in different parts of the source
tree, they are now specified together. The src/imports
area has effectively been absorbed into the other
corresponding subdirectories below src with this change.
Task-number: QTBUG-91621
Change-Id: I9bd32e9eb78c198ccc9db04e2829303cac323502
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/CMakeLists.txt | 35 | ||||
-rw-r--r-- | src/quicktemplates2/doc/src/qtquicktemplates2-index.qdoc | 58 | ||||
-rw-r--r-- | src/quicktemplates2/doc/src/qtquicktemplates2-qmltypes.qdoc | 64 | ||||
-rw-r--r-- | src/quicktemplates2/qtquicktemplates2plugin.cpp | 106 |
4 files changed, 242 insertions, 21 deletions
diff --git a/src/quicktemplates2/CMakeLists.txt b/src/quicktemplates2/CMakeLists.txt index 4f4bf552..b326e467 100644 --- a/src/quicktemplates2/CMakeLists.txt +++ b/src/quicktemplates2/CMakeLists.txt @@ -1,10 +1,16 @@ -# Generated from quicktemplates2.pro. - ##################################################################### ## QuickTemplates2 Module: ##################################################################### -qt_internal_add_module(QuickTemplates2 +qt_internal_add_qml_module(QuickTemplates2 + URI "QtQuick.Templates" + VERSION "${PROJECT_VERSION}" + CLASSNAME QtQuickTemplates2Plugin + DEPENDENCIES + QtQuick/auto + PLUGIN_TARGET qtquicktemplates2plugin + NO_PLUGIN_OPTIONAL + NO_GENERATE_PLUGIN_SOURCE SOURCES accessible/qaccessiblequickpage.cpp accessible/qaccessiblequickpage_p.h qquickabstractbutton.cpp qquickabstractbutton_p.h @@ -131,16 +137,6 @@ qt_internal_add_module(QuickTemplates2 Qt::Quick ) -#### Keys ignored in scope 1:.:.:quicktemplates2.pro:<TRUE>: -# MODULE = "quicktemplates2" -# QMLTYPES_FILENAME = "plugins.qmltypes" -# QMLTYPES_INSTALL_DIR = "$$[QT_INSTALL_QML]/QtQuick/Templates" -# QML_IMPORT_NAME = "QtQuick.Templates" -# QML_IMPORT_VERSION = "$$QT_VERSION" - -## Scopes: -##################################################################### - qt_internal_extend_target(QuickTemplates2 CONDITION TARGET Qt::QmlModels LIBRARIES Qt::QmlModelsPrivate @@ -156,12 +152,9 @@ qt_internal_extend_target(QuickTemplates2 CONDITION QT_FEATURE_quick_listview AN qquicktumbler_p_p.h ) -set_target_properties(QuickTemplates2 PROPERTIES - QT_QML_MODULE_INSTALL_QMLTYPES TRUE - QT_QML_MODULE_VERSION ${PROJECT_VERSION} - QT_QML_MODULE_URI QtQuick.Templates - QT_QMLTYPES_FILENAME plugins.qmltypes - QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtQuick/Templates" +qt_internal_extend_Target(qtquicktemplates2plugin + SOURCES + qtquicktemplates2plugin.cpp + LIBRARIES + Qt::QuickTemplates2Private ) - -qt6_qml_type_registration(QuickTemplates2) diff --git a/src/quicktemplates2/doc/src/qtquicktemplates2-index.qdoc b/src/quicktemplates2/doc/src/qtquicktemplates2-index.qdoc new file mode 100644 index 00000000..c7e25548 --- /dev/null +++ b/src/quicktemplates2/doc/src/qtquicktemplates2-index.qdoc @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtquicktemplates2-index.html + \title Qt Quick Templates 2 + \brief A set of templates to create user interface controls in Qt Quick + + Qt Quick Templates are the foundations of \l {Qt Quick Controls}. Templates + are non-visual implementations of controls' logic and behavior. They offer + an interface to visualize the controls in QML using \l {Qt Quick}. + + Even though the templates aim to be as style-agnostic as possible, in some + cases they have to make certain assumptions about the visual structure of + a control. For example, a spinbox has buttons that increment and decrement + the value of the spinbox. In order to implement the behavior of a spinbox, + the spinbox template needs to know if the user is interacting with the up + or down button. A visual implementation of the spinbox template merely needs + to position the up and down buttons and visualize them in normal, pressed, + and disabled states. Any input event handling and state processing is taken + care of by the underlying template. + + \section1 Module Evolution + \l{Changes to Qt Quick Controls} lists important changes in the + module API and functionality that were done for the Qt 6 series of Qt. + + \section1 Related Information + + \list + \li \l{Qt Quick} + \li \l{Qt Quick Controls} + \li \l{Qt Quick Templates 2 QML Types} + \endlist +*/ diff --git a/src/quicktemplates2/doc/src/qtquicktemplates2-qmltypes.qdoc b/src/quicktemplates2/doc/src/qtquicktemplates2-qmltypes.qdoc new file mode 100644 index 00000000..396dbdc5 --- /dev/null +++ b/src/quicktemplates2/doc/src/qtquicktemplates2-qmltypes.qdoc @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmlmodule QtQuick.Templates 2.\QtMinorVersion + \title Qt Quick Templates 2 QML Types + \ingroup qmlmodules + \brief Provides QML types for templates (Qt Quick Templates). + + The \l {Qt Quick Templates 2} module provides a set of non-visual templates + that can be used to build user interface controls in QML using \l {Qt Quick}. + + The QML types can be imported using the following import statement in your + \c .qml file: + + \qml + import QtQuick.Templates as T + \endqml + + For the sake of clarity, there is a one-to-one mapping between the types + provided by the \c QtQuick.Templates and \c QtQuick.Controls imports. For + every type available in the \c QtQuick.Controls import, a non-visual template + type by the same name exists in the \c QtQuick.Templates import. + + \note It is recommended to use a namespace for the templates import to avoid + overlap with the types provided by the \c QtQuick.Controls import. + + \section1 QML Types + + \generatelist {qmltypesbymodule QtQuick.Controls} + + \section1 Related Information + + \list + \li \l {Qt Quick Controls QML Types} + \li \l {Using Qt Quick Controls types in property declarations} + \endlist + + \noautolist +*/ diff --git a/src/quicktemplates2/qtquicktemplates2plugin.cpp b/src/quicktemplates2/qtquicktemplates2plugin.cpp new file mode 100644 index 00000000..da89601d --- /dev/null +++ b/src/quicktemplates2/qtquicktemplates2plugin.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Templates 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 <QtQml/qqmlextensionplugin.h> +#include <QtQml/private/qqmlglobal_p.h> +#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> + +#if QT_CONFIG(shortcut) +#include <QtQuickTemplates2/private/qquickshortcutcontext_p_p.h> + +// qtdeclarative/src/quick/util/qquickshortcut.cpp +typedef bool (*ShortcutContextMatcher)(QObject *, Qt::ShortcutContext); +extern ShortcutContextMatcher qt_quick_shortcut_context_matcher(); +extern void qt_quick_set_shortcut_context_matcher(ShortcutContextMatcher matcher); +#endif + +QT_BEGIN_NAMESPACE + +class QtQuickTemplates2Plugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QtQuickTemplates2Plugin(QObject *parent = nullptr); + ~QtQuickTemplates2Plugin(); + + void registerTypes(const char *uri) override; + void unregisterTypes() override; + +private: + bool registered; +#if QT_CONFIG(shortcut) + ShortcutContextMatcher originalContextMatcher; +#endif +}; + +QtQuickTemplates2Plugin::QtQuickTemplates2Plugin(QObject *parent) + : QQmlExtensionPlugin(parent), registered(false) +{ + volatile auto registration = &qml_register_types_QtQuick_Templates; + volatile auto initialization = &QQuickTemplates_initializeModule; + + Q_UNUSED(registration) + Q_UNUSED(initialization) +} + +QtQuickTemplates2Plugin::~QtQuickTemplates2Plugin() +{ + // Intentionally empty: we use register/unregisterTypes() to do + // initialization and cleanup, as plugins are not unloaded on macOS. +} + +void QtQuickTemplates2Plugin::registerTypes(const char */*uri*/) +{ +#if QT_CONFIG(shortcut) + originalContextMatcher = qt_quick_shortcut_context_matcher(); + qt_quick_set_shortcut_context_matcher(QQuickShortcutContext::matcher); +#endif + + registered = true; +} + +void QtQuickTemplates2Plugin::unregisterTypes() +{ +#if QT_CONFIG(shortcut) + qt_quick_set_shortcut_context_matcher(originalContextMatcher); +#endif +} + +QT_END_NAMESPACE + +#include "qtquicktemplates2plugin.moc" |