diff --git a/internal/frontend/qml/Gui.qml b/internal/frontend/qml/Gui.qml index 64f9675c..a543db82 100644 --- a/internal/frontend/qml/Gui.qml +++ b/internal/frontend/qml/Gui.qml @@ -107,17 +107,21 @@ Item { gui.openMainWindow(false) if (go.isConnectionOK) { if( winMain.updateState=="noInternet") { - go.setUpdateState("upToDate") + go.updateState = "upToDate" } } else { - go.setUpdateState("noInternet") + go.updateState = "noInternet" } } - onSetUpdateState : { + onUpdateStateChanged : { + // if main window is closed - most probably it is destroyed (see closeMainWindow()) + if (winMain == null) { + return + } // once app is outdated prevent from state change if (winMain.updateState != "forceUpdate") { - winMain.updateState = updateState + winMain.updateState = go.updateState } } @@ -129,15 +133,14 @@ Item { } onNotifyManualUpdate: { - go.setUpdateState("oldVersion") + go.updateState = "oldVersion" } onNotifyManualUpdateRestartNeeded: { if (!winMain.dialogUpdate.visible) { - gui.openMainWindow(true) winMain.dialogUpdate.show() } - go.setUpdateState("updateRestart") + go.updateState = "updateRestart" winMain.dialogUpdate.finished(false) // after manual update - just retart immidiatly @@ -147,28 +150,25 @@ Item { onNotifyManualUpdateError: { if (!winMain.dialogUpdate.visible) { - gui.openMainWindow(true) winMain.dialogUpdate.show() } - go.setUpdateState("updateError") + go.updateState = "updateError" winMain.dialogUpdate.finished(true) } onNotifyForceUpdate : { - go.setUpdateState("forceUpdate") + go.updateState = "forceUpdate" if (!winMain.dialogUpdate.visible) { - gui.openMainWindow(true) winMain.dialogUpdate.show() } } onNotifySilentUpdateRestartNeeded: { - go.setUpdateState("updateRestart") + go.updateState = "updateRestart" } onNotifySilentUpdateError: { - go.setUpdateState("updateError") - gui.openMainWindow(true) + go.updateState = "updateError" } onNotifyLogout : { @@ -287,9 +287,17 @@ Item { if (showAndRise) { gui.winMain.showAndRise() } + + // restore update notification bar: trigger updateStateChanged + var tmp = go.updateState + go.updateState = "" + go.updateState = tmp } function closeMainWindow () { + // Historical reasons: once upon a time there was a report about high GPU + // usage on MacOS while bridge is closed. Legends say that destroying + // MainWindow solved this. gui.winMain.hide() gui.winMain.destroy(5000) gui.winMain = null diff --git a/internal/frontend/qml/GuiIE.qml b/internal/frontend/qml/GuiIE.qml index dee84052..0507793f 100644 --- a/internal/frontend/qml/GuiIE.qml +++ b/internal/frontend/qml/GuiIE.qml @@ -96,17 +96,17 @@ Item { go.isConnectionOK = isAvailable if (go.isConnectionOK) { if( winMain.updateState==gui.enums.statusNoInternet) { - go.setUpdateState(gui.enums.statusUpToDate) + go.updateState = gui.enums.statusUpToDate } } else { - go.setUpdateState(gui.enums.statusNoInternet) + go.updateState = gui.enums.statusNoInternet } } - onSetUpdateState : { + onUpdateStateChanged : { // once app is outdated prevent from state change if (winMain.updateState != "forceUpdate") { - winMain.updateState = updateState + winMain.updateState = go.updateState } } @@ -207,14 +207,14 @@ Item { } onNotifyManualUpdate: { - go.setUpdateState("oldVersion") + go.updateState = "oldVersion" } onNotifyManualUpdateRestartNeeded: { if (!winMain.dialogUpdate.visible) { winMain.dialogUpdate.show() } - go.setUpdateState("updateRestart") + go.updateState = "updateRestart" winMain.dialogUpdate.finished(false) // after manual update - just retart immidiatly @@ -226,23 +226,23 @@ Item { if (!winMain.dialogUpdate.visible) { winMain.dialogUpdate.show() } - go.setUpdateState("updateError") + go.updateState = "updateError" winMain.dialogUpdate.finished(true) } onNotifyForceUpdate : { - go.setUpdateState("forceUpdate") + go.updateState = "forceUpdate" if (!winMain.dialogUpdate.visible) { winMain.dialogUpdate.show() } } onNotifySilentUpdateRestartNeeded: { - go.setUpdateState("updateRestart") + go.updateState = "updateRestart" } onNotifySilentUpdateError: { - go.setUpdateState("updateError") + go.updateState = "updateError" } onNotifyLogout : { diff --git a/internal/frontend/qml/tst_Gui.qml b/internal/frontend/qml/tst_Gui.qml index a751ecd0..ddf127f0 100644 --- a/internal/frontend/qml/tst_Gui.qml +++ b/internal/frontend/qml/tst_Gui.qml @@ -299,6 +299,7 @@ Window { property string fullversion : "QA.1.0 (d9f8sdf9) 2020-02-19T10:57:23+01:00" property string downloadLink: "https://protonmail.com/download/beta/protonmail-bridge-1.1.5-1.x86_64.rpm;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;" + property string updateState property string updateVersion : "QA.1.0" property bool updateCanInstall: true property string updateLandingPage : "https://protonmail.com/bridge/download/" @@ -340,7 +341,6 @@ Window { signal notifyPortIssue(bool busyPortIMAP, bool busyPortSMTP) signal notifyVersionIsTheLatest() - signal setUpdateState(string updateState) signal notifyKeychainRebuild() signal notifyHasNoKeychain() diff --git a/internal/frontend/qml/tst_GuiIE.qml b/internal/frontend/qml/tst_GuiIE.qml index 854084f1..2cd32e4d 100644 --- a/internal/frontend/qml/tst_GuiIE.qml +++ b/internal/frontend/qml/tst_GuiIE.qml @@ -856,6 +856,7 @@ Window { property string fullversion : "QA.1.0 (d9f8sdf9) 2020-02-19T10:57:23+01:00" property string downloadLink: "https://protonmail.com/download/beta/protonmail-bridge-1.1.5-1.x86_64.rpm;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;https://www.protonmail.com/downloads/beta/Desktop-Bridge-link1.exe;" + property string updateState property string updateVersion : "q0.1.0" property bool updateCanInstall: true property string updateLandingPage : "https://protonmail.com/import-export/download/" @@ -900,7 +901,6 @@ Window { signal showQuit() signal notifyVersionIsTheLatest() - signal setUpdateState(string updateState) signal showMainWin() signal hideMainWin() diff --git a/internal/frontend/qt-ie/ui.go b/internal/frontend/qt-ie/ui.go index 2e0552a3..52903e67 100644 --- a/internal/frontend/qt-ie/ui.go +++ b/internal/frontend/qt-ie/ui.go @@ -53,6 +53,7 @@ type GoQMLInterface struct { _ string `property:"fullversion"` _ string `property:"downloadLink"` + _ string `property:"updateState"` _ string `property:"updateVersion"` _ bool `property:"updateCanInstall"` _ string `property:"updateLandingPage"` @@ -77,7 +78,6 @@ type GoQMLInterface struct { _ string `property:"versionCheckFailed"` // _ func(isAvailable bool) `signal:"setConnectionStatus"` - _ func(updateState string) `signal:"setUpdateState"` _ func() `slot:"checkInternet"` _ func() `slot:"setToRestart"` diff --git a/internal/frontend/qt/ui.go b/internal/frontend/qt/ui.go index acb8d91b..00363cb1 100644 --- a/internal/frontend/qt/ui.go +++ b/internal/frontend/qt/ui.go @@ -50,6 +50,7 @@ type GoQMLInterface struct { _ string `property:"fullversion"` _ string `property:"downloadLink"` + _ string `property:"updateState"` _ string `property:"updateVersion"` _ bool `property:"updateCanInstall"` _ string `property:"updateLandingPage"` @@ -82,9 +83,8 @@ type GoQMLInterface struct { _ float32 `property:"progress"` _ string `property:"progressDescription"` - _ func(isAvailable bool) `signal:"setConnectionStatus"` - _ func(updateState string) `signal:"setUpdateState"` - _ func() `slot:"checkInternet"` + _ func(isAvailable bool) `signal:"setConnectionStatus"` + _ func() `slot:"checkInternet"` _ func() `slot:"setToRestart"`