Changeset View
Changeset View
Standalone View
Standalone View
plasmoid/contents/ui/PulleyItem.qml
- This file was added.
1 | import QtQuick 2.9 | ||||
---|---|---|---|---|---|
2 | import org.kde.plasma.core 2.0 as PlasmaCore | ||||
3 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||||
4 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||||
5 | import QtGraphicalEffects 1.0 | ||||
6 | | ||||
7 | Item { | ||||
8 | id: pulleyFrame | ||||
9 | anchors.fill: parent | ||||
10 | anchors.topMargin: units.gridUnit * 0.05 | ||||
11 | anchors.bottomMargin: units.gridUnit * 0.02 | ||||
12 | property bool opened: state === "PulleyExpanded" | ||||
13 | property bool closed: state === "PulleyClosed" | ||||
14 | property bool _isVisible | ||||
15 | property var barColor | ||||
16 | signal pulleyExpanded() | ||||
17 | signal pulleyClosed() | ||||
18 | | ||||
19 | function open() { | ||||
20 | pulleyFrame.state = "PulleyExpanded"; | ||||
21 | pulleyExpanded(); | ||||
22 | } | ||||
23 | | ||||
24 | function close() { | ||||
25 | pulleyFrame.state = "PulleyClosed"; | ||||
26 | pulleyListView.positionViewAtBeginning() | ||||
27 | pulleyClosed(); | ||||
28 | } | ||||
29 | | ||||
30 | states: [ | ||||
31 | State { | ||||
32 | name: "PulleyExpanded" | ||||
33 | PropertyChanges { target: pulleyMenu; height: pulleyFrame.height - pulleyIconBar.height; } | ||||
34 | PropertyChanges { target: pulleyListView; interactive: true; } | ||||
35 | PropertyChanges { target: menudrawIcon; source: "go-down";} | ||||
36 | }, | ||||
37 | State { | ||||
38 | name: "PulleyClosed" | ||||
39 | PropertyChanges { target: pulleyMenu; height: 0; } | ||||
40 | PropertyChanges { target: pulleyListView; interactive: false; } | ||||
41 | PropertyChanges { target: menudrawIcon; source: "go-up";} | ||||
42 | } | ||||
43 | ] | ||||
44 | | ||||
45 | | ||||
46 | transitions: [ | ||||
47 | Transition { | ||||
48 | to: "*" | ||||
49 | NumberAnimation { target: pulleyMenu; properties: "height"; duration: 450; easing.type: Easing.OutCubic; } | ||||
50 | } | ||||
51 | ] | ||||
52 | | ||||
53 | Rectangle { | ||||
54 | id: pulleyIconBar | ||||
55 | anchors.bottom: pulleyMenu.top | ||||
56 | anchors.bottomMargin: 4 | ||||
57 | height: units.gridUnit * 0.40 | ||||
58 | color: barColor | ||||
59 | width: cbwidth | ||||
60 | PlasmaCore.IconItem { | ||||
61 | id: menudrawIcon | ||||
62 | visible: _isVisible | ||||
63 | anchors.centerIn: parent | ||||
64 | source: "go-up" | ||||
65 | width: units.gridUnit * 1.25 | ||||
66 | height: units.gridUnit * 1.25 | ||||
67 | } | ||||
68 | | ||||
69 | MouseArea{ | ||||
70 | anchors.fill: parent | ||||
71 | propagateComposedEvents: true | ||||
72 | onClicked: { | ||||
73 | if (pulleyFrame.opened) { | ||||
74 | pulleyFrame.close(); | ||||
75 | } else { | ||||
76 | pulleyFrame.open(); | ||||
77 | } | ||||
78 | } | ||||
79 | } | ||||
80 | } | ||||
81 | | ||||
82 | Rectangle { | ||||
83 | id: pulleyMenu | ||||
84 | width: parent.width | ||||
85 | color: PlasmaCore.ColorScope.backgroundColor | ||||
86 | anchors.bottom: parent.bottom | ||||
87 | height: 0 | ||||
88 | | ||||
89 | ListView { | ||||
90 | id: pulleyListView | ||||
91 | width: parent.width | ||||
92 | anchors.top: parent.top | ||||
93 | anchors.bottom: pulleyEndArea.bottom | ||||
94 | model: SkillModel{} | ||||
95 | clip: true | ||||
96 | interactive: false; | ||||
97 | spacing: 5 | ||||
98 | delegate: | ||||
99 | Rectangle { | ||||
100 | id: pulleyDelegateListBg | ||||
101 | height: units.gridUnit * 2.5 | ||||
102 | color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) | ||||
103 | radius: 4 | ||||
104 | anchors.left: parent.left | ||||
105 | anchors.right: parent.right | ||||
106 | anchors.leftMargin: units.gridUnit * 0.50 | ||||
107 | anchors.rightMargin: units.gridUnit * 0.50 | ||||
108 | layer.enabled: true | ||||
109 | layer.effect: DropShadow { | ||||
110 | horizontalOffset: 0 | ||||
111 | verticalOffset: 1 | ||||
112 | radius: 10 | ||||
113 | samples: 32 | ||||
114 | spread: 0.1 | ||||
115 | color: Qt.rgba(0, 0, 0, 0.3) | ||||
116 | } | ||||
117 | | ||||
118 | PlasmaComponents.Label { | ||||
119 | id: pulleyDelegateListLabel | ||||
120 | anchors.centerIn: parent | ||||
121 | text: CommandList.get(0).Commands | ||||
122 | color: PlasmaCore.ColorScope.textColor | ||||
123 | | ||||
124 | MouseArea { | ||||
125 | anchors.fill: parent | ||||
126 | hoverEnabled: true | ||||
127 | propagateComposedEvents: true | ||||
128 | | ||||
129 | onEntered: { | ||||
130 | pulleyDelegateListBg.color = theme.linkColor | ||||
131 | } | ||||
132 | onExited: { | ||||
133 | pulleyDelegateListBg.color = Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2) | ||||
134 | } | ||||
135 | onClicked: { | ||||
136 | pulleyFrame.close(); | ||||
137 | var genExampleQuery = CommandList.get(0).Commands; | ||||
138 | var exampleQuery = genExampleQuery.toString().split(","); | ||||
139 | var socketmessage = {}; | ||||
140 | socketmessage.type = "recognizer_loop:utterance"; | ||||
141 | socketmessage.data = {}; | ||||
142 | socketmessage.data.utterances = [exampleQuery[1].toLowerCase()]; | ||||
143 | socket.sendTextMessage(JSON.stringify(socketmessage)); | ||||
144 | qinput.text = ""; | ||||
145 | } | ||||
146 | } | ||||
147 | } | ||||
148 | } | ||||
149 | } | ||||
150 | | ||||
151 | Item { | ||||
152 | id: pulleyEndArea | ||||
153 | anchors.bottom: parent.bottom | ||||
154 | anchors.bottomMargin: units.gridUnit * 1.22 | ||||
155 | width: parent.width | ||||
156 | height: units.gridUnit * 2.5 | ||||
157 | } | ||||
158 | } | ||||
159 | } |