--- a/MqttMonitor/MqttMonitorWidget.py Mon Sep 03 18:52:50 2018 +0200 +++ b/MqttMonitor/MqttMonitorWidget.py Sat Sep 08 16:51:39 2018 +0200 @@ -341,6 +341,14 @@ self.subscribeButton.setEnabled(bool(topic)) @pyqtSlot() + def on_subscribeTopicEdit_returnPressed(self): + """ + Private slot handling the user pressing the return button to subscribe + a topic. + """ + self.on_subscribeButton_clicked() + + @pyqtSlot() def on_subscribeButton_clicked(self): """ Private slot to subscribe to the entered topic. @@ -406,7 +414,9 @@ if msgInfo.rc == 0: if topic not in self.__publishedTopics: self.__publishedTopics.append(topic) - self.__updatePublishTopicComboBox() + self.__updatePublishTopicComboBox(resetTopic=False) + if self.clearPublishCheckBox.isChecked(): + self.on_publishClearButton_clicked() @pyqtSlot() def on_publishClearButton_clicked(self): @@ -513,13 +523,22 @@ self.unsubscribeTopicComboBox.addItems(sorted(self.__subscribedTopics)) self.unsubscribeButton.setEnabled(len(self.__subscribedTopics) > 0) - def __updatePublishTopicComboBox(self): + def __updatePublishTopicComboBox(self, resetTopic=True): """ Private method to update the publish topic combo box. + + @param resetTopic flag indicating to reset the topic + @type bool """ + currentTopic = self.publishTopicComboBox.currentText() self.publishTopicComboBox.clear() self.publishTopicComboBox.addItems( - [""] + list(set(self.__publishedTopics + self.__subscribedTopics))) + list(set(self.__publishedTopics + self.__subscribedTopics))) + if resetTopic: + self.publishTopicComboBox.clearEditText() + else: + topicIndex = self.publishTopicComboBox.findText(currentTopic) + self.publishTopicComboBox.setCurrentIndex(topicIndex) def __appendMessage(self, topic, payload): """