50 else: |
50 else: |
51 self.__pluginManager = pluginManager |
51 self.__pluginManager = pluginManager |
52 self.__external = False |
52 self.__external = False |
53 |
53 |
54 self.pluginDirectoryCombo.addItem( |
54 self.pluginDirectoryCombo.addItem( |
55 self.trUtf8("User plugins directory"), |
55 self.tr("User plugins directory"), |
56 self.__pluginManager.getPluginDir("user")) |
56 self.__pluginManager.getPluginDir("user")) |
57 |
57 |
58 globalDir = self.__pluginManager.getPluginDir("global") |
58 globalDir = self.__pluginManager.getPluginDir("global") |
59 if globalDir is not None and os.access(globalDir, os.W_OK): |
59 if globalDir is not None and os.access(globalDir, os.W_OK): |
60 self.pluginDirectoryCombo.addItem( |
60 self.pluginDirectoryCombo.addItem( |
61 self.trUtf8("Global plugins directory"), |
61 self.tr("Global plugins directory"), |
62 globalDir) |
62 globalDir) |
63 |
63 |
64 @pyqtSlot(int) |
64 @pyqtSlot(int) |
65 def on_pluginDirectoryCombo_currentIndexChanged(self, index): |
65 def on_pluginDirectoryCombo_currentIndexChanged(self, index): |
66 """ |
66 """ |
100 .itemData(self.pluginNameCombo.currentIndex()) |
100 .itemData(self.pluginNameCombo.currentIndex()) |
101 |
101 |
102 if not self.__pluginManager.unloadPlugin(pluginName): |
102 if not self.__pluginManager.unloadPlugin(pluginName): |
103 E5MessageBox.critical( |
103 E5MessageBox.critical( |
104 self, |
104 self, |
105 self.trUtf8("Plugin Uninstallation"), |
105 self.tr("Plugin Uninstallation"), |
106 self.trUtf8( |
106 self.tr( |
107 """<p>The plugin <b>{0}</b> could not be unloaded.""" |
107 """<p>The plugin <b>{0}</b> could not be unloaded.""" |
108 """ Aborting...</p>""").format(pluginName)) |
108 """ Aborting...</p>""").format(pluginName)) |
109 return False |
109 return False |
110 |
110 |
111 if not pluginDirectory in sys.path: |
111 if not pluginDirectory in sys.path: |
112 sys.path.insert(2, pluginDirectory) |
112 sys.path.insert(2, pluginDirectory) |
113 module = imp.load_source(pluginName, pluginFile) |
113 module = imp.load_source(pluginName, pluginFile) |
114 if not hasattr(module, "packageName"): |
114 if not hasattr(module, "packageName"): |
115 E5MessageBox.critical( |
115 E5MessageBox.critical( |
116 self, |
116 self, |
117 self.trUtf8("Plugin Uninstallation"), |
117 self.tr("Plugin Uninstallation"), |
118 self.trUtf8( |
118 self.tr( |
119 """<p>The plugin <b>{0}</b> has no 'packageName'""" |
119 """<p>The plugin <b>{0}</b> has no 'packageName'""" |
120 """ attribute. Aborting...</p>""").format(pluginName)) |
120 """ attribute. Aborting...</p>""").format(pluginName)) |
121 return False |
121 return False |
122 |
122 |
123 package = getattr(module, "packageName") |
123 package = getattr(module, "packageName") |
165 |
165 |
166 os.remove(pluginFile) |
166 os.remove(pluginFile) |
167 except OSError as err: |
167 except OSError as err: |
168 E5MessageBox.critical( |
168 E5MessageBox.critical( |
169 self, |
169 self, |
170 self.trUtf8("Plugin Uninstallation"), |
170 self.tr("Plugin Uninstallation"), |
171 self.trUtf8( |
171 self.tr( |
172 """<p>The plugin package <b>{0}</b> could not be""" |
172 """<p>The plugin package <b>{0}</b> could not be""" |
173 """ removed. Aborting...</p>""" |
173 """ removed. Aborting...</p>""" |
174 """<p>Reason: {1}</p>""").format(packageDir, str(err))) |
174 """<p>Reason: {1}</p>""").format(packageDir, str(err))) |
175 return False |
175 return False |
176 |
176 |
177 if not self.__external: |
177 if not self.__external: |
178 ui = e5App().getObject("UserInterface") |
178 ui = e5App().getObject("UserInterface") |
179 if ui.notificationsEnabled(): |
179 if ui.notificationsEnabled(): |
180 ui.showNotification( |
180 ui.showNotification( |
181 UI.PixmapCache.getPixmap("plugin48.png"), |
181 UI.PixmapCache.getPixmap("plugin48.png"), |
182 self.trUtf8("Plugin Uninstallation"), |
182 self.tr("Plugin Uninstallation"), |
183 self.trUtf8( |
183 self.tr( |
184 """<p>The plugin <b>{0}</b> was uninstalled""" |
184 """<p>The plugin <b>{0}</b> was uninstalled""" |
185 """ successfully from {1}.</p>""") |
185 """ successfully from {1}.</p>""") |
186 .format(pluginName, pluginDirectory)) |
186 .format(pluginName, pluginDirectory)) |
187 return True |
187 return True |
188 |
188 |
189 E5MessageBox.information( |
189 E5MessageBox.information( |
190 self, |
190 self, |
191 self.trUtf8("Plugin Uninstallation"), |
191 self.tr("Plugin Uninstallation"), |
192 self.trUtf8( |
192 self.tr( |
193 """<p>The plugin <b>{0}</b> was uninstalled successfully""" |
193 """<p>The plugin <b>{0}</b> was uninstalled successfully""" |
194 """ from {1}.</p>""") |
194 """ from {1}.</p>""") |
195 .format(pluginName, pluginDirectory)) |
195 .format(pluginName, pluginDirectory)) |
196 return True |
196 return True |
197 |
197 |