diff -r 3e68b5ce2b0b -r a0853f7a8b80 MqttMonitor/MqttMonitorWidget.py --- a/MqttMonitor/MqttMonitorWidget.py Mon Sep 10 16:42:15 2018 +0200 +++ b/MqttMonitor/MqttMonitorWidget.py Mon Sep 10 16:52:37 2018 +0200 @@ -43,8 +43,6 @@ # two columns with log level and message # colorize entries depending on log level -# TODO: add log level entry to disable logging - class MqttMonitorWidget(QWidget, Ui_MqttMonitorWidget): """ Class implementing the MQTT Monitor widget. @@ -73,7 +71,8 @@ self.pixmapLabel.setPixmap(UI.PixmapCache.getPixmap( os.path.join("MqttMonitor", "icons", "mqtt48.png"))) - for logLevel in (MqttClient.LogDebug, + for logLevel in (MqttClient.LogDisabled, + MqttClient.LogDebug, MqttClient.LogInfo, MqttClient.LogNotice, MqttClient.LogWarning, @@ -594,7 +593,8 @@ if hostAndPort in brokerList: brokerList.remove(hostAndPort) brokerList.insert(0, hostAndPort) - # TODO: limit to most recently used 20 entries + # limit to most recently used 20 entries + brokerList = brokerList[:20] self.__plugin.setPreferences("RecentBrokersWithPort", brokerList) self.__populateBrokerComboBoxes() @@ -603,30 +603,37 @@ """ Private method to populate the broker name and port combo boxes. """ - brokerList = self.__plugin.getPreferences("RecentBrokersWithPort") + brokerPortList = self.__plugin.getPreferences("RecentBrokersWithPort") # step 1: clear combo boxes self.brokerComboBox.clear() self.brokerPortComboBox.clear() # step 2a: populate the broker name list - # TODO: make list unique and sorted - self.brokerComboBox.addItems([b[0].strip() for b in brokerList]) - - self.__setConnectButtonState() + if brokerPortList: + currentBroker = brokerPortList[0][0] + else: + currentBroker = "" + brokerSet = {b[0].strip() for b in brokerPortList} + self.brokerComboBox.addItems(sorted(brokerSet)) + index = self.brokerComboBox.findText(currentBroker) + self.brokerComboBox.setCurrentIndex(index) # step 2b: populate the broker ports list - if brokerList: - currentPort = brokerList[0][1] + if brokerPortList: + currentPort = brokerPortList[0][1] else: currentPort = 1883 currentPortStr = "{0:5}".format(currentPort) - portsSet = {b[1] for b in brokerList} + portsSet = {b[1] for b in brokerPortList} portsSet.update({1883, 8883}) self.brokerPortComboBox.addItems( sorted("{0:5}".format(p) for p in portsSet)) index = self.brokerPortComboBox.findText(currentPortStr) self.brokerPortComboBox.setCurrentIndex(index) + + # step 3: update the connect button state + self.__setConnectButtonState() def __populateProfileComboBox(self): """