diff -r d83409a59365 -r 26430067aa09 PluginPipxInterface.py --- a/PluginPipxInterface.py Mon Jun 24 15:22:19 2024 +0200 +++ b/PluginPipxInterface.py Mon Jun 24 17:13:07 2024 +0200 @@ -10,12 +10,25 @@ import os import sysconfig -from PyQt6.QtCore import QCoreApplication, QObject, QTranslator +from PyQt6.QtCore import QCoreApplication, QObject, Qt, QTranslator +from PyQt6.QtGui import QKeySequence from eric7 import Preferences +from eric7.EricGui import EricPixmapCache +from eric7.EricGui.EricAction import EricAction from eric7.EricWidgets.EricApplication import ericApp from eric7.SystemUtilities import OSUtilities +try: + from eric7.UI.UserInterface import UserInterfaceSide + + _Side = UserInterfaceSide.Right +except ImportError: + # backward compatibility for eric < 24.2 + from eric7.UI.UserInterface import UserInterface + + _Side = UserInterface.RightSide + # Start-Of-Header __header__ = { "name": "pipx Interface", @@ -56,7 +69,7 @@ "programEntry": True, "header": QCoreApplication.translate( "PluginPipxInterface", "PyPI Application Management" - ), + ), "exe": pipx, "versionCommand": "--version", "versionStartsWith": "", @@ -153,8 +166,44 @@ @return tuple of None and activation status @rtype bool """ - global error + global error, pipxInterfacePluginObject error = "" # clear previous error + pipxInterfacePluginObject = self + + from PipxInterface.PipxWidget import PipxWidget + + self.__widget = PipxWidget(self, fromEric=True) + iconName = "pipx96" if self.__ui.getLayoutType() == "Sidebars" else "pipx22" + self.__ui.addSideWidget( + _Side, + self.__widget, + EricPixmapCache.getIcon(os.path.join("PipxInterface", "icons", iconName)), + self.tr("PyPI Application Management"), + ) + + self.__activateAct = EricAction( + self.tr("PyPI Application Management"), + self.tr("PyPI Application Management"), + QKeySequence(self.tr("Ctrl+Alt+Shift+A")), + 0, + self, + "pipx_interface_activate", + ) + self.__activateAct.setStatusTip( + self.tr("Switch the input focus to the PyPI Application Management window.") + ) + self.__activateAct.setWhatsThis( + self.tr( + """<b>Activate PyPI Application Management</b>""" + """<p>This switches the input focus to the PyPI Application""" + """ Management window.</p>""" + ) + ) + self.__activateAct.triggered.connect(self.__activateWidget) + + self.__ui.addEricActions([self.__activateAct], "ui") + menu = self.__ui.getMenu("subwindow") + menu.addAction(self.__activateAct) return None, True @@ -162,7 +211,12 @@ """ Public method to deactivate this plug-in. """ - pass + menu = self.__ui.getMenu("subwindow") + menu.removeAction(self.__activateAct) + self.__ui.removeEricActions([self.__activateAct], "ui") + self.__ui.removeSideWidget(self.__widget) + + self.__initialize() def __loadTranslator(self): """ @@ -187,6 +241,22 @@ ) print("Using default.") + def __activateWidget(self): + """ + Private slot to handle the activation of the MQTT Monitor. + """ + uiLayoutType = self.__ui.getLayoutType() + + if uiLayoutType == "Toolboxes": + self.__ui.rToolboxDock.show() + self.__ui.rToolbox.setCurrentWidget(self.__widget) + elif uiLayoutType == "Sidebars": + self.__ui.rightSidebar.show() + self.__ui.rightSidebar.setCurrentWidget(self.__widget) + else: + self.__widget.show() + self.__widget.setFocus(Qt.FocusReason.ActiveWindowFocusReason) + def getPreferences(self, key): """ Public method to retrieve the various settings values.