Sat, 08 Sep 2018 16:51:39 +0200
MqttMonitorWidget: improved handling of the Publish and Subscribe sections.
MqttMonitor/MqttMonitorWidget.py | file | annotate | diff | comparison | revisions | |
MqttMonitor/MqttMonitorWidget.ui | file | annotate | diff | comparison | revisions |
--- 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): """
--- a/MqttMonitor/MqttMonitorWidget.ui Mon Sep 03 18:52:50 2018 +0200 +++ b/MqttMonitor/MqttMonitorWidget.ui Sat Sep 08 16:51:39 2018 +0200 @@ -311,6 +311,16 @@ </item> </layout> </item> + <item> + <widget class="QCheckBox" name="clearPublishCheckBox"> + <property name="toolTip"> + <string>Select to clear the publish data after the message was published</string> + </property> + <property name="text"> + <string>Clear when sent</string> + </property> + </widget> + </item> </layout> </widget> </item> @@ -366,7 +376,10 @@ </spacer> </item> <item> - <widget class="QPushButton" name="pushButton"> + <widget class="QPushButton" name="messagesClearButton"> + <property name="toolTip"> + <string>Press to clear the list of received messages</string> + </property> <property name="text"> <string>Clear</string> </property> @@ -1172,25 +1185,41 @@ <tabstop>publishPayloadEdit</tabstop> <tabstop>publishButton</tabstop> <tabstop>messagesEdit</tabstop> - <tabstop>pushButton</tabstop> + <tabstop>messagesClearButton</tabstop> <tabstop>brokerStatusButton</tabstop> <tabstop>scrollArea</tabstop> </tabstops> <resources/> <connections> <connection> - <sender>pushButton</sender> + <sender>messagesClearButton</sender> <signal>clicked()</signal> <receiver>messagesEdit</receiver> <slot>clear()</slot> <hints> <hint type="sourcelabel"> - <x>378</x> - <y>578</y> + <x>343</x> + <y>565</y> </hint> <hint type="destinationlabel"> - <x>179</x> - <y>272</y> + <x>218</x> + <y>336</y> + </hint> + </hints> + </connection> + <connection> + <sender>clearPublishCheckBox</sender> + <signal>clicked(bool)</signal> + <receiver>publishClearButton</receiver> + <slot>setHidden(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>60</x> + <y>548</y> + </hint> + <hint type="destinationlabel"> + <x>65</x> + <y>521</y> </hint> </hints> </connection>