PluginManager/PluginUninstallDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3366
6084bb3c3911
child 3621
15f23ed3f216
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
52 else: 52 else:
53 self.__pluginManager = pluginManager 53 self.__pluginManager = pluginManager
54 self.__external = False 54 self.__external = False
55 55
56 self.pluginDirectoryCombo.addItem( 56 self.pluginDirectoryCombo.addItem(
57 self.trUtf8("User plugins directory"), 57 self.tr("User plugins directory"),
58 self.__pluginManager.getPluginDir("user")) 58 self.__pluginManager.getPluginDir("user"))
59 59
60 globalDir = self.__pluginManager.getPluginDir("global") 60 globalDir = self.__pluginManager.getPluginDir("global")
61 if globalDir is not None and os.access(globalDir, os.W_OK): 61 if globalDir is not None and os.access(globalDir, os.W_OK):
62 self.pluginDirectoryCombo.addItem( 62 self.pluginDirectoryCombo.addItem(
63 self.trUtf8("Global plugins directory"), 63 self.tr("Global plugins directory"),
64 globalDir) 64 globalDir)
65
66 msh = self.minimumSizeHint()
67 self.resize(max(self.width(), msh.width()), msh.height())
65 68
66 @pyqtSlot(int) 69 @pyqtSlot(int)
67 def on_pluginDirectoryCombo_currentIndexChanged(self, index): 70 def on_pluginDirectoryCombo_currentIndexChanged(self, index):
68 """ 71 """
69 Private slot to populate the plugin name combo upon a change of the 72 Private slot to populate the plugin name combo upon a change of the
102 .itemData(self.pluginNameCombo.currentIndex()) 105 .itemData(self.pluginNameCombo.currentIndex())
103 106
104 if not self.__pluginManager.unloadPlugin(pluginName): 107 if not self.__pluginManager.unloadPlugin(pluginName):
105 E5MessageBox.critical( 108 E5MessageBox.critical(
106 self, 109 self,
107 self.trUtf8("Plugin Uninstallation"), 110 self.tr("Plugin Uninstallation"),
108 self.trUtf8( 111 self.tr(
109 """<p>The plugin <b>{0}</b> could not be unloaded.""" 112 """<p>The plugin <b>{0}</b> could not be unloaded."""
110 """ Aborting...</p>""").format(pluginName)) 113 """ Aborting...</p>""").format(pluginName))
111 return False 114 return False
112 115
113 if not pluginDirectory in sys.path: 116 if not pluginDirectory in sys.path:
114 sys.path.insert(2, pluginDirectory) 117 sys.path.insert(2, pluginDirectory)
115 module = imp.load_source(pluginName, pluginFile) 118 module = imp.load_source(pluginName, pluginFile)
116 if not hasattr(module, "packageName"): 119 if not hasattr(module, "packageName"):
117 E5MessageBox.critical( 120 E5MessageBox.critical(
118 self, 121 self,
119 self.trUtf8("Plugin Uninstallation"), 122 self.tr("Plugin Uninstallation"),
120 self.trUtf8( 123 self.tr(
121 """<p>The plugin <b>{0}</b> has no 'packageName'""" 124 """<p>The plugin <b>{0}</b> has no 'packageName'"""
122 """ attribute. Aborting...</p>""").format(pluginName)) 125 """ attribute. Aborting...</p>""").format(pluginName))
123 return False 126 return False
124 127
125 package = getattr(module, "packageName") 128 package = getattr(module, "packageName")
167 170
168 os.remove(pluginFile) 171 os.remove(pluginFile)
169 except OSError as err: 172 except OSError as err:
170 E5MessageBox.critical( 173 E5MessageBox.critical(
171 self, 174 self,
172 self.trUtf8("Plugin Uninstallation"), 175 self.tr("Plugin Uninstallation"),
173 self.trUtf8( 176 self.tr(
174 """<p>The plugin package <b>{0}</b> could not be""" 177 """<p>The plugin package <b>{0}</b> could not be"""
175 """ removed. Aborting...</p>""" 178 """ removed. Aborting...</p>"""
176 """<p>Reason: {1}</p>""").format(packageDir, str(err))) 179 """<p>Reason: {1}</p>""").format(packageDir, str(err)))
177 return False 180 return False
178 181
179 if not self.__external: 182 if not self.__external:
180 ui = e5App().getObject("UserInterface") 183 ui = e5App().getObject("UserInterface")
181 if ui.notificationsEnabled(): 184 if ui.notificationsEnabled():
182 ui.showNotification( 185 ui.showNotification(
183 UI.PixmapCache.getPixmap("plugin48.png"), 186 UI.PixmapCache.getPixmap("plugin48.png"),
184 self.trUtf8("Plugin Uninstallation"), 187 self.tr("Plugin Uninstallation"),
185 self.trUtf8( 188 self.tr(
186 """<p>The plugin <b>{0}</b> was uninstalled""" 189 """<p>The plugin <b>{0}</b> was uninstalled"""
187 """ successfully from {1}.</p>""") 190 """ successfully from {1}.</p>""")
188 .format(pluginName, pluginDirectory)) 191 .format(pluginName, pluginDirectory))
189 return True 192 return True
190 193
191 E5MessageBox.information( 194 E5MessageBox.information(
192 self, 195 self,
193 self.trUtf8("Plugin Uninstallation"), 196 self.tr("Plugin Uninstallation"),
194 self.trUtf8( 197 self.tr(
195 """<p>The plugin <b>{0}</b> was uninstalled successfully""" 198 """<p>The plugin <b>{0}</b> was uninstalled successfully"""
196 """ from {1}.</p>""") 199 """ from {1}.</p>""")
197 .format(pluginName, pluginDirectory)) 200 .format(pluginName, pluginDirectory))
198 return True 201 return True
199 202
218 221
219 self.cw = PluginUninstallWidget(pluginManager, self) 222 self.cw = PluginUninstallWidget(pluginManager, self)
220 size = self.cw.size() 223 size = self.cw.size()
221 self.__layout.addWidget(self.cw) 224 self.__layout.addWidget(self.cw)
222 self.resize(size) 225 self.resize(size)
223 226 self.setWindowTitle(self.cw.windowTitle())
224 self.cw.buttonBox.accepted[()].connect(self.accept) 227
225 self.cw.buttonBox.rejected[()].connect(self.reject) 228 self.cw.buttonBox.accepted.connect(self.accept)
229 self.cw.buttonBox.rejected.connect(self.reject)
226 230
227 231
228 class PluginUninstallWindow(E5MainWindow): 232 class PluginUninstallWindow(E5MainWindow):
229 """ 233 """
230 Main window class for the standalone dialog. 234 Main window class for the standalone dialog.
238 super(PluginUninstallWindow, self).__init__(parent) 242 super(PluginUninstallWindow, self).__init__(parent)
239 self.cw = PluginUninstallWidget(None, self) 243 self.cw = PluginUninstallWidget(None, self)
240 size = self.cw.size() 244 size = self.cw.size()
241 self.setCentralWidget(self.cw) 245 self.setCentralWidget(self.cw)
242 self.resize(size) 246 self.resize(size)
247 self.setWindowTitle(self.cw.windowTitle())
243 248
244 self.setStyle(Preferences.getUI("Style"), 249 self.setStyle(Preferences.getUI("Style"),
245 Preferences.getUI("StyleSheet")) 250 Preferences.getUI("StyleSheet"))
246 251
247 self.cw.buttonBox.accepted[()].connect(self.close) 252 self.cw.buttonBox.accepted.connect(self.close)
248 self.cw.buttonBox.rejected[()].connect(self.close) 253 self.cw.buttonBox.rejected.connect(self.close)

eric ide

mercurial