aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2020-04-22 18:20:28 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2020-04-22 19:18:16 +0200
commitb7264c4db0e4705ce1e653fb7b8187ea1d397036 (patch)
treeb5b28591dd4c33fcfd4e15476aecc550c75983cb /examples
parenta3205716de5bef7f21d557dcb9bb7cdb0044d57c (diff)
Keep simple copy of EventListener and Simulator
This is for the example. Change-Id: I6a56aaba023d4a45451bcfe1d3004c2de462e364 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/imports/EventList/EventList.qml82
-rw-r--r--examples/imports/EventList/qmldir2
-rw-r--r--examples/imports/EventSimulator/EventListener.qml47
-rw-r--r--examples/imports/EventSimulator/EventSimulator.qml87
-rw-r--r--examples/imports/EventSimulator/qmldir3
5 files changed, 221 insertions, 0 deletions
diff --git a/examples/imports/EventList/EventList.qml b/examples/imports/EventList/EventList.qml
new file mode 100644
index 0000000..5fa2dbc
--- /dev/null
+++ b/examples/imports/EventList/EventList.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Quick Designer Components.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.10
+import QtQuick.Window 2.2
+
+ListView {
+ signal eventTriggered(string eventId, string parameters)
+ anchors.fill: parent
+ highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
+ delegate:
+ Rectangle {
+ id: wrapper
+ width: parent.width
+ height: 40
+
+ MouseArea {
+ anchors.fill: parent
+ onDoubleClicked: {
+ if (parameters != undefined)
+ eventTriggered(eventId, parameters)
+ else
+ eventTriggered(eventId, undefined)
+ }
+ }
+ Row {
+ spacing: 32
+ Text {
+ width: 400
+ text: eventId
+ color: "grey"
+ }
+ Text {
+ width: 200
+ text: shortcut
+ horizontalAlignment: Text.AlignRight
+ }
+ }
+ color: "lightgrey"
+ Shortcut {
+ sequence: shortcut
+ onActivated : {
+ if (parameters != undefined)
+ eventTriggered(eventId, parameters)
+ else
+ eventTriggered(eventId, undefined)
+ }
+ }
+ }
+}
+
+/*##^##
+Designer {
+ D{i:0;autoSize:true;height:480;width:640}
+}
+##^##*/
diff --git a/examples/imports/EventList/qmldir b/examples/imports/EventList/qmldir
new file mode 100644
index 0000000..6f0d3cc
--- /dev/null
+++ b/examples/imports/EventList/qmldir
@@ -0,0 +1,2 @@
+module EventList
+EventList 1.0 EventList.qml
diff --git a/examples/imports/EventSimulator/EventListener.qml b/examples/imports/EventSimulator/EventListener.qml
new file mode 100644
index 0000000..b5875ea
--- /dev/null
+++ b/examples/imports/EventSimulator/EventListener.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Quick Designer Components.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** 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$
+**
+****************************************************************************/
+
+import QtQuick 2.10
+import EventList 1.0
+
+QtObject {
+ id: root
+ signal triggered(var parameters)
+ property string eventIds
+
+ function __receiveEvent(eventId, parameters) {
+ var split = root.eventIds.split(',').map(item=>item.trim());
+ if (root.eventIds === eventId || split.indexOf(eventId) > -1)
+ root.triggered(parameters)
+ }
+
+ Component.onCompleted: {
+ EventSimulator.eventTriggered.connect(__receiveEvent)
+ }
+}
diff --git a/examples/imports/EventSimulator/EventSimulator.qml b/examples/imports/EventSimulator/EventSimulator.qml
new file mode 100644
index 0000000..7a2014b
--- /dev/null
+++ b/examples/imports/EventSimulator/EventSimulator.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Quick Designer Components.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** 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 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** 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$
+**
+****************************************************************************/
+
+pragma Singleton
+import QtQuick 2.10
+import QtQuick.Window 2.2
+import EventList 1.0
+
+QtObject {
+ id: root
+ property ListModel model
+ signal eventTriggered(string eventID, string parameters)
+
+ function init(modelURI) {
+ eventListLoader.loaded.connect(modelLoaded)
+ eventListLoader.source = modelURI
+ }
+
+ function modelLoaded()
+ {
+ eventList.model = eventListLoader.item
+ eventList.eventTriggered.connect(eventTriggered)
+ }
+
+ function show(x, y, width, height)
+ {
+ if (x !== undefined)
+ eventDialog.x = x
+ if (y !== undefined)
+ eventDialog.y = y
+ if (width !== undefined)
+ eventDialog.width = width
+ if (height !== undefined)
+ eventDialog.height = height
+
+ //eventDialog.modality = Qt.ApplicationModal
+ eventDialog.show()
+ eventDialog.raise()
+ }
+
+ function hide()
+ {
+ eventDialog.modality = Qt.NonModal
+ eventDialog.hide()
+ eventDialog.lower()
+ }
+
+ property Window eventDialog: Window {
+ width: 250
+ height: 250
+ modality: Qt.NonModal
+
+ EventList {
+ id: eventList
+ }
+
+ Loader {
+ id: eventListLoader
+ }
+ }
+}
diff --git a/examples/imports/EventSimulator/qmldir b/examples/imports/EventSimulator/qmldir
new file mode 100644
index 0000000..868599c
--- /dev/null
+++ b/examples/imports/EventSimulator/qmldir
@@ -0,0 +1,3 @@
+module io.qt.EventSimulator
+singleton EventSimulator 1.0 EventSimulator.qml
+EventListener 1.0 EventListener.qml