14 import glob |
14 import glob |
15 |
15 |
16 from PyQt6.QtCore import pyqtSlot, pyqtSignal |
16 from PyQt6.QtCore import pyqtSlot, pyqtSignal |
17 from PyQt6.QtWidgets import QWidget, QDialog, QDialogButtonBox, QVBoxLayout |
17 from PyQt6.QtWidgets import QWidget, QDialog, QDialogButtonBox, QVBoxLayout |
18 |
18 |
19 from E5Gui import E5MessageBox |
19 from E5Gui import EricMessageBox |
20 from E5Gui.E5MainWindow import E5MainWindow |
20 from E5Gui.EricMainWindow import EricMainWindow |
21 from E5Gui.E5Application import e5App |
21 from E5Gui.EricApplication import ericApp |
22 |
22 |
23 from .Ui_PluginUninstallDialog import Ui_PluginUninstallDialog |
23 from .Ui_PluginUninstallDialog import Ui_PluginUninstallDialog |
24 |
24 |
25 import Preferences |
25 import Preferences |
26 import UI.PixmapCache |
26 import UI.PixmapCache |
103 pluginName = self.pluginNameCombo.currentText() |
103 pluginName = self.pluginNameCombo.currentText() |
104 pluginFile = self.pluginNameCombo.itemData( |
104 pluginFile = self.pluginNameCombo.itemData( |
105 self.pluginNameCombo.currentIndex()) |
105 self.pluginNameCombo.currentIndex()) |
106 |
106 |
107 if not self.__pluginManager.unloadPlugin(pluginName): |
107 if not self.__pluginManager.unloadPlugin(pluginName): |
108 E5MessageBox.critical( |
108 EricMessageBox.critical( |
109 self, |
109 self, |
110 self.tr("Plugin Uninstallation"), |
110 self.tr("Plugin Uninstallation"), |
111 self.tr( |
111 self.tr( |
112 """<p>The plugin <b>{0}</b> could not be unloaded.""" |
112 """<p>The plugin <b>{0}</b> could not be unloaded.""" |
113 """ Aborting...</p>""").format(pluginName)) |
113 """ Aborting...</p>""").format(pluginName)) |
117 sys.path.insert(2, pluginDirectory) |
117 sys.path.insert(2, pluginDirectory) |
118 spec = importlib.util.spec_from_file_location(pluginName, pluginFile) |
118 spec = importlib.util.spec_from_file_location(pluginName, pluginFile) |
119 module = importlib.util.module_from_spec(spec) |
119 module = importlib.util.module_from_spec(spec) |
120 spec.loader.exec_module(module) |
120 spec.loader.exec_module(module) |
121 if not hasattr(module, "packageName"): |
121 if not hasattr(module, "packageName"): |
122 E5MessageBox.critical( |
122 EricMessageBox.critical( |
123 self, |
123 self, |
124 self.tr("Plugin Uninstallation"), |
124 self.tr("Plugin Uninstallation"), |
125 self.tr( |
125 self.tr( |
126 """<p>The plugin <b>{0}</b> has no 'packageName'""" |
126 """<p>The plugin <b>{0}</b> has no 'packageName'""" |
127 """ attribute. Aborting...</p>""").format(pluginName)) |
127 """ attribute. Aborting...</p>""").format(pluginName)) |
173 pluginDirCache, "{0}*.pyc".format(pluginFileName))): |
173 pluginDirCache, "{0}*.pyc".format(pluginFileName))): |
174 os.remove(fnamec) |
174 os.remove(fnamec) |
175 |
175 |
176 os.remove(pluginFile) |
176 os.remove(pluginFile) |
177 except OSError as err: |
177 except OSError as err: |
178 E5MessageBox.critical( |
178 EricMessageBox.critical( |
179 self, |
179 self, |
180 self.tr("Plugin Uninstallation"), |
180 self.tr("Plugin Uninstallation"), |
181 self.tr( |
181 self.tr( |
182 """<p>The plugin package <b>{0}</b> could not be""" |
182 """<p>The plugin package <b>{0}</b> could not be""" |
183 """ removed. Aborting...</p>""" |
183 """ removed. Aborting...</p>""" |
184 """<p>Reason: {1}</p>""").format(packageDir, str(err))) |
184 """<p>Reason: {1}</p>""").format(packageDir, str(err))) |
185 return False |
185 return False |
186 |
186 |
187 if not self.__external: |
187 if not self.__external: |
188 ui = e5App().getObject("UserInterface") |
188 ui = ericApp().getObject("UserInterface") |
189 ui.showNotification( |
189 ui.showNotification( |
190 UI.PixmapCache.getPixmap("plugin48"), |
190 UI.PixmapCache.getPixmap("plugin48"), |
191 self.tr("Plugin Uninstallation"), |
191 self.tr("Plugin Uninstallation"), |
192 self.tr( |
192 self.tr( |
193 """<p>The plugin <b>{0}</b> was uninstalled""" |
193 """<p>The plugin <b>{0}</b> was uninstalled""" |
194 """ successfully from {1}.</p>""") |
194 """ successfully from {1}.</p>""") |
195 .format(pluginName, pluginDirectory)) |
195 .format(pluginName, pluginDirectory)) |
196 return True |
196 return True |
197 |
197 |
198 E5MessageBox.information( |
198 EricMessageBox.information( |
199 self, |
199 self, |
200 self.tr("Plugin Uninstallation"), |
200 self.tr("Plugin Uninstallation"), |
201 self.tr( |
201 self.tr( |
202 """<p>The plugin <b>{0}</b> was uninstalled successfully""" |
202 """<p>The plugin <b>{0}</b> was uninstalled successfully""" |
203 """ from {1}.</p>""") |
203 """ from {1}.</p>""") |
231 |
231 |
232 self.cw.buttonBox.accepted.connect(self.accept) |
232 self.cw.buttonBox.accepted.connect(self.accept) |
233 self.cw.buttonBox.rejected.connect(self.reject) |
233 self.cw.buttonBox.rejected.connect(self.reject) |
234 |
234 |
235 |
235 |
236 class PluginUninstallWindow(E5MainWindow): |
236 class PluginUninstallWindow(EricMainWindow): |
237 """ |
237 """ |
238 Main window class for the standalone dialog. |
238 Main window class for the standalone dialog. |
239 """ |
239 """ |
240 def __init__(self, parent=None): |
240 def __init__(self, parent=None): |
241 """ |
241 """ |