From 18668aafc94a981418170e423196545e95d86eca Mon Sep 17 00:00:00 2001 From: Alexander Bilyak Date: Thu, 25 Feb 2021 12:51:32 +0100 Subject: [PATCH] GODT-1029: Fix tray icon not updating under certain conditions --- internal/frontend/qml/Gui.qml | 32 +++++++++++++++++++ internal/frontend/qml/GuiIE.qml | 1 - .../frontend/qml/ProtonUI/InformationBar.qml | 32 ++++++++----------- internal/frontend/qml/tst_Gui.qml | 4 +-- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/internal/frontend/qml/Gui.qml b/internal/frontend/qml/Gui.qml index a543db82..8b9df27e 100644 --- a/internal/frontend/qml/Gui.qml +++ b/internal/frontend/qml/Gui.qml @@ -115,6 +115,38 @@ Item { } onUpdateStateChanged : { + // Update tray icon if needed + switch (go.updateState) { + case "internetCheck": + break; + case "noInternet" : + gui.warningFlags |= Style.warnInfoBar + break; + case "oldVersion": + gui.warningFlags |= Style.warnInfoBar + break; + case "forceUpdate": + // Force update should presist once it happened and never be overwritten. + // That means that tray icon should allways remain in error state. + // But since we have only two sources of error icon in tray (force update + // + installation fail) and both are unrecoverable and we do not ever remove + // error flag from gui.warningFlags - it is ok to rely on gui.warningFlags and + // not on winMain.updateState (which presist forceUpdate) + gui.warningFlags |= Style.errorInfoBar + break; + case "upToDate": + gui.warningFlags &= ~Style.warnInfoBar + break; + case "updateRestart": + gui.warningFlags |= Style.warnInfoBar + break; + case "updateError": + gui.warningFlags |= Style.errorInfoBar + break; + default : + break; + } + // if main window is closed - most probably it is destroyed (see closeMainWindow()) if (winMain == null) { return diff --git a/internal/frontend/qml/GuiIE.qml b/internal/frontend/qml/GuiIE.qml index 0507793f..7e8b9f5c 100644 --- a/internal/frontend/qml/GuiIE.qml +++ b/internal/frontend/qml/GuiIE.qml @@ -30,7 +30,6 @@ Item { id: gui property alias winMain: winMain property bool isFirstWindow: true - property int warningFlags: 0 property var locale : Qt.locale("en_US") property date netBday : new Date("1989-03-13T00:00:00") diff --git a/internal/frontend/qml/ProtonUI/InformationBar.qml b/internal/frontend/qml/ProtonUI/InformationBar.qml index 3aad1960..dc012c4f 100644 --- a/internal/frontend/qml/ProtonUI/InformationBar.qml +++ b/internal/frontend/qml/ProtonUI/InformationBar.qml @@ -108,31 +108,25 @@ Rectangle { onStateChanged : { switch (root.state) { case "internetCheck": - break; + break; case "noInternet" : - gui.warningFlags |= Style.warnInfoBar - retryInternet.start() - secLeft=checkInterval[iTry] - break; + retryInternet.start() + secLeft=checkInterval[iTry] + break; case "oldVersion": - gui.warningFlags |= Style.warnInfoBar - break; + break; case "forceUpdate": - gui.warningFlags |= Style.errorInfoBar - break; + break; case "upToDate": - gui.warningFlags &= ~Style.warnInfoBar - iTry = 0 - secLeft=checkInterval[iTry] - break; + iTry = 0 + secLeft=checkInterval[iTry] + break; case "updateRestart": - gui.warningFlags |= Style.warnInfoBar - break; + break; case "updateError": - gui.warningFlags |= Style.errorInfoBar - break; + break; default : - break; + break; } if (root.state!="noInternet") { @@ -271,7 +265,7 @@ Rectangle { target: closeSign visible: true onClicked: { - root.state = "upToDate" + go.updateState = "upToDate" } } }, diff --git a/internal/frontend/qml/tst_Gui.qml b/internal/frontend/qml/tst_Gui.qml index ddf127f0..6ab0c799 100644 --- a/internal/frontend/qml/tst_Gui.qml +++ b/internal/frontend/qml/tst_Gui.qml @@ -24,7 +24,7 @@ import QtQuick.Window 2.2 Window { id: testroot - width : 150 + width : 250 height : 600 flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint visible : true @@ -60,7 +60,7 @@ Window { Text { id: systrText anchors { - right : test_systray.right + horizontalCenter: parent.horizontalCenter verticalCenter: test_systray.verticalCenter } text: "unset"