GODT-1029: Fix tray icon not updating under certain conditions

This commit is contained in:
Alexander Bilyak
2021-02-25 12:51:32 +01:00
committed by Jakub Cuth
parent fd73ec6861
commit 18668aafc9
4 changed files with 47 additions and 22 deletions

View File

@ -115,6 +115,38 @@ Item {
} }
onUpdateStateChanged : { 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 main window is closed - most probably it is destroyed (see closeMainWindow())
if (winMain == null) { if (winMain == null) {
return return

View File

@ -30,7 +30,6 @@ Item {
id: gui id: gui
property alias winMain: winMain property alias winMain: winMain
property bool isFirstWindow: true property bool isFirstWindow: true
property int warningFlags: 0
property var locale : Qt.locale("en_US") property var locale : Qt.locale("en_US")
property date netBday : new Date("1989-03-13T00:00:00") property date netBday : new Date("1989-03-13T00:00:00")

View File

@ -110,26 +110,20 @@ Rectangle {
case "internetCheck": case "internetCheck":
break; break;
case "noInternet" : case "noInternet" :
gui.warningFlags |= Style.warnInfoBar
retryInternet.start() retryInternet.start()
secLeft=checkInterval[iTry] secLeft=checkInterval[iTry]
break; break;
case "oldVersion": case "oldVersion":
gui.warningFlags |= Style.warnInfoBar
break; break;
case "forceUpdate": case "forceUpdate":
gui.warningFlags |= Style.errorInfoBar
break; break;
case "upToDate": case "upToDate":
gui.warningFlags &= ~Style.warnInfoBar
iTry = 0 iTry = 0
secLeft=checkInterval[iTry] secLeft=checkInterval[iTry]
break; break;
case "updateRestart": case "updateRestart":
gui.warningFlags |= Style.warnInfoBar
break; break;
case "updateError": case "updateError":
gui.warningFlags |= Style.errorInfoBar
break; break;
default : default :
break; break;
@ -271,7 +265,7 @@ Rectangle {
target: closeSign target: closeSign
visible: true visible: true
onClicked: { onClicked: {
root.state = "upToDate" go.updateState = "upToDate"
} }
} }
}, },

View File

@ -24,7 +24,7 @@ import QtQuick.Window 2.2
Window { Window {
id: testroot id: testroot
width : 150 width : 250
height : 600 height : 600
flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint flags : Qt.Window | Qt.Dialog | Qt.FramelessWindowHint
visible : true visible : true
@ -60,7 +60,7 @@ Window {
Text { Text {
id: systrText id: systrText
anchors { anchors {
right : test_systray.right horizontalCenter: parent.horizontalCenter
verticalCenter: test_systray.verticalCenter verticalCenter: test_systray.verticalCenter
} }
text: "unset" text: "unset"