|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 """ |
|
4 Module implementing WifiConnectionDialog. |
|
5 """ |
|
6 |
|
7 from PyQt6.QtCore import pyqtSlot |
|
8 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLineEdit |
|
9 |
|
10 from eric7 import Preferences |
|
11 from eric7.EricGui import EricPixmapCache |
|
12 |
|
13 from .Ui_WifiConnectionDialog import Ui_WifiConnectionDialog |
|
14 |
|
15 |
|
16 class WifiConnectionDialog(QDialog, Ui_WifiConnectionDialog): |
|
17 """ |
|
18 Class documentation goes here. |
|
19 """ |
|
20 |
|
21 def __init__(self, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param parent reference to the parent widget (defaults to None) |
|
26 @type QWidget (optional) |
|
27 """ |
|
28 super().__init__(parent) |
|
29 self.setupUi(self) |
|
30 |
|
31 self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword")) |
|
32 |
|
33 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
34 |
|
35 # populate the field with data saved to the preferences |
|
36 self.ssidEdit.setText(Preferences.getMicroPython("WifiName")) |
|
37 self.passwordEdit.setText(Preferences.getMicroPython("WifiPassword")) |
|
38 |
|
39 msh = self.minimumSizeHint() |
|
40 self.resize(max(self.width(), msh.width()), msh.height()) |
|
41 |
|
42 @pyqtSlot(str) |
|
43 def on_ssidEdit_textChanged(self, ssid): |
|
44 """ |
|
45 Private slot handling a change of the SSID |
|
46 |
|
47 @param ssid entered SSID |
|
48 @type str |
|
49 """ |
|
50 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(ssid)) |
|
51 |
|
52 @pyqtSlot(bool) |
|
53 def on_showPasswordButton_clicked(self, checked): |
|
54 """ |
|
55 Private slot to show or hide the password. |
|
56 |
|
57 @param checked state of the button |
|
58 @type bool |
|
59 """ |
|
60 if checked: |
|
61 self.passwordEdit.setEchoMode(QLineEdit.EchoMode.Normal) |
|
62 self.showPasswordButton.setIcon(EricPixmapCache.getIcon("hidePassword")) |
|
63 self.showPasswordButton.setToolTip(self.tr("Press to hide the password")) |
|
64 else: |
|
65 self.passwordEdit.setEchoMode(QLineEdit.EchoMode.Password) |
|
66 self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword")) |
|
67 self.showPasswordButton.setToolTip(self.tr("Press to show the password")) |
|
68 |
|
69 def getConnectionParameters(self): |
|
70 """ |
|
71 Public method to get the entered connection parameters. |
|
72 |
|
73 @return tuple containing the SSID, password and a flag indicating, if the |
|
74 parameters shall be saved to the preferences |
|
75 @rtype tuple of (str, str, bool) |
|
76 """ |
|
77 return ( |
|
78 self.ssidEdit.text(), |
|
79 self.passwordEdit.text(), |
|
80 self.rememberCheckBox.isChecked(), |
|
81 ) |