|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the parameters for the WebREPL server. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_MicroPythonWebreplParametersDialog import Ui_MicroPythonWebreplParametersDialog |
|
14 |
|
15 |
|
16 class MicroPythonWebreplParametersDialog( |
|
17 QDialog, Ui_MicroPythonWebreplParametersDialog |
|
18 ): |
|
19 """ |
|
20 Class implementing a dialog to enter the parameters for the WebREPL server. |
|
21 """ |
|
22 |
|
23 def __init__(self, parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param parent reference to the parent widget (defaults to None) |
|
28 @type QWidget (optional) |
|
29 """ |
|
30 super().__init__(parent) |
|
31 self.setupUi(self) |
|
32 |
|
33 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
34 |
|
35 self.passwordEdit.textChanged.connect(self.__updateOk) |
|
36 self.passwordConfirmEdit.textChanged.connect(self.__updateOk) |
|
37 |
|
38 @pyqtSlot() |
|
39 def __updateOk(self): |
|
40 """ |
|
41 Private slot to update the enabled state of the OK button. |
|
42 """ |
|
43 pw = self.passwordEdit.text() |
|
44 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
|
45 4 <= len(pw) <= 9 and self.passwordConfirmEdit.text() == pw |
|
46 ) |
|
47 |
|
48 def getParameters(self): |
|
49 """ |
|
50 Public method to retrieve the entered data. |
|
51 |
|
52 @return tuple containing the password |
|
53 @rtype tuple of (str,) |
|
54 """ |
|
55 return (self.passwordEdit.text(),) |