Changeset View
Changeset View
Standalone View
Standalone View
source/qml/lib/DemoTouch.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Fabian Riethmayer | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.2 | ||||
21 | import QtQuick.Layouts 1.2 | ||||
22 | import QtQuick.Controls 2.2 | ||||
23 | import org.kde.kirigami 2.4 as Kirigami | ||||
24 | import "tools.js" as T | ||||
25 | import "annotate.js" as A | ||||
26 | | ||||
27 | Rectangle { | ||||
28 | width: 380 | ||||
29 | height: 320 | ||||
30 | color: "white" | ||||
31 | id: root | ||||
32 | | ||||
33 | Row { | ||||
34 | anchors.fill: parent | ||||
35 | spacing: Kirigami.Units.largeSpacing | ||||
36 | anchors.margins: Kirigami.Units.gridUnit * 2 | ||||
37 | | ||||
38 | ComboBox { | ||||
39 | model: [ "Item1", "Item2", "Item3" ] | ||||
40 | } | ||||
41 | | ||||
42 | Component { | ||||
43 | id: delegateComponent | ||||
44 | Kirigami.SwipeListItem { | ||||
45 | id: listItem | ||||
46 | contentItem: RowLayout { | ||||
47 | Label { | ||||
48 | Layout.fillWidth: true | ||||
49 | height: Math.max(implicitHeight, Kirigami.Units.iconSizes.smallMedium) | ||||
50 | text: model.title | ||||
51 | color: listItem.checked || (listItem.pressed && !listItem.checked && !listItem.sectionDelegate) ? listItem.activeTextColor : listItem.textColor | ||||
52 | } | ||||
53 | } | ||||
54 | actions: [ | ||||
55 | Kirigami.Action { | ||||
56 | iconName: "document-decrypt" | ||||
57 | text: "Action 1" | ||||
58 | onTriggered: showPassiveNotification(model.text + " Action 1 clicked") | ||||
59 | }, | ||||
60 | Kirigami.Action { | ||||
61 | iconName: "mail-reply-sender" | ||||
62 | text: "Action 2" | ||||
63 | onTriggered: showPassiveNotification(model.text + " Action 2 clicked") | ||||
64 | }] | ||||
65 | } | ||||
66 | } | ||||
67 | ListView { | ||||
68 | width: 200 | ||||
69 | height: 200 | ||||
70 | id: mainList | ||||
71 | Timer { | ||||
72 | id: refreshRequestTimer | ||||
73 | interval: 3000 | ||||
74 | onTriggered: page.refreshing = false | ||||
75 | } | ||||
76 | model: ListModel { | ||||
77 | id: listModel | ||||
78 | | ||||
79 | Component.onCompleted: { | ||||
80 | for (var i = 0; i < 200; ++i) { | ||||
81 | listModel.append({"title": "Item " + i, | ||||
82 | "actions": [{text: "Action 1", icon: "document-decrypt"}, | ||||
83 | {text: "Action 2", icon: "mail-reply-sender"}] | ||||
84 | }) | ||||
85 | } | ||||
86 | } | ||||
87 | } | ||||
88 | moveDisplaced: Transition { | ||||
89 | YAnimator { | ||||
90 | duration: Kirigami.Units.longDuration | ||||
91 | easing.type: Easing.InOutQuad | ||||
92 | } | ||||
93 | } | ||||
94 | delegate: Kirigami.DelegateRecycler { | ||||
95 | width: parent ? parent.width : implicitWidth | ||||
96 | sourceComponent: delegateComponent | ||||
97 | } | ||||
98 | } | ||||
99 | } | ||||
100 | | ||||
101 | // HACK coordinates are only final after a small delay | ||||
102 | Timer { | ||||
103 | interval: 1000 | ||||
104 | repeat: false | ||||
105 | running: true | ||||
106 | onTriggered: { | ||||
107 | var a = new A.An(root); | ||||
108 | //a.tree(); | ||||
109 | a.find("swipelistitem").first().swipe({fromX: +90, fromY: 0, toX: -80, toY: 0}); | ||||
110 | } | ||||
111 | } | ||||
112 | | ||||
113 | // Draw helpers and anotation | ||||
114 | Raster { | ||||
115 | base: Kirigami.Units.gridUnit | ||||
116 | desktop: true | ||||
117 | } | ||||
118 | } |