Skip to content

Commit 3ec31f7

Browse files
author
borysiasty
committed
Plugin installer update: one-step plugin install and uninstall in QGIS>=1.4
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12476 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 014600e commit 3ec31f7

File tree

6 files changed

+258
-193
lines changed

6 files changed

+258
-193
lines changed

python/plugins/plugin_installer/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
Copyright (C) 2007-2008 Matthew Perry
34
Copyright (C) 2008-2009 Borys Jurgiel
@@ -14,7 +15,7 @@ def name():
1415
return "Plugin Installer"
1516

1617
def version():
17-
return "Version 1.0.5"
18+
return "Version 1.0.6"
1819

1920
def description():
2021
return "Downloads and installs QGIS python plugins"

python/plugins/plugin_installer/installer_data.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@
5757
QGIS_MAJOR_VER = 1
5858
else:
5959
QGIS_MAJOR_VER = 0
60+
QGIS_14 = False
6061
except:
6162
QGIS_VER = QGis.QGIS_VERSION
6263
QGIS_MAJOR_VER = 1
64+
QGIS_14 = (QGIS_VER[2] > 3)
6365

6466

6567

python/plugins/plugin_installer/installer_gui.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
from ui_qgsplugininstallerbase import Ui_QgsPluginInstallerDialogBase
2626
from installer_data import *
2727

28+
try:
29+
from qgis.utils import startPlugin, unloadPlugin
30+
except Exception:
31+
pass
2832

2933

3034
# --- common functions ------------------------------------------------------------------- #
@@ -259,6 +263,8 @@ def __init__(self, parent, fl):
259263
self.connect(self.buttonUninstall, SIGNAL("clicked()"), self.uninstallPlugin)
260264
self.buttonInstall.setEnabled(False)
261265
self.buttonUninstall.setEnabled(False)
266+
self.buttonHelp.setEnabled(QGIS_14)
267+
self.connect(self.buttonHelp, SIGNAL("clicked()"), self.runHelp)
262268
# repositories handling
263269
self.connect(self.treeRepositories, SIGNAL("doubleClicked(QModelIndex)"), self.editRepository)
264270
self.connect(self.buttonFetchRepositories, SIGNAL("clicked()"), self.addKnownRepositories)
@@ -593,9 +599,11 @@ def installPlugin(self):
593599
plugin = plugins.all()[key]
594600
if not plugin["error"]:
595601
if previousStatus in ["not installed", "new"]:
596-
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
602+
if QGIS_14: infoString = (self.tr("Plugin installed successfully"), self.tr("Plugin installed successfully"))
603+
else: infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
597604
else:
598605
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
606+
startPlugin(plugin["localdir"])
599607
else:
600608
if plugin["error"] == "incompatible":
601609
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
@@ -649,7 +657,7 @@ def uninstallPlugin(self):
649657
plugin = plugins.all()[key]
650658
if not plugin:
651659
return
652-
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n" + plugin["name"]
660+
warning = self.tr("Are you sure you want to uninstall the following plugin?") + "\n(" + plugin["name"] + ")"
653661
if plugin["status"] == "orphan" and not plugin["error"]:
654662
warning += "\n\n"+self.tr("Warning: this plugin isn't available in any accessible repository!")
655663
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
@@ -660,6 +668,10 @@ def uninstallPlugin(self):
660668
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
661669
else:
662670
# safe remove
671+
try:
672+
unloadPlugin(plugin["localdir"])
673+
except:
674+
pass
663675
try:
664676
exec ("plugins[%s].unload()" % plugin["localdir"])
665677
exec ("del plugins[%s]" % plugin["localdir"])
@@ -672,7 +684,8 @@ def uninstallPlugin(self):
672684
plugins.getAllInstalled()
673685
plugins.rebuild()
674686
self.populatePluginTree()
675-
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."))
687+
if QGIS_14: QMessageBox.information(self, self.tr("Plugin uninstalled successfully"), self.tr("Plugin uninstalled successfully"))
688+
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."))
676689
history.markChange(key,'D')
677690

678691

@@ -834,6 +847,12 @@ def deleteRepository(self):
834847
self.populatePluginTree()
835848

836849

850+
# ----------------------------------------- #
851+
def runHelp(self):
852+
""" open the context help browser """
853+
QgsContextHelp.run("QgsPluginInstallerDialog")
854+
855+
837856
# ----------------------------------------- #
838857
def reject(self):
839858
""" update the list of seen plugins before exit (both 'done' and 'x' buttons emit 'reject' signal) """

python/plugins/plugin_installer/installer_plugin.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
Copyright (C) 2007-2008 Matthew Perry
34
Copyright (C) 2008-2009 Borys Jurgiel

0 commit comments

Comments
 (0)