--- a/PluginMqttMonitor.py Sun May 30 17:40:40 2021 +0200 +++ b/PluginMqttMonitor.py Sun May 30 18:21:40 2021 +0200 @@ -10,11 +10,11 @@ import os import json -from PyQt5.QtCore import Qt, QObject, QTranslator, QCoreApplication -from PyQt5.QtGui import QKeySequence +from PyQt6.QtCore import Qt, QObject, QTranslator, QCoreApplication +from PyQt6.QtGui import QKeySequence -from E5Gui.E5Application import e5App -from E5Gui.E5Action import E5Action +from EricWidgets.EricApplication import ericApp +from EricGui.EricAction import EricAction import UI.PixmapCache import Preferences @@ -24,7 +24,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "3.1.0" +version = "1.0.0" className = "MqttMonitorPlugin" packageName = "MqttMonitor" shortDescription = "Plug-in implementing a tool to connect to a MQTT broker" @@ -33,9 +33,8 @@ """ to topics, present received messages and publish messages.""" """ It displays broker statistics (the $SYS/# topic tree) and""" """ log messages of the underlying paho-mqtt client. This tool""" - """ support unencrypted connections (port 1883) as well as encrypted""" - """ SSL/TLS connections (port 8883)\n\n""" - """Note: The paho-mqtt Python package must be installed.""" + """ supports unencrypted connections (port 1883) as well as encrypted""" + """ SSL/TLS connections (port 8883).""" ) needsRestart = False pyqtApi = 2 @@ -112,7 +111,7 @@ Public method to activate this plug-in. @return tuple of None and activation status - @rtype bool + @rtype tuple of (None, bool) """ global error error = "" # clear previous error @@ -125,17 +124,10 @@ from MqttMonitor.MqttMonitorWidget import MqttMonitorWidget - try: - usesDarkPalette = e5App().usesDarkPalette() - except AttributeError: - # eric6 < 20.4 - from PyQt5.QtGui import QPalette - palette = e5App().palette() - lightness = palette.color(QPalette.Window).lightness() - usesDarkPalette = lightness <= 128 + usesDarkPalette = ericApp().usesDarkPalette() iconSuffix = "dark" if usesDarkPalette else "light" - self.__widget = MqttMonitorWidget(self, iconSuffix) + self.__widget = MqttMonitorWidget(self, usesDarkPalette) self.__ui.addSideWidget( self.__ui.RightSide, self.__widget, UI.PixmapCache.getIcon( @@ -143,7 +135,7 @@ "mqtt22-{0}".format(iconSuffix))), self.tr("MQTT Monitor")) - self.__activateAct = E5Action( + self.__activateAct = EricAction( self.tr('MQTT Monitor'), self.tr('M&QTT Monitor'), QKeySequence(self.tr("Alt+Shift+Q")), @@ -158,7 +150,7 @@ )) self.__activateAct.triggered.connect(self.__activateWidget) - self.__ui.addE5Actions([self.__activateAct], 'ui') + self.__ui.addEricActions([self.__activateAct], 'ui') menu = self.__ui.getMenu("subwindow") menu.addAction(self.__activateAct) @@ -170,7 +162,7 @@ """ menu = self.__ui.getMenu("subwindow") menu.removeAction(self.__activateAct) - self.__ui.removeE5Actions([self.__activateAct], 'ui') + self.__ui.removeEricActions([self.__activateAct], 'ui') self.__ui.removeSideWidget(self.__widget) self.__initialize() @@ -189,7 +181,7 @@ loaded = translator.load(translation, locale_dir) if loaded: self.__translator = translator - e5App().installTranslator(self.__translator) + ericApp().installTranslator(self.__translator) else: print("Warning: translation file '{0}' could not be" " loaded.".format(translation)) @@ -209,14 +201,16 @@ self.__ui.rightSidebar.setCurrentWidget(self.__widget) else: self.__widget.show() - self.__widget.setFocus(Qt.ActiveWindowFocusReason) + self.__widget.setFocus(Qt.FocusReason.ActiveWindowFocusReason) def getPreferences(self, key): """ Public method to retrieve the various settings. - @param key the key of the value to get - @return the requested setting + @param key key of the setting + @type str + @return value of the requested setting + @rtype Any """ if key in ["RecentBrokersWithPort", "BrokerProfiles"]: return json.loads(Preferences.Prefs.settings.value( @@ -229,8 +223,10 @@ """ Public method to store the various settings. - @param key the key of the setting to be set (string) - @param value the value to be set + @param key key of the setting to be set + @type str + @param value value to be set + @type Any """ if key in ["RecentBrokersWithPort", "BrokerProfiles"]: Preferences.Prefs.settings.setValue(