diff --git a/python/plugins/plugin_installer/CMakeLists.txt b/python/plugins/plugin_installer/CMakeLists.txt index 6c3a79dc8ae..68c98c4eb2e 100644 --- a/python/plugins/plugin_installer/CMakeLists.txt +++ b/python/plugins/plugin_installer/CMakeLists.txt @@ -2,30 +2,33 @@ # file or the ui change SET(INSTALLER_FILES dialog.py +fetchingbase.py +fetchingbase.ui +guibase.py +guibase.ui gui.py icon.xpm __init__.py -installer_plugin.py -qgis_plugins.py -resources.py -repository_ui.py -repository_dialog.py -qgis-icon.png -installingbase.ui -fetchingbase.py -guibase.py -repositorybase.py -plugin_installer.png -unzip.py -installer_gui.py -installingbase.py -pluginerrorbase.ui installer_data.py -repoConnected.png -guibase.ui +installer_gui.py +installer_plugin.py +installingbase.py +installingbase.ui pluginerrorbase.py -repositorybase.ui -resources_rc.py +pluginerrorbase.ui +plugin_installer.png +PluginInstaller.png +qgis-icon.png +qgis_plugins.py +repoConnected.png repoDisabled.png +repositorybase.py +repositorybase.ui +repository_dialog.py +repository_ui.py +repoUnavailable.png +resources.py +resources_rc.py +unzip.py ) INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/plugin_installer) diff --git a/python/plugins/plugin_installer/PluginInstaller.png b/python/plugins/plugin_installer/PluginInstaller.png new file mode 100644 index 00000000000..b8bf9fa4218 Binary files /dev/null and b/python/plugins/plugin_installer/PluginInstaller.png differ diff --git a/python/plugins/plugin_installer/__init__.py b/python/plugins/plugin_installer/__init__.py index a680fe51c77..0174745a939 100644 --- a/python/plugins/plugin_installer/__init__.py +++ b/python/plugins/plugin_installer/__init__.py @@ -20,7 +20,7 @@ def author_name(): return "perrygeo, borysiasty" def version(): - return "Version 0.05.6" + return "Version 0.06.1" def classFactory(iface): from installer_plugin import InstallerPlugin diff --git a/python/plugins/plugin_installer/fetchingbase.py b/python/plugins/plugin_installer/fetchingbase.py index ff326b99349..f8cce405c60 100644 --- a/python/plugins/plugin_installer/fetchingbase.py +++ b/python/plugins/plugin_installer/fetchingbase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'fetchingbase.ui' # -# Created: Sun Sep 7 16:22:19 2008 +# Created: Fri Sep 12 19:21:37 2008 # by: PyQt4 UI code generator 4.3 # # WARNING! All changes made in this file will be lost! diff --git a/python/plugins/plugin_installer/fetchingbase.ui b/python/plugins/plugin_installer/fetchingbase.ui new file mode 100644 index 00000000000..8d482498ec6 --- /dev/null +++ b/python/plugins/plugin_installer/fetchingbase.ui @@ -0,0 +1,200 @@ + + Matthew Perry, Borys Jurgiel + QgsPluginInstallerFetchingDialog + + + + 0 + 0 + 521 + 332 + + + + Fetching repositories + + + :/plugins/installer/qgis-icon.png + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 249 + 10 + + + + + + + + Overall progress: + + + + + + + 24 + + + Qt::AlignHCenter + + + QProgressBar::TopToBottom + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 248 + 10 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 140 + 27 + + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Qt::NoFocus + + + Abort fetching + + + false + + + false + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 140 + 27 + + + + + + + + + + true + + + Qt::ScrollBarAsNeeded + + + false + + + QAbstractItemView::NoSelection + + + QAbstractItemView::ScrollPerItem + + + false + + + false + + + + Repository + + + + + State + + + + + + + + + + + + buttonSkip + clicked() + QgsPluginInstallerFetchingDialog + reject() + + + 350 + 321 + + + 250 + 76 + + + + + diff --git a/python/plugins/plugin_installer/guibase.py b/python/plugins/plugin_installer/guibase.py index c154a7139ce..354787787a5 100644 --- a/python/plugins/plugin_installer/guibase.py +++ b/python/plugins/plugin_installer/guibase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'guibase.ui' # -# Created: Sun Sep 7 21:28:01 2008 +# Created: Fri Sep 12 19:21:37 2008 # by: PyQt4 UI code generator 4.3 # # WARNING! All changes made in this file will be lost! diff --git a/python/plugins/plugin_installer/installer_data.py b/python/plugins/plugin_installer/installer_data.py index da0175fc189..e1210a9fa33 100644 --- a/python/plugins/plugin_installer/installer_data.py +++ b/python/plugins/plugin_installer/installer_data.py @@ -229,7 +229,6 @@ class Repositories(QObject): # ----------------------------------------- # def xmlDownloaded(self,nr,state): - #print reposName, nr, state if not self.httpId.has_key(nr): return reposName = self.httpId[nr] @@ -296,8 +295,8 @@ class Plugins(QObject): # ----------------------------------------- # - def firstByName(self, name): - plugins = [i for i in self.mPlugins if self.mPlugins[i]["name"] == name] + def keyByUrl(self, name): + plugins = [i for i in self.mPlugins if self.mPlugins[i]["url"] == name] if plugins: return plugins[0] return None @@ -420,6 +419,11 @@ class Plugins(QObject): self.mPlugins[key] = plugin # add the plugin if not present yet or if is newer than existing one + # ----------------------------------------- # + def remove(self, key): + del self.mPlugins[key] + + # ----------------------------------------- # def updatePlugin(self, key, readOnly): try: @@ -452,6 +456,11 @@ class Plugins(QObject): desc = "" auth = "" homepage = "" + if readOnly: + path = QgsApplication.pkgDataPath() + else: + path = QgsApplication.qgisSettingsDirPath() + path = QDir.cleanPath(unicode(path,"utf-8") + "python/plugins/" + key) normVer = self.normalizeVersion(QString(ver)) plugin = { "name" : nam, @@ -461,7 +470,7 @@ class Plugins(QObject): "desc_repo" : "", "author" : auth, "homepage" : homepage, - "url" : "", + "url" : path, "filename" : "", "status" : stat, "repository" : "", @@ -478,10 +487,6 @@ class Plugins(QObject): self.mPlugins[key]["name"] = plugin["name"] # local name has higher priority, except invalid plugins self.mPlugins[key]["version_inst"] = plugin["version_inst"] self.mPlugins[key]["desc_local"] = plugin["desc_local"] - if plugin["author"]: - self.mPlugins[key]["author"] = plugin["author"] #local author name has higher priority, if exists - if plugin["homepage"]: - self.mPlugins[key]["homepage"] = plugin["homepage"] # local homepage adress has higher priority, if exists # set status # # installed available status @@ -509,7 +514,6 @@ class Plugins(QObject): # ----------------------------------------- # def getAllInstalled(self): """ update the mPlugins dict with alredy installed plugins """ - #print "getting list of installed plugins" # first, try to add the read-only plugins... try: pluginDir = QDir.cleanPath(unicode(QgsApplication.pkgDataPath(),'utf-8') + "/python/plugins") @@ -537,7 +541,6 @@ class Plugins(QObject): # ----------------------------------------- # def markNews(self): """ mark all new plugins as new """ - #print "marking the new plugins" settings = QSettings() seenPlugins = settings.value(seenPluginGroup, QVariant(QStringList(self.mPlugins.keys()))).toStringList() if len(seenPlugins) > 0: @@ -549,7 +552,6 @@ class Plugins(QObject): # ----------------------------------------- # def updateSeenPluginsList(self): """ update the list of all seen plugins """ - #print "updating the list of seen plugins" settings = QSettings() seenPlugins = settings.value(seenPluginGroup, QVariant(QStringList(self.mPlugins.keys()))).toStringList() for i in self.mPlugins.keys(): diff --git a/python/plugins/plugin_installer/installer_gui.py b/python/plugins/plugin_installer/installer_gui.py index 17be8ba306a..2bd6f608c10 100644 --- a/python/plugins/plugin_installer/installer_gui.py +++ b/python/plugins/plugin_installer/installer_gui.py @@ -15,7 +15,7 @@ Copyright (C) 2008 Borys Jurgiel from PyQt4.QtCore import * from PyQt4.QtGui import * from qgis.core import QgsApplication, QgsContextHelp -import sys +import sys, time from fetchingbase import Ui_QgsPluginInstallerFetchingDialog from installingbase import Ui_QgsPluginInstallerInstallingDialog from repositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialog @@ -24,6 +24,7 @@ from guibase import Ui_QgsPluginInstallerDialog from installer_data import * + # --- common functions ------------------------------------------------------------------- # def removeDir(path): result = QString() @@ -44,11 +45,15 @@ def removeDir(path): iterator = QDirIterator(path, fltr, QDirIterator.Subdirectories) while iterator.hasNext(): item = iterator.next() - if QDir(item).rmpath("."): + if QDir().rmpath(item): #print " Directory removing successfull: %s" % item pass if QFile(path).exists(): result = QCoreApplication.translate("QgsPluginInstaller","Failed to remove directory")+" "+path+" \n"+QCoreApplication.translate("QgsPluginInstaller","Check permissions or remove it manually") + # restore plugin directory if removed by QDir().rmpath() + pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins") + if not QDir(pluginDir).exists(): + QDir().mkpath(pluginDir) return result # --- /common functions ------------------------------------------------------------------ # @@ -189,23 +194,18 @@ class QgsPluginInstallerInstallingDialog(QDialog, Ui_QgsPluginInstallerInstallin # make sure that the parent directory exists if not QDir(pluginDir).exists(): - QDir(pluginDir).mkpath(".") - + QDir().mkpath(pluginDir) #print "Extracting to plugin directory (%s)" % pluginDir - #try: - - - un = unzip() - un.extract(tmpPath, pluginDir) # test extract. If fails, then exception will be raised and no removing occurs - #print "Removing old plugin files if exist" - removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists - un.extract(tmpPath, pluginDir) # final extract. - - - #except: - #self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions") - #self.reject() - #return + try: + un = unzip() + un.extract(tmpPath, pluginDir) # test extract. If fails, then exception will be raised and no removing occurs + #print "Removing old plugin files if exist" + removeDir(QDir.cleanPath(pluginDir+"/"+self.plugin["localdir"])) # remove old plugin if exists + un.extract(tmpPath, pluginDir) # final extract. + except: + self.mResult = self.tr("Failed to unzip file to ") + pluginDir + "\n" + self.tr("check permissions") + self.reject() + return try: #print "Cleaning: removing the zip file (%s)" % tmpPath @@ -414,13 +414,8 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): p["desc_local"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies") p["desc_repo"] = self.tr("This plugin seems to be invalid or have unfulfilled dependencies\nIt has been installed, but can't be loaded") if p["status"] == "orphan": - if p["read-only"]: - url = unicode(QgsApplication.pkgDataPath(),'utf-8') + "/python/plugins/" + p["localdir"] - else: - url = unicode(QgsApplication.qgisSettingsDirPath(),'utf-8') + "/python/plugins/" + p["localdir"] repository = self.tr("only locally available") else: - url = p["url"] repository = p["repository"] if not p["desc_local"]: p["desc_local"] = p["desc_repo"] @@ -438,7 +433,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): else: a.setToolTip(4,"") a.setText(5,repository) - a.setToolTip(5,url) + a.setToolTip(5,p["url"]) # set fonts and colours for i in [0,1,2,3,4,5]: if p["status"] == "invalid": @@ -483,7 +478,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): item = self.treePlugins.currentItem() if not item: return - key = plugins.firstByName(item.text(1)) + key = plugins.keyByUrl(item.toolTip(5)) if not key: return plugin = plugins.all()[key] @@ -501,7 +496,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): """ install currently selected plugin """ if not self.treePlugins.currentItem(): return - key = plugins.firstByName(self.treePlugins.currentItem().text(1)) + key = plugins.keyByUrl(self.treePlugins.currentItem().toolTip(5)) plugin = plugins.all()[key] if not plugin: return @@ -547,7 +542,7 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): """ uninstall currently selected plugin """ if not self.treePlugins.currentItem(): return - key = plugins.firstByName(self.treePlugins.currentItem().text(1)) + key = plugins.keyByUrl(self.treePlugins.currentItem().toolTip(5)) plugin = plugins.all()[key] if not plugin: return @@ -568,9 +563,12 @@ class QgsPluginInstallerDialog(QDialog, Ui_QgsPluginInstallerDialog): exec ("del sys.modules[%s]" % plugin["localdir"]) except: pass - plugins.setPluginData(key, "status", "not installed") - plugins.setPluginData(key, "version_inst", "") - plugins.setPluginData(key, "desc_local", "") + if plugin["status"] == "orphan": + plugins.remove(key) + else: + plugins.setPluginData(key, "status", "not installed") + plugins.setPluginData(key, "version_inst", "") + plugins.setPluginData(key, "desc_local", "") self.populatePluginTree() QApplication.restoreOverrideCursor() QMessageBox.information(self, self.tr("QGIS Python Plugin Installer"), self.tr("Plugin uninstalled successfully")) diff --git a/python/plugins/plugin_installer/installer_plugin.py b/python/plugins/plugin_installer/installer_plugin.py index 51bae86997a..e8399d50e91 100644 --- a/python/plugins/plugin_installer/installer_plugin.py +++ b/python/plugins/plugin_installer/installer_plugin.py @@ -33,14 +33,14 @@ class InstallerPlugin: # ----------------------------------------- # def initGui(self): """ create action that will start plugin window and then add it to menu """ - self.action = QAction(QIcon(":/plugins/installer/PluginInstaller.png"), QCoreApplication.translate("QgsPluginInstaller","Plugin Installer..."), self.mainWindow()) + self.action = QAction(QIcon(":/plugins/installer/PluginInstaller.png"), QCoreApplication.translate("QgsPluginInstaller","Fetch Python Plugins..."), self.mainWindow()) self.action.setWhatsThis(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories")) self.action.setStatusTip(QCoreApplication.translate("QgsPluginInstaller","Install more plugins from remote repositories")) if str(QGis.qgisVersion)[0] == "0": nextAction = self.mainWindow().menuBar().actions()[4].menu().actions()[1] self.mainWindow().menuBar().actions()[4].menu().insertAction(nextAction,self.action) else: - nextAction = self.iface.actionPluginSeparator1() + nextAction = self.iface.actionManagePlugins() #actionPluginSeparator1() self.iface.pluginMenu().insertAction(nextAction,self.action) QObject.connect(self.action, SIGNAL("activated()"), self.run) self.statusLabel = None diff --git a/python/plugins/plugin_installer/installingbase.py b/python/plugins/plugin_installer/installingbase.py index 8404a757dc6..bd895d7ac70 100644 --- a/python/plugins/plugin_installer/installingbase.py +++ b/python/plugins/plugin_installer/installingbase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'installingbase.ui' # -# Created: Sun Sep 7 16:22:38 2008 +# Created: Fri Sep 12 19:21:37 2008 # by: PyQt4 UI code generator 4.3 # # WARNING! All changes made in this file will be lost! diff --git a/python/plugins/plugin_installer/pluginerrorbase.py b/python/plugins/plugin_installer/pluginerrorbase.py index 7d70bdcb6e7..663c9531374 100644 --- a/python/plugins/plugin_installer/pluginerrorbase.py +++ b/python/plugins/plugin_installer/pluginerrorbase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'pluginerrorbase.ui' # -# Created: Sun Sep 7 16:22:47 2008 +# Created: Fri Sep 12 19:21:37 2008 # by: PyQt4 UI code generator 4.3 # # WARNING! All changes made in this file will be lost! diff --git a/python/plugins/plugin_installer/repoUnavailable.png b/python/plugins/plugin_installer/repoUnavailable.png new file mode 100644 index 00000000000..1890efe8d96 Binary files /dev/null and b/python/plugins/plugin_installer/repoUnavailable.png differ diff --git a/python/plugins/plugin_installer/repositorybase.py b/python/plugins/plugin_installer/repositorybase.py index 96b3e161b92..2132c1d7426 100644 --- a/python/plugins/plugin_installer/repositorybase.py +++ b/python/plugins/plugin_installer/repositorybase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'repositorybase.ui' # -# Created: Tue Sep 9 00:09:51 2008 +# Created: Fri Sep 12 19:21:37 2008 # by: PyQt4 UI code generator 4.3 # # WARNING! All changes made in this file will be lost! diff --git a/python/plugins/plugin_installer/resources_rc.py b/python/plugins/plugin_installer/resources_rc.py index be214a8d6ec..5d1fbaa858b 100644 --- a/python/plugins/plugin_installer/resources_rc.py +++ b/python/plugins/plugin_installer/resources_rc.py @@ -2,7 +2,7 @@ # Resource object code # -# Created: ?r. wrz 3 18:43:47 2008 +# Created: pt. wrz 12 19:21:37 2008 # by: The Resource Compiler for PyQt (Qt v4.3.2) # # WARNING! All changes made in this file will be lost!