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 +++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 21 deletions(-) (limited to 'components') 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) } -- cgit v1.2.3