summaryrefslogtreecommitdiffstats
path: root/components/package
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-13 16:24:31 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-16 14:54:14 +0100
commit630f45719a527f8ee739b03bc62f886badea6df3 (patch)
treeb9d859cbfedb30ad8a9570e3b87a419bf24ba6c7 /components/package
parentb1a2e2de201985a00980bead5272977cda4ef637 (diff)
downloadkube-630f45719a527f8ee739b03bc62f886badea6df3.tar.gz
kube-630f45719a527f8ee739b03bc62f886badea6df3.zip
Revamp of composercontroller to use actions more.
Instead of setting all properties individually we directly assign all properties to a context that we assign to the actions. This way actions can automatically update themselves as new data becomes available, and we avoid the setter/getter boilerplate, at the cost of a less explicit interface (But that could be improved by allowing to define the required properties of a context in c++). By relying on prehandler/posthandler to execute certain actions we simplify the control flow and enable the future extension with handlers that i.e. do encryption etc.
Diffstat (limited to 'components/package')
-rw-r--r--components/package/contents/ui/FocusComposer.qml55
1 files changed, 34 insertions, 21 deletions
diff --git a/components/package/contents/ui/FocusComposer.qml b/components/package/contents/ui/FocusComposer.qml
index 8b7c2db9..aee20cd5 100644
--- a/components/package/contents/ui/FocusComposer.qml
+++ b/components/package/contents/ui/FocusComposer.qml
@@ -23,24 +23,39 @@ import QtQuick.Controls 2.0 as Controls2
23import org.kde.kirigami 1.0 as Kirigami 23import org.kde.kirigami 1.0 as Kirigami
24 24
25import org.kube.framework.domain 1.0 as KubeFramework 25import org.kube.framework.domain 1.0 as KubeFramework
26import org.kube.framework.actions 1.0 as KubeAction
26 27
27Controls2.Popup { 28Controls2.Popup {
28 id: root 29 id: root
29 30
30 //Controler 31 //Controller
31 KubeFramework.ComposerController { 32 KubeFramework.ComposerController {
32 id: composer 33 id: composer
34
35 mailContext: KubeAction.Context {
36 id: mailcontext
37 property variant to
38 property variant cc
39 property variant bcc
40 property variant from
41 property variant subject
42 property variant body
43 }
44
45 /* onDone: { */
46 /* root.close() */
47 /* } */
33 } 48 }
34 49
50 //actions
51 property variant sendAction: composer.sendAction
52 property variant saveAsDraftAction: composer.saveAsDraftAction
53
35 //BEGIN functions 54 //BEGIN functions
36 function loadMessage(message, loadAsDraft) { 55 function loadMessage(message, loadAsDraft) {
37 composer.loadMessage(message, loadAsDraft) 56 composer.loadMessage(message, loadAsDraft)
38 } 57 }
39 58
40 function send() {
41 composer.send()
42 }
43
44 function saveAsDraft() { 59 function saveAsDraft() {
45 composer.saveAsDraft() 60 composer.saveAsDraft()
46 } 61 }
@@ -84,9 +99,9 @@ Controls2.Popup {
84 99
85 Layout.fillWidth: true 100 Layout.fillWidth: true
86 101
87 text: composer.to 102 text: mailcontext.to
88 onTextChanged: { 103 onTextChanged: {
89 composer.to = text; 104 mailcontext.to = text;
90 } 105 }
91 106
92 model: composer.recepientAutocompletionModel 107 model: composer.recepientAutocompletionModel
@@ -109,10 +124,10 @@ Controls2.Popup {
109 124
110 visible: false 125 visible: false
111 126
112 text: composer.cc 127 text: mailcontext.cc
113 128
114 onTextChanged: { 129 onTextChanged: {
115 composer.cc = text; 130 mailcontext.cc = text;
116 } 131 }
117 132
118 model: composer.recepientAutocompletionModel 133 model: composer.recepientAutocompletionModel
@@ -134,10 +149,10 @@ Controls2.Popup {
134 149
135 visible : false 150 visible : false
136 151
137 text: composer.bcc 152 text: mailcontext.bcc
138 153
139 onTextChanged: { 154 onTextChanged: {
140 composer.bcc = text; 155 mailcontext.bcc = text;
141 } 156 }
142 157
143 model: composer.recepientAutocompletionModel 158 model: composer.recepientAutocompletionModel
@@ -194,20 +209,20 @@ Controls2.Popup {
194 209
195 placeholderText: "Enter Subject..." 210 placeholderText: "Enter Subject..."
196 211
197 text: composer.subject 212 text: mailcontext.subject
198 213
199 onTextChanged: { 214 onTextChanged: {
200 composer.subject = text; 215 mailcontext.subject = text;
201 } 216 }
202 } 217 }
203 218
204 Controls2.TextArea { 219 Controls2.TextArea {
205 id: content 220 id: content
206 221
207 text: composer.body 222 text: mailcontext.body
208 223
209 onTextChanged: { 224 onTextChanged: {
210 composer.body = text; 225 mailcontext.body = text;
211 } 226 }
212 227
213 Layout.fillWidth: true 228 Layout.fillWidth: true
@@ -220,7 +235,6 @@ Controls2.Popup {
220 width: parent.width 235 width: parent.width
221 236
222 Controls2.Button { 237 Controls2.Button {
223
224 text: "Discard" 238 text: "Discard"
225 239
226 onClicked: { 240 onClicked: {
@@ -234,21 +248,20 @@ Controls2.Popup {
234 248
235 249
236 Controls2.Button { 250 Controls2.Button {
237
238 text: "Save as Draft" 251 text: "Save as Draft"
239 252
253 enabled: saveAsDraftAction.ready
240 onClicked: { 254 onClicked: {
241 saveAsDraft() 255 saveAsDraftAction.execute()
242 root.close()
243 } 256 }
244 } 257 }
245 258
246 Controls2.Button { 259 Controls2.Button {
247 text: "Send" 260 text: "Send"
248 261
262 enabled: sendAction.ready
249 onClicked: { 263 onClicked: {
250 send() 264 sendAction.execute()
251 root.close()
252 } 265 }
253 } 266 }
254 } 267 }