Skip to content
Permalink
Browse files
Use 'with OverrideCursor(Qt.WaitCursor)' block in installer.py
  • Loading branch information
gacarrillor committed Sep 11, 2021
1 parent d8f02f9 commit a0b7f14d58cbf152f25cd8a55a5d3637439e9850
Showing with 34 additions and 39 deletions.
  1. +34 −39 python/pyplugin_installer/installer.py
@@ -34,7 +34,7 @@
import qgis
from qgis.core import Qgis, QgsApplication, QgsNetworkAccessManager, QgsSettings, QgsNetworkRequestParameters
from qgis.gui import QgsMessageBar, QgsPasswordLineEdit, QgsHelp
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin,
from qgis.utils import (iface, startPlugin, unloadPlugin, loadPlugin, OverrideCursor,
reloadPlugin, updateAvailablePlugins, plugins_metadata_parser)
from .installer_data import (repositories, plugins, officialRepo,
settingsGroup, reposGroup, removeDir)
@@ -112,25 +112,22 @@ def fetchAvailablePlugins(self, reloadMode):
""" Fetch plugins from all enabled repositories."""
""" reloadMode = true: Fully refresh data from QgsSettings to mRepositories """
""" reloadMode = false: Fetch unready repositories only """
QApplication.setOverrideCursor(Qt.WaitCursor)

if reloadMode:
repositories.load()
plugins.clearRepoCache()
plugins.getAllInstalled()
with OverrideCursor(Qt.WaitCursor):
if reloadMode:
repositories.load()
plugins.clearRepoCache()
plugins.getAllInstalled()

for key in repositories.allEnabled():
if reloadMode or repositories.all()[key]["state"] == 3: # if state = 3 (error or not fetched yet), try to fetch once again
repositories.requestFetching(key, force_reload=reloadMode)

if repositories.fetchingInProgress():
fetchDlg = QgsPluginInstallerFetchingDialog(iface.mainWindow())
fetchDlg.exec_()
del fetchDlg
for key in repositories.all():
repositories.killConnection(key)
for key in repositories.allEnabled():
if reloadMode or repositories.all()[key]["state"] == 3: # if state = 3 (error or not fetched yet), try to fetch once again
repositories.requestFetching(key, force_reload=reloadMode)

QApplication.restoreOverrideCursor()
if repositories.fetchingInProgress():
fetchDlg = QgsPluginInstallerFetchingDialog(iface.mainWindow())
fetchDlg.exec_()
del fetchDlg
for key in repositories.all():
repositories.killConnection(key)

# display error messages for every unavailable repository, unless Shift pressed nor all repositories are unavailable
keepQuiet = QgsApplication.keyboardModifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier)
@@ -325,11 +322,10 @@ def installPlugin(self, key, quiet=False, stable=True):
"the list of installed plugins. You should find the plugin there, but it's not possible to "
"determine which of them it is and it's also not possible to inform you about available updates. "
"Please contact the plugin author and submit this issue.").format(plugin_path))
QApplication.setOverrideCursor(Qt.WaitCursor)
plugins.getAllInstalled()
plugins.rebuild()
self.exportPluginsToManager()
QApplication.restoreOverrideCursor()
with OverrideCursor(Qt.WaitCursor):
plugins.getAllInstalled()
plugins.rebuild()
self.exportPluginsToManager()
else:
QApplication.setOverrideCursor(Qt.WaitCursor)
# update the list of plugins in plugin handling routines
@@ -649,24 +645,23 @@ def installFromZipFile(self, filePath):
keepTrying = False

if success:
QApplication.setOverrideCursor(Qt.WaitCursor)
updateAvailablePlugins()
self.processDependencies(pluginName)
loadPlugin(pluginName)
plugins.getAllInstalled()
plugins.rebuild()

if settings.contains('/PythonPlugins/' + pluginName): # Plugin was available?
if settings.value('/PythonPlugins/' + pluginName, False, bool): # Plugin was also active?
reloadPlugin(pluginName) # unloadPlugin + loadPlugin + startPlugin
with OverrideCursor(Qt.WaitCursor):
updateAvailablePlugins()
self.processDependencies(pluginName)
loadPlugin(pluginName)
plugins.getAllInstalled()
plugins.rebuild()

if settings.contains('/PythonPlugins/' + pluginName): # Plugin was available?
if settings.value('/PythonPlugins/' + pluginName, False, bool): # Plugin was also active?
reloadPlugin(pluginName) # unloadPlugin + loadPlugin + startPlugin
else:
unloadPlugin(pluginName)
loadPlugin(pluginName)
else:
unloadPlugin(pluginName)
loadPlugin(pluginName)
else:
if startPlugin(pluginName):
settings.setValue('/PythonPlugins/' + pluginName, True)
if startPlugin(pluginName):
settings.setValue('/PythonPlugins/' + pluginName, True)

QApplication.restoreOverrideCursor()
self.exportPluginsToManager()
msg = "<b>%s</b>" % self.tr("Plugin installed successfully")
else:

0 comments on commit a0b7f14

Please sign in to comment.