|
26 | 26 | from installer_data import *
|
27 | 27 |
|
28 | 28 | try:
|
29 |
| - from qgis.utils import startPlugin, unloadPlugin |
| 29 | + from qgis.utils import startPlugin, unloadPlugin, loadPlugin # QGIS >= 1.4 |
| 30 | + from qgis.utils import updateAvailablePlugins # QGIS >= 1.5 |
30 | 31 | except Exception:
|
31 | 32 | pass
|
32 | 33 |
|
@@ -592,28 +593,31 @@ def installPlugin(self):
|
592 | 593 | plugins.rebuild()
|
593 | 594 | QApplication.restoreOverrideCursor()
|
594 | 595 | else:
|
595 |
| - try: |
596 |
| - exec ("sys.path_importer_cache.clear()") |
597 |
| - exec ("import %s" % plugin["localdir"]) |
598 |
| - exec ("reload (%s)" % plugin["localdir"]) |
599 |
| - except: |
600 |
| - pass |
| 596 | + if QGIS_14: |
| 597 | + if QGIS_15: # update the list of plugins in plugin handling routines |
| 598 | + updateAvailablePlugins() |
| 599 | + # try to load the plugin |
| 600 | + loadPlugin(plugin["localdir"]) |
| 601 | + else: # QGIS < 1.4 |
| 602 | + try: |
| 603 | + exec ("sys.path_importer_cache.clear()") |
| 604 | + exec ("import %s" % plugin["localdir"]) |
| 605 | + exec ("reload (%s)" % plugin["localdir"]) |
| 606 | + except: |
| 607 | + pass |
601 | 608 | plugins.getAllInstalled()
|
602 | 609 | plugins.rebuild()
|
603 | 610 | plugin = plugins.all()[key]
|
604 | 611 | if not plugin["error"]:
|
605 | 612 | if previousStatus in ["not installed", "new"]:
|
606 |
| - if QGIS_14: |
| 613 | + if QGIS_14: # plugins can be started in python from QGIS >= 1.4 |
607 | 614 | infoString = (self.tr("Plugin installed successfully"), self.tr("Plugin installed successfully"))
|
608 | 615 | settings = QSettings()
|
609 | 616 | settings.setValue("/PythonPlugins/"+plugin["localdir"], QVariant(True))
|
| 617 | + startPlugin(plugin["localdir"]) |
610 | 618 | else: infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
|
611 | 619 | else:
|
612 | 620 | infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
|
613 |
| - try: |
614 |
| - startPlugin(plugin["localdir"]) |
615 |
| - except: |
616 |
| - pass |
617 | 621 | else:
|
618 | 622 | if plugin["error"] == "incompatible":
|
619 | 623 | message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
|
|
0 commit comments