Skip to content

Commit

Permalink
Plugin installer update: one-step plugin install and uninstall in QGI…
Browse files Browse the repository at this point in the history
…S>=1.4

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12476 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
borysiasty committed Dec 15, 2009
1 parent 014600e commit 3ec31f7
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 193 deletions.
3 changes: 2 additions & 1 deletion python/plugins/plugin_installer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Expand All @@ -14,7 +15,7 @@ def name():
return "Plugin Installer"

def version():
return "Version 1.0.5"
return "Version 1.0.6"

def description():
return "Downloads and installs QGIS python plugins"
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/plugin_installer/installer_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@
QGIS_MAJOR_VER = 1
else:
QGIS_MAJOR_VER = 0
QGIS_14 = False
except:
QGIS_VER = QGis.QGIS_VERSION
QGIS_MAJOR_VER = 1
QGIS_14 = (QGIS_VER[2] > 3)



Expand Down
25 changes: 22 additions & 3 deletions python/plugins/plugin_installer/installer_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
from ui_qgsplugininstallerbase import Ui_QgsPluginInstallerDialogBase
from installer_data import *

try:
from qgis.utils import startPlugin, unloadPlugin
except Exception:
pass


# --- common functions ------------------------------------------------------------------- #
Expand Down Expand Up @@ -259,6 +263,8 @@ def __init__(self, parent, fl):
self.connect(self.buttonUninstall, SIGNAL("clicked()"), self.uninstallPlugin)
self.buttonInstall.setEnabled(False)
self.buttonUninstall.setEnabled(False)
self.buttonHelp.setEnabled(QGIS_14)
self.connect(self.buttonHelp, SIGNAL("clicked()"), self.runHelp)
# repositories handling
self.connect(self.treeRepositories, SIGNAL("doubleClicked(QModelIndex)"), self.editRepository)
self.connect(self.buttonFetchRepositories, SIGNAL("clicked()"), self.addKnownRepositories)
Expand Down Expand Up @@ -593,9 +599,11 @@ def installPlugin(self):
plugin = plugins.all()[key]
if not plugin["error"]:
if previousStatus in ["not installed", "new"]:
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
if QGIS_14: infoString = (self.tr("Plugin installed successfully"), self.tr("Plugin installed successfully"))
else: infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
else:
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
startPlugin(plugin["localdir"])
else:
if plugin["error"] == "incompatible":
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
Expand Down Expand Up @@ -649,7 +657,7 @@ def uninstallPlugin(self):
plugin = plugins.all()[key]
if not plugin:
return
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n" + plugin["name"]
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n(" + plugin["name"] + ")"
if plugin["status"] == "orphan" and not plugin["error"]:
warning += "\n\n"+self.tr("Warning: this plugin isn't available in any accessible repository!")
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
Expand All @@ -660,6 +668,10 @@ def uninstallPlugin(self):
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
else:
# safe remove
try:
unloadPlugin(plugin["localdir"])
except:
pass
try:
exec ("plugins[%s].unload()" % plugin["localdir"])
exec ("del plugins[%s]" % plugin["localdir"])
Expand All @@ -672,7 +684,8 @@ def uninstallPlugin(self):
plugins.getAllInstalled()
plugins.rebuild()
self.populatePluginTree()
QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Python plugin uninstalled. Note that you may need to restart Quantum GIS in order to remove it completely."))
if QGIS_14: QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Plugin uninstalled successfully"))
else: QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Python plugin uninstalled. Note that you may need to restart Quantum GIS in order to remove it completely."))
history.markChange(key,'D')


Expand Down Expand Up @@ -834,6 +847,12 @@ def deleteRepository(self):
self.populatePluginTree()


# ----------------------------------------- #
def runHelp(self):
""" open the context help browser """
QgsContextHelp.run("QgsPluginInstallerDialog")


# ----------------------------------------- #
def reject(self):
""" update the list of seen plugins before exit (both 'done' and 'x' buttons emit 'reject' signal) """
Expand Down
1 change: 1 addition & 0 deletions python/plugins/plugin_installer/installer_plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2007-2008 Matthew Perry
Copyright (C) 2008-2009 Borys Jurgiel
Expand Down
Loading

0 comments on commit 3ec31f7

Please sign in to comment.