diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-04 19:19:41 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-04-04 19:19:41 +0200 |
commit | d9295fc8f19e4005f8454e7f193f80316550ac0c (patch) | |
tree | f27c370d54bced09212b9c4a12b827d1cebb6110 /framework/qml/MailListView.qml | |
parent | d002eae7f8b443dd1bad914444c296088c2b6e85 (diff) | |
download | kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.tar.gz kube-d9295fc8f19e4005f8454e7f193f80316550ac0c.zip |
One framework plugin to rule them all
Diffstat (limited to 'framework/qml/MailListView.qml')
-rw-r--r-- | framework/qml/MailListView.qml | 292 |
1 files changed, 292 insertions, 0 deletions
diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml new file mode 100644 index 00000000..2d5d6601 --- /dev/null +++ b/framework/qml/MailListView.qml | |||
@@ -0,0 +1,292 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, 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 General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 2.0 | ||
21 | import QtQuick.Controls 1.4 as Controls | ||
22 | import QtQuick.Layouts 1.1 | ||
23 | |||
24 | import org.kube.components.theme 1.0 as KubeTheme | ||
25 | import org.kube.framework.domain 1.0 as KubeFramework | ||
26 | |||
27 | Item { | ||
28 | id: root | ||
29 | property variant parentFolder | ||
30 | property variant currentMail: null | ||
31 | property bool isDraft : false | ||
32 | property int currentIndex | ||
33 | property string filterString: searchBar.text; | ||
34 | |||
35 | onParentFolderChanged: { | ||
36 | currentMail = null | ||
37 | } | ||
38 | |||
39 | ToolBar { | ||
40 | id: toolbar | ||
41 | |||
42 | width: parent.width | ||
43 | |||
44 | Row { | ||
45 | anchors.centerIn: parent | ||
46 | |||
47 | spacing: KubeTheme.Units.smallSpacing | ||
48 | |||
49 | Controls.ToolButton { | ||
50 | iconName: KubeTheme.Icons.markAsRead | ||
51 | text: qsTr("Mark As Read") | ||
52 | enabled: mailController.markAsReadAction.enabled | ||
53 | tooltip: qsTr("mark mail as read") | ||
54 | onClicked: { | ||
55 | mailController.markAsReadAction.execute() | ||
56 | } | ||
57 | } | ||
58 | |||
59 | Controls.ToolButton { | ||
60 | iconName: KubeTheme.Icons.markImportant | ||
61 | text: qsTr("Mark Important") | ||
62 | enabled: mailController.markAsImportantAction.enabled | ||
63 | tooltip: qsTr("mark mail as important") | ||
64 | onClicked: { | ||
65 | mailController.markAsImportantAction.execute() | ||
66 | } | ||
67 | } | ||
68 | |||
69 | Controls.ToolButton { | ||
70 | iconName: KubeTheme.Icons.moveToTrash | ||
71 | text: qsTr("Delete Mail") | ||
72 | enabled: mailController.moveToTrashAction.enabled | ||
73 | tooltip: qsTr("delete email") | ||
74 | onClicked: { | ||
75 | mailController.moveToTrashAction.execute() | ||
76 | } | ||
77 | } | ||
78 | |||
79 | Controls.ToolButton { | ||
80 | iconName: KubeTheme.Icons.undo | ||
81 | text: qsTr("Restore Mail") | ||
82 | enabled: mailController.restoreFromTrashAction.enabled | ||
83 | tooltip: qsTr("restore email") | ||
84 | onClicked: { | ||
85 | mailController.restoreFromTrashAction.execute() | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | TextField { | ||
92 | id: searchBar | ||
93 | anchors.top: toolbar.bottom | ||
94 | width: parent.width | ||
95 | placeholderText: qsTr("Filter...") | ||
96 | } | ||
97 | |||
98 | Label { | ||
99 | anchors.top: searchBar.bottom | ||
100 | visible: listView.count === 0 | ||
101 | //TODO depending on whether we synchronized already or not the label should change. | ||
102 | text: "Nothing here..." | ||
103 | } | ||
104 | |||
105 | ListView { | ||
106 | id: listView | ||
107 | |||
108 | anchors.top: searchBar.bottom | ||
109 | |||
110 | width: parent.width | ||
111 | height: parent.height - toolbar.height | ||
112 | |||
113 | focus: true | ||
114 | clip: true | ||
115 | |||
116 | ScrollBar.vertical: ScrollBar{ | ||
117 | id: scrollbar | ||
118 | } | ||
119 | |||
120 | //BEGIN keyboard nav | ||
121 | Keys.onDownPressed: { | ||
122 | incrementCurrentIndex() | ||
123 | } | ||
124 | Keys.onUpPressed: { | ||
125 | decrementCurrentIndex() | ||
126 | } | ||
127 | //END keyboard nav | ||
128 | |||
129 | currentIndex: root.currentIndex | ||
130 | onCurrentItemChanged: { | ||
131 | root.currentMail = currentItem.currentData.domainObject; | ||
132 | root.isDraft = currentItem.currentData.draft; | ||
133 | } | ||
134 | |||
135 | model: KubeFramework.MailListModel { | ||
136 | parentFolder: root.parentFolder | ||
137 | filter: root.filterString | ||
138 | } | ||
139 | |||
140 | delegate: Item { | ||
141 | id: origin | ||
142 | |||
143 | property variant currentData: model | ||
144 | |||
145 | width: delegateRoot.width | ||
146 | height: delegateRoot.height | ||
147 | |||
148 | Item { | ||
149 | id: delegateRoot | ||
150 | |||
151 | property variant mail : model.domainObject | ||
152 | |||
153 | width: scrollbar.visible ? listView.width - scrollbar.width : listView.width | ||
154 | height: KubeTheme.Units.gridUnit * 5 | ||
155 | |||
156 | states: [ | ||
157 | State { | ||
158 | name: "dnd" | ||
159 | when: mouseArea.drag.active | ||
160 | |||
161 | PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor} | ||
162 | PropertyChanges {target: delegateRoot; x: x; y:y} | ||
163 | PropertyChanges {target: delegateRoot; parent: root} | ||
164 | |||
165 | PropertyChanges {target: delegateRoot; opacity: 0.7} | ||
166 | PropertyChanges {target: background; color: KubeTheme.Colors.highlightColor} | ||
167 | PropertyChanges {target: subject; color: KubeTheme.Colors.highlightedTextColor} | ||
168 | PropertyChanges {target: sender; color: KubeTheme.Colors.highlightedTextColor} | ||
169 | PropertyChanges {target: date; color: KubeTheme.Colors.highlightedTextColor} | ||
170 | PropertyChanges {target: threadCounter; color: KubeTheme.Colors.highlightedTextColor} | ||
171 | }, | ||
172 | State { | ||
173 | name: "selected" | ||
174 | when: listView.currentIndex == index && !mouseArea.drag.active | ||
175 | |||
176 | PropertyChanges {target: background; color: KubeTheme.Colors.highlightColor} | ||
177 | PropertyChanges {target: subject; color: KubeTheme.Colors.highlightedTextColor} | ||
178 | PropertyChanges {target: sender; color: KubeTheme.Colors.highlightedTextColor} | ||
179 | PropertyChanges {target: date; color: KubeTheme.Colors.highlightedTextColor} | ||
180 | PropertyChanges {target: threadCounter; color: KubeTheme.Colors.highlightedTextColor} | ||
181 | }, | ||
182 | State { | ||
183 | name: "hovered" | ||
184 | when: mouseArea.containsMouse && !mouseArea.drag.active | ||
185 | |||
186 | PropertyChanges {target: background; color: KubeTheme.Colors.highlightColor; opacity: 0.7} | ||
187 | PropertyChanges {target: subject; color: KubeTheme.Colors.highlightedTextColor} | ||
188 | PropertyChanges {target: sender; color: KubeTheme.Colors.highlightedTextColor} | ||
189 | PropertyChanges {target: date; color: KubeTheme.Colors.highlightedTextColor} | ||
190 | PropertyChanges {target: threadCounter; color: KubeTheme.Colors.highlightedTextColor} | ||
191 | } | ||
192 | ] | ||
193 | |||
194 | Drag.active: mouseArea.drag.active | ||
195 | Drag.hotSpot.x: mouseArea.mouseX | ||
196 | Drag.hotSpot.y: mouseArea.mouseY | ||
197 | Drag.source: delegateRoot | ||
198 | |||
199 | MouseArea { | ||
200 | id: mouseArea | ||
201 | |||
202 | anchors.fill: parent | ||
203 | |||
204 | hoverEnabled: true | ||
205 | drag.target: parent | ||
206 | |||
207 | onClicked: { | ||
208 | listView.currentIndex = index | ||
209 | } | ||
210 | onReleased: parent.Drag.drop() | ||
211 | } | ||
212 | |||
213 | Rectangle { | ||
214 | id: background | ||
215 | |||
216 | anchors.fill: parent | ||
217 | |||
218 | color: KubeTheme.Colors.viewBackgroundColor | ||
219 | |||
220 | border.color: KubeTheme.Colors.backgroundColor | ||
221 | border.width: 1 | ||
222 | } | ||
223 | |||
224 | Item { | ||
225 | id: content | ||
226 | |||
227 | anchors { | ||
228 | top: parent.top | ||
229 | bottom: parent.bottom | ||
230 | left: parent.left | ||
231 | right: parent.right | ||
232 | margins: KubeTheme.Units.smallSpacing | ||
233 | } | ||
234 | |||
235 | Column { | ||
236 | anchors { | ||
237 | verticalCenter: parent.verticalCenter | ||
238 | left: parent.left | ||
239 | leftMargin: KubeTheme.Units.largeSpacing | ||
240 | } | ||
241 | |||
242 | Text{ | ||
243 | id: subject | ||
244 | |||
245 | text: model.subject | ||
246 | color: model.unread ? KubeTheme.Colors.highlightColor : KubeTheme.Colors.textColor | ||
247 | |||
248 | maximumLineCount: 2 | ||
249 | width: content.width - KubeTheme.Units.gridUnit * 3 | ||
250 | wrapMode: Text.WrapAnywhere | ||
251 | elide: Text.ElideRight | ||
252 | } | ||
253 | |||
254 | Text { | ||
255 | id: sender | ||
256 | |||
257 | text: model.senderName | ||
258 | font.italic: true | ||
259 | color: KubeTheme.Colors.textColor | ||
260 | width: delegateRoot.width - KubeTheme.Units.gridUnit * 3 | ||
261 | elide: Text.ElideRight | ||
262 | } | ||
263 | } | ||
264 | |||
265 | Text { | ||
266 | id: date | ||
267 | |||
268 | anchors { | ||
269 | right: parent.right | ||
270 | bottom: parent.bottom | ||
271 | } | ||
272 | text: Qt.formatDateTime(model.date, "dd MMM yyyy") | ||
273 | font.italic: true | ||
274 | color: KubeTheme.Colors.disabledTextColor | ||
275 | font.pointSize: 9 | ||
276 | } | ||
277 | |||
278 | Text { | ||
279 | id: threadCounter | ||
280 | |||
281 | anchors { | ||
282 | right: parent.right | ||
283 | } | ||
284 | text: model.threadSize | ||
285 | color: model.unread ? KubeTheme.Colors.highlightColor : KubeTheme.Colors.disabledTextColor | ||
286 | visible: model.threadSize > 1 | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | } | ||