aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-14 14:09:14 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-14 22:07:43 +0000
commite18b178d9a3bff54c92d80f1a0923ab72bf27267 (patch)
treedb53c8f6fe62d3873ef37442cdc735370df2a744 /src/imports
parent8a10e85db212d88887ad7f14ad7e4048a87a8c2d (diff)
Register types in C++ (instead of qmldir)
Later on, we can choose to register types from different style-subdirs based on a yet unknown style selector (app manifest file, env var, ...) This is also a step to the right direction to get QML types inherit enums and attached properties from the respective C++ base types. The qmlRegisterType(QUrl) overload for composite types probably needs a template argument to help figure out the missing meta-object link between the composite type and the C++ base type. Change-Id: I9b3c2afdd93fff56d1e7513879b3e9229f483cbf Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/controls/qmldir22
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp48
-rw-r--r--src/imports/extras/qmldir4
-rw-r--r--src/imports/extras/qtquickextras2plugin.cpp7
4 files changed, 55 insertions, 26 deletions
diff --git a/src/imports/controls/qmldir b/src/imports/controls/qmldir
index 5de9450a..496eec5f 100644
--- a/src/imports/controls/qmldir
+++ b/src/imports/controls/qmldir
@@ -1,25 +1,3 @@
module QtQuick.Controls
plugin qtquickcontrols2plugin
classname QtQuickControls2Plugin
-ApplicationWindow 2.0 ApplicationWindow.qml
-BusyIndicator 2.0 BusyIndicator.qml
-Button 2.0 Button.qml
-CheckBox 2.0 CheckBox.qml
-Frame 2.0 Frame.qml
-GroupBox 2.0 GroupBox.qml
-Label 2.0 Label.qml
-PageIndicator 2.0 PageIndicator.qml
-ProgressBar 2.0 ProgressBar.qml
-RadioButton 2.0 RadioButton.qml
-ScrollBar 2.0 ScrollBar.qml
-ScrollIndicator 2.0 ScrollIndicator.qml
-Slider 2.0 Slider.qml
-StackView 2.0 StackView.qml
-Switch 2.0 Switch.qml
-TabBar 2.0 TabBar.qml
-TabButton 2.0 TabButton.qml
-TextArea 2.0 TextArea.qml
-TextField 2.0 TextField.qml
-ToggleButton 2.0 ToggleButton.qml
-ToolBar 2.0 ToolBar.qml
-ToolButton 2.0 ToolButton.qml
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index fb701a35..6c0f9ecc 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -35,7 +35,31 @@
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
+#include <QtCore/qdir.h>
+
#include <QtQuickControls/private/qquickexclusivegroup_p.h>
+#include <QtQuickControls/private/qquickapplicationwindow_p.h>
+#include <QtQuickControls/private/qquickbusyindicator_p.h>
+#include <QtQuickControls/private/qquickbutton_p.h>
+#include <QtQuickControls/private/qquickcheckbox_p.h>
+#include <QtQuickControls/private/qquickframe_p.h>
+#include <QtQuickControls/private/qquickgroupbox_p.h>
+#include <QtQuickControls/private/qquicklabel_p.h>
+#include <QtQuickControls/private/qquickpageindicator_p.h>
+#include <QtQuickControls/private/qquickprogressbar_p.h>
+#include <QtQuickControls/private/qquickradiobutton_p.h>
+#include <QtQuickControls/private/qquickscrollbar_p.h>
+#include <QtQuickControls/private/qquickscrollindicator_p.h>
+#include <QtQuickControls/private/qquickslider_p.h>
+#include <QtQuickControls/private/qquickstackview_p.h>
+#include <QtQuickControls/private/qquickswitch_p.h>
+#include <QtQuickControls/private/qquicktabbar_p.h>
+#include <QtQuickControls/private/qquicktabbutton_p.h>
+#include <QtQuickControls/private/qquicktextarea_p.h>
+#include <QtQuickControls/private/qquicktextfield_p.h>
+#include <QtQuickControls/private/qquicktogglebutton_p.h>
+#include <QtQuickControls/private/qquicktoolbar_p.h>
+#include <QtQuickControls/private/qquicktoolbutton_p.h>
#include "qquicktheme_p.h"
void initResources()
@@ -61,6 +85,30 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickExclusiveGroup>(uri, 2, 0, "ExclusiveGroup");
qmlRegisterType<QQuickExclusiveGroupAttached>();
+
+ QDir baseDir(baseUrl().toLocalFile());
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ApplicationWindow.qml"))), uri, 2, 0, "ApplicationWindow");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("BusyIndicator.qml"))), uri, 2, 0, "BusyIndicator");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Button.qml"))), uri, 2, 0, "Button");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("CheckBox.qml"))), uri, 2, 0, "CheckBox");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Frame.qml"))), uri, 2, 0, "Frame");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("GroupBox.qml"))), uri, 2, 0, "GroupBox");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Label.qml"))), uri, 2, 0, "Label");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("PageIndicator.qml"))), uri, 2, 0, "PageIndicator");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ProgressBar.qml"))), uri, 2, 0, "ProgressBar");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("RadioButton.qml"))), uri, 2, 0, "RadioButton");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ScrollBar.qml"))), uri, 2, 0, "ScrollBar");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ScrollIndicator.qml"))), uri, 2, 0, "ScrollIndicator");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Slider.qml"))), uri, 2, 0, "Slider");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("StackView.qml"))), uri, 2, 0, "StackView");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Switch.qml"))), uri, 2, 0, "Switch");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("TabBar.qml"))), uri, 2, 0, "TabBar");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("TabButton.qml"))), uri, 2, 0, "TabButton");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("TextArea.qml"))), uri, 2, 0, "TextArea");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("TextField.qml"))), uri, 2, 0, "TextField");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ToggleButton.qml"))), uri, 2, 0, "ToggleButton");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ToolBar.qml"))), uri, 2, 0, "ToolBar");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("ToolButton.qml"))), uri, 2, 0, "ToolButton");
}
void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *uri)
diff --git a/src/imports/extras/qmldir b/src/imports/extras/qmldir
index 51c99e31..8822d83b 100644
--- a/src/imports/extras/qmldir
+++ b/src/imports/extras/qmldir
@@ -1,7 +1,3 @@
module QtQuick.Extras
plugin qtquickextras2plugin
classname QtQuickExtras2Plugin
-Dial 2.0 Dial.qml
-Drawer 2.0 Drawer.qml
-SwipeView 2.0 SwipeView.qml
-Tumbler 2.0 Tumbler.qml
diff --git a/src/imports/extras/qtquickextras2plugin.cpp b/src/imports/extras/qtquickextras2plugin.cpp
index 8b1ebb50..f1307558 100644
--- a/src/imports/extras/qtquickextras2plugin.cpp
+++ b/src/imports/extras/qtquickextras2plugin.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
+#include <QtCore/qdir.h>
#include "qquickdial_p.h"
#include "qquickdrawer_p.h"
@@ -59,6 +60,12 @@ void QtQuickExtras2Plugin::registerTypes(const char *uri)
qmlRegisterType<QQuickSwipeView>(uri, 2, 0, "AbstractSwipeView");
qmlRegisterType<QQuickTumbler>(uri, 2, 0, "AbstractTumbler");
qmlRegisterType<QQuickTumblerAttached>();
+
+ QDir baseDir(baseUrl().toLocalFile());
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Dial.qml"))), uri, 2, 0, "Dial");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Drawer.qml"))), uri, 2, 0, "Drawer");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("SwipeView.qml"))), uri, 2, 0, "SwipeView");
+ qmlRegisterType(QUrl::fromLocalFile(baseDir.filePath(QStringLiteral("Tumbler.qml"))), uri, 2, 0, "Tumbler");
}
QT_END_NAMESPACE