src/eric7/MicroPython/WifiDialogs/WifiConnectionDialog.py

branch
mpy_network
changeset 9776
210bf87ae5c7
child 9789
d8e0ab86ddca
diff -r c6806d24468b -r 210bf87ae5c7 src/eric7/MicroPython/WifiDialogs/WifiConnectionDialog.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/MicroPython/WifiDialogs/WifiConnectionDialog.py	Sat Feb 18 18:12:32 2023 +0100
@@ -0,0 +1,81 @@
+# -*- coding: utf-8 -*-
+
+"""
+Module implementing WifiConnectionDialog.
+"""
+
+from PyQt6.QtCore import pyqtSlot
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QLineEdit
+
+from eric7 import Preferences
+from eric7.EricGui import EricPixmapCache
+
+from .Ui_WifiConnectionDialog import Ui_WifiConnectionDialog
+
+
+class WifiConnectionDialog(QDialog, Ui_WifiConnectionDialog):
+    """
+    Class documentation goes here.
+    """
+
+    def __init__(self, parent=None):
+        """
+        Constructor
+
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+
+        self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword"))
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+
+        # populate the field with data saved to the preferences
+        self.ssidEdit.setText(Preferences.getMicroPython("WifiName"))
+        self.passwordEdit.setText(Preferences.getMicroPython("WifiPassword"))
+
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+
+    @pyqtSlot(str)
+    def on_ssidEdit_textChanged(self, ssid):
+        """
+        Private slot handling a change of the SSID
+
+        @param ssid entered SSID
+        @type str
+        """
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(ssid))
+
+    @pyqtSlot(bool)
+    def on_showPasswordButton_clicked(self, checked):
+        """
+        Private slot to show or hide the password.
+
+        @param checked state of the button
+        @type bool
+        """
+        if checked:
+            self.passwordEdit.setEchoMode(QLineEdit.EchoMode.Normal)
+            self.showPasswordButton.setIcon(EricPixmapCache.getIcon("hidePassword"))
+            self.showPasswordButton.setToolTip(self.tr("Press to hide the password"))
+        else:
+            self.passwordEdit.setEchoMode(QLineEdit.EchoMode.Password)
+            self.showPasswordButton.setIcon(EricPixmapCache.getIcon("showPassword"))
+            self.showPasswordButton.setToolTip(self.tr("Press to show the password"))
+
+    def getConnectionParameters(self):
+        """
+        Public method to get the entered connection parameters.
+
+        @return tuple containing the SSID, password and a flag indicating, if the
+            parameters shall be saved to the preferences
+        @rtype tuple of (str, str, bool)
+        """
+        return (
+            self.ssidEdit.text(),
+            self.passwordEdit.text(),
+            self.rememberCheckBox.isChecked(),
+        )

eric ide

mercurial