summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bohlender <michael.bohlender@kdemail.net>2016-11-16 19:17:33 +0100
committerMichael Bohlender <michael.bohlender@kdemail.net>2016-11-16 19:17:33 +0100
commitc685ac89abed2b1cb61c63f361f414d6f9852cb9 (patch)
tree2b8b0559372609a7dd82c15f637841b5b826b98b
parentc10ea09be56a1945c9025afaaf0c98b7c37657e7 (diff)
downloadkube-c685ac89abed2b1cb61c63f361f414d6f9852cb9.tar.gz
kube-c685ac89abed2b1cb61c63f361f414d6f9852cb9.zip
port composer to qqc2 popup
-rw-r--r--components/mail/contents/ui/main.qml76
-rw-r--r--components/package/contents/ui/Composer.qml243
-rw-r--r--components/package/contents/ui/FocusComposer.qml254
3 files changed, 270 insertions, 303 deletions
diff --git a/components/mail/contents/ui/main.qml b/components/mail/contents/ui/main.qml
index c891ea5f..c4340465 100644
--- a/components/mail/contents/ui/main.qml
+++ b/components/mail/contents/ui/main.qml
@@ -86,6 +86,35 @@ Controls2.ApplicationWindow {
86 } 86 }
87 //END Actions 87 //END Actions
88 88
89 //BEGIN ActionHandler
90
91 //TODO
92 /*
93 KubeAction.ActionHandler {
94 actionId: "org.kde.kube.actions.reply"
95 function isReady(context) {
96 return context.mail ? true : false;
97 }
98
99 function handler(context) {
100 var component = composerComponent.createObject(app)
101 component.loadMessage(context.mail, false)
102 }
103 }
104
105 KubeAction.ActionHandler {
106 actionId: "org.kde.kube.actions.edit"
107 function isReady(context) {
108 return context.mail && context.isDraft;
109 }
110 function handler(context) {
111 var component= composerComponent.createObject(app, {"draftMessage": context.mail})
112 component.loadMessage(context.mail, true)
113 }
114 }
115 */
116 //END ActionHandler
117
89 //BEGIN Shortcuts 118 //BEGIN Shortcuts
90 Shortcut { 119 Shortcut {
91 sequence: StandardKey.Refresh 120 sequence: StandardKey.Refresh
@@ -218,38 +247,6 @@ Controls2.ApplicationWindow {
218 height: parent.height 247 height: parent.height
219 width: mailView.width 248 width: mailView.width
220 249
221 Component {
222 id: composerComponent
223
224 KubeComponents.FocusComposer {
225 id: composer
226 anchors.fill: parent
227 }
228 }
229
230 KubeAction.ActionHandler {
231 actionId: "org.kde.kube.actions.reply"
232 function isReady(context) {
233 return context.mail ? true : false;
234 }
235
236 function handler(context) {
237 var component = composerComponent.createObject(app)
238 component.loadMessage(context.mail, false)
239 }
240 }
241
242 KubeAction.ActionHandler {
243 actionId: "org.kde.kube.actions.edit"
244 function isReady(context) {
245 return context.mail && context.isDraft;
246 }
247 function handler(context) {
248 var component= composerComponent.createObject(app, {"draftMessage": context.mail})
249 component.loadMessage(context.mail, true)
250 }
251 }
252
253 Button { 250 Button {
254 id: newMailButton 251 id: newMailButton
255 252
@@ -257,7 +254,7 @@ Controls2.ApplicationWindow {
257 text: "New Email" 254 text: "New Email"
258 tooltip: "compose new email" 255 tooltip: "compose new email"
259 onClicked: { 256 onClicked: {
260 composerComponent.createObject(app) 257 composer.open()
261 } 258 }
262 } 259 }
263 260
@@ -305,4 +302,17 @@ Controls2.ApplicationWindow {
305 } 302 }
306 } 303 }
307 //END ToolBar 304 //END ToolBar
305
306 //BEGIN Composer
307 KubeComponents.FocusComposer {
308 id: composer
309
310 height: app.height * 0.85
311 width: app.width * 0.85
312
313 x: app.width * 0.075
314 y: toolbar.y + toolbar.height
315 }
316 //END Composer
317
308} 318}
diff --git a/components/package/contents/ui/Composer.qml b/components/package/contents/ui/Composer.qml
deleted file mode 100644
index ebc414f7..00000000
--- a/components/package/contents/ui/Composer.qml
+++ /dev/null
@@ -1,243 +0,0 @@
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
19import QtQuick 2.4
20import QtQuick.Controls 1.4
21import QtQuick.Layouts 1.1
22import QtQuick.Dialogs 1.0
23
24import org.kde.kirigami 1.0 as Kirigami
25
26import org.kube.framework.domain 1.0 as KubeFramework
27
28
29Item {
30 id: root
31
32 function loadMessage(message, loadAsDraft) {
33 composer.loadMessage(message, loadAsDraft)
34 }
35
36 function send() {
37 composer.send()
38 }
39
40 function saveAsDraft() {
41 composer.saveAsDraft()
42 }
43
44 function clear() {
45 composer.clear();
46 }
47
48 KubeFramework.ComposerController {
49 id: composer
50 }
51
52 ColumnLayout {
53
54 anchors.fill: parent
55
56 TextField {
57 id: subject
58
59 Layout.fillWidth: true
60
61 placeholderText: "Enter Subject..."
62
63 text: composer.subject
64
65 onTextChanged: {
66 composer.subject = text;
67 }
68 }
69
70 GridLayout {
71
72 columns: 2
73
74 Kirigami.Label {
75 text: "To"
76 }
77
78 RowLayout {
79 Layout.fillWidth: true
80
81 TextField {
82 id: to
83
84 Layout.fillWidth: true
85
86 text: composer.to
87
88 onTextChanged: {
89 composer.to = text;
90 }
91 }
92 }
93
94 Kirigami.Label {
95 text: "Cc"
96
97 visible: cc.visible
98 }
99
100 TextField {
101 id: cc
102
103 Layout.fillWidth: true
104
105 visible: false
106
107 text: composer.cc
108
109 onTextChanged: {
110 composer.cc = text;
111 }
112 }
113
114 Kirigami.Label {
115 text: "Bcc"
116
117 visible: bcc.visible
118 }
119
120 TextField {
121 id: bcc
122
123 Layout.fillWidth: true
124
125 visible : false
126
127 text: composer.bcc
128
129 onTextChanged: {
130 composer.bcc = text;
131 }
132 }
133 }
134
135 RowLayout {
136 Kirigami.Label {
137 text: "Sending as"
138 }
139
140 ComboBox {
141 id: identityCombo
142 model: composer.identityModel
143 textRole: "displayName"
144
145 Layout.fillWidth: true
146
147 onCurrentIndexChanged: {
148 composer.currentIdentityIndex = currentIndex
149 }
150 }
151
152 Button {
153 id: ccButton
154
155 text: "Cc"
156
157 onClicked: {
158 cc.visible = true
159 ccButton.visible = false
160 }
161 }
162
163 Button {
164 id: bccButton
165
166 text: "Bcc"
167
168 onClicked: {
169 bcc.visible = true
170 bccButton.visible = false
171 }
172 }
173 }
174
175 Item {
176
177 Layout.fillWidth: true
178
179 height: subject.height * 1.5
180
181 Button {
182
183 anchors {
184 bottom: parent.bottom
185 right: parent.right
186 }
187
188 text: "Attach"
189
190 onClicked: {
191 fileDialog.open();
192 }
193 }
194 }
195
196 RowLayout {
197
198 Layout.fillWidth: true
199
200 Repeater {
201
202 model: composer.attachments
203
204 delegate: Kirigami.Label {
205 id: name
206
207 text: modelData
208
209 Rectangle {
210
211 anchors.fill: parent
212
213 color: "lightsteelblue"
214 }
215 }
216 }
217 }
218
219 TextArea {
220 id: content
221
222 text: composer.body
223
224 onTextChanged: {
225 composer.body = text;
226 }
227
228 Layout.fillWidth: true
229 Layout.fillHeight: true
230 }
231 }
232
233 FileDialog {
234 id: fileDialog
235
236 title: "Please choose a file"
237
238 onAccepted: {
239 console.log("You chose: " + fileDialog.fileUrl)
240 composer.addAttachment(fileDialog.fileUrl);
241 }
242 }
243}
diff --git a/components/package/contents/ui/FocusComposer.qml b/components/package/contents/ui/FocusComposer.qml
index 9129dba9..c22983f5 100644
--- a/components/package/contents/ui/FocusComposer.qml
+++ b/components/package/contents/ui/FocusComposer.qml
@@ -17,25 +17,48 @@
17*/ 17*/
18 18
19import QtQuick 2.4 19import QtQuick 2.4
20import QtQuick.Controls 1.4
21import QtQuick.Layouts 1.1 20import QtQuick.Layouts 1.1
21import QtQuick.Controls 1.4 as Controls
22import QtQuick.Controls 2.0 as Controls2
22 23
23import org.kde.kirigami 1.0 as Kirigami 24import org.kde.kirigami 1.0 as Kirigami
24 25
25import org.kube.components 1.0 as KubeComponents 26import org.kube.framework.domain 1.0 as KubeFramework
26 27
27KubeComponents.OverlayDialog { 28Controls2.Popup {
28 id: root 29 id: root
29 30
31 //Controler
32 KubeFramework.ComposerController {
33 id: composer
34 }
35
36 //BEGIN functions
30 function loadMessage(message, loadAsDraft) { 37 function loadMessage(message, loadAsDraft) {
31 composer.loadMessage(message, loadAsDraft); 38 composer.loadMessage(message, loadAsDraft)
39 }
40
41 function send() {
42 composer.send()
43 }
44
45 function saveAsDraft() {
46 composer.saveAsDraft()
32 } 47 }
33 48
49 function clear() {
50 composer.clear();
51 }
52 //END functions
53
54 modal: true
55 focus: true
56 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
57
34 Item { 58 Item {
35 anchors.centerIn: parent
36 59
37 height: root.height * 0.8 60 height: parent.height
38 width: root.width * 0.8 61 width: parent.width
39 62
40 ColumnLayout { 63 ColumnLayout {
41 64
@@ -44,45 +67,222 @@ KubeComponents.OverlayDialog {
44 margins: Kirigami.Units.largeSpacing 67 margins: Kirigami.Units.largeSpacing
45 } 68 }
46 69
47 Composer { 70 ColumnLayout {
48 id: composer
49 71
50 Layout.fillWidth: true 72 anchors.fill: parent
51 Layout.fillHeight: true 73
52 } 74 Controls.TextField {
75 id: subject
53 76
54 RowLayout { 77 Layout.fillWidth: true
55 78
56 Button { 79 placeholderText: "Enter Subject..."
57 80
58 text: "Discard" 81 text: composer.subject
59 82
60 onClicked: { 83 onTextChanged: {
61 root.destroy() 84 composer.subject = text;
85 }
86 }
87
88 GridLayout {
89
90 columns: 2
91
92 Kirigami.Label {
93 text: "To"
94 }
95
96 RowLayout {
97 Layout.fillWidth: true
98
99 Controls.TextField {
100 id: to
101
102 Layout.fillWidth: true
103
104 text: composer.to
105
106 onTextChanged: {
107 composer.to = text;
108 }
109 }
110 }
111
112 Kirigami.Label {
113 text: "Cc"
114
115 visible: cc.visible
116 }
117
118 Controls.TextField {
119 id: cc
120
121 Layout.fillWidth: true
122
123 visible: false
124
125 text: composer.cc
126
127 onTextChanged: {
128 composer.cc = text;
129 }
130 }
131
132 Kirigami.Label {
133 text: "Bcc"
134
135 visible: bcc.visible
136 }
137
138 Controls.TextField {
139 id: bcc
140
141 Layout.fillWidth: true
142
143 visible : false
144
145 text: composer.bcc
146
147 onTextChanged: {
148 composer.bcc = text;
149 }
150 }
151 }
152
153 RowLayout {
154 Kirigami.Label {
155 text: "Sending as"
156 }
157
158 Controls.ComboBox {
159 id: identityCombo
160 model: composer.identityModel
161 textRole: "displayName"
162
163 Layout.fillWidth: true
164
165 onCurrentIndexChanged: {
166 composer.currentIdentityIndex = currentIndex
167 }
168 }
169
170 Controls.Button {
171 id: ccButton
172
173 text: "Cc"
174
175 onClicked: {
176 cc.visible = true
177 ccButton.visible = false
178 }
179 }
180
181 Controls.Button {
182 id: bccButton
183
184 text: "Bcc"
185
186 onClicked: {
187 bcc.visible = true
188 bccButton.visible = false
189 }
62 } 190 }
63 } 191 }
64 192
65 Item { 193 Item {
194
66 Layout.fillWidth: true 195 Layout.fillWidth: true
196
197 height: subject.height * 1.5
198
199 Controls.Button {
200
201 anchors {
202 bottom: parent.bottom
203 right: parent.right
204 }
205
206 text: "Attach"
207
208 onClicked: {
209 fileDialog.open();
210 }
211 }
67 } 212 }
68 213
214 RowLayout {
215
216 Layout.fillWidth: true
217
218 Repeater {
219
220 model: composer.attachments
69 221
70 Button { 222 delegate: Kirigami.Label {
223 id: name
71 224
72 text: "Save as Draft" 225 text: modelData
73 226
74 onClicked: { 227 Rectangle {
75 composer.saveAsDraft() 228
76 root.destroy() 229 anchors.fill: parent
230
231 color: "lightsteelblue"
232 }
233 }
77 } 234 }
78 } 235 }
79 236
80 Button { 237 Controls.TextArea {
81 text: "Send" 238 id: content
239
240 text: composer.body
241
242 onTextChanged: {
243 composer.body = text;
244 }
245
246 Layout.fillWidth: true
247 Layout.fillHeight: true
248 }
249
250 RowLayout {
251 id: bottomBar
252
253 width: parent.width
254
255 Controls.Button {
256
257 text: "Discard"
258
259 onClicked: {
260 root.close()
261 }
262 }
263
264 Item {
265 Layout.fillWidth: true
266 }
267
268
269 Controls.Button {
270
271 text: "Save as Draft"
272
273 onClicked: {
274 saveAsDraft()
275 root.close()
276 }
277 }
278
279 Controls.Button {
280 text: "Send"
82 281
83 onClicked: { 282 onClicked: {
84 composer.send() 283 send()
85 root.destroy() 284 root.close()
285 }
86 } 286 }
87 } 287 }
88 } 288 }