From 1b46726b46197776c70adb9367fd604d50522755 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 28 Jun 2018 11:21:51 +0200 Subject: Only show the logview if notificaitons are available and rename to Notification view --- components/kube/qml/Kube.qml | 8 ++++++- components/kube/qml/ViewManager.qml | 48 +++++++++++++++++++++---------------- framework/qml/Messages.qml | 1 + views/log/qml/View.qml | 7 ++++++ 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml index 8d77ddb5..e33119aa 100644 --- a/components/kube/qml/Kube.qml +++ b/components/kube/qml/Kube.qml @@ -199,13 +199,18 @@ Controls2.ApplicationWindow { onClicked: kubeViews.showView("log") activeFocusOnTab: true checkable: true + visible: false Kube.Listener { filter: Kube.Messages.errorPending onMessageReceived: logButton.alert = message.errorPending } + Kube.Listener { + filter: Kube.Messages.notificationPending + onMessageReceived: logButton.visible = true + } checked: kubeViews.currentViewName == "log" Controls2.ButtonGroup.group: viewButtonGroup - tooltip: qsTr("logview") + tooltip: qsTr("Notification View") } Kube.IconButton { @@ -232,6 +237,7 @@ Controls2.ApplicationWindow { Component.onCompleted: { dontFocus = true + prepareViewInBackground("log", {}) showView("conversation") if (startupCheck.noAccount) { showView("accounts") diff --git a/components/kube/qml/ViewManager.qml b/components/kube/qml/ViewManager.qml index 15ff2638..e29efaaf 100644 --- a/components/kube/qml/ViewManager.qml +++ b/components/kube/qml/ViewManager.qml @@ -44,6 +44,29 @@ StackView { item.objectName = name } + function createView(name, properties) { + //Creating a new view + var source = extensionModel.findSource(name, "View.qml"); + //On windows it will be async anyways, so just always create it async + var component = Qt.createComponent(source, Qt.Asynchronous) + + function finishCreation() { + if (component.status == Component.Ready) { + var view = component.createObject(root); + viewDict[name] = view + pushView(view, properties, name) + } else { + console.error("Error while loading the component: ", source, "\nError: ", component.errorString()) + } + } + + if (component.status == Component.Loading) { + component.statusChanged.connect(finishCreation); + } else { + finishCreation(); + } + } + function showOrReplaceView(name, properties, replace) { if (currentItem && currentItem.objectName == name) { return @@ -70,32 +93,17 @@ StackView { } } - //Creating a new view - var source = extensionModel.findSource(name, "View.qml"); - //On windows it will be async anyways, so just always create it async - var component = Qt.createComponent(source, Qt.Asynchronous) - - function finishCreation() { - if (component.status == Component.Ready) { - var view = component.createObject(root); - viewDict[name] = view - pushView(view, properties, name) - } else { - console.error("Error while loading the component: ", source, "\nError: ", component.errorString()) - } - } - - if (component.status == Component.Loading) { - component.statusChanged.connect(finishCreation); - } else { - finishCreation(); - } + createView(name) } function showView(name, properties) { showOrReplaceView(name, properties, false) } + function prepareViewInBackground(name, properties) { + createView(name, properties) + } + function replaceView(name, properties) { showOrReplaceView(name, properties, true) } diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml index d9734a0a..1555507f 100644 --- a/framework/qml/Messages.qml +++ b/framework/qml/Messages.qml @@ -52,6 +52,7 @@ Item { property string componentDone: "done" property string errorPending: "errorPending" + property string notificationPending: "notificationPending" property string selectNextConversation: "selectNextConversation" property string selectPreviousConversation: "selectPreviousConversation" diff --git a/views/log/qml/View.qml b/views/log/qml/View.qml index 3aa76025..4dc2bce8 100644 --- a/views/log/qml/View.qml +++ b/views/log/qml/View.qml @@ -27,12 +27,17 @@ Controls1.SplitView { id: root property bool pendingError: false; + property bool pendingNotification: false; onPendingErrorChanged: { Kube.Fabric.postMessage(Kube.Messages.errorPending, {errorPending: pendingError}) } + onPendingNotificationChanged: { + Kube.Fabric.postMessage(Kube.Messages.notificationPending, {notificationPending: pendingNotification}) + } Controls2.StackView.onActivated: { root.pendingError = false; + root.pendingNotification = false; //Always select the latest notification listView.currentIndex = 0 } @@ -53,6 +58,8 @@ Controls1.SplitView { root.pendingError = true } + root.pendingNotification = true + var error = { timestamp: new Date(), message: message.message, -- cgit v1.2.3