src/eric7/MicroPython/WifiDialogs/WifiConnectionDialog.py

branch
eric7
changeset 10153
ffe7432f716b
parent 9870
0399d3607829
child 10439
21c28b0f9e41
equal deleted inserted replaced
10152:33e7b9d3f91c 10153:ffe7432f716b
21 """ 21 """
22 Class implementing a dialog to enter the parameters needed to connect to a WiFi 22 Class implementing a dialog to enter the parameters needed to connect to a WiFi
23 network. 23 network.
24 """ 24 """
25 25
26 def __init__(self, parent=None): 26 def __init__(self, withCountry=False, parent=None):
27 """ 27 """
28 Constructor 28 Constructor
29 29
30 @param withCountry flag indicating to show the country entry (defaults to False)
31 @type bool
30 @param parent reference to the parent widget (defaults to None) 32 @param parent reference to the parent widget (defaults to None)
31 @type QWidget (optional) 33 @type QWidget (optional)
32 """ 34 """
33 super().__init__(parent) 35 super().__init__(parent)
34 self.setupUi(self) 36 self.setupUi(self)
35 37
36 self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword")) 38 self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword"))
37 39
40 self.countryLabel.setVisible(withCountry)
41 self.countryEdit.setVisible(withCountry)
42
38 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) 43 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
39 44
40 # populate the field with data saved to the preferences 45 # populate the field with data saved to the preferences
41 self.ssidEdit.setText(Preferences.getMicroPython("WifiName")) 46 self.ssidEdit.setText(Preferences.getMicroPython("WifiName"))
42 self.passwordEdit.setText(Preferences.getMicroPython("WifiPassword")) 47 self.passwordEdit.setText(Preferences.getMicroPython("WifiPassword"))
48 self.hostnameEdit.setText(Preferences.getMicroPython("WifiHostname"))
49 if withCountry:
50 self.countryEdit.setText(Preferences.getMicroPython("WifiCountry").upper())
43 51
44 msh = self.minimumSizeHint() 52 msh = self.minimumSizeHint()
45 self.resize(max(self.width(), msh.width()), msh.height()) 53 self.resize(max(self.width(), msh.width()), msh.height())
46 54
47 @pyqtSlot(str) 55 @pyqtSlot(str)
77 Public slot accepting the dialog. 85 Public slot accepting the dialog.
78 """ 86 """
79 if self.rememberCheckBox.isChecked(): 87 if self.rememberCheckBox.isChecked():
80 Preferences.setMicroPython("WifiName", self.ssidEdit.text()) 88 Preferences.setMicroPython("WifiName", self.ssidEdit.text())
81 Preferences.setMicroPython("WifiPassword", self.passwordEdit.text()) 89 Preferences.setMicroPython("WifiPassword", self.passwordEdit.text())
90 Preferences.setMicroPython("WifiHostname", self.hostnameEdit.text())
91 if self.countryEdit.isVisible():
92 Preferences.setMicroPython(
93 "WifiCountry", self.countryEdit.text().upper()
94 )
82 95
83 super().accept() 96 super().accept()
84 97
85 def getConnectionParameters(self): 98 def getConnectionParameters(self):
86 """ 99 """
87 Public method to get the entered connection parameters. 100 Public method to get the entered connection parameters.
88 101
89 @return tuple containing the SSID and the password 102 @return tuple containing the SSID, the password and the host name
90 @rtype tuple of (str, str) 103 @rtype tuple of (str, str, str)
91 """ 104 """
92 return ( 105 return (
93 self.ssidEdit.text(), 106 self.ssidEdit.text(),
94 self.passwordEdit.text(), 107 self.passwordEdit.text(),
108 self.hostnameEdit.text(),
95 ) 109 )
110
111 def getCountryCode(self):
112 """
113 Public method to get the entered country code.
114
115 @return DESCRIPTION
116 @rtype TYPE
117 """
118 return self.countryEdit.text().upper()

eric ide

mercurial