|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the MQTT Monitor configuration page. |
|
8 """ |
|
9 |
|
10 from Preferences.ConfigurationPages.ConfigurationPageBase import ( |
|
11 ConfigurationPageBase |
|
12 ) |
|
13 |
|
14 from .Ui_MqttPage import Ui_MqttPage |
|
15 |
|
16 from ..MqttProtocols import MqttProtocols |
|
17 |
|
18 |
|
19 class MqttPage(ConfigurationPageBase, Ui_MqttPage): |
|
20 """ |
|
21 Class implementing the MQTT Monitor configuration page. |
|
22 """ |
|
23 def __init__(self, plugin): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param plugin reference to the plugin object |
|
28 @type RefactoringRopePlugin |
|
29 """ |
|
30 ConfigurationPageBase.__init__(self) |
|
31 self.setupUi(self) |
|
32 self.setObjectName("MqttPage") |
|
33 |
|
34 self.__plugin = plugin |
|
35 |
|
36 # set initial values |
|
37 protocol = self.__plugin.getPreferences("DefaultProtocol") |
|
38 self.mqttv31Button.setChecked( |
|
39 protocol == MqttProtocols.MQTTv31) |
|
40 self.mqttv311Button.setChecked( |
|
41 protocol == MqttProtocols.MQTTv311) |
|
42 self.mqttv5Button.setChecked( |
|
43 protocol == MqttProtocols.MQTTv5) |
|
44 self.recentBrokersSpinBox.setValue( |
|
45 self.__plugin.getPreferences("RecentBrokersNumber")) |
|
46 self.recentTopicsSpinBox.setValue( |
|
47 self.__plugin.getPreferences("RecentTopicsNumber")) |
|
48 |
|
49 def save(self): |
|
50 """ |
|
51 Public slot to save the Rope Autocompletion configuration. |
|
52 """ |
|
53 if self.mqttv31Button.isChecked(): |
|
54 protocol = MqttProtocols.MQTTv31 |
|
55 elif self.mqttv311Button.isChecked(): |
|
56 protocol = MqttProtocols.MQTTv311 |
|
57 elif self.mqttv5Button.isChecked(): |
|
58 protocol = MqttProtocols.MQTTv5 |
|
59 else: |
|
60 # should never happen |
|
61 protocol = MqttProtocols.MQTTv311 |
|
62 |
|
63 self.__plugin.setPreferences("DefaultProtocol", protocol) |
|
64 self.__plugin.setPreferences("RecentBrokersNumber", |
|
65 self.recentBrokersSpinBox.value()) |
|
66 self.__plugin.setPreferences("RecentTopicsNumber", |
|
67 self.recentTopicsSpinBox.value()) |