From cbc471a70270e5fba60e5029f5b3c4a2d04974d9 Mon Sep 17 00:00:00 2001 From: Guts Date: Wed, 28 Aug 2019 12:44:13 +0200 Subject: [PATCH] inform the user if one opencatalog is missing #54 --- IsogeoToOffice.py | 21 ++++++++++++++++++--- modules/threads.py | 12 +++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/IsogeoToOffice.py b/IsogeoToOffice.py index e570ae74..40cb5ea2 100644 --- a/IsogeoToOffice.py +++ b/IsogeoToOffice.py @@ -844,9 +844,9 @@ def settings_reset(self): self.close() # -- UI Slots ------------------------------------------------------------- - @pyqtSlot(str, str) + @pyqtSlot(str, str, bool) def fill_app_props( - self, app_infos_retrieved: str = "", latest_online_version: str = "" + self, app_infos_retrieved: str = "", latest_online_version: str = "", opencatalog_warning: bool = 0 ): """Get app properties and fillfull the share frame in settings tab. @@ -859,7 +859,7 @@ def fill_app_props( try: if semver.compare(__version__, latest_online_version) < 0: logger.info("A newer version is available.") - version_msg = self.tr("New version available.") + version_msg = self.tr("New version available. You can download it here: ") + "/~https://github.com/isogeo/isogeo-2-office/releases/latest" self.setWindowTitle(self.windowTitle() + " ! " + version_msg) else: logger.debug("Used version is up-to-date") @@ -880,6 +880,21 @@ def fill_app_props( status_msg=self.tr("Application information has been retrieved"), ) + # if needed, inform the user about a missing OpenCatalog + if opencatalog_warning: + oc_msg = self.tr("OpenCatalog is missing in one share at least. Check the settings tab to identify which one and fix it.") + self.tray_icon.showMessage( + "Isogeo to Office", + oc_msg, + QIcon("resources/favicon.png"), + ) + self.update_status_bar( + prog_step=0, + status_msg=oc_msg, + color="orange" + ) + + @pyqtSlot() def update_credentials(self): """Executed after credentials have been updated. diff --git a/modules/threads.py b/modules/threads.py index 299376d8..fa456687 100644 --- a/modules/threads.py +++ b/modules/threads.py @@ -47,7 +47,7 @@ # API REQUESTS ---------------------------------------------------------------- class ThreadAppProperties(QThread): # signals - sig_finished = pyqtSignal(str, str) + sig_finished = pyqtSignal(str, str, bool) def __init__(self, api_manager: object): QThread.__init__(self) @@ -57,6 +57,9 @@ def __init__(self, api_manager: object): def run(self): """Get application informations and build the text to display into the settings tab. """ + # local vers + opencatalog_warning = 0 + # insert text text = "" # opening html content # properties of the authenticated application @@ -100,6 +103,7 @@ def run(self): text += "

{} {}".format( self.tr("OpenCatalog status:"), self.tr("disabled") ) + opencatalog_warning = 1 # last modification (share renamed, changes in catalogs or applications, etc.) text += "

{} {}

".format( @@ -124,7 +128,9 @@ def run(self): ).json()[0] online_version = latest_v.get("tag_name") except Exception as e: - logger.error("Unable to get the latest application version from Github: ".format(e)) + logger.error( + "Unable to get the latest application version from Github: ".format(e) + ) online_version = "0.0.0" # handle version label starting with a non digit char @@ -132,7 +138,7 @@ def run(self): online_version = online_version[1:] # Now inform the main thread with the output (fill_app_props) - self.sig_finished.emit(text, online_version) + self.sig_finished.emit(text, online_version, opencatalog_warning) class ThreadSearch(QThread):