9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot, QUuid |
12 from PyQt5.QtCore import pyqtSlot, QUuid |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton |
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton |
|
14 |
|
15 from E5Gui import E5MessageBox |
14 |
16 |
15 from .Ui_MqttConnectionOptionsDialog import Ui_MqttConnectionOptionsDialog |
17 from .Ui_MqttConnectionOptionsDialog import Ui_MqttConnectionOptionsDialog |
16 |
18 |
17 |
19 |
18 class MqttConnectionOptionsDialog(QDialog, Ui_MqttConnectionOptionsDialog): |
20 class MqttConnectionOptionsDialog(QDialog, Ui_MqttConnectionOptionsDialog): |
37 self.setupUi(self) |
39 self.setupUi(self) |
38 |
40 |
39 self.__client = client |
41 self.__client = client |
40 |
42 |
41 self.__populateDefaults(options=options) |
43 self.__populateDefaults(options=options) |
|
44 |
|
45 self.__updateOkButton() |
|
46 |
|
47 def __updateOkButton(self): |
|
48 """ |
|
49 Private method to update the enabled state of the OK button. |
|
50 """ |
|
51 if self.clientIdEdit.text() == "" and \ |
|
52 not self.cleanSessionCheckBox.isChecked(): |
|
53 enable = False |
|
54 E5MessageBox.critical( |
|
55 self, |
|
56 self.tr("Invalid Connection Parameters"), |
|
57 self.tr("""An empty Client ID requires a clean session.""")) |
|
58 else: |
|
59 enable = True |
|
60 |
|
61 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) |
42 |
62 |
43 @pyqtSlot() |
63 @pyqtSlot() |
44 def on_generateIdButton_clicked(self): |
64 def on_generateIdButton_clicked(self): |
45 """ |
65 """ |
46 Private slot to generate a client ID. |
66 Private slot to generate a client ID. |
108 "WillTopic": self.willTopicEdit.text(), |
128 "WillTopic": self.willTopicEdit.text(), |
109 "WillMessage": self.willMessageEdit.toPlainText(), |
129 "WillMessage": self.willMessageEdit.toPlainText(), |
110 "WillQos": self.willQosSpinBox.value(), |
130 "WillQos": self.willQosSpinBox.value(), |
111 "WillRetain": self.willRetainCheckBox.isChecked(), |
131 "WillRetain": self.willRetainCheckBox.isChecked(), |
112 } |
132 } |
|
133 |
|
134 @pyqtSlot(str) |
|
135 def on_clientIdEdit_textChanged(self, clientId): |
|
136 """ |
|
137 Private slot handling a change of the client ID string. |
|
138 |
|
139 @param clientId client ID |
|
140 @type str |
|
141 """ |
|
142 self.__updateOkButton() |
|
143 |
|
144 @pyqtSlot(bool) |
|
145 def on_cleanSessionCheckBox_clicked(self, checked): |
|
146 """ |
|
147 Private slot to handle a change of the clean session selection. |
|
148 |
|
149 @param checked current state of the clean session selection |
|
150 @type bool |
|
151 """ |
|
152 self.__updateOkButton() |