diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-10 16:26:46 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-11 10:32:38 +0200 |
commit | 03fd92efdb0407b34beee13a0d2f4888b4397916 (patch) | |
tree | d24f57edc3489b531984c8f07e8ba2f4680a5e67 /components | |
parent | 24cd706a39ac50c77dd9b88f50b8197bb2013173 (diff) | |
download | kube-03fd92efdb0407b34beee13a0d2f4888b4397916.tar.gz kube-03fd92efdb0407b34beee13a0d2f4888b4397916.zip |
A new composer based on Kube.View
Kube.View is a sort of split-view that always only shows a fixed number
of splits (and doesn't support manual resizing).
Diffstat (limited to 'components')
-rw-r--r-- | components/kube/contents/ui/ComposerView.qml | 347 | ||||
-rw-r--r-- | components/kube/contents/ui/Kube.qml | 14 |
2 files changed, 347 insertions, 14 deletions
diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml index d1bc2ea5..f6bd8396 100644 --- a/components/kube/contents/ui/ComposerView.qml +++ b/components/kube/contents/ui/ComposerView.qml | |||
@@ -19,20 +19,347 @@ | |||
19 | 19 | ||
20 | 20 | ||
21 | import QtQuick 2.7 | 21 | import QtQuick 2.7 |
22 | import QtQuick.Controls 1.3 | ||
23 | import QtQuick.Controls 2.0 as Controls2 | ||
24 | import QtQuick.Layouts 1.1 | ||
25 | |||
22 | import org.kube.framework 1.0 as Kube | 26 | import org.kube.framework 1.0 as Kube |
23 | 27 | ||
24 | Item { | 28 | Kube.View { |
25 | id:root | 29 | id: root |
26 | signal done | 30 | |
27 | property alias message: composer.message | 31 | property bool loadAsDraft: false |
28 | property alias loadAsDraft: composer.loadAsDraft | 32 | property variant message: {} |
33 | |||
34 | //FIXME mean hack to unfuck hiding | ||
35 | property variant _composerController: Kube.ComposerController { | ||
36 | id: composerController | ||
37 | onDone: Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | ||
38 | } | ||
39 | |||
40 | //actions | ||
41 | property variant sendAction: composerController.sendAction | ||
42 | property variant saveAsDraftAction: composerController.saveAsDraftAction | ||
43 | |||
44 | Component.onCompleted: loadMessage(root.message, root.loadAsDraft) | ||
45 | |||
46 | function loadMessage(message, loadAsDraft) { | ||
47 | if (message) { | ||
48 | composerController.loadMessage(message, loadAsDraft) | ||
49 | } | ||
50 | } | ||
51 | |||
52 | function closeFirstSplitIfNecessary() { | ||
53 | //Move the view forward | ||
54 | if (root.currentIndex == 0) { | ||
55 | root.incrementCurrentIndex() | ||
56 | } | ||
57 | } | ||
58 | |||
59 | //Drafts | ||
60 | Rectangle { | ||
61 | width: Kube.Units.gridUnit * 20 | ||
62 | Layout.minimumWidth: Kube.Units.gridUnit * 5 | ||
63 | anchors { | ||
64 | top: parent.top | ||
65 | bottom: parent.bottom | ||
66 | } | ||
67 | |||
68 | color: Kube.Colors.textColor | ||
69 | focus: true | ||
70 | |||
71 | ColumnLayout { | ||
72 | anchors { | ||
73 | fill: parent | ||
74 | margins: Kube.Units.largeSpacing | ||
75 | } | ||
76 | spacing: Kube.Units.smallSpacing | ||
77 | |||
78 | Kube.PositiveButton { | ||
79 | anchors { | ||
80 | left: parent.left | ||
81 | right: parent.right | ||
82 | margins: Kube.Units.largeSpacing | ||
83 | } | ||
84 | focus: true | ||
85 | text: qsTr("New Mail") | ||
86 | onClicked: { | ||
87 | composerController.clear() | ||
88 | subject.forceActiveFocus() | ||
89 | } | ||
90 | } | ||
91 | Kube.Label{ | ||
92 | text: qsTr("Drafts") | ||
93 | color: Kube.Colors.highlightedTextColor | ||
94 | } | ||
95 | ListView { | ||
96 | id: listView | ||
97 | Layout.fillHeight: true | ||
98 | anchors { | ||
99 | left: parent.left | ||
100 | right: parent.right | ||
101 | } | ||
102 | |||
103 | clip: true | ||
104 | |||
105 | // Controls2.ScrollBar.vertical: Controls2.ScrollBar { | ||
106 | // id: scrollbar | ||
107 | // } | ||
108 | |||
109 | //BEGIN keyboard nav | ||
110 | onActiveFocusChanged: { | ||
111 | if (activeFocus && currentIndex < 0) { | ||
112 | currentIndex = 0 | ||
113 | } | ||
114 | } | ||
115 | |||
116 | Keys.onDownPressed: { | ||
117 | listView.incrementCurrentIndex() | ||
118 | } | ||
119 | Keys.onUpPressed: { | ||
120 | listView.decrementCurrentIndex() | ||
121 | } | ||
122 | //END keyboard nav | ||
123 | |||
124 | onCurrentItemChanged: { | ||
125 | root.loadMessage(currentItem.currentData.domainObject, true) | ||
126 | } | ||
127 | |||
128 | model: Kube.MailListModel { | ||
129 | id: mailListModel | ||
130 | showDrafts: true | ||
131 | } | ||
132 | |||
133 | delegate: Item { | ||
134 | property variant currentData: model | ||
135 | |||
136 | width: delegateRoot.width | ||
137 | height: delegateRoot.height | ||
138 | |||
139 | Item { | ||
140 | id: delegateRoot | ||
141 | |||
142 | property variant mail : model.domainObject | ||
143 | |||
144 | // width: scrollbar.visible ? listView.width - scrollbar.width : listView.width | ||
145 | width: listView.width | ||
146 | height: Kube.Units.gridUnit * 4 | ||
147 | |||
148 | states: [ | ||
149 | State { | ||
150 | name: "selected" | ||
151 | when: listView.currentIndex == index | ||
152 | |||
153 | PropertyChanges {target: background; color: Kube.Colors.highlightColor} | ||
154 | PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor} | ||
155 | }, | ||
156 | State { | ||
157 | name: "hovered" | ||
158 | when: ( mouseArea.containsMouse || buttons.containsMouse ) | ||
159 | |||
160 | PropertyChanges {target: background; color: Kube.Colors.highlightColor; opacity: 0.6} | ||
161 | PropertyChanges {target: subject; color: Kube.Colors.highlightedTextColor} | ||
162 | } | ||
163 | ] | ||
29 | 164 | ||
30 | Kube.FocusComposer { | 165 | MouseArea { |
31 | id: composer | 166 | id: mouseArea |
167 | anchors.fill: parent | ||
168 | hoverEnabled: true | ||
169 | onClicked: listView.currentIndex = index | ||
170 | } | ||
171 | |||
172 | Rectangle { | ||
173 | id: background | ||
174 | anchors.fill: parent | ||
175 | color: Kube.Colors.textColor | ||
176 | } | ||
177 | |||
178 | Item { | ||
179 | id: content | ||
180 | |||
181 | anchors { | ||
182 | top: parent.top | ||
183 | bottom: parent.bottom | ||
184 | left: parent.left | ||
185 | right: parent.right | ||
186 | margins: Kube.Units.smallSpacing | ||
187 | } | ||
188 | |||
189 | Column { | ||
190 | anchors { | ||
191 | verticalCenter: parent.verticalCenter | ||
192 | left: parent.left | ||
193 | leftMargin: Kube.Units.largeSpacing | ||
194 | } | ||
195 | |||
196 | Kube.Label{ | ||
197 | id: subject | ||
198 | width: content.width - Kube.Units.gridUnit * 3 | ||
199 | text: model.subject | ||
200 | color: Kube.Colors.highlightedTextColor | ||
201 | maximumLineCount: 2 | ||
202 | wrapMode: Text.WrapAnywhere | ||
203 | elide: Text.ElideRight | ||
204 | } | ||
205 | } | ||
206 | |||
207 | Kube.Label { | ||
208 | id: date | ||
209 | |||
210 | anchors { | ||
211 | right: parent.right | ||
212 | bottom: parent.bottom | ||
213 | } | ||
214 | text: Qt.formatDateTime(model.date, "dd MMM yyyy") | ||
215 | font.italic: true | ||
216 | color: Kube.Colors.disabledTextColor | ||
217 | font.pointSize: 9 | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | //Content | ||
227 | Rectangle { | ||
228 | Layout.fillWidth: true | ||
229 | Layout.minimumWidth: Kube.Units.gridUnit * 5 | ||
230 | anchors { | ||
231 | top: parent.top | ||
232 | bottom: parent.bottom | ||
233 | } | ||
234 | color: Kube.Colors.backgroundColor | ||
235 | |||
236 | ColumnLayout { | ||
237 | anchors { | ||
238 | fill: parent | ||
239 | margins: Kube.Units.largeSpacing | ||
240 | leftMargin: Kube.Units.largeSpacing + Kube.Units.gridUnit * 2 | ||
241 | rightMargin: Kube.Units.largeSpacing + Kube.Units.gridUnit * 2 | ||
242 | } | ||
243 | Kube.TextField { | ||
244 | id: subject | ||
245 | Layout.fillWidth: true | ||
246 | |||
247 | placeholderText: "Enter Subject..." | ||
248 | text: composerController.subject | ||
249 | onTextChanged: composerController.subject = text; | ||
250 | onActiveFocusChanged: closeFirstSplitIfNecessary() | ||
251 | } | ||
252 | |||
253 | Controls2.TextArea { | ||
254 | id: content | ||
255 | Layout.fillWidth: true | ||
256 | Layout.fillHeight: true | ||
257 | |||
258 | text: composerController.body | ||
259 | onTextChanged: composerController.body = text; | ||
260 | onActiveFocusChanged: closeFirstSplitIfNecessary() | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
265 | //Recepients | ||
266 | Rectangle { | ||
267 | width: Kube.Units.gridUnit * 20 | ||
268 | Layout.minimumWidth: Kube.Units.gridUnit * 5 | ||
32 | anchors { | 269 | anchors { |
33 | fill: parent | 270 | top: parent.top |
34 | margins: Kube.Units.smallSpacing | 271 | bottom: parent.bottom |
272 | } | ||
273 | color: Kube.Colors.backgroundColor | ||
274 | ColumnLayout { | ||
275 | anchors { | ||
276 | fill: parent | ||
277 | margins: Kube.Units.largeSpacing | ||
278 | } | ||
279 | width: parent.width | ||
280 | |||
281 | Kube.Label { | ||
282 | text: "Sending Email to" | ||
283 | } | ||
284 | Kube.AutocompleteLineEdit { | ||
285 | id: to | ||
286 | Layout.fillWidth: true | ||
287 | text: composerController.to | ||
288 | onTextChanged: composerController.to = text | ||
289 | model: composerController.recipientCompleter.model | ||
290 | onSearchTermChanged: composerController.recipientCompleter.searchString = searchTerm | ||
291 | } | ||
292 | |||
293 | Kube.Label { | ||
294 | text: "Sending Copy to (CC)" | ||
295 | } | ||
296 | Kube.AutocompleteLineEdit { | ||
297 | id: cc | ||
298 | Layout.fillWidth: true | ||
299 | text: composerController.cc | ||
300 | onTextChanged: composerController.cc = text | ||
301 | model: composerController.recipientCompleter.model | ||
302 | onSearchTermChanged: composerController.recipientCompleter.searchString = searchTerm | ||
303 | } | ||
304 | |||
305 | Kube.Label { | ||
306 | text: "Sending Secret Copy to (Bcc)" | ||
307 | } | ||
308 | Kube.AutocompleteLineEdit { | ||
309 | id: bcc | ||
310 | Layout.fillWidth: true | ||
311 | text: composerController.bcc | ||
312 | onTextChanged: composerController.bcc = text; | ||
313 | model: composerController.recipientCompleter.model | ||
314 | onSearchTermChanged: composerController.recipientCompleter.searchString = searchTerm | ||
315 | } | ||
316 | |||
317 | Item { | ||
318 | Layout.fillHeight: true | ||
319 | } | ||
320 | |||
321 | |||
322 | Item { | ||
323 | Layout.fillHeight: true | ||
324 | } | ||
325 | |||
326 | |||
327 | Kube.Button { | ||
328 | id: saveDraftButton | ||
329 | |||
330 | text: "Save as Draft" | ||
331 | //TODO enabled: saveAsDraftAction.enabled | ||
332 | onClicked: { | ||
333 | saveAsDraftAction.execute() | ||
334 | } | ||
335 | } | ||
336 | Kube.Button { | ||
337 | text: "Discard" | ||
338 | onClicked: Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | ||
339 | } | ||
340 | |||
341 | Kube.Label { | ||
342 | text: "You are sending this from:" | ||
343 | } | ||
344 | Kube.ComboBox { | ||
345 | id: identityCombo | ||
346 | model: composerController.identitySelector.model | ||
347 | textRole: "displayName" | ||
348 | Layout.fillWidth: true | ||
349 | onCurrentIndexChanged: { | ||
350 | composerController.identitySelector.currentIndex = currentIndex | ||
351 | } | ||
352 | } | ||
353 | |||
354 | Kube.PositiveButton { | ||
355 | width: saveDraftButton.width | ||
356 | |||
357 | text: "Send" | ||
358 | enabled: sendAction.enabled | ||
359 | onClicked: { | ||
360 | sendAction.execute() | ||
361 | } | ||
362 | } | ||
35 | } | 363 | } |
36 | onDone: root.done() | ||
37 | } | 364 | } |
38 | } | 365 | } |
diff --git a/components/kube/contents/ui/Kube.qml b/components/kube/contents/ui/Kube.qml index 115123b7..21c6f4fd 100644 --- a/components/kube/contents/ui/Kube.qml +++ b/components/kube/contents/ui/Kube.qml | |||
@@ -117,10 +117,12 @@ Controls2.ApplicationWindow { | |||
117 | 117 | ||
118 | Kube.IconButton { | 118 | Kube.IconButton { |
119 | iconName: Kube.Icons.search_inverted | 119 | iconName: Kube.Icons.search_inverted |
120 | onClicked: search.open() | ||
121 | } | ||
120 | 122 | ||
121 | onClicked: { | 123 | Kube.IconButton { |
122 | search.open() | 124 | iconName: Kube.Icons.edit_inverted |
123 | } | 125 | onClicked: kubeViews.openComposer() |
124 | } | 126 | } |
125 | 127 | ||
126 | Kube.IconButton { | 128 | Kube.IconButton { |
@@ -166,6 +168,11 @@ Controls2.ApplicationWindow { | |||
166 | Layout.fillWidth: true | 168 | Layout.fillWidth: true |
167 | initialItem: mailView | 169 | initialItem: mailView |
168 | 170 | ||
171 | Kube.Listener { | ||
172 | filter: Kube.Messages.componentDone | ||
173 | onMessageReceived: kubeViews.pop({immediate: true}) | ||
174 | } | ||
175 | |||
169 | function setPeopleView() { | 176 | function setPeopleView() { |
170 | //TODO replacing here while a composer is open is destructive | 177 | //TODO replacing here while a composer is open is destructive |
171 | kubeViews.push({item: peopleView, replace: true, immediate: true}) | 178 | kubeViews.push({item: peopleView, replace: true, immediate: true}) |
@@ -202,7 +209,6 @@ Controls2.ApplicationWindow { | |||
202 | Component { | 209 | Component { |
203 | id: composerView | 210 | id: composerView |
204 | ComposerView { | 211 | ComposerView { |
205 | onDone: kubeViews.pop({immediate: true}) | ||
206 | } | 212 | } |
207 | } | 213 | } |
208 | Component { | 214 | Component { |