MqttMonitor/MqttConnectionProfilesDialog.py

Sun, 09 Sep 2018 12:21:19 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 09 Sep 2018 12:21:19 +0200
changeset 30
17ef10819773
parent 26
ad232a5129cc
child 31
40582e448c4b
permissions
-rw-r--r--

Some smaller improvements and added some TODOs.

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 """
30
17ef10819773 Some smaller improvements and added some TODOs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 26
diff changeset
31 # TODO: add 'Clear Will'
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
32 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
33 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
36 @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
37 @type MqttClient
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
38 @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
39 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
40 "BrokerAddress", "BrokerPort", "ClientId",
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
41 "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
42 "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
43 "TlsClientCert", "TlsClientKey".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
44 @type dict
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @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
46 @type QWidget
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 super(MqttConnectionProfilesDialog, self).__init__(parent)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.setupUi(self)
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
50
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
51 self.__client = client
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
52
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
53 self.__profiles = collections.defaultdict(self.__defaultProfile)
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
54 self.__profiles.update(profiles)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
55 self.__profilesChanged = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
56
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
57 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
58 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
59 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
60
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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
77 self.profileTabWidget.setCurrentIndex(0)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
78
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
79 if len(self.__profiles) == 0:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
80 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
81 self.copyButton.setEnabled(False)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
82
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
83 self.profileFrame.setEnabled(False)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
84 self.__populatingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
85 self.__deletingProfile = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
86
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
87 self.__populateProfilesList()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 @pyqtSlot(str)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
90 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
91 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
92 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
93
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
94 @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
95 @type str
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
97 self.__updateApplyButton()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @pyqtSlot(QAbstractButton)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 def on_profileButtonBox_clicked(self, button):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
102 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
103
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
104 @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
105 @type QAbstractButton
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
107 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
108 currentProfile = self.__applyProfile()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
109 self.__populateProfilesList(currentProfile)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
110
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
111 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
112 self.__resetProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
113
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
114 elif button == self.profileButtonBox.button(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
115 QDialogButtonBox.RestoreDefaults):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
116 self.__populateProfileDefault()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @pyqtSlot(QListWidgetItem, QListWidgetItem)
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 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
120 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
121 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
122
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
123 @param current new current item
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @type QListWidgetItem
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
125 @param previous previous current item
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 @type QListWidgetItem
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
128 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
129 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
130
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
131 if current is not previous:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
132 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
133 # modified profile belongs to previous
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
134 yes = E5MessageBox.yesNo(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
135 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
136 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
137 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
138 """ Shall these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
139 icon=E5MessageBox.Warning,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
140 yesDefault=True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
141 if yes:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
142 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
143
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
144 if current:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
145 profileName = current.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
146 self.__populateProfile(profileName)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
147 else:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
148 self.__clearProfile()
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @pyqtSlot()
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 def on_plusButton_clicked(self):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
153 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
154 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
155 profileName, ok = QInputDialog.getText(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
156 self,
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
157 self.tr("New Connection Profile"),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 """ 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
167 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
168 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
169 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
170 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
171 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
172
ad232a5129cc 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 @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
174 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
175 """
ad232a5129cc 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 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
177 """
ad232a5129cc 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 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 """ 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
193 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
194 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
195 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
196 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
197 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
198
ad232a5129cc 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 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
200 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
201 self.brokerAddressEdit.setFocus(Qt.OtherFocusReason)
17
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 @pyqtSlot()
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 def on_minusButton_clicked(self):
ee738a0efe9c MqttConnectionProfilesDialog: started to implement the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
206 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
207 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
208 itm = self.profilesList.currentItem()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
209 if itm:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
210 profileName = itm.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
211 yes = E5MessageBox.yesNo(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
212 self,
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
213 self.tr("Delete Connection Profile"),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
214 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
215 """ really be deleted?</p>""").format(profileName)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
216 )
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
217 if yes:
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
218 self.__deletingProfile = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
219 del self.__profiles[profileName]
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
220 self.__profilesChanged = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
221 self.__populateProfilesList()
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
222 self.__deletingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
223
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
224 self.profilesList.setFocus(Qt.OtherFocusReason)
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
225
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
226 def getProfiles(self):
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
227 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
228 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
229
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
230 @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
231 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
232 "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
233 "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
234 "TlsEnable", "TlsCaCert", "TlsClientCert", "TlsClientKey".
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
235 @rtype dict
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
236 """
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
237 profilesDict = {}
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
238 profilesDict.update(self.__profiles)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
239 return profilesDict
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
240
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
241 def __applyProfile(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
242 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
243 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
244
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
245 @return name of the applied profile
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
246 @rtype str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
247 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
248 profileName = self.profileEdit.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
249 profile = {
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
250 "BrokerAddress": self.brokerAddressEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
251 "BrokerPort": self.brokerPortSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
252 "ClientId": self.clientIdEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
253 "Keepalive": self.keepaliveSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
254 "CleanSession": self.cleanSessionCheckBox.isChecked(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
255 "Username": self.usernameEdit.text(),
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
256 "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
257 "WillTopic": self.willTopicEdit.text(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
258 "WillMessage": self.willMessageEdit.toPlainText(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
259 "WillQos": self.willQosSpinBox.value(),
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
260 "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
261 "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
262 "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
263 "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
264 "TlsClientKey": "",
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
265 }
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
266 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
267 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
268 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
269 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
270 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
271 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
272 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
273 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
274 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
275 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
276
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
277 self.__profiles[profileName] = profile
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
278 self.__profilesChanged = True
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
279
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
280 return profileName
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
281
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
282 def __defaultProfile(self):
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
283 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
284 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
285
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
286 @return default dictionary entry
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
287 @rtype dict
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
288 """
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
289 defaultProfile = self.__client.defaultConnectionOptions()
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
290 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
291 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
292 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
293 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
294 defaultProfile["BrokerPort"] = 1883
18
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
295
bbfe5866b6aa MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 17
diff changeset
296 return defaultProfile
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
297
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
298 def __populateProfilesList(self, currentProfile=""):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
299 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
300 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
301
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
302 @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
303 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
304 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
305 if not currentProfile:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
306 currentItem = self.profilesList.currentItem()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
307 if currentItem:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
308 currentProfile = currentItem.text()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
309
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
310 self.profilesList.clear()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
311 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
312
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
313 if currentProfile:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
314 items = self.profilesList.findItems(
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
315 currentProfile, Qt.MatchExactly)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
316 if items:
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
317 self.profilesList.setCurrentItem(items[0])
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
318
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
319 if len(self.__profiles) == 0:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
320 self.profileFrame.setEnabled(False)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
321
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
322 def __populateProfile(self, profileName):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
323 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
324 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
325
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
326 @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
327 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
328 """
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
329 profile = self.__defaultProfile()
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
330 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
331 profile.update(self.__profiles[profileName])
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
332
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
333 self.__populatingProfile = True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
334 if profileName is not None:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
335 self.profileEdit.setText(profileName)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
336 self.brokerAddressEdit.setText(profile["BrokerAddress"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
337 self.brokerPortSpinBox.setValue(profile["BrokerPort"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
338 self.clientIdEdit.setText(profile["ClientId"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
339 self.keepaliveSpinBox.setValue(profile["Keepalive"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
340 self.cleanSessionCheckBox.setChecked(profile["CleanSession"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
341 self.usernameEdit.setText(profile["Username"])
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
342 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
343 self.willTopicEdit.setText(profile["WillTopic"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
344 self.willMessageEdit.setPlainText(profile["WillMessage"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
345 self.willQosSpinBox.setValue(profile["WillQos"])
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 self.tlsDefaultCertsButton.setChecked(True)
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
360 self.__populatingProfile = False
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
361
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
362 self.profileFrame.setEnabled(True)
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
363 self.__updateApplyButton()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
364
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
365 def __clearProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
366 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
367 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
368 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
369 self.__populatingProfile = True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
370 self.profileEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
371 self.brokerAddressEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
372 self.brokerPortSpinBox.setValue(1883)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
373 self.clientIdEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
374 self.keepaliveSpinBox.setValue(60)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
375 self.cleanSessionCheckBox.setChecked(True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
376 self.usernameEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
377 self.passwordEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
378 self.willTopicEdit.setText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
379 self.willMessageEdit.setPlainText("")
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
380 self.willQosSpinBox.setValue(0)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
381 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
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 self.tlsSelfSignedClientKeyFilePicker.setText("")
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
390 self.__populatingProfile = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
391
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
392 self.profileFrame.setEnabled(False)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
393 self.__updateApplyButton()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
394
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
395 def __resetProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
396 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
397 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
398 values.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
399 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
400 profileName = self.profileEdit.text()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
401 if profileName in self.__profiles:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
402 self.__populateProfile(profileName)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
403
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
404 def __populateProfileDefault(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
405 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
406 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
407 profile values.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
408 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
409 self.__populateProfile(None)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
410
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
411 def __isChangedProfile(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
412 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
413 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
414 changed data.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
415
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
416 @return flag indicating changed data
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
417 @type bool
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
418 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
419 profileName = self.profileEdit.text()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
420 if profileName == "":
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
421 return False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
422
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
423 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
424 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
425 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
426 changed = (
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
427 self.brokerAddressEdit.text() != profile["BrokerAddress"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
428 self.brokerPortSpinBox.value() != profile["BrokerPort"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
429 self.clientIdEdit.text() != profile["ClientId"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
430 self.keepaliveSpinBox.value() != profile["Keepalive"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
431 self.cleanSessionCheckBox.isChecked() !=
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
432 profile["CleanSession"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
433 self.usernameEdit.text() != profile["Username"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
434 self.passwordEdit.text() !=
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
435 pwConvert(profile["Password"], encode=False) or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
436 self.willTopicEdit.text() != profile["WillTopic"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
437 self.willMessageEdit.toPlainText() != profile["WillMessage"] or
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
438 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
439 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
440 self.tlsGroupBox.isChecked() != profile["TlsEnable"]
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
441 )
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
442 # 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
443 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
444 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
445 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
446 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
447 )
ad232a5129cc 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 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
449 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
450 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
451 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
452 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
453 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
454 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
455 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
456 )
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
457 return changed
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
458
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
459 else:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
460 return True
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
461
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
462 def __updateApplyButton(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
463 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
464 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
465 """
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
466 # 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
467 enable = (bool(self.profileEdit.text()) and
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
468 bool(self.brokerAddressEdit.text()))
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
469
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
470 # 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
471 if not self.__populatingProfile:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
472 if self.clientIdEdit.text() == "" and \
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
473 not self.cleanSessionCheckBox.isChecked():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
474 enable = False
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
475 E5MessageBox.critical(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
476 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
477 self.tr("Invalid Connection Parameters"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
478 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
479
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
480 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
481 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
482 # 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
483 # 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
484 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
485 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
486 # 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
487 # 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
488 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
489 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
490 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
491 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
492 )
ad232a5129cc MqttConnectionProfilesDialog: added support for TLS and added a button to copy the current profile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 23
diff changeset
493
19
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
494 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
495
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
496 @pyqtSlot(str)
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
497 def on_brokerAddressEdit_textChanged(self, address):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
498 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
499 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
500
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
501 @param address broker address
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
502 @type str
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
503 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
504 self.__updateApplyButton()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
505
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
506 @pyqtSlot()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
507 def on_generateIdButton_clicked(self):
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
508 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
509 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
510 """
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
511 uuid = QUuid.createUuid()
889a7c3c0e63 MqttConnectionProfilesDialog: continued implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
512 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
513
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
514 @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
515 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
516 """
ad232a5129cc 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 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
518
ad232a5129cc 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 @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
520 @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
521 """
ad232a5129cc 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 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
523
ad232a5129cc 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 @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
525 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
526 """
ad232a5129cc 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 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
528
ad232a5129cc 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 @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
530 @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
531 """
ad232a5129cc 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 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
533
ad232a5129cc 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 @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
535 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
536 """
ad232a5129cc 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 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
538
ad232a5129cc 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 @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
540 @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
541 """
ad232a5129cc 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 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
543
ad232a5129cc 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 @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
545 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
546 """
ad232a5129cc 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 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
548
ad232a5129cc 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 @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
550 @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
551 """
ad232a5129cc 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 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
553
ad232a5129cc 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 @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
555 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
556 """
ad232a5129cc 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 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
558
ad232a5129cc 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 @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
560 @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
561 """
ad232a5129cc 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 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
563
ad232a5129cc 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 @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
565 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
566 """
ad232a5129cc 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 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
568
ad232a5129cc 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 @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
570 @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
571 """
ad232a5129cc 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 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
573
ad232a5129cc 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 @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
575 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
576 """
ad232a5129cc 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 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
578
ad232a5129cc 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 @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
580 @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
581 """
ad232a5129cc 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 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
583 # 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
584 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
585 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
586 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
587 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
588 """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
589 """ 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
590 """ 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
591 """ 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
592 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
593 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
594 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
595 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
596 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
597 # 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
598 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
599 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
600 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
601 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
602 """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
603 """ 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
604 """ 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
605 """ 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
606 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
607 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
608 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
609 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
610
ad232a5129cc 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 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
612
ad232a5129cc 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 @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
614 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
615 """
ad232a5129cc 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 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
617 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
618
ad232a5129cc 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 @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
620 @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
621 """
ad232a5129cc 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 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
623
ad232a5129cc 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 @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
625 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
626 """
ad232a5129cc 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 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
628 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
629
ad232a5129cc 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 @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
631 @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
632 """
ad232a5129cc 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 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
634
ad232a5129cc 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 @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
636 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
637 """
ad232a5129cc 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 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
639 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
640
ad232a5129cc 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 @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
642 @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
643 """
ad232a5129cc 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 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
645
23
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
646 @pyqtSlot()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
647 def reject(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
648 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
649 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
650 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
651 if self.__isChangedProfile():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
652 button = E5MessageBox.warning(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
653 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
654 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
655 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
656 """ these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
657 E5MessageBox.StandardButtons(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
658 E5MessageBox.Discard |
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 E5MessageBox.Save)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
661 if button == E5MessageBox.Save:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
662 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
663 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
664
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
665 if self.__profilesChanged:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
666 button = E5MessageBox.warning(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
667 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
668 self.tr("Changed Connection Profiles"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
669 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
670 """ changes."""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
671 E5MessageBox.StandardButtons(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
672 E5MessageBox.Abort |
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
673 E5MessageBox.Discard |
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 E5MessageBox.Save)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
676 if button == E5MessageBox.Save:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
677 super(MqttConnectionProfilesDialog, self).accept()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
678 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
679 elif button == E5MessageBox.Abort:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
680 return
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
681
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
682 super(MqttConnectionProfilesDialog, self).reject()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
683
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
684 @pyqtSlot()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
685 def accept(self):
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
686 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
687 Public slot to accept the dialog.
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
688 """
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
689 if self.__isChangedProfile():
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
690 yes = E5MessageBox.yesNo(
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
691 self,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
692 self.tr("Changed Connection Profile"),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
693 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
694 """ these be saved?"""),
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
695 icon=E5MessageBox.Warning,
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
696 yesDefault=True)
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
697 if yes:
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
698 self.__applyProfile()
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
699
0b23bd856e43 MqttConnectionProfilesDialog: finished implementing the connections profile dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 19
diff changeset
700 super(MqttConnectionProfilesDialog, self).accept()

eric ide

mercurial