42 "TlsClientCert", "TlsClientKey", "ConnectionTimeout". |
42 "TlsClientCert", "TlsClientKey", "ConnectionTimeout". |
43 @type dict |
43 @type dict |
44 @param parent reference to the parent widget |
44 @param parent reference to the parent widget |
45 @type QWidget |
45 @type QWidget |
46 """ |
46 """ |
47 super(MqttConnectionProfilesDialog, self).__init__(parent) |
47 super().__init__(parent) |
48 self.setupUi(self) |
48 self.setupUi(self) |
49 |
49 |
50 self.__client = client |
50 self.__client = client |
51 |
51 |
52 self.__profiles = collections.defaultdict(self.__defaultProfile) |
52 self.__profiles = collections.defaultdict(self.__defaultProfile) |
125 @type QListWidgetItem |
125 @type QListWidgetItem |
126 """ |
126 """ |
127 self.minusButton.setEnabled(current is not None) |
127 self.minusButton.setEnabled(current is not None) |
128 self.copyButton.setEnabled(current is not None) |
128 self.copyButton.setEnabled(current is not None) |
129 |
129 |
130 if current is not previous: |
130 if ( |
131 if not self.__deletingProfile and self.__isChangedProfile(): |
131 current is not previous and |
132 # modified profile belongs to previous |
132 not self.__deletingProfile and |
133 yes = E5MessageBox.yesNo( |
133 self.__isChangedProfile() |
134 self, |
134 ): |
135 self.tr("Changed Connection Profile"), |
135 # modified profile belongs to previous |
136 self.tr("""The current profile has unsaved changes.""" |
136 yes = E5MessageBox.yesNo( |
137 """ Shall these be saved?"""), |
137 self, |
138 icon=E5MessageBox.Warning, |
138 self.tr("Changed Connection Profile"), |
139 yesDefault=True) |
139 self.tr("""The current profile has unsaved changes.""" |
140 if yes: |
140 """ Shall these be saved?"""), |
141 self.__applyProfile() |
141 icon=E5MessageBox.Warning, |
|
142 yesDefault=True) |
|
143 if yes: |
|
144 self.__applyProfile() |
142 |
145 |
143 if current: |
146 if current: |
144 profileName = current.text() |
147 profileName = current.text() |
145 self.__populateProfile(profileName) |
148 self.__populateProfile(profileName) |
146 else: |
149 else: |
470 # condition 1: profile name and broker address need to be given |
473 # condition 1: profile name and broker address need to be given |
471 enable = (bool(self.profileEdit.text()) and |
474 enable = (bool(self.profileEdit.text()) and |
472 bool(self.brokerAddressEdit.text())) |
475 bool(self.brokerAddressEdit.text())) |
473 |
476 |
474 # condition 2: if client ID is empty, clean session must be selected |
477 # condition 2: if client ID is empty, clean session must be selected |
475 if not self.__populatingProfile: |
478 if ( |
476 if ( |
479 not self.__populatingProfile and |
477 self.clientIdEdit.text() == "" and |
480 self.clientIdEdit.text() == "" and |
478 not self.cleanSessionCheckBox.isChecked() |
481 not self.cleanSessionCheckBox.isChecked() |
479 ): |
482 ): |
480 enable = False |
483 enable = False |
481 E5MessageBox.critical( |
484 E5MessageBox.critical( |
482 self, |
485 self, |
483 self.tr("Invalid Connection Parameters"), |
486 self.tr("Invalid Connection Parameters"), |
484 self.tr("An empty Client ID requires a clean session.")) |
487 self.tr("An empty Client ID requires a clean session.")) |
485 |
488 |
486 if self.tlsGroupBox.isChecked(): |
489 if self.tlsGroupBox.isChecked(): |
487 if self.tlsCertsFileButton.isChecked(): |
490 if self.tlsCertsFileButton.isChecked(): |
488 # condition 3a: if CA certificates file shall be used, it must |
491 # condition 3a: if CA certificates file shall be used, it must |
489 # be given |
492 # be given |
678 E5MessageBox.Abort | |
681 E5MessageBox.Abort | |
679 E5MessageBox.Discard | |
682 E5MessageBox.Discard | |
680 E5MessageBox.Save), |
683 E5MessageBox.Save), |
681 E5MessageBox.Save) |
684 E5MessageBox.Save) |
682 if button == E5MessageBox.Save: |
685 if button == E5MessageBox.Save: |
683 super(MqttConnectionProfilesDialog, self).accept() |
686 super().accept() |
684 return |
687 return |
685 elif button == E5MessageBox.Abort: |
688 elif button == E5MessageBox.Abort: |
686 return |
689 return |
687 |
690 |
688 super(MqttConnectionProfilesDialog, self).reject() |
691 super().reject() |
689 |
692 |
690 @pyqtSlot() |
693 @pyqtSlot() |
691 def accept(self): |
694 def accept(self): |
692 """ |
695 """ |
693 Public slot to accept the dialog. |
696 Public slot to accept the dialog. |