diff options
-rw-r--r-- | components/kube/qml/ViewManager.qml | 12 | ||||
-rw-r--r-- | framework/qml/View.qml | 16 | ||||
-rw-r--r-- | views/composer/qml/View.qml | 11 |
3 files changed, 35 insertions, 4 deletions
diff --git a/components/kube/qml/ViewManager.qml b/components/kube/qml/ViewManager.qml index eff0f3f7..517d8de3 100644 --- a/components/kube/qml/ViewManager.qml +++ b/components/kube/qml/ViewManager.qml | |||
@@ -33,12 +33,20 @@ StackView { | |||
33 | 33 | ||
34 | property var viewDict: new Object | 34 | property var viewDict: new Object |
35 | function getView(name, replaceView) { | 35 | function getView(name, replaceView) { |
36 | if (!replaceView && name in viewDict) { | 36 | if (name in viewDict) { |
37 | var item = viewDict[name] | 37 | var item = viewDict[name] |
38 | if (item) { | 38 | if (item) { |
39 | return item | 39 | if (replaceView) { |
40 | if (item && item.aborted) { | ||
41 | //Call the aborted hook on the view | ||
42 | item.aborted() | ||
43 | } | ||
44 | } else { | ||
45 | return item | ||
46 | } | ||
40 | } | 47 | } |
41 | } | 48 | } |
49 | |||
42 | var component = Qt.createComponent(extensionModel.findSource(name, "View.qml")) | 50 | var component = Qt.createComponent(extensionModel.findSource(name, "View.qml")) |
43 | if (component.status == Component.Ready) { | 51 | if (component.status == Component.Ready) { |
44 | var o = component.createObject(root) | 52 | var o = component.createObject(root) |
diff --git a/framework/qml/View.qml b/framework/qml/View.qml index b0c108fc..f4a34701 100644 --- a/framework/qml/View.qml +++ b/framework/qml/View.qml | |||
@@ -31,12 +31,28 @@ FocusScope { | |||
31 | property int count: contentItems.length | 31 | property int count: contentItems.length |
32 | default property alias contentItems: content.data | 32 | default property alias contentItems: content.data |
33 | 33 | ||
34 | property bool __aborted: false | ||
35 | |||
34 | //This signal will be emitted once all initial properties have been set and the view is ready to load | 36 | //This signal will be emitted once all initial properties have been set and the view is ready to load |
35 | signal setup() | 37 | signal setup() |
36 | Controls2.StackView.onActivated: { | 38 | Controls2.StackView.onActivated: { |
37 | root.setup() | 39 | root.setup() |
38 | } | 40 | } |
39 | 41 | ||
42 | //This signal will be emitted before destruction if the view was not done | ||
43 | signal aborted() | ||
44 | onAborted: { | ||
45 | __aborted = true | ||
46 | } | ||
47 | |||
48 | //This signal will be emitted when the view is done | ||
49 | signal done() | ||
50 | onDone: { | ||
51 | if (!__aborted) { | ||
52 | Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | ||
53 | } | ||
54 | } | ||
55 | |||
40 | onCurrentIndexChanged: showRelevantSplits() | 56 | onCurrentIndexChanged: showRelevantSplits() |
41 | Component.onCompleted: showRelevantSplits() | 57 | Component.onCompleted: showRelevantSplits() |
42 | 58 | ||
diff --git a/views/composer/qml/View.qml b/views/composer/qml/View.qml index 85e8b559..9afc5316 100644 --- a/views/composer/qml/View.qml +++ b/views/composer/qml/View.qml | |||
@@ -39,7 +39,7 @@ Kube.View { | |||
39 | htmlBody: html.checked | 39 | htmlBody: html.checked |
40 | sign: signCheckbox.checked | 40 | sign: signCheckbox.checked |
41 | encrypt: encryptCheckbox.checked | 41 | encrypt: encryptCheckbox.checked |
42 | onDone: Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | 42 | onDone: root.done() |
43 | 43 | ||
44 | property bool foundAllKeys: composerController.to.foundAllKeys && composerController.cc.foundAllKeys && composerController.bcc.foundAllKeys | 44 | property bool foundAllKeys: composerController.to.foundAllKeys && composerController.cc.foundAllKeys && composerController.bcc.foundAllKeys |
45 | 45 | ||
@@ -55,6 +55,13 @@ Kube.View { | |||
55 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "contacts"}) | 55 | Kube.Fabric.postMessage(Kube.Messages.synchronize, {"type": "contacts"}) |
56 | } | 56 | } |
57 | 57 | ||
58 | onAborted: { | ||
59 | //Avoid loosing the message | ||
60 | if (composerController.saveAsDraftAction.enabled) { | ||
61 | composerController.saveAsDraftAction.execute() | ||
62 | } | ||
63 | } | ||
64 | |||
58 | function loadMessage(message, loadType) { | 65 | function loadMessage(message, loadType) { |
59 | if (message) { | 66 | if (message) { |
60 | switch(loadType) { | 67 | switch(loadType) { |
@@ -488,7 +495,7 @@ Kube.View { | |||
488 | Kube.Button { | 495 | Kube.Button { |
489 | width: saveDraftButton.width | 496 | width: saveDraftButton.width |
490 | text: qsTr("Discard") | 497 | text: qsTr("Discard") |
491 | onClicked: Kube.Fabric.postMessage(Kube.Messages.componentDone, {}) | 498 | onClicked: root.done() |
492 | } | 499 | } |
493 | 500 | ||
494 | Kube.Button { | 501 | Kube.Button { |