diff options
Diffstat (limited to 'examples/qml/qmlextensionplugins')
15 files changed, 0 insertions, 368 deletions
diff --git a/examples/qml/qmlextensionplugins/CMakeLists.txt b/examples/qml/qmlextensionplugins/CMakeLists.txt deleted file mode 100644 index 753f05b173..0000000000 --- a/examples/qml/qmlextensionplugins/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(qmlqtimeexample LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/qmlextensionplugins/imports/TimeExample") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) - -#![0] -set(qml_files - imports/TimeExample/Clock.qml -) - -set(images - imports/TimeExample/center.png - imports/TimeExample/clock.png - imports/TimeExample/hour.png - imports/TimeExample/minute.png -) -#![0] - -foreach(file IN LISTS qml_files images) - get_filename_component(filename ${file} NAME) - set_source_files_properties(${file} PROPERTIES QT_RESOURCE_ALIAS ${filename}) -endforeach() - -#![1] -qt_add_qml_module(qmlqtimeexample - OUTPUT_DIRECTORY imports/TimeExample - URI "TimeExample" - SOURCES timemodel.cpp timemodel.h - AUTO_RESOURCE_PREFIX - QML_FILES ${qml_files} - RESOURCES ${images} -) -#![1] - -set_target_properties(qmlqtimeexample PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(qmlqtimeexample PUBLIC - Qt::Core - Qt::Gui - Qt::Qml -) - -install(TARGETS qmlqtimeexample - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/qml/qmlextensionplugins/doc/images/qml-plugins-example.png b/examples/qml/qmlextensionplugins/doc/images/qml-plugins-example.png Binary files differdeleted file mode 100644 index c2d4886ea2..0000000000 --- a/examples/qml/qmlextensionplugins/doc/images/qml-plugins-example.png +++ /dev/null diff --git a/examples/qml/qmlextensionplugins/doc/src/qmlpluginex.qdoc b/examples/qml/qmlextensionplugins/doc/src/qmlpluginex.qdoc deleted file mode 100644 index 80f39e36ce..0000000000 --- a/examples/qml/qmlextensionplugins/doc/src/qmlpluginex.qdoc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \title QML Plugin Example - \example qmlextensionplugins - - \brief This example creates a C++ plugin extension by subclassing QQmlEngineExtensionPlugin. - - \image qml-plugins-example.png - - To run this example, use the following commands on the prompt: - - \if defined(onlinedocs) - \tab {build-qt-app}{tab-cmake}{CMake}{checked} - \tab {build-qt-app}{tab-qmake}{qmake}{} - \tabcontent {tab-cmake} - \else - \section1 Using CMake - \endif - \badcode \QtVersion - cmake -DCMAKE_PREFIX_PATH=path/to/Qt/\1/your_platform -S <source-dir> -B <build-dir> -G Ninja - cd path/to/build/dir - ninja - qml -I imports plugins.qml - \endcode - For more information about building on the command line using CMake, - see \l {Building projects on the command line}. - \if defined(onlinedocs) - \endtabcontent - \tabcontent {tab-qmake} - \else - \section1 Using qmake - \endif - \badcode - qmake - make - qml -I imports plugins.qml - \endcode - \if defined(onlinedocs) - \endtabcontent - \endif -*/ diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml b/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml deleted file mode 100644 index b071e2e031..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/Clock.qml +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant shift : 0 - - Image { id: background; source: "clock.png" } - - Image { - x: 92.5; y: 27 - source: "hour.png" - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/center.png b/examples/qml/qmlextensionplugins/imports/TimeExample/center.png Binary files differdeleted file mode 100644 index 7fbd802a44..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/center.png +++ /dev/null diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/clock.png b/examples/qml/qmlextensionplugins/imports/TimeExample/clock.png Binary files differdeleted file mode 100644 index 462edacc0e..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/clock.png +++ /dev/null diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/hour.png b/examples/qml/qmlextensionplugins/imports/TimeExample/hour.png Binary files differdeleted file mode 100644 index 9f33fc5d48..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/hour.png +++ /dev/null diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/minute.png b/examples/qml/qmlextensionplugins/imports/TimeExample/minute.png Binary files differdeleted file mode 100644 index e2f216c897..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/minute.png +++ /dev/null diff --git a/examples/qml/qmlextensionplugins/imports/TimeExample/qmldir b/examples/qml/qmlextensionplugins/imports/TimeExample/qmldir deleted file mode 100644 index 252e662e12..0000000000 --- a/examples/qml/qmlextensionplugins/imports/TimeExample/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module TimeExample -Clock 1.0 Clock.qml -plugin qmlqtimeexampleplugin diff --git a/examples/qml/qmlextensionplugins/plugin.cpp b/examples/qml/qmlextensionplugins/plugin.cpp deleted file mode 100644 index 066d284a5e..0000000000 --- a/examples/qml/qmlextensionplugins/plugin.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QtQml/QQmlEngineExtensionPlugin> -#include <qdebug.h> - -//![plugin] -class QExampleQmlPlugin : public QQmlEngineExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid) -}; -//![plugin] - -#include "plugin.moc" diff --git a/examples/qml/qmlextensionplugins/plugins.qml b/examples/qml/qmlextensionplugins/plugins.qml deleted file mode 100644 index 55e8903400..0000000000 --- a/examples/qml/qmlextensionplugins/plugins.qml +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -//![0] -import TimeExample // import types from the plugin - -Clock { // this class is defined in QML (imports/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute - -} -//![0] diff --git a/examples/qml/qmlextensionplugins/plugins.qmlproject b/examples/qml/qmlextensionplugins/plugins.qmlproject deleted file mode 100644 index c2de5f5703..0000000000 --- a/examples/qml/qmlextensionplugins/plugins.qmlproject +++ /dev/null @@ -1,18 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plugins.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - - importPaths: [ "imports" ] -} diff --git a/examples/qml/qmlextensionplugins/qmlextensionplugins.pro b/examples/qml/qmlextensionplugins/qmlextensionplugins.pro deleted file mode 100644 index c074b8d671..0000000000 --- a/examples/qml/qmlextensionplugins/qmlextensionplugins.pro +++ /dev/null @@ -1,46 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin qmltypes -QT += qml - -QML_IMPORT_NAME = TimeExample -QML_IMPORT_MAJOR_VERSION = 1 - -DESTDIR = imports/$$QML_IMPORT_NAME -TARGET = qmlqtimeexampleplugin -QMLTYPES_FILENAME = $$DESTDIR/plugins.qmltypes - -SOURCES += \ - plugin.cpp \ - timemodel.cpp - -HEADERS += \ - timemodel.h - -PLUGINFILES = \ - imports/$$QML_IMPORT_NAME/qmldir \ - imports/$$QML_IMPORT_NAME/center.png \ - imports/$$QML_IMPORT_NAME/clock.png \ - imports/$$QML_IMPORT_NAME/Clock.qml \ - imports/$$QML_IMPORT_NAME/hour.png \ - imports/$$QML_IMPORT_NAME/minute.png - -target.path = $$[QT_INSTALL_EXAMPLES]/qml/qmlextensionplugins/imports/$$QML_IMPORT_NAME - -pluginfiles_copy.files = $$PLUGINFILES -pluginfiles_copy.path = $$DESTDIR - -pluginfiles_install.files = $$PLUGINFILES $$OUT_PWD/$$DESTDIR/plugins.qmltypes -pluginfiles_install.path = $$[QT_INSTALL_EXAMPLES]/qml/qmlextensionplugins/imports/$$QML_IMPORT_NAME - -qml_copy.files = plugins.qml plugins.qmlproject -qml_copy.path = $$OUT_PWD - -qml_install.files = plugins.qml plugins.qmlproject -qml_install.path = $$[QT_INSTALL_EXAMPLES]/qml/qmlextensionplugins - -INSTALLS += target qml_install pluginfiles_install -COPIES += qml_copy pluginfiles_copy - -OTHER_FILES += $$PLUGINFILES plugins.qml - -CONFIG += install_ok # Do not cargo-cult this! diff --git a/examples/qml/qmlextensionplugins/timemodel.cpp b/examples/qml/qmlextensionplugins/timemodel.cpp deleted file mode 100644 index a94a7e773d..0000000000 --- a/examples/qml/qmlextensionplugins/timemodel.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "timemodel.h" - -int TimeModel::instances=0; -MinuteTimer *TimeModel::timer=nullptr; - -void MinuteTimer::start() -{ - if (!timer.isActive()) { - time = QTime::currentTime(); - timer.start(60000-time.second()*1000, this); - } -} - -void MinuteTimer::stop() -{ - timer.stop(); -} - -void MinuteTimer::timerEvent(QTimerEvent *) -{ - QTime now = QTime::currentTime(); - if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { - // just missed time tick over, force it, wait extra 0.5 seconds - time = time.addSecs(60); - timer.start(60500, this); - } else { - time = now; - timer.start(60000-time.second()*1000, this); - } - emit timeChanged(); -} - -TimeModel::TimeModel(QObject *parent) : QObject(parent) -{ - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(QCoreApplication::instance()); - connect(timer, &MinuteTimer::timeChanged, this, &TimeModel::timeChanged); - timer->start(); - } -} - -TimeModel::~TimeModel() -{ - if (--instances == 0) { - timer->stop(); - } -} diff --git a/examples/qml/qmlextensionplugins/timemodel.h b/examples/qml/qmlextensionplugins/timemodel.h deleted file mode 100644 index 2c27a6dada..0000000000 --- a/examples/qml/qmlextensionplugins/timemodel.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef TIMEMODEL_H -#define TIMEMODEL_H - -#include <QtQml/qqml.h> -#include <QtCore/qdatetime.h> -#include <QtCore/qbasictimer.h> -#include <QtCore/qcoreapplication.h> - -// Implements a "TimeModel" class with hour and minute properties -// that change on-the-minute yet efficiently sleep the rest -// of the time. - -class MinuteTimer : public QObject -{ - Q_OBJECT -public: - MinuteTimer(QObject *parent) : QObject(parent) {} - - void start(); - void stop(); - - int hour() const { return time.hour(); } - int minute() const { return time.minute(); } - -signals: - void timeChanged(); - -protected: - void timerEvent(QTimerEvent *) override; - -private: - QTime time; - QBasicTimer timer; -}; - -//![0] -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) - QML_NAMED_ELEMENT(Time) -//![0] - -public: - TimeModel(QObject *parent=nullptr); - ~TimeModel() override; - - int minute() const { return timer->minute(); } - int hour() const { return timer->hour(); } - -signals: - void timeChanged(); - -private: - QTime t; - static MinuteTimer *timer; - static int instances; -}; - -#endif // TIMEMODEL_H |