68 self.__messagesFormat = self.messagesEdit.currentCharFormat() |
68 self.__messagesFormat = self.messagesEdit.currentCharFormat() |
69 self.__messagesTopicFormat = self.messagesEdit.currentCharFormat() |
69 self.__messagesTopicFormat = self.messagesEdit.currentCharFormat() |
70 self.__messagesTopicFormat.setFontWeight(QFont.Bold) |
70 self.__messagesTopicFormat.setFontWeight(QFont.Bold) |
71 self.__messagesQosFormat = self.messagesEdit.currentCharFormat() |
71 self.__messagesQosFormat = self.messagesEdit.currentCharFormat() |
72 self.__messagesQosFormat.setFontItalic(True) |
72 self.__messagesQosFormat.setFontItalic(True) |
|
73 |
|
74 self.__isAlternate = False |
73 |
75 |
74 for logLevel in (MqttClient.LogDisabled, |
76 for logLevel in (MqttClient.LogDisabled, |
75 MqttClient.LogDebug, |
77 MqttClient.LogDebug, |
76 MqttClient.LogInfo, |
78 MqttClient.LogInfo, |
77 MqttClient.LogNotice, |
79 MqttClient.LogNotice, |
706 @param payload payload of the received message |
708 @param payload payload of the received message |
707 @type bytes |
709 @type bytes |
708 @param qos quality of service indicator (0, 1, 2) |
710 @param qos quality of service indicator (0, 1, 2) |
709 @type int |
711 @type int |
710 """ |
712 """ |
|
713 if self.messagesEdit.blockCount() != 1: |
|
714 # empty document has block count of 1 |
|
715 self.messagesEdit.insertPlainText("\n") |
|
716 |
711 payloadStr = str(payload, encoding="utf-8", errors="replace") |
717 payloadStr = str(payload, encoding="utf-8", errors="replace") |
712 |
718 |
|
719 textCursor = self.messagesEdit.textCursor() |
|
720 textBlockFormat = textCursor.blockFormat() |
|
721 if self.__isAlternate: |
|
722 textBlockFormat.setBackground( |
|
723 self.messagesEdit.palette().alternateBase()) |
|
724 else: |
|
725 textBlockFormat.setBackground( |
|
726 self.messagesEdit.palette().base()) |
|
727 textCursor.setBlockFormat(textBlockFormat) |
|
728 self.messagesEdit.setTextCursor(textCursor) |
|
729 |
713 self.messagesEdit.setCurrentCharFormat(self.__messagesTopicFormat) |
730 self.messagesEdit.setCurrentCharFormat(self.__messagesTopicFormat) |
714 self.messagesEdit.appendPlainText(topic) |
731 self.messagesEdit.insertPlainText(topic + "\n") |
715 self.messagesEdit.setCurrentCharFormat(self.__messagesQFormat) |
732 self.messagesEdit.setCurrentCharFormat(self.__messagesQosFormat) |
716 self.messagesEdit.appendPlainText(self.tr("QoS: {0}").format(qos)) |
733 self.messagesEdit.insertPlainText(self.tr("QoS: {0}\n").format(qos)) |
717 self.messagesEdit.setCurrentCharFormat(self.__messagesFormat) |
734 self.messagesEdit.setCurrentCharFormat(self.__messagesFormat) |
718 self.messagesEdit.appendPlainText( |
735 self.messagesEdit.insertPlainText( |
719 Utilities.filterAnsiSequences(payloadStr)) |
736 Utilities.filterAnsiSequences(payloadStr)) |
720 self.messagesEdit.appendPlainText(60 * "#") |
|
721 self.messagesEdit.ensureCursorVisible() |
737 self.messagesEdit.ensureCursorVisible() |
|
738 |
|
739 self.__isAlternate = not self.__isAlternate |
722 |
740 |
723 def __handleBrokerStatusMessage(self, topic, payload): |
741 def __handleBrokerStatusMessage(self, topic, payload): |
724 """ |
742 """ |
725 Private method to append a received message to the output. |
743 Private method to append a received message to the output. |
726 |
744 |