diff -r 889a7c3c0e63 -r 3737a78bb6c5 MqttMonitor/MqttConnectionOptionsDialog.py --- a/MqttMonitor/MqttConnectionOptionsDialog.py Wed Sep 05 19:52:30 2018 +0200 +++ b/MqttMonitor/MqttConnectionOptionsDialog.py Thu Sep 06 19:02:53 2018 +0200 @@ -12,6 +12,8 @@ from PyQt5.QtCore import pyqtSlot, QUuid from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton +from E5Gui import E5MessageBox + from .Ui_MqttConnectionOptionsDialog import Ui_MqttConnectionOptionsDialog @@ -39,6 +41,24 @@ self.__client = client self.__populateDefaults(options=options) + + self.__updateOkButton() + + def __updateOkButton(self): + """ + Private method to update the enabled state of the OK button. + """ + if self.clientIdEdit.text() == "" and \ + not self.cleanSessionCheckBox.isChecked(): + enable = False + E5MessageBox.critical( + self, + self.tr("Invalid Connection Parameters"), + self.tr("""An empty Client ID requires a clean session.""")) + else: + enable = True + + self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) @pyqtSlot() def on_generateIdButton_clicked(self): @@ -110,3 +130,23 @@ "WillQos": self.willQosSpinBox.value(), "WillRetain": self.willRetainCheckBox.isChecked(), } + + @pyqtSlot(str) + def on_clientIdEdit_textChanged(self, clientId): + """ + Private slot handling a change of the client ID string. + + @param clientId client ID + @type str + """ + self.__updateOkButton() + + @pyqtSlot(bool) + def on_cleanSessionCheckBox_clicked(self, checked): + """ + Private slot to handle a change of the clean session selection. + + @param checked current state of the clean session selection + @type bool + """ + self.__updateOkButton()