MqttMonitor/MqttConnectionProfilesDialog.py

Sat, 08 Sep 2018 15:29:39 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 Sep 2018 15:29:39 +0200
branch
connection_profiles
changeset 26
ad232a5129cc
parent 23
0b23bd856e43
child 30
17ef10819773
permissions
-rw-r--r--

MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.

17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de>
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit the MQTT connection profiles.
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
12 import collections
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
13
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
14 from PyQt5.QtCore import pyqtSlot, Qt, QUuid
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton, \
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
16 QListWidgetItem, QInputDialog, QLineEdit
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
17
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
18 from E5Gui import E5MessageBox
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
19 from E5Gui.E5PathPicker import E5PathPickerModes
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from .Ui_MqttConnectionProfilesDialog import Ui_MqttConnectionProfilesDialog
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
23 import UI.PixmapCache
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
24 from Utilities.crypto import pwConvert
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
25
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 class MqttConnectionProfilesDialog(QDialog, Ui_MqttConnectionProfilesDialog):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing a dialog to edit the MQTT connection profiles.
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
31 def __init__(self, client, profiles, parent=None):
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
35 @param client reference to the MQTT client object
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
36 @type MqttClient
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
37 @param profiles dictionary containing dictionaries containing the
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
38 connection parameters. Each entry must have the keys
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
39 "BrokerAddress", "BrokerPort", "ClientId",
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
40 "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
41 "WillMessage", "WillQos", "WillRetain", "TlsEnable", "TlsCaCert",
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
42 "TlsClientCert", "TlsClientKey".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
43 @type dict
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @param parent reference to the parent widget
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @type QWidget
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 super(MqttConnectionProfilesDialog, self).__init__(parent)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setupUi(self)
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
49
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
50 self.__client = client
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
51
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
52 self.__profiles = collections.defaultdict(self.__defaultProfile)
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
53 self.__profiles.update(profiles)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
54 self.__profilesChanged = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
55
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
56 self.plusButton.setIcon(UI.PixmapCache.getIcon("plus.png"))
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
57 self.copyButton.setIcon(UI.PixmapCache.getIcon("editCopy.png"))
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
58 self.minusButton.setIcon(UI.PixmapCache.getIcon("minus.png"))
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
59
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
60 self.tlsCertsFilePicker.setMode(E5PathPickerModes.OpenFileMode)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
61 self.tlsCertsFilePicker.setFilters(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
62 self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
63 self.tlsSelfSignedCertsFilePicker.setMode(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
64 E5PathPickerModes.OpenFileMode)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
65 self.tlsSelfSignedCertsFilePicker.setFilters(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
66 self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
67 self.tlsSelfSignedClientCertFilePicker.setMode(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
68 E5PathPickerModes.OpenFileMode)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
69 self.tlsSelfSignedClientCertFilePicker.setFilters(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
70 self.tr("Certificate Files (*.crt *.pem);;All Files (*)"))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
71 self.tlsSelfSignedClientKeyFilePicker.setMode(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
72 E5PathPickerModes.OpenFileMode)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
73 self.tlsSelfSignedClientKeyFilePicker.setFilters(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
74 self.tr("Key Files (*.key *.pem);;All Files (*)"))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
75
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
76 self.profileTabWidget.setCurrentIndex(0)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
77
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
78 if len(self.__profiles) == 0:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
79 self.minusButton.setEnabled(False)
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
80 self.copyButton.setEnabled(False)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
81
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
82 self.profileFrame.setEnabled(False)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
83 self.__populatingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
84 self.__deletingProfile = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
85
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
86 self.__populateProfilesList()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 @pyqtSlot(str)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
89 def on_profileEdit_textChanged(self, name):
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
91 Private slot to handle changes of the profile name.
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
93 @param name name of the profile
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 @type str
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
96 self.__updateApplyButton()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @pyqtSlot(QAbstractButton)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def on_profileButtonBox_clicked(self, button):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
101 Private slot handling presses of the profile buttons.
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
103 @param button reference to the pressed button
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @type QAbstractButton
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
106 if button == self.profileButtonBox.button(QDialogButtonBox.Apply):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
107 currentProfile = self.__applyProfile()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
108 self.__populateProfilesList(currentProfile)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
109
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
110 elif button == self.profileButtonBox.button(QDialogButtonBox.Reset):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
111 self.__resetProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
112
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
113 elif button == self.profileButtonBox.button(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
114 QDialogButtonBox.RestoreDefaults):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
115 self.__populateProfileDefault()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @pyqtSlot(QListWidgetItem, QListWidgetItem)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 def on_profilesList_currentItemChanged(self, current, previous):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
120 Private slot to handle a change of the current profile.
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
122 @param current new current item
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @type QListWidgetItem
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
124 @param previous previous current item
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @type QListWidgetItem
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
127 self.minusButton.setEnabled(current is not None)
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
128 self.copyButton.setEnabled(current is not None)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
129
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
130 if current is not previous:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
131 if not self.__deletingProfile and self.__isChangedProfile():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
132 # modified profile belongs to previous
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
133 yes = E5MessageBox.yesNo(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
134 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
135 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
136 self.tr("""The current profile has unsaved changes."""
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
137 """ Shall these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
138 icon=E5MessageBox.Warning,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
139 yesDefault=True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
140 if yes:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
141 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
142
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
143 if current:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
144 profileName = current.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
145 self.__populateProfile(profileName)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
146 else:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
147 self.__clearProfile()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @pyqtSlot()
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def on_plusButton_clicked(self):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
152 Private slot to add a new empty profile entry.
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
154 profileName, ok = QInputDialog.getText(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
155 self,
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
156 self.tr("New Connection Profile"),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
157 self.tr("Enter name for the new Connection Profile:"),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
158 QLineEdit.Normal)
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
159 if ok and bool(profileName):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
160 if profileName in self.__profiles:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
161 E5MessageBox.warning(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
162 self,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
163 self.tr("New Connection Profile"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
164 self.tr("""<p>A connection named <b>{0}</b> exists"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
165 """ already. Aborting...</p>""").format(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
166 profileName))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
167 else:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
168 itm = QListWidgetItem(profileName, self.profilesList)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
169 self.profilesList.setCurrentItem(itm)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
170 self.brokerAddressEdit.setFocus(Qt.OtherFocusReason)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
171
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
172 @pyqtSlot()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
173 def on_copyButton_clicked(self):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
174 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
175 Private slot to copy the selected profile entry.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
176 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
177 itm = self.profilesList.currentItem()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
178 if itm:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
179 profileName = itm.text()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
180 newProfileName, ok = QInputDialog.getText(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
181 self,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
182 self.tr("Copy Connection Profile"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
183 self.tr("Enter name for the copied Connection Profile:"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
184 QLineEdit.Normal)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
185 if ok and bool(newProfileName):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
186 if newProfileName in self.__profiles:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
187 E5MessageBox.warning(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
188 self,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
189 self.tr("Copy Connection Profile"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
190 self.tr("""<p>A connection named <b>{0}</b> exists"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
191 """ already. Aborting...</p>""").format(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
192 newProfileName))
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
193 else:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
194 profile = self.__defaultProfile()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
195 profile.update(self.__profiles[profileName])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
196 self.__profiles[newProfileName] = profile
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
197
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
198 itm = QListWidgetItem(newProfileName, self.profilesList)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
199 self.profilesList.setCurrentItem(itm)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
200 self.brokerAddressEdit.setFocus(Qt.OtherFocusReason)
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @pyqtSlot()
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 def on_minusButton_clicked(self):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
205 Private slot to delete the selected entry.
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
207 itm = self.profilesList.currentItem()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
208 if itm:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
209 profileName = itm.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
210 yes = E5MessageBox.yesNo(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
211 self,
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
212 self.tr("Delete Connection Profile"),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
213 self.tr("""<p>Shall the Connection Profile <b>{0}</b>"""
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
214 """ really be deleted?</p>""").format(profileName)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
215 )
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
216 if yes:
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
217 self.__deletingProfile = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
218 del self.__profiles[profileName]
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
219 self.__profilesChanged = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
220 self.__populateProfilesList()
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
221 self.__deletingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
222
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
223 self.profilesList.setFocus(Qt.OtherFocusReason)
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
224
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
225 def getProfiles(self):
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
226 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
227 Public method to return a dictionary of profiles.
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
228
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
229 @return dictionary containing dictionaries containing the defined
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
230 connection profiles. Each entry have the keys "BrokerAddress",
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
231 "BrokerPort", "ClientId", "Keepalive", "CleanSession", "Username",
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
232 "Password", "WillTopic", "WillMessage", "WillQos", "WillRetain",
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
233 "TlsEnable", "TlsCaCert", "TlsClientCert", "TlsClientKey".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
234 @rtype dict
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
235 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
236 profilesDict = {}
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
237 profilesDict.update(self.__profiles)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
238 return profilesDict
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
239
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
240 def __applyProfile(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
241 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
242 Private method to apply the entered data to the list of profiles.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
243
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
244 @return name of the applied profile
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
245 @rtype str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
246 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
247 profileName = self.profileEdit.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
248 profile = {
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
249 "BrokerAddress": self.brokerAddressEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
250 "BrokerPort": self.brokerPortSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
251 "ClientId": self.clientIdEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
252 "Keepalive": self.keepaliveSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
253 "CleanSession": self.cleanSessionCheckBox.isChecked(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
254 "Username": self.usernameEdit.text(),
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
255 "Password": pwConvert(self.passwordEdit.text(), encode=True),
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
256 "WillTopic": self.willTopicEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
257 "WillMessage": self.willMessageEdit.toPlainText(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
258 "WillQos": self.willQosSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
259 "WillRetain": self.willRetainCheckBox.isChecked(),
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
260 "TlsEnable": self.tlsGroupBox.isChecked(),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
261 "TlsCaCert": "",
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
262 "TlsClientCert": "",
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
263 "TlsClientKey": "",
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
264 }
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
265 if profile["TlsEnable"]:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
266 if self.tlsCertsFileButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
267 profile["TlsCaCert"] = self.tlsCertsFilePicker.text()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
268 elif self.tlsSelfSignedCertsButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
269 profile["TlsCaCert"] = \
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
270 self.tlsSelfSignedCertsFilePicker.text()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
271 profile["TlsClientCert"] = \
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
272 self.tlsSelfSignedClientCertFilePicker.text()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
273 profile["TlsClientKey"] = \
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
274 self.tlsSelfSignedClientKeyFilePicker.text()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
275
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
276 self.__profiles[profileName] = profile
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
277 self.__profilesChanged = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
278
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
279 return profileName
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
280
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
281 def __defaultProfile(self):
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
282 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
283 Private method to populate non-existing profile items.
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
284
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
285 @return default dictionary entry
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
286 @rtype dict
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
287 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
288 defaultProfile = self.__client.defaultConnectionOptions()
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
289 defaultProfile["BrokerAddress"] = ""
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
290 if defaultProfile["TlsEnable"]:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
291 defaultProfile["BrokerPort"] = 8883
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
292 else:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
293 defaultProfile["BrokerPort"] = 1883
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
294
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
295 return defaultProfile
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
296
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
297 def __populateProfilesList(self, currentProfile=""):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
298 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
299 Private method to populate the list of defined profiles.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
300
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
301 @param currentProfile name of the current profile
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
302 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
303 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
304 if not currentProfile:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
305 currentItem = self.profilesList.currentItem()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
306 if currentItem:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
307 currentProfile = currentItem.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
308
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
309 self.profilesList.clear()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
310 self.profilesList.addItems(sorted(self.__profiles.keys()))
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
311
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
312 if currentProfile:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
313 items = self.profilesList.findItems(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
314 currentProfile, Qt.MatchExactly)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
315 if items:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
316 self.profilesList.setCurrentItem(items[0])
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
317
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
318 if len(self.__profiles) == 0:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
319 self.profileFrame.setEnabled(False)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
320
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
321 def __populateProfile(self, profileName):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
322 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
323 Private method to populate the profile data entry fields.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
324
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
325 @param profileName name of the profile to get data from
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
326 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
327 """
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
328 profile = self.__defaultProfile()
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
329 if profileName:
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
330 profile.update(self.__profiles[profileName])
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
331
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
332 self.__populatingProfile = True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
333 if profileName is not None:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
334 self.profileEdit.setText(profileName)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
335 self.brokerAddressEdit.setText(profile["BrokerAddress"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
336 self.brokerPortSpinBox.setValue(profile["BrokerPort"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
337 self.clientIdEdit.setText(profile["ClientId"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
338 self.keepaliveSpinBox.setValue(profile["Keepalive"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
339 self.cleanSessionCheckBox.setChecked(profile["CleanSession"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
340 self.usernameEdit.setText(profile["Username"])
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
341 self.passwordEdit.setText(pwConvert(profile["Password"], encode=False))
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
342 self.willTopicEdit.setText(profile["WillTopic"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
343 self.willMessageEdit.setPlainText(profile["WillMessage"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
344 self.willQosSpinBox.setValue(profile["WillQos"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
345 self.willRetainCheckBox.setChecked(profile["WillRetain"])
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
346 self.tlsGroupBox.setChecked(profile["TlsEnable"])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
347 if profile["TlsCaCert"] and profile["TlsClientCert"]:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
348 self.tlsSelfSignedCertsButton.setChecked(True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
349 self.tlsSelfSignedCertsFilePicker.setText(profile["TlsCaCert"])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
350 self.tlsSelfSignedClientCertFilePicker.setText(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
351 profile["TlsClientCert"])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
352 self.tlsSelfSignedClientKeyFilePicker.setText(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
353 profile["TlsClientKey"])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
354 elif profile["TlsCaCert"]:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
355 self.tlsCertsFileButton.setChecked(True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
356 self.tlsCertsFilePicker.setText(profile["TlsCaCert"])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
357 else:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
358 self.tlsDefaultCertsButton.setChecked(True)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
359 self.__populatingProfile = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
360
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
361 self.profileFrame.setEnabled(True)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
362 self.__updateApplyButton()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
363
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
364 def __clearProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
365 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
366 Private method to clear the profile data entry fields.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
367 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
368 self.__populatingProfile = True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
369 self.profileEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
370 self.brokerAddressEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
371 self.brokerPortSpinBox.setValue(1883)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
372 self.clientIdEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
373 self.keepaliveSpinBox.setValue(60)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
374 self.cleanSessionCheckBox.setChecked(True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
375 self.usernameEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
376 self.passwordEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
377 self.willTopicEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
378 self.willMessageEdit.setPlainText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
379 self.willQosSpinBox.setValue(0)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
380 self.willRetainCheckBox.setChecked(False)
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
381 self.tlsGroupBox.setChecked(False)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
382 self.tlsDefaultCertsButton.setChecked(True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
383 self.tlsCertsFileButton.setChecked(True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
384 self.tlsCertsFilePicker.setText("")
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
385 self.tlsSelfSignedCertsButton.setChecked(False)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
386 self.tlsSelfSignedCertsFilePicker.setText("")
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
387 self.tlsSelfSignedClientCertFilePicker.setText("")
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
388 self.tlsSelfSignedClientKeyFilePicker.setText("")
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
389 self.__populatingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
390
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
391 self.profileFrame.setEnabled(False)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
392 self.__updateApplyButton()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
393
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
394 def __resetProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
395 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
396 Private method to reset the profile data entry fields to their stored
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
397 values.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
398 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
399 profileName = self.profileEdit.text()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
400 if profileName in self.__profiles:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
401 self.__populateProfile(profileName)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
402
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
403 def __populateProfileDefault(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
404 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
405 Private method to populate the profile data entry fields with default
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
406 profile values.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
407 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
408 self.__populateProfile(None)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
409
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
410 def __isChangedProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
411 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
412 Private method to check, if the currently shown profile contains some
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
413 changed data.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
414
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
415 @return flag indicating changed data
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
416 @type bool
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
417 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
418 profileName = self.profileEdit.text()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
419 if profileName == "":
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
420 return False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
421
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
422 elif profileName in self.__profiles:
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
423 profile = self.__defaultProfile()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
424 profile.update(self.__profiles[profileName])
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
425 changed = (
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
426 self.brokerAddressEdit.text() != profile["BrokerAddress"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
427 self.brokerPortSpinBox.value() != profile["BrokerPort"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
428 self.clientIdEdit.text() != profile["ClientId"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
429 self.keepaliveSpinBox.value() != profile["Keepalive"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
430 self.cleanSessionCheckBox.isChecked() !=
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
431 profile["CleanSession"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
432 self.usernameEdit.text() != profile["Username"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
433 self.passwordEdit.text() !=
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
434 pwConvert(profile["Password"], encode=False) or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
435 self.willTopicEdit.text() != profile["WillTopic"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
436 self.willMessageEdit.toPlainText() != profile["WillMessage"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
437 self.willQosSpinBox.value() != profile["WillQos"] or
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
438 self.willRetainCheckBox.isChecked() != profile["WillRetain"] or
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
439 self.tlsGroupBox.isChecked() != profile["TlsEnable"]
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
440 )
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
441 # check TLS stuff only, if not yet changed
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
442 if not changed:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
443 if self.tlsCertsFileButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
444 changed |= (
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
445 self.tlsCertsFilePicker.text() != profile["TlsCaCert"]
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
446 )
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
447 elif self.tlsSelfSignedCertsButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
448 changed |= (
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
449 self.tlsSelfSignedCertsFilePicker.text() !=
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
450 profile["TlsCaCert"] or
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
451 self.tlsSelfSignedClientCertFilePicker.text() !=
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
452 profile["TlsClientCert"] or
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
453 self.tlsSelfSignedClientKeyFilePicker.text() !=
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
454 profile["TlsClientKey"]
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
455 )
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
456 return changed
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
457
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
458 else:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
459 return True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
460
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
461 def __updateApplyButton(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
462 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
463 Private method to set the state of the Apply button.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
464 """
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
465 # condition 1: profile name and broker address need to be given
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
466 enable = (bool(self.profileEdit.text()) and
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
467 bool(self.brokerAddressEdit.text()))
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
468
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
469 # condition 2: if client ID is empty, clean session must be selected
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
470 if not self.__populatingProfile:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
471 if self.clientIdEdit.text() == "" and \
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
472 not self.cleanSessionCheckBox.isChecked():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
473 enable = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
474 E5MessageBox.critical(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
475 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
476 self.tr("Invalid Connection Parameters"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
477 self.tr("An empty Client ID requires a clean session."))
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
478
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
479 if self.tlsGroupBox.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
480 if self.tlsCertsFileButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
481 # condition 3a: if CA certificates file shall be used, it must
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
482 # be given
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
483 enable &= bool(self.tlsCertsFilePicker.text())
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
484 elif self.tlsSelfSignedCertsButton.isChecked():
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
485 # condition 3b: if client certificates shall be used, all files
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
486 # must be given
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
487 enable &= (
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
488 bool(self.tlsSelfSignedCertsFilePicker.text()) and
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
489 bool(self.tlsSelfSignedClientCertFilePicker.text()) and
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
490 bool(self.tlsSelfSignedClientKeyFilePicker.text())
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
491 )
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
492
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
493 self.profileButtonBox.button(QDialogButtonBox.Apply).setEnabled(enable)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
494
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
495 @pyqtSlot(str)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
496 def on_brokerAddressEdit_textChanged(self, address):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
497 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
498 Private slot handling a change of the broker address.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
499
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
500 @param address broker address
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
501 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
502 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
503 self.__updateApplyButton()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
504
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
505 @pyqtSlot()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
506 def on_generateIdButton_clicked(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
507 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
508 Private slot to generate a client ID.
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
509 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
510 uuid = QUuid.createUuid()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
511 self.clientIdEdit.setText(uuid.toString(QUuid.WithoutBraces))
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
512
26
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
513 @pyqtSlot(str)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
514 def on_clientIdEdit_textChanged(self, clientId):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
515 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
516 Private slot handling a change of the client ID string.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
517
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
518 @param clientId client ID
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
519 @type str
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
520 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
521 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
522
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
523 @pyqtSlot(bool)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
524 def on_cleanSessionCheckBox_clicked(self, checked):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
525 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
526 Private slot to handle a change of the clean session selection.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
527
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
528 @param checked current state of the clean session selection
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
529 @type bool
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
530 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
531 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
532
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
533 @pyqtSlot(str)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
534 def on_tlsCertsFilePicker_textChanged(self, path):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
535 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
536 Private slot handling a change of the TLS CA certificates file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
537
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
538 @param path file path
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
539 @type str
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
540 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
541 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
542
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
543 @pyqtSlot(str)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
544 def on_tlsSelfSignedCertsFilePicker_textChanged(self, path):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
545 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
546 Private slot handling a change of the TLS CA certificates file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
547
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
548 @param path file path
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
549 @type str
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
550 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
551 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
552
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
553 @pyqtSlot(str)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
554 def on_tlsSelfSignedClientCertFilePicker_textChanged(self, path):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
555 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
556 Private slot handling a change of the TLS client certificate file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
557
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
558 @param path file path
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
559 @type str
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
560 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
561 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
562
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
563 @pyqtSlot(str)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
564 def on_tlsSelfSignedClientKeyFilePicker_textChanged(self, path):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
565 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
566 Private slot handling a change of the TLS client key file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
567
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
568 @param path file path
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
569 @type str
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
570 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
571 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
572
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
573 @pyqtSlot(bool)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
574 def on_tlsGroupBox_toggled(self, checked):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
575 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
576 Private slot handling the selection of TLS mode.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
577
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
578 @param checked state of the selection
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
579 @type bool
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
580 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
581 if checked and self.brokerPortSpinBox.value() == 1883:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
582 # port is still standard non-TLS port
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
583 yes = E5MessageBox.yesNo(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
584 self,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
585 self.tr("SSL/TLS Enabled"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
586 self.tr(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
587 """Encrypted connection using SSL/TLS has been enabled."""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
588 """ However, the broker port is still the default"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
589 """ unencrypted port (port 1883). Shall this be"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
590 """ changed?"""),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
591 icon=E5MessageBox.Warning,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
592 yesDefault=True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
593 if yes:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
594 self.brokerPortSpinBox.setValue(8883)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
595 elif not checked and self.brokerPortSpinBox.value() == 8883:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
596 # port is still standard TLS port
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
597 yes = E5MessageBox.yesNo(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
598 self,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
599 self.tr("SSL/TLS Disabled"),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
600 self.tr(
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
601 """Encrypted connection using SSL/TLS has been disabled."""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
602 """ However, the broker port is still the default"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
603 """ encrypted port (port 8883). Shall this be"""
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
604 """ changed?"""),
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
605 icon=E5MessageBox.Warning,
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
606 yesDefault=True)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
607 if yes:
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
608 self.brokerPortSpinBox.setValue(1883)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
609
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
610 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
611
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
612 @pyqtSlot(bool)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
613 def on_tlsDefaultCertsButton_toggled(self, checked):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
614 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
615 Private slot handling the selection of using the default
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
616 certificates file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
617
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
618 @param checked state of the selection
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
619 @type bool
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
620 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
621 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
622
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
623 @pyqtSlot(bool)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
624 def on_tlsCertsFileButton_toggled(self, checked):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
625 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
626 Private slot handling the selection of using a non-default
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
627 certificates file.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
628
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
629 @param checked state of the selection
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
630 @type bool
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
631 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
632 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
633
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
634 @pyqtSlot(bool)
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
635 def on_tlsSelfSignedCertsButton_toggled(self, checked):
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
636 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
637 Private slot handling the selection of using self signed
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
638 client certificate and key files.
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
639
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
640 @param checked state of the selection
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
641 @type bool
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
642 """
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
643 self.__updateApplyButton()
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
644
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
645 @pyqtSlot()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
646 def reject(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
647 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
648 Public slot to reject the dialog changes.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
649 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
650 if self.__isChangedProfile():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
651 button = E5MessageBox.warning(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
652 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
653 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
654 self.tr("""The current profile has unsaved changes. Shall"""
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
655 """ these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
656 E5MessageBox.StandardButtons(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
657 E5MessageBox.Discard |
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
658 E5MessageBox.Save),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
659 E5MessageBox.Save)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
660 if button == E5MessageBox.Save:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
661 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
662 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
663
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
664 if self.__profilesChanged:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
665 button = E5MessageBox.warning(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
666 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
667 self.tr("Changed Connection Profiles"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
668 self.tr("""The list of connection profiles has unsaved"""
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
669 """ changes."""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
670 E5MessageBox.StandardButtons(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
671 E5MessageBox.Abort |
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
672 E5MessageBox.Discard |
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
673 E5MessageBox.Save),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
674 E5MessageBox.Save)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
675 if button == E5MessageBox.Save:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
676 super(MqttConnectionProfilesDialog, self).accept()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
677 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
678 elif button == E5MessageBox.Abort:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
679 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
680
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
681 super(MqttConnectionProfilesDialog, self).reject()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
682
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
683 @pyqtSlot()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
684 def accept(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
685 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
686 Public slot to accept the dialog.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
687 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
688 if self.__isChangedProfile():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
689 yes = E5MessageBox.yesNo(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
690 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
691 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
692 self.tr("""The current profile has unsaved changes. Shall"""
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
693 """ these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
694 icon=E5MessageBox.Warning,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
695 yesDefault=True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
696 if yes:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
697 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
698
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
699 super(MqttConnectionProfilesDialog, self).accept()

eric ide

mercurial