Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtquicktemplates2plugin.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <QtQml/qqmlextensionplugin.h>
6#include <QtQml/private/qqmlglobal_p.h>
7#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
8
9#if QT_CONFIG(shortcut)
10#include <QtQuickTemplates2/private/qquickshortcutcontext_p_p.h>
11
12QT_BEGIN_NAMESPACE
13
14// qtdeclarative/src/quick/util/qquickshortcut.cpp
15typedef bool (*ShortcutContextMatcher)(QObject *, Qt::ShortcutContext);
16extern ShortcutContextMatcher qt_quick_shortcut_context_matcher();
17extern void qt_quick_set_shortcut_context_matcher(ShortcutContextMatcher matcher);
18#endif
19
22
24{
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
27
28public:
31
32 void registerTypes(const char *uri) override;
34
35private:
36#if QT_CONFIG(shortcut)
38#endif
39};
40
41QtQuickTemplates2Plugin::QtQuickTemplates2Plugin(QObject *parent)
42 : QQmlExtensionPlugin(parent)
43{
44 volatile auto registration = &qml_register_types_QtQuick_Templates;
45 volatile auto initialization = &QQuickTemplates_initializeModule;
46
47 Q_UNUSED(registration)
48 Q_UNUSED(initialization)
49}
50
52{
53 // Intentionally empty: we use register/unregisterTypes() to do
54 // initialization and cleanup, as plugins are not unloaded on macOS.
55}
56
57void QtQuickTemplates2Plugin::registerTypes(const char * /*uri*/)
58{
59#if QT_CONFIG(shortcut)
60 originalContextMatcher = qt_quick_shortcut_context_matcher();
61 qt_quick_set_shortcut_context_matcher(QQuickShortcutContext::matcher);
62#endif
63}
64
66{
67#if QT_CONFIG(shortcut)
68 qt_quick_set_shortcut_context_matcher(originalContextMatcher);
69#endif
70}
71
72QT_END_NAMESPACE
73
74#include "qtquicktemplates2plugin.moc"
void registerTypes(const char *uri) override
Registers the QML types in the given uri.
Q_GHS_KEEP_REFERENCE(QQuickTemplates_initializeModule)
Q_GHS_KEEP_REFERENCE(qml_register_types_QtQuick_Templates)