mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Improvements to plugin installer:
- ability to support custom repositories - better error handling git-svn-id: http://svn.osgeo.org/qgis/trunk@7909 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
64f92543f0
commit
484a9322fe
@ -8,5 +8,7 @@ __init__.py
|
||||
installer_plugin.py
|
||||
qgis_plugins.py
|
||||
resources.py
|
||||
repository_ui.py
|
||||
repository_dialog.py
|
||||
)
|
||||
INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/qgis/python/plugins/plugin_installer)
|
||||
|
@ -6,14 +6,14 @@ PYUIC = /usr/bin/pyuic4
|
||||
RC_PY_FILE = resources.py
|
||||
UI_PY_FILE = gui.py
|
||||
|
||||
all: $(RC_PY_FILE) $(UI_PY_FILE)
|
||||
all: $(RC_PY_FILE) $(UI_PY_FILE) repository_ui.py
|
||||
|
||||
install: all
|
||||
mkdir -p $(INST_DIR)
|
||||
cp *.py $(INST_DIR)/
|
||||
|
||||
clean:
|
||||
rm -f $(RC_PY_FILE) $(UI_PY_FILE)
|
||||
rm -f $(RC_PY_FILE) $(UI_PY_FILE) repository_ui.py
|
||||
rm -f *.pyc
|
||||
|
||||
zip:
|
||||
@ -25,3 +25,5 @@ $(RC_PY_FILE): resources.qrc
|
||||
$(UI_PY_FILE): gui.ui
|
||||
$(PYUIC) -o $(UI_PY_FILE) gui.ui
|
||||
|
||||
repository_ui.py: repository.ui
|
||||
$(PYUIC) -o repository_ui.py repository.ui
|
||||
|
@ -1,5 +1,3 @@
|
||||
# load TestPlugin class from file testplugin.py
|
||||
from installer_plugin import InstallerPlugin
|
||||
|
||||
def name():
|
||||
return "Plugin installer"
|
||||
@ -11,4 +9,6 @@ def version():
|
||||
return "Version 0.02"
|
||||
|
||||
def classFactory(iface):
|
||||
# load TestPlugin class from file testplugin.py
|
||||
from installer_plugin import InstallerPlugin
|
||||
return InstallerPlugin(iface)
|
||||
|
@ -1,26 +1,211 @@
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
from qgis.core import QgsContextHelp
|
||||
from qgis.core import QgsApplication, QgsContextHelp
|
||||
|
||||
from gui import Ui_Dialog
|
||||
import resources
|
||||
|
||||
from repository_dialog import RepositoryDialog
|
||||
|
||||
|
||||
class InstallerPluginGui(QDialog, Ui_Dialog):
|
||||
def __init__(self, parent, fl):
|
||||
QDialog.__init__(self, parent, fl)
|
||||
|
||||
self.default_repository_name = "Official QGIS repository"
|
||||
self.default_repository = "http://spatialserver.net/cgi-bin/pyqgis_plugin.rb"
|
||||
|
||||
self.setupUi(self)
|
||||
|
||||
def on_buttonBrowse_released(self):
|
||||
self.emit(SIGNAL("retrieveList(QString )"),"test" )
|
||||
print "browse"
|
||||
|
||||
def on_pbnOK_released(self):
|
||||
#self.hide()
|
||||
self.emit(SIGNAL("installPlugin(QString )"), self.linePlugin.text() )
|
||||
return
|
||||
#self.done(1)
|
||||
self.connect(self.buttonBrowse, SIGNAL("clicked()"), self.getAvailablePlugins)
|
||||
self.connect(self.pbnOK, SIGNAL("clicked()"), self.installPlugin)
|
||||
|
||||
# grab the click on the treelist
|
||||
self.connect(self.treePlugins, SIGNAL("itemClicked(QTreeWidgetItem *,int)"), self.treeClicked)
|
||||
|
||||
# repositories handling
|
||||
self.connect(self.buttonAddRep, SIGNAL("clicked()"), self.addRepository)
|
||||
self.connect(self.buttonEditRep, SIGNAL("clicked()"), self.editRepository)
|
||||
self.connect(self.buttonDeleteRep, SIGNAL("clicked()"), self.deleteRepository)
|
||||
|
||||
self.populateRepositories()
|
||||
|
||||
|
||||
def on_pbnCancel_clicked(self):
|
||||
self.close()
|
||||
|
||||
|
||||
def getAvailablePlugins(self):
|
||||
print "getting list of plugins"
|
||||
repository = self.getRepository()
|
||||
if not repository:
|
||||
return
|
||||
repository_url = str(repository[1])
|
||||
|
||||
from qgis_plugins import retrieve_list
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
|
||||
try:
|
||||
pluginlist = retrieve_list(repository_url)
|
||||
except IOError:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, "Error", "Couldn't connect to the repository.")
|
||||
return
|
||||
except Exception:
|
||||
QApplication.restoreOverrideCursor()
|
||||
QMessageBox.warning(self, "Error", "Couldn't parse output from repository.")
|
||||
return
|
||||
|
||||
#output = "QGIS python plugins avialable from \n%s\n" % self.repository
|
||||
#for p in pluginlist:
|
||||
# output += "\n%s ( version %s )" % (p["name"], p["version"])
|
||||
# output += "\n\t%s by %s" % (p["desc"],p["author"])
|
||||
#self.gui.txtAvailable.setText(output)
|
||||
self.treePlugins.clear()
|
||||
for p in pluginlist:
|
||||
a = QTreeWidgetItem(self.treePlugins)
|
||||
a.setText(0,p["name"])
|
||||
a.setText(1,p["version"])
|
||||
a.setText(2,p["desc"])
|
||||
a.setText(3,p["author"])
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
# resize the columns
|
||||
# plugin name
|
||||
self.treePlugins.resizeColumnToContents(0);
|
||||
# version
|
||||
self.treePlugins.resizeColumnToContents(1);
|
||||
# author/contributor
|
||||
self.treePlugins.resizeColumnToContents(3);
|
||||
# description
|
||||
self.treePlugins.setColumnWidth(2, 560);
|
||||
|
||||
|
||||
def installPlugin(self):
|
||||
""" installs currently selected plugin """
|
||||
plugin = self.linePlugin.text()
|
||||
repository = self.getRepository()
|
||||
if not repository:
|
||||
return
|
||||
repository_url = str(repository[1])
|
||||
plugindir = str(QgsApplication.qgisSettingsDirPath()) + "/python/plugins"
|
||||
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
from qgis_plugins import retrieve_list, install_plugin
|
||||
print "install_plugin",plugin,plugindir,repository_url
|
||||
result = install_plugin(plugin, plugindir, repository_url)
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
if result[0]:
|
||||
QMessageBox.information(self, "Plugin installed successfully", result[1])
|
||||
else:
|
||||
QMessageBox.warning(self, "Plugin installation failed", result[1])
|
||||
|
||||
|
||||
def treeClicked(self, item, col):
|
||||
self.linePlugin.setText(item.text(0))
|
||||
|
||||
|
||||
def getRepository(self):
|
||||
""" returns Name and URL of the current repository as a tuple or None if no repository is selected """
|
||||
if self.comboRepositories.currentIndex() == -1:
|
||||
return None
|
||||
|
||||
settings = QSettings()
|
||||
reposGroup = "/Qgis/plugin-repos"
|
||||
reposName = self.comboRepositories.currentText()
|
||||
reposURL = settings.value(reposGroup+"/"+reposName+"/url", QVariant()).toString()
|
||||
return (reposName, reposURL)
|
||||
|
||||
|
||||
def populateRepositories(self):
|
||||
""" populate repository combo box from the settings """
|
||||
self.comboRepositories.clear()
|
||||
|
||||
settings = QSettings()
|
||||
reposGroup = "/Qgis/plugin-repos"
|
||||
settings.beginGroup(reposGroup)
|
||||
|
||||
# add the default repository when there isn't any...
|
||||
if len(settings.childGroups()) == 0:
|
||||
settings.setValue(self.default_repository_name+"/url", QVariant(self.default_repository))
|
||||
|
||||
for key in settings.childGroups():
|
||||
self.comboRepositories.addItem(key)
|
||||
|
||||
settings.endGroup()
|
||||
|
||||
|
||||
def addRepository(self):
|
||||
""" add repository button has been clicked """
|
||||
print "add"
|
||||
dlg = RepositoryDialog(self)
|
||||
if not dlg.exec_():
|
||||
return
|
||||
|
||||
settings = QSettings()
|
||||
reposGroup = "/Qgis/plugin-repos"
|
||||
settings.beginGroup(reposGroup)
|
||||
|
||||
reposName = dlg.editName.text()
|
||||
reposURL = dlg.editURL.text()
|
||||
print "name: "+reposName
|
||||
print "url: "+reposURL
|
||||
|
||||
# add to settings
|
||||
settings.setValue(reposName+"/url", QVariant(reposURL))
|
||||
|
||||
# add to combobox
|
||||
self.comboRepositories.addItem(reposName)
|
||||
|
||||
|
||||
def editRepository(self):
|
||||
""" edit repository button has been clicked """
|
||||
print "edit"
|
||||
|
||||
current = self.comboRepositories.currentIndex()
|
||||
if current == -1:
|
||||
return
|
||||
|
||||
(reposName, reposURL) = self.getRepository()
|
||||
|
||||
dlg = RepositoryDialog(self)
|
||||
dlg.editName.setText(reposName)
|
||||
dlg.editURL.setText(reposURL)
|
||||
if not dlg.exec_():
|
||||
return
|
||||
|
||||
settings = QSettings()
|
||||
reposGroup = "/Qgis/plugin-repos"
|
||||
settings.beginGroup(reposGroup)
|
||||
|
||||
# first delete old setting
|
||||
settings.remove(reposName)
|
||||
|
||||
# and create new one
|
||||
settings.setValue(dlg.editName.text()+"/url", QVariant(dlg.editURL.text()))
|
||||
|
||||
# update the name if it has been changed
|
||||
self.comboRepositories.setItemText(current, dlg.editName.text())
|
||||
|
||||
|
||||
def deleteRepository(self):
|
||||
""" delete repository button has been clicked """
|
||||
print "delete"
|
||||
|
||||
current = self.comboRepositories.currentIndex()
|
||||
if current == -1:
|
||||
return
|
||||
|
||||
settings = QSettings()
|
||||
reposGroup = "/Qgis/plugin-repos"
|
||||
settings.beginGroup(reposGroup)
|
||||
|
||||
# delete from settings
|
||||
reposName = self.comboRepositories.currentText()
|
||||
settings.remove(reposName)
|
||||
|
||||
# delete from combo box
|
||||
self.comboRepositories.removeItem(current)
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'gui.ui'
|
||||
#
|
||||
# Created: Sun Dec 30 18:07:25 2007
|
||||
# by: PyQt4 UI code generator 4.3.3
|
||||
# Created: Thu Jan 10 13:11:48 2008
|
||||
# by: PyQt4 UI code generator 4.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
@ -17,17 +17,38 @@ class Ui_Dialog(object):
|
||||
self.vboxlayout = QtGui.QVBoxLayout(Dialog)
|
||||
self.vboxlayout.setObjectName("vboxlayout")
|
||||
|
||||
self.vboxlayout1 = QtGui.QVBoxLayout()
|
||||
self.label = QtGui.QLabel(Dialog)
|
||||
self.label.setObjectName("label")
|
||||
self.vboxlayout.addWidget(self.label)
|
||||
|
||||
self.groupBox = QtGui.QGroupBox(Dialog)
|
||||
self.groupBox.setObjectName("groupBox")
|
||||
|
||||
self.vboxlayout1 = QtGui.QVBoxLayout(self.groupBox)
|
||||
self.vboxlayout1.setObjectName("vboxlayout1")
|
||||
|
||||
self.hboxlayout = QtGui.QHBoxLayout()
|
||||
self.hboxlayout.setObjectName("hboxlayout")
|
||||
|
||||
self.label = QtGui.QLabel(Dialog)
|
||||
self.label.setObjectName("label")
|
||||
self.hboxlayout.addWidget(self.label)
|
||||
self.label_4 = QtGui.QLabel(self.groupBox)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.hboxlayout.addWidget(self.label_4)
|
||||
|
||||
self.buttonBrowse = QtGui.QPushButton(Dialog)
|
||||
self.comboRepositories = QtGui.QComboBox(self.groupBox)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.comboRepositories.sizePolicy().hasHeightForWidth())
|
||||
self.comboRepositories.setSizePolicy(sizePolicy)
|
||||
self.comboRepositories.setObjectName("comboRepositories")
|
||||
self.hboxlayout.addWidget(self.comboRepositories)
|
||||
self.vboxlayout1.addLayout(self.hboxlayout)
|
||||
|
||||
self.hboxlayout1 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout1.setObjectName("hboxlayout1")
|
||||
|
||||
self.buttonBrowse = QtGui.QPushButton(self.groupBox)
|
||||
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
@ -35,37 +56,54 @@ class Ui_Dialog(object):
|
||||
sizePolicy.setHeightForWidth(self.buttonBrowse.sizePolicy().hasHeightForWidth())
|
||||
self.buttonBrowse.setSizePolicy(sizePolicy)
|
||||
self.buttonBrowse.setObjectName("buttonBrowse")
|
||||
self.hboxlayout.addWidget(self.buttonBrowse)
|
||||
self.vboxlayout1.addLayout(self.hboxlayout)
|
||||
self.hboxlayout1.addWidget(self.buttonBrowse)
|
||||
|
||||
spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
|
||||
self.hboxlayout1.addItem(spacerItem)
|
||||
|
||||
self.buttonAddRep = QtGui.QPushButton(self.groupBox)
|
||||
self.buttonAddRep.setObjectName("buttonAddRep")
|
||||
self.hboxlayout1.addWidget(self.buttonAddRep)
|
||||
|
||||
self.buttonEditRep = QtGui.QPushButton(self.groupBox)
|
||||
self.buttonEditRep.setObjectName("buttonEditRep")
|
||||
self.hboxlayout1.addWidget(self.buttonEditRep)
|
||||
|
||||
self.buttonDeleteRep = QtGui.QPushButton(self.groupBox)
|
||||
self.buttonDeleteRep.setObjectName("buttonDeleteRep")
|
||||
self.hboxlayout1.addWidget(self.buttonDeleteRep)
|
||||
self.vboxlayout1.addLayout(self.hboxlayout1)
|
||||
self.vboxlayout.addWidget(self.groupBox)
|
||||
|
||||
self.treePlugins = QtGui.QTreeWidget(Dialog)
|
||||
self.treePlugins.setAlternatingRowColors(True)
|
||||
self.treePlugins.setRootIsDecorated(False)
|
||||
self.treePlugins.setItemsExpandable(False)
|
||||
self.treePlugins.setObjectName("treePlugins")
|
||||
self.vboxlayout1.addWidget(self.treePlugins)
|
||||
|
||||
self.hboxlayout1 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout1.setObjectName("hboxlayout1")
|
||||
|
||||
self.label_2 = QtGui.QLabel(Dialog)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.hboxlayout1.addWidget(self.label_2)
|
||||
|
||||
self.linePlugin = QtGui.QLineEdit(Dialog)
|
||||
self.linePlugin.setObjectName("linePlugin")
|
||||
self.hboxlayout1.addWidget(self.linePlugin)
|
||||
|
||||
self.pbnOK = QtGui.QPushButton(Dialog)
|
||||
self.pbnOK.setObjectName("pbnOK")
|
||||
self.hboxlayout1.addWidget(self.pbnOK)
|
||||
self.vboxlayout1.addLayout(self.hboxlayout1)
|
||||
self.vboxlayout.addWidget(self.treePlugins)
|
||||
|
||||
self.hboxlayout2 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout2.setObjectName("hboxlayout2")
|
||||
|
||||
self.label_2 = QtGui.QLabel(Dialog)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.hboxlayout2.addWidget(self.label_2)
|
||||
|
||||
self.linePlugin = QtGui.QLineEdit(Dialog)
|
||||
self.linePlugin.setObjectName("linePlugin")
|
||||
self.hboxlayout2.addWidget(self.linePlugin)
|
||||
|
||||
self.pbnOK = QtGui.QPushButton(Dialog)
|
||||
self.pbnOK.setObjectName("pbnOK")
|
||||
self.hboxlayout2.addWidget(self.pbnOK)
|
||||
self.vboxlayout.addLayout(self.hboxlayout2)
|
||||
|
||||
self.hboxlayout3 = QtGui.QHBoxLayout()
|
||||
self.hboxlayout3.setObjectName("hboxlayout3")
|
||||
|
||||
self.label_3 = QtGui.QLabel(Dialog)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.hboxlayout2.addWidget(self.label_3)
|
||||
self.hboxlayout3.addWidget(self.label_3)
|
||||
|
||||
self.pbnCancel = QtGui.QPushButton(Dialog)
|
||||
|
||||
@ -75,17 +113,21 @@ class Ui_Dialog(object):
|
||||
sizePolicy.setHeightForWidth(self.pbnCancel.sizePolicy().hasHeightForWidth())
|
||||
self.pbnCancel.setSizePolicy(sizePolicy)
|
||||
self.pbnCancel.setObjectName("pbnCancel")
|
||||
self.hboxlayout2.addWidget(self.pbnCancel)
|
||||
self.vboxlayout1.addLayout(self.hboxlayout2)
|
||||
self.vboxlayout.addLayout(self.vboxlayout1)
|
||||
self.hboxlayout3.addWidget(self.pbnCancel)
|
||||
self.vboxlayout.addLayout(self.hboxlayout3)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "QGIS Plugin Installer", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("Dialog", "Retrieve the list of available plugins, select one and install it", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("Dialog", "Select repository, retrieve the list of available plugins, select one and install it", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.groupBox.setTitle(QtGui.QApplication.translate("Dialog", "Repository", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_4.setText(QtGui.QApplication.translate("Dialog", "Active repository:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.buttonBrowse.setText(QtGui.QApplication.translate("Dialog", "Get List", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.buttonAddRep.setText(QtGui.QApplication.translate("Dialog", "Add", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.buttonEditRep.setText(QtGui.QApplication.translate("Dialog", "Edit", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.buttonDeleteRep.setText(QtGui.QApplication.translate("Dialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treePlugins.headerItem().setText(0,QtGui.QApplication.translate("Dialog", "Name", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treePlugins.headerItem().setText(1,QtGui.QApplication.translate("Dialog", "Version", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treePlugins.headerItem().setText(2,QtGui.QApplication.translate("Dialog", "Description", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
@ -1,122 +1,185 @@
|
||||
<ui version="4.0" >
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>761</width>
|
||||
<height>471</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>QGIS Plugin Installer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>761</width>
|
||||
<height>471</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>QGIS Plugin Installer</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Select repository, retrieve the list of available plugins, select one and install it</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Repository</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Retrieve the list of available plugins, select one and install it</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Active repository:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboRepositories" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonBrowse" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Get List</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonBrowse" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Get List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonAddRep" >
|
||||
<property name="text" >
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonEditRep" >
|
||||
<property name="text" >
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonDeleteRep" >
|
||||
<property name="text" >
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treePlugins" >
|
||||
<property name="alternatingRowColors" >
|
||||
<bool>true</bool>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treePlugins" >
|
||||
<property name="alternatingRowColors" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rootIsDecorated" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="itemsExpandable" >
|
||||
<bool>false</bool>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Version</string>
|
||||
</property>
|
||||
<column>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Author</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Name</string>
|
||||
<string>Name of plugin to install</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linePlugin" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbnOK" >
|
||||
<property name="text" >
|
||||
<string>Version</string>
|
||||
<string>Install Plugin</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Description</string>
|
||||
<string>The plugin will be installed to ~/.qgis/python/plugins</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbnCancel" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Author</string>
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Name of plugin to install</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linePlugin" />
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbnOK" >
|
||||
<property name="text" >
|
||||
<string>Install Plugin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>The plugin will be installed to ~/.qgis/python/plugins</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbnCancel" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Done</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -3,8 +3,6 @@ from PyQt4.QtGui import *
|
||||
from qgis.core import *
|
||||
from dialog import InstallerPluginGui
|
||||
import resources
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
class InstallerPlugin:
|
||||
|
||||
@ -12,7 +10,6 @@ class InstallerPlugin:
|
||||
def __init__(self, iface):
|
||||
# save reference to the QGIS interface
|
||||
self.iface = iface
|
||||
self.repository = "http://spatialserver.net/cgi-bin/pyqgis_plugin.rb"
|
||||
|
||||
# ----------------------------------------- #
|
||||
def initGui(self):
|
||||
@ -35,66 +32,5 @@ class InstallerPlugin:
|
||||
def run(self):
|
||||
# create and show a configuration dialog
|
||||
flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMaximizeButtonHint
|
||||
gui = InstallerPluginGui(self.iface.getMainWindow(),flags)
|
||||
|
||||
# connect to the submitAddresses signal which triggers the geocoding engine
|
||||
QObject.connect(gui, SIGNAL("retrieveList(QString )"), self.getAvailablePlugins)
|
||||
|
||||
# connect to the submitOutput signal which sets the output text file
|
||||
QObject.connect(gui, SIGNAL("installPlugin(QString )"), self.installPlugin)
|
||||
|
||||
# grab the click on the treelist
|
||||
QObject.connect(gui.treePlugins, SIGNAL("itemClicked(QTreeWidgetItem *,int)"), self.treeClicked)
|
||||
|
||||
gui.show()
|
||||
self.gui = gui
|
||||
|
||||
|
||||
def getAvailablePlugins(self):
|
||||
print "getting list of plugins"
|
||||
from qgis_plugins import retrieve_list
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
pluginlist = retrieve_list(self.repository)
|
||||
output = "QGIS python plugins avialable from \n%s\n" % self.repository
|
||||
#for p in pluginlist:
|
||||
# output += "\n%s ( version %s )" % (p["name"], p["version"])
|
||||
# output += "\n\t%s by %s" % (p["desc"],p["author"])
|
||||
#self.gui.txtAvailable.setText(output)
|
||||
for p in pluginlist:
|
||||
a = QTreeWidgetItem(self.gui.treePlugins)
|
||||
a.setText(0,p["name"])
|
||||
a.setText(1,p["version"])
|
||||
a.setText(2,p["desc"])
|
||||
a.setText(3,p["author"])
|
||||
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
|
||||
# resize the columns
|
||||
# plugin name
|
||||
self.gui.treePlugins.resizeColumnToContents(0);
|
||||
# version
|
||||
self.gui.treePlugins.resizeColumnToContents(1);
|
||||
# author/contributor
|
||||
self.gui.treePlugins.resizeColumnToContents(3);
|
||||
# description
|
||||
self.gui.treePlugins.setColumnWidth(2, 560);
|
||||
return
|
||||
|
||||
def installPlugin(self, plugin):
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
from qgis_plugins import retrieve_list, install_plugin
|
||||
plugindir = str(QgsApplication.qgisSettingsDirPath()) + "/python/plugins"
|
||||
result = install_plugin(plugin, plugindir, self.repository)
|
||||
QApplication.restoreOverrideCursor()
|
||||
if result[0]:
|
||||
mb=QMessageBox(self.iface.getMainWindow())
|
||||
mb.information(mb, "Plugin installed successfully", result[1])
|
||||
else:
|
||||
mb=QMessageBox(self.iface.getMainWindow())
|
||||
mb.information(mb, "Plugin installation failed", result[1])
|
||||
return
|
||||
|
||||
def treeClicked(self, item, col):
|
||||
self.gui.linePlugin.setText(item.text(0))
|
||||
return
|
||||
self.gui = InstallerPluginGui(self.iface.getMainWindow(),flags)
|
||||
self.gui.show()
|
||||
|
100
python/plugins/plugin_installer/repository.ui
Normal file
100
python/plugins/plugin_installer/repository.ui
Normal file
@ -0,0 +1,100 @@
|
||||
<ui version="4.0" >
|
||||
<class>RepositoryDetailsDialog</class>
|
||||
<widget class="QDialog" name="RepositoryDetailsDialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>395</width>
|
||||
<height>169</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Repository details</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="editName" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="editURL" >
|
||||
<property name="text" >
|
||||
<string>http://</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>181</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RepositoryDetailsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RepositoryDetailsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
20
python/plugins/plugin_installer/repository_dialog.py
Normal file
20
python/plugins/plugin_installer/repository_dialog.py
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
from repository_ui import Ui_RepositoryDetailsDialog
|
||||
|
||||
class RepositoryDialog(QDialog, Ui_RepositoryDetailsDialog):
|
||||
def __init__(self, parent=None):
|
||||
QDialog.__init__(self, parent)
|
||||
|
||||
self.setupUi(self)
|
||||
|
||||
self.connect(self.editName, SIGNAL("textChanged(const QString &)"), self.changed)
|
||||
self.connect(self.editURL, SIGNAL("textChanged(const QString &)"), self.changed)
|
||||
|
||||
self.changed(None)
|
||||
|
||||
def changed(self, string):
|
||||
enable = (self.editName.text().count() > 0 and self.editURL.text().count() > 0)
|
||||
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
|
55
python/plugins/plugin_installer/repository_ui.py
Normal file
55
python/plugins/plugin_installer/repository_ui.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'repository.ui'
|
||||
#
|
||||
# Created: Thu Jan 10 14:22:08 2008
|
||||
# by: PyQt4 UI code generator 4.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
class Ui_RepositoryDetailsDialog(object):
|
||||
def setupUi(self, RepositoryDetailsDialog):
|
||||
RepositoryDetailsDialog.setObjectName("RepositoryDetailsDialog")
|
||||
RepositoryDetailsDialog.resize(QtCore.QSize(QtCore.QRect(0,0,395,169).size()).expandedTo(RepositoryDetailsDialog.minimumSizeHint()))
|
||||
|
||||
self.gridlayout = QtGui.QGridLayout(RepositoryDetailsDialog)
|
||||
self.gridlayout.setObjectName("gridlayout")
|
||||
|
||||
self.label = QtGui.QLabel(RepositoryDetailsDialog)
|
||||
self.label.setObjectName("label")
|
||||
self.gridlayout.addWidget(self.label,0,0,1,1)
|
||||
|
||||
self.editName = QtGui.QLineEdit(RepositoryDetailsDialog)
|
||||
self.editName.setObjectName("editName")
|
||||
self.gridlayout.addWidget(self.editName,0,1,1,1)
|
||||
|
||||
self.label_2 = QtGui.QLabel(RepositoryDetailsDialog)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.gridlayout.addWidget(self.label_2,1,0,1,1)
|
||||
|
||||
self.editURL = QtGui.QLineEdit(RepositoryDetailsDialog)
|
||||
self.editURL.setObjectName("editURL")
|
||||
self.gridlayout.addWidget(self.editURL,1,1,1,1)
|
||||
|
||||
spacerItem = QtGui.QSpacerItem(181,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding)
|
||||
self.gridlayout.addItem(spacerItem,2,0,1,2)
|
||||
|
||||
self.buttonBox = QtGui.QDialogButtonBox(RepositoryDetailsDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.NoButton|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.gridlayout.addWidget(self.buttonBox,3,0,1,2)
|
||||
|
||||
self.retranslateUi(RepositoryDetailsDialog)
|
||||
QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),RepositoryDetailsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),RepositoryDetailsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(RepositoryDetailsDialog)
|
||||
|
||||
def retranslateUi(self, RepositoryDetailsDialog):
|
||||
RepositoryDetailsDialog.setWindowTitle(QtGui.QApplication.translate("RepositoryDetailsDialog", "Repository details", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("RepositoryDetailsDialog", "Name:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label_2.setText(QtGui.QApplication.translate("RepositoryDetailsDialog", "URL:", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.editURL.setText(QtGui.QApplication.translate("RepositoryDetailsDialog", "http://", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
# Resource object code
|
||||
#
|
||||
# Created: Sun Oct 21 12:16:25 2007
|
||||
# by: The Resource Compiler for PyQt (Qt v4.3.2)
|
||||
# Created: Thu Jan 10 13:11:47 2008
|
||||
# by: The Resource Compiler for PyQt (Qt v4.2.3)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user