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 : {
// 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

View File

@ -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")

View File

@ -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"
}
}
},

View File

@ -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"