Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor review of the Python code in the QGIS plugin manager
  • Loading branch information
Gustry authored and nyalldawson committed Aug 3, 2023
1 parent ac45ceb commit 54438f7
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions python/pyplugin_installer/installer.py
Expand Up @@ -43,7 +43,7 @@
from qgis.PyQt.QtNetwork import QNetworkRequest

import qgis
from qgis.core import Qgis, QgsApplication, QgsNetworkAccessManager, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
from qgis.core import Qgis, QgsApplication, QgsMessageLog, QgsNetworkAccessManager, QgsSettings, QgsSettingsTree, QgsNetworkRequestParameters
from qgis.gui import QgsMessageBar, QgsPasswordLineEdit, QgsHelp
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin, OverrideCursor,
reloadPlugin, updateAvailablePlugins, plugins_metadata_parser)
Expand Down Expand Up @@ -155,30 +155,30 @@ def checkingDone(self):
plugins.rebuild()
# look for news in the repositories
plugins.markNews()
status = None
# then check for updates (and eventually overwrite status)
updatable_count = 0
updatable_plugin_name = None
updatable_plugin_names = []
for _, properties in plugins.all().items():
if properties["status"] == "upgradeable":
updatable_count += 1
updatable_plugin_name = properties["name"]
updatable_plugin_names.append(properties["name"])

if updatable_count:
if updatable_count > 1:
status = self.tr("Multiple plugin updates are available")
else:
status = self.tr("An update to the {} plugin is available").format(updatable_plugin_name)
tabIndex = 3 # PLUGMAN_TAB_UPGRADEABLE

# finally set the notify label
if status:
bar = iface.messageBar()
self.message_bar_widget = bar.createMessage('', status)
update_button = QPushButton("Install Updates…")
update_button.pressed.connect(partial(self.showPluginManagerWhenReady, tabIndex))
self.message_bar_widget.layout().addWidget(update_button)
bar.pushWidget(self.message_bar_widget, Qgis.Info)
if not updatable_plugin_names:
return

if len(updatable_plugin_names) >= 2:
status = self.tr("Multiple plugin updates are available")
else:
status = self.tr("An update to the {} plugin is available").format(updatable_plugin_names[0])

QgsMessageLog.logMessage(
"Plugin update(s) available : {}".format(','.join(updatable_plugin_names)), self.tr("Plugins"))

bar = iface.messageBar()
self.message_bar_widget = bar.createMessage('', status)
update_button = QPushButton(self.tr("Install Updates…"))
tab_index = 3 # PLUGMAN_TAB_UPGRADEABLE
update_button.pressed.connect(partial(self.showPluginManagerWhenReady, tab_index))
self.message_bar_widget.layout().addWidget(update_button)
bar.pushWidget(self.message_bar_widget, Qgis.Info)

# ----------------------------------------- #
def exportRepositoriesToManager(self):
Expand Down

0 comments on commit 54438f7

Please sign in to comment.