summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/kube/qml/Kube.qml5
-rw-r--r--components/kube/qml/ViewManager.qml88
-rw-r--r--framework/qml/Messages.qml1
-rw-r--r--views/log/qml/View.qml3
4 files changed, 53 insertions, 44 deletions
diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml
index 61933908..8d77ddb5 100644
--- a/components/kube/qml/Kube.qml
+++ b/components/kube/qml/Kube.qml
@@ -199,7 +199,10 @@ Controls2.ApplicationWindow {
199 onClicked: kubeViews.showView("log") 199 onClicked: kubeViews.showView("log")
200 activeFocusOnTab: true 200 activeFocusOnTab: true
201 checkable: true 201 checkable: true
202 alert: kubeViews.getView("log").pendingError 202 Kube.Listener {
203 filter: Kube.Messages.errorPending
204 onMessageReceived: logButton.alert = message.errorPending
205 }
203 checked: kubeViews.currentViewName == "log" 206 checked: kubeViews.currentViewName == "log"
204 Controls2.ButtonGroup.group: viewButtonGroup 207 Controls2.ButtonGroup.group: viewButtonGroup
205 tooltip: qsTr("logview") 208 tooltip: qsTr("logview")
diff --git a/components/kube/qml/ViewManager.qml b/components/kube/qml/ViewManager.qml
index 4c28403f..15ff2638 100644
--- a/components/kube/qml/ViewManager.qml
+++ b/components/kube/qml/ViewManager.qml
@@ -19,49 +19,17 @@
19 19
20import QtQuick 2.7 20import QtQuick 2.7
21import QtQuick.Controls 2.0 21import QtQuick.Controls 2.0
22/* 22
23* TODO
24* * Only replace composer if necessary (on reply, edit draft, ...)
25* * Shutdown procedure to save draft before destruction
26* * Separate logging from view and and make accessible to log (initialize()) call?
27*/
28StackView { 23StackView {
29 id: root 24 id: root
30 property string currentViewName: currentItem ? currentItem.objectName : "" 25 property string currentViewName: currentItem ? currentItem.objectName : ""
31 property variant extensionModel: null 26 property variant extensionModel: null
32 property bool dontFocus: false 27 property bool dontFocus: false
33 28
29 /*
30 * We maintain the view's lifetimes separately from the StackView in the viewDict.
31 */
34 property var viewDict: new Object 32 property var viewDict: new Object
35 function getView(name, replaceView) {
36 if (name in viewDict) {
37 var item = viewDict[name]
38 if (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 }
47 }
48 }
49
50 var source = extensionModel.findSource(name, "View.qml");
51 var component = Qt.createComponent(source)
52 if (component.status == Component.Ready) {
53 var o = component.createObject(root)
54 viewDict[name] = o
55 return o
56 } else if (component.status == Component.Error) {
57 console.error("Error while loading the component: ", source, "\nError: ", component.errorString())
58 } else if (component.status == Component.Loading) {
59 console.error("Error while loading the component: ", source, "\nThe component is loading.")
60 } else {
61 console.error("Unknown error while loading the component: ", source)
62 }
63 return null
64 }
65 33
66 onCurrentItemChanged: { 34 onCurrentItemChanged: {
67 if (currentItem && !dontFocus) { 35 if (currentItem && !dontFocus) {
@@ -69,6 +37,13 @@ StackView {
69 } 37 }
70 } 38 }
71 39
40 function pushView(view, properties, name) {
41 var item = push(view, properties, StackView.Immediate)
42 item.parent = root
43 item.anchors.fill = root
44 item.objectName = name
45 }
46
72 function showOrReplaceView(name, properties, replace) { 47 function showOrReplaceView(name, properties, replace) {
73 if (currentItem && currentItem.objectName == name) { 48 if (currentItem && currentItem.objectName == name) {
74 return 49 return
@@ -80,14 +55,41 @@ StackView {
80 if (currentItem && currentItem.objectName == name) { 55 if (currentItem && currentItem.objectName == name) {
81 return 56 return
82 } 57 }
83 var view = getView(name, replace) 58
84 if (!view) { 59 var item = name in viewDict ? viewDict[name] : null
85 return 60 if (item) {
61 if (replace) {
62 if (item.aborted) {
63 //Call the aborted hook on the view
64 item.aborted()
65 }
66 //Fall through to create new component to replace this one
67 } else {
68 pushView(item, properties, name)
69 return
70 }
71 }
72
73 //Creating a new view
74 var source = extensionModel.findSource(name, "View.qml");
75 //On windows it will be async anyways, so just always create it async
76 var component = Qt.createComponent(source, Qt.Asynchronous)
77
78 function finishCreation() {
79 if (component.status == Component.Ready) {
80 var view = component.createObject(root);
81 viewDict[name] = view
82 pushView(view, properties, name)
83 } else {
84 console.error("Error while loading the component: ", source, "\nError: ", component.errorString())
85 }
86 }
87
88 if (component.status == Component.Loading) {
89 component.statusChanged.connect(finishCreation);
90 } else {
91 finishCreation();
86 } 92 }
87 var item = push(view, properties, StackView.Immediate)
88 item.parent = root
89 item.anchors.fill = root
90 item.objectName = name
91 } 93 }
92 94
93 function showView(name, properties) { 95 function showView(name, properties) {
diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml
index 1483a71c..f357b78b 100644
--- a/framework/qml/Messages.qml
+++ b/framework/qml/Messages.qml
@@ -51,6 +51,7 @@ Item {
51 property string sendOutbox: "sendOutbox" 51 property string sendOutbox: "sendOutbox"
52 52
53 property string componentDone: "done" 53 property string componentDone: "done"
54 property string errorPending: "errorPending"
54 55
55 property string selectNextConversation: "selectNextConversation" 56 property string selectNextConversation: "selectNextConversation"
56 property string selectPreviousConversation: "selectPreviousConversation" 57 property string selectPreviousConversation: "selectPreviousConversation"
diff --git a/views/log/qml/View.qml b/views/log/qml/View.qml
index bf06b76c..3aa76025 100644
--- a/views/log/qml/View.qml
+++ b/views/log/qml/View.qml
@@ -27,6 +27,9 @@ Controls1.SplitView {
27 id: root 27 id: root
28 28
29 property bool pendingError: false; 29 property bool pendingError: false;
30 onPendingErrorChanged: {
31 Kube.Fabric.postMessage(Kube.Messages.errorPending, {errorPending: pendingError})
32 }
30 33
31 Controls2.StackView.onActivated: { 34 Controls2.StackView.onActivated: {
32 root.pendingError = false; 35 root.pendingError = false;