PluginManager/PluginRepositoryDialog.py

changeset 945
8cd4d08fa9f6
parent 896
f855351d5e98
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
34 34
35 import UI.PixmapCache 35 import UI.PixmapCache
36 36
37 from eric5config import getConfig 37 from eric5config import getConfig
38 38
39 descrRole = Qt.UserRole 39 descrRole = Qt.UserRole
40 urlRole = Qt.UserRole + 1 40 urlRole = Qt.UserRole + 1
41 filenameRole = Qt.UserRole + 2 41 filenameRole = Qt.UserRole + 2
42 authorRole = Qt.UserRole + 3 42 authorRole = Qt.UserRole + 3
43
43 44
44 class PluginRepositoryWidget(QWidget, Ui_PluginRepositoryDialog): 45 class PluginRepositoryWidget(QWidget, Ui_PluginRepositoryDialog):
45 """ 46 """
46 Class implementing a dialog showing the available plugins. 47 Class implementing a dialog showing the available plugins.
47 48
48 @signal closeAndInstall() emitted when the Close & Install button is pressed 49 @signal closeAndInstall() emitted when the Close & Install button is pressed
49 """ 50 """
50 closeAndInstall = pyqtSignal() 51 closeAndInstall = pyqtSignal()
51 52
52 def __init__(self, parent = None): 53 def __init__(self, parent=None):
53 """ 54 """
54 Constructor 55 Constructor
55 56
56 @param parent parent of this dialog (QWidget) 57 @param parent parent of this dialog (QWidget)
57 """ 58 """
64 self.buttonBox.addButton(self.trUtf8("Download"), QDialogButtonBox.ActionRole) 65 self.buttonBox.addButton(self.trUtf8("Download"), QDialogButtonBox.ActionRole)
65 self.__downloadButton.setEnabled(False) 66 self.__downloadButton.setEnabled(False)
66 self.__downloadCancelButton = \ 67 self.__downloadCancelButton = \
67 self.buttonBox.addButton(self.trUtf8("Cancel"), QDialogButtonBox.ActionRole) 68 self.buttonBox.addButton(self.trUtf8("Cancel"), QDialogButtonBox.ActionRole)
68 self.__installButton = \ 69 self.__installButton = \
69 self.buttonBox.addButton(self.trUtf8("Close && Install"), 70 self.buttonBox.addButton(self.trUtf8("Close && Install"),
70 QDialogButtonBox.ActionRole) 71 QDialogButtonBox.ActionRole)
71 self.__downloadCancelButton.setEnabled(False) 72 self.__downloadCancelButton.setEnabled(False)
72 self.__installButton.setEnabled(False) 73 self.__installButton.setEnabled(False)
73 74
74 self.repositoryList.headerItem().setText(self.repositoryList.columnCount(), "") 75 self.repositoryList.headerItem().setText(self.repositoryList.columnCount(), "")
169 def __updateList(self): 170 def __updateList(self):
170 """ 171 """
171 Private slot to download a new list and display the contents. 172 Private slot to download a new list and display the contents.
172 """ 173 """
173 url = Preferences.getUI("PluginRepositoryUrl5") 174 url = Preferences.getUI("PluginRepositoryUrl5")
174 self.__downloadFile(url, 175 self.__downloadFile(url,
175 self.pluginRepositoryFile, 176 self.pluginRepositoryFile,
176 self.__downloadRepositoryFileDone) 177 self.__downloadRepositoryFileDone)
177 178
178 def __downloadRepositoryFileDone(self, status, filename): 179 def __downloadRepositoryFileDone(self, status, filename):
179 """ 180 """
180 Private method called after the repository file was downloaded. 181 Private method called after the repository file was downloaded.
202 203
203 def __downloadPlugin(self): 204 def __downloadPlugin(self):
204 """ 205 """
205 Private method to download the next plugin. 206 Private method to download the next plugin.
206 """ 207 """
207 self.__downloadFile(self.__pluginsToDownload[0][0], 208 self.__downloadFile(self.__pluginsToDownload[0][0],
208 self.__pluginsToDownload[0][1], 209 self.__pluginsToDownload[0][1],
209 self.__downloadPluginDone) 210 self.__downloadPluginDone)
210 211
211 def __downloadPlugins(self): 212 def __downloadPlugins(self):
212 """ 213 """
213 Private slot to download the selected plugins. 214 Private slot to download the selected plugins.
242 243
243 def __resortRepositoryList(self): 244 def __resortRepositoryList(self):
244 """ 245 """
245 Private method to resort the tree. 246 Private method to resort the tree.
246 """ 247 """
247 self.repositoryList.sortItems(self.repositoryList.sortColumn(), 248 self.repositoryList.sortItems(self.repositoryList.sortColumn(),
248 self.repositoryList.header().sortIndicatorOrder()) 249 self.repositoryList.header().sortIndicatorOrder())
249 250
250 def __populateList(self): 251 def __populateList(self):
251 """ 252 """
252 Private method to populate the list of available plugins. 253 Private method to populate the list of available plugins.
275 self.trUtf8("<p>The plugins repository file <b>{0}</b> " 276 self.trUtf8("<p>The plugins repository file <b>{0}</b> "
276 "could not be read. Select Update</p>")\ 277 "could not be read. Select Update</p>")\
277 .format(self.pluginRepositoryFile)) 278 .format(self.pluginRepositoryFile))
278 else: 279 else:
279 self.__repositoryMissing = True 280 self.__repositoryMissing = True
280 QTreeWidgetItem(self.repositoryList, 281 QTreeWidgetItem(self.repositoryList,
281 ["", 282 ["",
282 self.trUtf8("No plugin repository file available.\nSelect Update.") 283 self.trUtf8("No plugin repository file available.\nSelect Update.")
283 ]) 284 ])
284 self.repositoryList.resizeColumnToContents(1) 285 self.repositoryList.resizeColumnToContents(1)
285 286
286 def __downloadFile(self, url, filename, doneMethod = None): 287 def __downloadFile(self, url, filename, doneMethod=None):
287 """ 288 """
288 Private slot to download the given file. 289 Private slot to download the given file.
289 290
290 @param url URL for the download (string) 291 @param url URL for the download (string)
291 @param filename local name of the file (string) 292 @param filename local name of the file (string)
462 self.trUtf8("SSL Errors"), 463 self.trUtf8("SSL Errors"),
463 self.trUtf8("""<p>SSL Errors:</p>""" 464 self.trUtf8("""<p>SSL Errors:</p>"""
464 """<p>{0}</p>""" 465 """<p>{0}</p>"""
465 """<p>Do you want to ignore these errors?</p>""")\ 466 """<p>Do you want to ignore these errors?</p>""")\
466 .format(errorString), 467 .format(errorString),
467 icon = E5MessageBox.Warning) 468 icon=E5MessageBox.Warning)
468 if ret: 469 if ret:
469 reply.ignoreSslErrors() 470 reply.ignoreSslErrors()
470 else: 471 else:
471 self.__downloadCancelled = True 472 self.__downloadCancelled = True
472 reply.abort() 473 reply.abort()
477 478
478 @return list of plugin filenames (list of strings) 479 @return list of plugin filenames (list of strings)
479 """ 480 """
480 return self.__pluginsDownloaded 481 return self.__pluginsDownloaded
481 482
483
482 class PluginRepositoryDialog(QDialog): 484 class PluginRepositoryDialog(QDialog):
483 """ 485 """
484 Class for the dialog variant. 486 Class for the dialog variant.
485 """ 487 """
486 def __init__(self, parent = None): 488 def __init__(self, parent=None):
487 """ 489 """
488 Constructor 490 Constructor
489 491
490 @param parent reference to the parent widget (QWidget) 492 @param parent reference to the parent widget (QWidget)
491 """ 493 """
517 519
518 @return list of plugin filenames (list of strings) 520 @return list of plugin filenames (list of strings)
519 """ 521 """
520 return self.cw.getDownloadedPlugins() 522 return self.cw.getDownloadedPlugins()
521 523
524
522 class PluginRepositoryWindow(QMainWindow): 525 class PluginRepositoryWindow(QMainWindow):
523 """ 526 """
524 Main window class for the standalone dialog. 527 Main window class for the standalone dialog.
525 """ 528 """
526 def __init__(self, parent = None): 529 def __init__(self, parent=None):
527 """ 530 """
528 Constructor 531 Constructor
529 532
530 @param parent reference to the parent widget (QWidget) 533 @param parent reference to the parent widget (QWidget)
531 """ 534 """

eric ide

mercurial