aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-02-20 13:18:00 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-02-20 15:08:29 +0100
commitaa20222e840fe328b2a5db8d71ec909c1606f838 (patch)
tree7d0be9dd2c5f5f9ed09aacb161351a88cf08c234
parent3bafe234940f6e3faef77f03a9a2d2071c12111b (diff)
Tools: Convert to static type registrations
qml and qmltime were still using qmlRegisterType() for some internals. Let's get rid of those. Change-Id: I68c0e7213f3b5b28670364c4db1cdec41d299b7d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tools/qml/main.cpp1
-rw-r--r--tools/qml/qml.pro4
-rw-r--r--tools/qmltime/qmltime.cpp39
-rw-r--r--tools/qmltime/qmltime.h68
-rw-r--r--tools/qmltime/qmltime.pro6
5 files changed, 81 insertions, 37 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index dc828b1f75..beeec88f07 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -436,7 +436,6 @@ int main(int argc, char *argv[])
app->setOrganizationDomain("qt-project.org");
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
- qmlRegisterTypesAndRevisions<Config, PartialScene>("QmlRuntime.Config", 1);
QQmlApplicationEngine e;
QStringList files;
QString confFile;
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index 5dcbb3567a..83e2e1bf80 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -5,6 +5,10 @@ qtHaveModule(widgets): QT += widgets
HEADERS += conf.h
SOURCES += main.cpp
RESOURCES += qml.qrc
+CONFIG += qmltypes
+
+QML_IMPORT_NAME = QmlRuntime.Config
+QML_IMPORT_VERSION = 1.0
QMAKE_TARGET_DESCRIPTION = QML Runtime
diff --git a/tools/qmltime/qmltime.cpp b/tools/qmltime/qmltime.cpp
index b0761a54d4..ca10fdde53 100644
--- a/tools/qmltime/qmltime.cpp
+++ b/tools/qmltime/qmltime.cpp
@@ -25,47 +25,18 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+
+#include "qmltime.h"
+
#include <QQmlEngine>
-#include <QQmlComponent>
#include <QDebug>
#include <QGuiApplication>
#include <QElapsedTimer>
#include <QQmlContext>
-#include <QQuickView>
#include <QQuickItem>
#include <private/qquickview_p.h>
-class Timer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QQmlComponent *component READ component WRITE setComponent)
-
-public:
- Timer();
-
- QQmlComponent *component() const;
- void setComponent(QQmlComponent *);
-
- static Timer *timerInstance();
-
- void run(uint);
-
- bool willParent() const;
- void setWillParent(bool p);
-
-private:
- void runTest(QQmlContext *, uint);
-
- QQmlComponent *m_component;
- static Timer *m_timer;
-
- bool m_willparent;
- QQuickView m_view;
- QQuickItem *m_item;
-};
-QML_DECLARE_TYPE(Timer);
-
Timer *Timer::m_timer = nullptr;
Timer::Timer()
@@ -207,8 +178,6 @@ int main(int argc, char ** argv)
QGuiApplication app(argc, argv);
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
- qmlRegisterTypesAndRevisions<Timer>("QmlTime", 1);
-
uint iterations = 1024;
QString filename;
bool willParent = false;
@@ -269,5 +238,3 @@ int main(int argc, char ** argv)
return 0;
}
-
-#include "qmltime.moc"
diff --git a/tools/qmltime/qmltime.h b/tools/qmltime/qmltime.h
new file mode 100644
index 0000000000..a23dc902e2
--- /dev/null
+++ b/tools/qmltime/qmltime.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLTIME_H
+#define QMLTIME_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+
+class Timer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlComponent *component READ component WRITE setComponent)
+ QML_ELEMENT
+
+public:
+ Timer();
+
+ QQmlComponent *component() const;
+ void setComponent(QQmlComponent *);
+
+ static Timer *timerInstance();
+
+ void run(uint);
+
+ bool willParent() const;
+ void setWillParent(bool p);
+
+private:
+ void runTest(QQmlContext *, uint);
+
+ QQmlComponent *m_component;
+ static Timer *m_timer;
+
+ bool m_willparent;
+ QQuickView m_view;
+ QQuickItem *m_item;
+};
+QML_DECLARE_TYPE(Timer);
+
+#endif // QMLTIME_H
diff --git a/tools/qmltime/qmltime.pro b/tools/qmltime/qmltime.pro
index 04a5fd5957..c915f6e8c1 100644
--- a/tools/qmltime/qmltime.pro
+++ b/tools/qmltime/qmltime.pro
@@ -4,5 +4,11 @@ QT += qml quick
QT += quick-private
macx:CONFIG -= app_bundle
+CONFIG += qmltypes
+QML_IMPORT_NAME = QmlTime
+QML_IMPORT_VERSION = 1.0
+
QMAKE_TARGET_DESCRIPTION = QML Time
+
SOURCES += qmltime.cpp
+HEADERS += qmltime.h