Skip to content

Commit af52ffa

Browse files
committed
Update plugin installer to new API
1 parent e6f9836 commit af52ffa

3 files changed

Lines changed: 141 additions & 136 deletions

File tree

python/pyplugin_installer/installer.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def __init__(self):
6161
# start fetching repositories
6262
self.statusLabel = QLabel(self.tr("Looking for new plugins...") + " ", iface.mainWindow().statusBar())
6363
iface.mainWindow().statusBar().insertPermanentWidget(0,self.statusLabel)
64-
QObject.connect(self.statusLabel, SIGNAL("linkActivated (QString)"), self.showPluginManagerWhenReady)
65-
QObject.connect(repositories, SIGNAL("checkingDone()"), self.checkingDone)
64+
self.statusLabel.linkActivated.connect(self.showPluginManagerWhenReady)
65+
repositories.checkingDone.connect(self.checkingDone)
6666
for key in repositories.allEnabled():
6767
repositories.requestFetching(key)
6868
else:
@@ -152,7 +152,7 @@ def exportRepositoriesToManager(self):
152152
""" Update manager's repository tree widget with current data """
153153
iface.pluginManagerInterface().clearRepositoryList()
154154
for key in repositories.all():
155-
url = QString(repositories.all()[key]["url"])
155+
url = repositories.all()[key]["url"]
156156
v=str(QGis.QGIS_VERSION_INT)
157157
url += "?qgis=%d.%d" % ( int(v[0]), int(v[1:3]) )
158158
repository = repositories.all()[key]
@@ -161,7 +161,7 @@ def exportRepositoriesToManager(self):
161161
"url" : url,
162162
"enabled" : repositories.all()[key]["enabled"] and "true" or "false",
163163
"valid" : repositories.all()[key]["valid"] and "true" or "false",
164-
"state" : QString(str(repositories.all()[key]["state"])),
164+
"state" : str(repositories.all()[key]["state"]),
165165
"error" : repositories.all()[key]["error"]
166166
})
167167

@@ -229,8 +229,8 @@ def showPluginManagerWhenReady(self, * params):
229229
# finally, show the plugin manager window
230230
tabIndex = -1
231231
if len( params ) == 1:
232-
(indx, ok) = params[0].mid(1).toInt()
233-
if ok and indx > -1 and indx < 7:
232+
indx = unicode(params[0])
233+
if indx.isdigit() and int(indx) > -1 and int(indx) < 7:
234234
tabIndex = indx
235235
iface.pluginManagerInterface().showPluginManager( tabIndex )
236236

@@ -287,11 +287,11 @@ def installPlugin(self, key, quiet=False):
287287
if previousStatus in ["not installed", "new"]:
288288
infoString = (self.tr("Plugin installed successfully"), self.tr("Plugin installed successfully"))
289289
settings = QSettings()
290-
settings.setValue("/PythonPlugins/"+plugin["id"], QVariant(True))
290+
settings.setValue("/PythonPlugins/"+plugin["id"], True)
291291
startPlugin(plugin["id"])
292292
else:
293293
settings = QSettings()
294-
if settings.value("/PythonPlugins/"+key).toBool(): # plugin will be reloaded on the fly only if currently loaded
294+
if settings.value("/PythonPlugins/"+key, False, type=bool): # plugin will be reloaded on the fly only if currently loaded
295295
infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Plugin reinstalled successfully"))
296296
reloadPlugin(key)
297297
else: infoString = (self.tr("Plugin reinstalled successfully"), self.tr("Python plugin reinstalled.\nYou need to restart QGIS in order to reload it."))
@@ -397,18 +397,18 @@ def addRepository(self):
397397
if not dlg.exec_():
398398
return
399399
for i in repositories.all().values():
400-
if dlg.editURL.text().trimmed() == i["url"]:
400+
if dlg.editURL.text().strip() == i["url"]:
401401
QMessageBox.warning(iface.mainWindow(), self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
402402
return
403403
settings = QSettings()
404404
settings.beginGroup(reposGroup)
405405
reposName = dlg.editName.text()
406-
reposURL = dlg.editURL.text().trimmed()
406+
reposURL = dlg.editURL.text().strip()
407407
if repositories.all().has_key(reposName):
408408
reposName = reposName + "(2)"
409409
# add to settings
410-
settings.setValue(reposName+"/url", QVariant(reposURL))
411-
settings.setValue(reposName+"/enabled", QVariant(bool(dlg.checkBoxEnabled.checkState())))
410+
settings.setValue(reposName+"/url", reposURL )
411+
settings.setValue(reposName+"/enabled", bool(dlg.checkBoxEnabled.checkState()))
412412
# refresh lists and populate widgets
413413
plugins.removeRepository(reposName)
414414
self.reloadAndExportData()
@@ -419,7 +419,6 @@ def editRepository(self, reposName):
419419
""" edit repository connection """
420420
if not reposName:
421421
return
422-
reposName = QString( reposName )
423422
checkState={False:Qt.Unchecked,True:Qt.Checked}
424423
dlg = QgsPluginInstallerRepositoryDialog( iface.mainWindow() )
425424
dlg.editName.setText(reposName)
@@ -435,7 +434,7 @@ def editRepository(self, reposName):
435434
if not dlg.exec_():
436435
return # nothing to do if cancelled
437436
for i in repositories.all().values():
438-
if dlg.editURL.text().trimmed() == i["url"] and dlg.editURL.text().trimmed() != repositories.all()[reposName]["url"]:
437+
if dlg.editURL.text().strip() == i["url"] and dlg.editURL.text().strip() != repositories.all()[reposName]["url"]:
439438
QMessageBox.warning(iface.mainWindow(), self.tr("QGIS Python Plugin Installer"), self.tr("Unable to add another repository with the same URL!"))
440439
return
441440
# delete old repo from QSettings and create new one
@@ -445,9 +444,9 @@ def editRepository(self, reposName):
445444
newName = dlg.editName.text()
446445
if repositories.all().has_key(newName) and newName != reposName:
447446
newName = newName + "(2)"
448-
settings.setValue(newName+"/url", QVariant(dlg.editURL.text().trimmed()))
449-
settings.setValue(newName+"/enabled", QVariant(bool(dlg.checkBoxEnabled.checkState())))
450-
if dlg.editURL.text().trimmed() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
447+
settings.setValue(newName+"/url", dlg.editURL.text().strip())
448+
settings.setValue(newName+"/enabled", bool(dlg.checkBoxEnabled.checkState()))
449+
if dlg.editURL.text().strip() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
451450
repositories.rename(reposName, newName)
452451
self.exportRepositoriesToManager()
453452
return # nothing else to do if only repository name was changed
@@ -460,7 +459,6 @@ def deleteRepository(self, reposName):
460459
""" delete repository connection """
461460
if not reposName:
462461
return
463-
reposName = QString( reposName )
464462
warning = self.tr("Are you sure you want to remove the following repository?") + "\n" + reposName
465463
if QMessageBox.warning(iface.mainWindow(), self.tr("QGIS Python Plugin Installer"), warning , QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
466464
return

0 commit comments

Comments
 (0)