diff options
Diffstat (limited to 'framework/qml/SearchPopup.qml')
-rw-r--r-- | framework/qml/SearchPopup.qml | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/framework/qml/SearchPopup.qml b/framework/qml/SearchPopup.qml new file mode 100644 index 00000000..b1787e1b --- /dev/null +++ b/framework/qml/SearchPopup.qml | |||
@@ -0,0 +1,184 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | |||
21 | import QtQuick 2.9 | ||
22 | import QtQuick.Controls 2 | ||
23 | import QtQuick.Layouts 1.1 | ||
24 | |||
25 | import org.kube.framework 1.0 as Kube | ||
26 | |||
27 | Item { | ||
28 | id: root | ||
29 | |||
30 | property rect searchArea | ||
31 | property string backgroundColor: Kube.Colors.darkCharcoalGrey | ||
32 | property real backgroundOpacity: 0 | ||
33 | property real searchAreaOpacity: backgroundOpacity / 4 | ||
34 | |||
35 | NumberAnimation on backgroundOpacity { | ||
36 | id: fadeIn | ||
37 | from: 0 | ||
38 | to: 0.8 | ||
39 | duration: 100 | ||
40 | } | ||
41 | |||
42 | Component.onCompleted: fadeIn.start() | ||
43 | |||
44 | NumberAnimation on backgroundOpacity { | ||
45 | id: fadeOut | ||
46 | running: false | ||
47 | to: 0 | ||
48 | duration: 100 | ||
49 | onRunningChanged: { | ||
50 | if (!running) { | ||
51 | root.destroy() | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | function close() { | ||
57 | fadeOut.start() | ||
58 | } | ||
59 | |||
60 | property string filter: "" | ||
61 | |||
62 | parent: ApplicationWindow.overlay | ||
63 | anchors.fill: parent | ||
64 | enabled: false | ||
65 | |||
66 | //left | ||
67 | Rectangle { | ||
68 | x: 0 | ||
69 | y: 0 | ||
70 | width: searchArea.x | ||
71 | height: parent.height | ||
72 | color: parent.backgroundColor | ||
73 | opacity: parent.backgroundOpacity | ||
74 | } | ||
75 | //bottom | ||
76 | Rectangle { | ||
77 | x: searchArea.x | ||
78 | y: searchArea.y + searchArea.height | ||
79 | width: searchArea.width | ||
80 | height: parent.height - y | ||
81 | color: parent.backgroundColor | ||
82 | opacity: parent.backgroundOpacity | ||
83 | } | ||
84 | //right | ||
85 | Rectangle { | ||
86 | x: searchArea.x + searchArea.width | ||
87 | y: 0 | ||
88 | width: parent.width - x | ||
89 | height: parent.height | ||
90 | color: parent.backgroundColor | ||
91 | opacity: parent.backgroundOpacity | ||
92 | } | ||
93 | //bottom | ||
94 | Rectangle { | ||
95 | x: searchArea.x | ||
96 | y: 0 | ||
97 | width: searchArea.width | ||
98 | height: searchArea.y | ||
99 | color: parent.backgroundColor | ||
100 | opacity: parent.backgroundOpacity | ||
101 | } | ||
102 | //outline | ||
103 | Rectangle { | ||
104 | x: searchArea.x | ||
105 | y: searchArea.y | ||
106 | width: searchArea.width | ||
107 | height: searchArea.height | ||
108 | color: "transparent" | ||
109 | border { | ||
110 | width: 3 | ||
111 | color: Kube.Colors.highlightColor | ||
112 | } | ||
113 | Rectangle { | ||
114 | anchors.fill: parent | ||
115 | color: parent.parent.backgroundColor | ||
116 | opacity: parent.parent.searchAreaOpacity | ||
117 | } | ||
118 | } | ||
119 | |||
120 | |||
121 | Rectangle { | ||
122 | id: filterField | ||
123 | enabled: true | ||
124 | parent: ApplicationWindow.overlay | ||
125 | |||
126 | anchors { | ||
127 | horizontalCenter: parent.horizontalCenter | ||
128 | } | ||
129 | y: parent.height / 3 | ||
130 | height: Kube.Units.gridUnit * 2 | ||
131 | width: Kube.Units.gridUnit * 30 | ||
132 | radius: Kube.Units.smallSpacing | ||
133 | |||
134 | color: Kube.Colors.darkBackgroundColor | ||
135 | |||
136 | states: [ | ||
137 | State { | ||
138 | name: "searchInProgress" | ||
139 | when: find.text.length != 0 | ||
140 | PropertyChanges {target: filterField; y: Kube.Units.gridUnit} | ||
141 | PropertyChanges {target: root; searchAreaOpacity: 0} | ||
142 | } | ||
143 | ] | ||
144 | |||
145 | transitions: Transition { | ||
146 | NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad } | ||
147 | } | ||
148 | |||
149 | function clearSearch() { | ||
150 | find.text = "" | ||
151 | root.close() | ||
152 | } | ||
153 | |||
154 | Shortcut { | ||
155 | sequences: [StandardKey.Cancel] | ||
156 | onActivated: filterField.clearSearch() | ||
157 | } | ||
158 | |||
159 | RowLayout { | ||
160 | anchors { | ||
161 | verticalCenter: parent.verticalCenter | ||
162 | } | ||
163 | |||
164 | width: parent.width - Kube.Units.smallSpacing | ||
165 | spacing: 0 | ||
166 | |||
167 | Kube.IconButton { | ||
168 | iconName: Kube.Icons.remove | ||
169 | activeFocusOnTab: visible | ||
170 | onClicked: filterField.clearSearch() | ||
171 | } | ||
172 | |||
173 | Kube.TextField { | ||
174 | id: find | ||
175 | Layout.fillWidth: true | ||
176 | placeholderText: qsTr("Filter...") | ||
177 | onTextChanged: root.filter = text | ||
178 | activeFocusOnTab: visible | ||
179 | focus: visible | ||
180 | Keys.onEscapePressed: filterField.clearSearch() | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | } | ||