1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Labs Templates module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include <QtQml/qqmlextensionplugin.h>
38#include <QtQml/qqml.h>
39#include <QtCore/qloggingcategory.h>
40
41#include "qquickplatformdialog_p.h"
42#include "qquickplatformcolordialog_p.h"
43#include "qquickplatformfiledialog_p.h"
44#include "qquickplatformfolderdialog_p.h"
45#include "qquickplatformfontdialog_p.h"
46#include "qquickplatformmessagedialog_p.h"
47
48#include "qquickplatformmenu_p.h"
49#include "qquickplatformmenubar_p.h"
50#include "qquickplatformmenuitem_p.h"
51#include "qquickplatformmenuitemgroup_p.h"
52#include "qquickplatformmenuseparator_p.h"
53
54#include "qquickplatformstandardpaths_p.h"
55#if QT_CONFIG(systemtrayicon)
56# include "qquickplatformsystemtrayicon_p.h"
57#endif
58
59#include "qquickplatformicon_p.h"
60
61QT_BEGIN_NAMESPACE
62
63Q_LOGGING_CATEGORY(qtLabsPlatformDialogs, "qt.labs.platform.dialogs")
64Q_LOGGING_CATEGORY(qtLabsPlatformMenus, "qt.labs.platform.menus")
65Q_LOGGING_CATEGORY(qtLabsPlatformTray, "qt.labs.platform.tray")
66
67class QtLabsPlatformPlugin: public QQmlExtensionPlugin
68{
69 Q_OBJECT
70 Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
71
72public:
73 QtLabsPlatformPlugin(QObject *parent = nullptr);
74 void registerTypes(const char *uri) override;
75};
76
77QtLabsPlatformPlugin::QtLabsPlatformPlugin(QObject *parent) : QQmlExtensionPlugin(parent)
78{
79}
80
81void QtLabsPlatformPlugin::registerTypes(const char *uri)
82{
83 qmlRegisterUncreatableType<QQuickPlatformDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "Dialog", reason: QQuickPlatformDialog::tr(s: "Dialog is an abstract base class"));
84 qmlRegisterType<QQuickPlatformColorDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "ColorDialog");
85 qmlRegisterType<QQuickPlatformFileDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "FileDialog");
86 qmlRegisterAnonymousType<QQuickPlatformFileNameFilter>(uri, versionMajor: 1);
87 qmlRegisterType<QQuickPlatformFolderDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "FolderDialog");
88 qmlRegisterType<QQuickPlatformFontDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "FontDialog");
89 qmlRegisterType<QQuickPlatformMessageDialog>(uri, versionMajor: 1, versionMinor: 0, qmlName: "MessageDialog");
90
91 qmlRegisterType<QQuickPlatformMenu>(uri, versionMajor: 1, versionMinor: 0, qmlName: "Menu");
92 qmlRegisterType<QQuickPlatformMenuBar>(uri, versionMajor: 1, versionMinor: 0, qmlName: "MenuBar");
93 qmlRegisterType<QQuickPlatformMenuItem>(uri, versionMajor: 1, versionMinor: 0, qmlName: "MenuItem");
94 qmlRegisterType<QQuickPlatformMenuItem, 1>(uri, versionMajor: 1, versionMinor: 1, qmlName: "MenuItem");
95 qmlRegisterType<QQuickPlatformMenuItemGroup>(uri, versionMajor: 1, versionMinor: 0, qmlName: "MenuItemGroup");
96 qmlRegisterType<QQuickPlatformMenuSeparator>(uri, versionMajor: 1, versionMinor: 0, qmlName: "MenuSeparator");
97 qRegisterMetaType<QPlatformMenu::MenuType>();
98
99 qmlRegisterUncreatableType<QPlatformDialogHelper>(uri, versionMajor: 1, versionMinor: 0, qmlName: "StandardButton", reason: QQuickPlatformDialog::tr(s: "Cannot create an instance of StandardButton"));
100 qmlRegisterSingletonType<QQuickPlatformStandardPaths>(uri, versionMajor: 1, versionMinor: 0, typeName: "StandardPaths", callback: QQuickPlatformStandardPaths::create);
101 qRegisterMetaType<QStandardPaths::StandardLocation>();
102 qRegisterMetaType<QStandardPaths::LocateOptions>();
103
104#if QT_CONFIG(systemtrayicon)
105 qmlRegisterType<QQuickPlatformSystemTrayIcon>(uri, versionMajor: 1, versionMinor: 0, qmlName: "SystemTrayIcon");
106 qmlRegisterType<QQuickPlatformSystemTrayIcon, 1>(uri, versionMajor: 1, versionMinor: 1, qmlName: "SystemTrayIcon");
107 qRegisterMetaType<QPlatformSystemTrayIcon::ActivationReason>();
108 qRegisterMetaType<QPlatformSystemTrayIcon::MessageIcon>();
109#endif
110
111 qmlRegisterAnonymousType<QQuickPlatformIcon>(uri, versionMajor: 1);
112 qRegisterMetaType<QQuickPlatformIcon>();
113}
114
115QT_END_NAMESPACE
116
117#include "qtlabsplatformplugin.moc"
118

source code of qtquickcontrols2/src/imports/platform/qtlabsplatformplugin.cpp