diff options
Diffstat (limited to 'examples/RemoteObjects/plugins')
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/Clock.qml | 88 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/center.png | bin | 0 -> 765 bytes | |||
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/clock.png | bin | 0 -> 20653 bytes | |||
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/hour.png | bin | 0 -> 625 bytes | |||
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/minute.png | bin | 0 -> 625 bytes | |||
-rw-r--r-- | examples/RemoteObjects/plugins/imports/TimeExample/qmldir | 3 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugin.cpp | 130 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugins.pro | 28 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugins.qml | 62 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugins0.qml | 48 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugins1.qml | 60 | ||||
-rw-r--r-- | examples/RemoteObjects/plugins/plugins2.qml | 71 |
12 files changed, 490 insertions, 0 deletions
diff --git a/examples/RemoteObjects/plugins/imports/TimeExample/Clock.qml b/examples/RemoteObjects/plugins/imports/TimeExample/Clock.qml new file mode 100644 index 0000000..ca57cae --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/Clock.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +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/RemoteObjects/plugins/imports/TimeExample/center.png b/examples/RemoteObjects/plugins/imports/TimeExample/center.png Binary files differnew file mode 100644 index 0000000..7fbd802 --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/center.png diff --git a/examples/RemoteObjects/plugins/imports/TimeExample/clock.png b/examples/RemoteObjects/plugins/imports/TimeExample/clock.png Binary files differnew file mode 100644 index 0000000..462edac --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/clock.png diff --git a/examples/RemoteObjects/plugins/imports/TimeExample/hour.png b/examples/RemoteObjects/plugins/imports/TimeExample/hour.png Binary files differnew file mode 100644 index 0000000..f8061a1 --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/hour.png diff --git a/examples/RemoteObjects/plugins/imports/TimeExample/minute.png b/examples/RemoteObjects/plugins/imports/TimeExample/minute.png Binary files differnew file mode 100644 index 0000000..1297ec7 --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/minute.png diff --git a/examples/RemoteObjects/plugins/imports/TimeExample/qmldir b/examples/RemoteObjects/plugins/imports/TimeExample/qmldir new file mode 100644 index 0000000..252e662 --- /dev/null +++ b/examples/RemoteObjects/plugins/imports/TimeExample/qmldir @@ -0,0 +1,3 @@ +module TimeExample +Clock 1.0 Clock.qml +plugin qmlqtimeexampleplugin diff --git a/examples/RemoteObjects/plugins/plugin.cpp b/examples/RemoteObjects/plugins/plugin.cpp new file mode 100644 index 0000000..0415fc3 --- /dev/null +++ b/examples/RemoteObjects/plugins/plugin.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQml/QQmlExtensionPlugin> +#include <QtQml/QQmlEngine> +#include <QtQml/qqml.h> +#include <QDebug> +#include <QDateTime> +#include <QBasicTimer> +#include <QCoreApplication> +#include <QRemoteObjectReplica> +#include <QRemoteObjectNode> +#include "rep_TimeModel_replica.h" + +// Implements a "TimeModel" class with hour and minute properties +// that change on-the-minute yet efficiently sleep the rest +// of the time. + +QRemoteObjectNode m_client; + +class TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) + Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged) + +public: + TimeModel(QObject *parent=0) : QObject(parent), d_ptr(Q_NULLPTR) + { + d_ptr.reset(m_client.acquire< MinuteTimerReplica >()); + connect(d_ptr.data(), SIGNAL(onHourChanged()), this, SIGNAL(timeChanged())); + connect(d_ptr.data(), SIGNAL(onMinuteChanged()), this, SIGNAL(timeChanged())); + connect(d_ptr.data(), SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + connect(d_ptr.data(), SIGNAL(timeChanged2(QTime)), this, SLOT(test(QTime))); + connect(d_ptr.data(), SIGNAL(sendCustom(PresetInfo)), this, SLOT(testCustom(PresetInfo))); + } + + ~TimeModel() + { + } + + int minute() const { return d_ptr->minute(); } + int hour() const { return d_ptr->hour(); } + bool isValid() const { return d_ptr->isReplicaValid(); } + +public slots: + //Test a signal with parameters + void test(QTime t) + { + qDebug()<<"Test"<<t; + d_ptr->SetTimeZone(t.minute()); + } + //Test a signal with a custom type + void testCustom(PresetInfo info) + { + qDebug()<<"testCustom"<<info.presetNumber()<<info.frequency()<<info.stationName(); + } + +signals: + void timeChanged(); + void timeChanged2(QTime t); + void sendCustom(PresetInfo info); + void isValidChanged(); + +private: + QScopedPointer<MinuteTimerReplica> d_ptr; +}; + +class QExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void initializeEngine(QQmlEngine *engine, const char *uri) + { + Q_UNUSED(engine); + Q_UNUSED(uri); + Q_ASSERT(uri == QLatin1String("TimeExample")); + engine->addImportPath(QStringLiteral("qrc:/qml")); + m_client = QRemoteObjectNode::createNodeConnectedToRegistry(); + } + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("TimeExample")); + qmlRegisterType<TimeModel>(uri, 1, 0, "Time"); + } + +}; + +#include "plugin.moc" diff --git a/examples/RemoteObjects/plugins/plugins.pro b/examples/RemoteObjects/plugins/plugins.pro new file mode 100644 index 0000000..ce1518f --- /dev/null +++ b/examples/RemoteObjects/plugins/plugins.pro @@ -0,0 +1,28 @@ +QT += qml remoteobjects + +TEMPLATE = lib +CONFIG += plugin + +REPC_REPLICA += $$PWD/../TimeModel.rep + +DESTDIR = imports/TimeExample +TARGET = qmlqtimeexampleplugin + +SOURCES += plugin.cpp + +pluginfiles.files += \ + imports/TimeExample/qmldir \ + imports/TimeExample/center.png \ + imports/TimeExample/clock.png \ + imports/TimeExample/Clock.qml \ + imports/TimeExample/hour.png \ + imports/TimeExample/minute.png + +#qml.files = plugins.qml +#qml.path += $$[QT_HOST_PREFIX]/qml/plugins +target.path += $$[QT_HOST_PREFIX]/qml/TimeExample +pluginfiles.path += $$[QT_HOST_PREFIX]/qml/TimeExample + +INSTALLS += target pluginfiles + +contains(QT_CONFIG, c++11): CONFIG += c++11 diff --git a/examples/RemoteObjects/plugins/plugins.qml b/examples/RemoteObjects/plugins/plugins.qml new file mode 100644 index 0000000..87318a6 --- /dev/null +++ b/examples/RemoteObjects/plugins/plugins.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Ford Motor Company +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 200 + height: 400 + property int counter: 0; + MouseArea { + anchors.fill: parent + onClicked: + { + counter = (counter + 1) % 3; + console.log(counter); + pageLoader.source = "plugins"+counter+".qml" + } + } + Loader { + id: pageLoader + source: "plugins0.qml" + } +} +//![0] diff --git a/examples/RemoteObjects/plugins/plugins0.qml b/examples/RemoteObjects/plugins/plugins0.qml new file mode 100644 index 0000000..958ae9f --- /dev/null +++ b/examples/RemoteObjects/plugins/plugins0.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 400 + color: "blue" +} +//![0] diff --git a/examples/RemoteObjects/plugins/plugins1.qml b/examples/RemoteObjects/plugins/plugins1.qml new file mode 100644 index 0000000..c9a9237 --- /dev/null +++ b/examples/RemoteObjects/plugins/plugins1.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import TimeExample 1.0 // import types from the plugin + +Rectangle { + width: 200 + height: 400 + color: "blue" + Clock { // this class is defined in QML (imports/TimeExample/Clock.qml) + id: clock1 + anchors.top: parent.top + Time { // this class is defined in C++ (plugin.cpp) + id: time + } + + hours: time.hour + minutes: time.minute + + } +} +//![0] diff --git a/examples/RemoteObjects/plugins/plugins2.qml b/examples/RemoteObjects/plugins/plugins2.qml new file mode 100644 index 0000000..55acb8a --- /dev/null +++ b/examples/RemoteObjects/plugins/plugins2.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import TimeExample 1.0 // import types from the plugin + +Rectangle { + width: 200 + height: 400 + Clock { // this class is defined in QML (imports/TimeExample/Clock.qml) + id: clock1 + anchors.top: parent.top + Time { // this class is defined in C++ (plugin.cpp) + id: time + } + + hours: time.hour + minutes: time.minute + + } + Clock { // this class is defined in QML (imports/TimeExample/Clock.qml) + id: clock2 + anchors.top: clock1.bottom + Time { // this class is defined in C++ (plugin.cpp) + id: time2 + } + + hours: time2.hour + minutes: time2.minute + + } + +} +//![0] |