16 |
16 |
17 class HgClientPromptDialog(QDialog, Ui_HgClientPromptDialog): |
17 class HgClientPromptDialog(QDialog, Ui_HgClientPromptDialog): |
18 """ |
18 """ |
19 Class implementing a prompt dialog for the Mercurial command server. |
19 Class implementing a prompt dialog for the Mercurial command server. |
20 """ |
20 """ |
|
21 |
21 def __init__(self, size, message, parent=None): |
22 def __init__(self, size, message, parent=None): |
22 """ |
23 """ |
23 Constructor |
24 Constructor |
24 |
25 |
25 @param size maximum length of the requested input (integer) |
26 @param size maximum length of the requested input (integer) |
26 @param message message sent by the server (string) |
27 @param message message sent by the server (string) |
27 @param parent reference to the parent widget (QWidget) |
28 @param parent reference to the parent widget (QWidget) |
28 """ |
29 """ |
29 super().__init__(parent) |
30 super().__init__(parent) |
30 self.setupUi(self) |
31 self.setupUi(self) |
31 |
32 |
32 self.buttonBox.button( |
33 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
33 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
34 |
34 |
|
35 self.inputEdit.setMaxLength(size) |
35 self.inputEdit.setMaxLength(size) |
36 self.messageEdit.setPlainText(message) |
36 self.messageEdit.setPlainText(message) |
37 |
37 |
38 tc = self.messageEdit.textCursor() |
38 tc = self.messageEdit.textCursor() |
39 tc.movePosition(QTextCursor.MoveOperation.End) |
39 tc.movePosition(QTextCursor.MoveOperation.End) |
40 self.messageEdit.setTextCursor(tc) |
40 self.messageEdit.setTextCursor(tc) |
41 self.messageEdit.ensureCursorVisible() |
41 self.messageEdit.ensureCursorVisible() |
42 |
42 |
43 self.inputEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
43 self.inputEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
44 |
44 |
45 @pyqtSlot(str) |
45 @pyqtSlot(str) |
46 def on_inputEdit_textChanged(self, txt): |
46 def on_inputEdit_textChanged(self, txt): |
47 """ |
47 """ |
48 Private slot to handle changes of the user input. |
48 Private slot to handle changes of the user input. |
49 |
49 |
50 @param txt text entered by the user (string) |
50 @param txt text entered by the user (string) |
51 """ |
51 """ |
52 self.buttonBox.button( |
52 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) |
53 QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) |
53 |
54 |
|
55 @pyqtSlot(bool) |
54 @pyqtSlot(bool) |
56 def on_passwordCheckBox_toggled(self, isOn): |
55 def on_passwordCheckBox_toggled(self, isOn): |
57 """ |
56 """ |
58 Private slot to handle the password checkbox toggled. |
57 Private slot to handle the password checkbox toggled. |
59 |
58 |
60 @param isOn flag indicating the status of the check box (boolean) |
59 @param isOn flag indicating the status of the check box (boolean) |
61 """ |
60 """ |
62 if isOn: |
61 if isOn: |
63 self.inputEdit.setEchoMode(QLineEdit.EchoMode.Password) |
62 self.inputEdit.setEchoMode(QLineEdit.EchoMode.Password) |
64 else: |
63 else: |
65 self.inputEdit.setEchoMode(QLineEdit.EchoMode.Normal) |
64 self.inputEdit.setEchoMode(QLineEdit.EchoMode.Normal) |
66 |
65 |
67 def getInput(self): |
66 def getInput(self): |
68 """ |
67 """ |
69 Public method to get the user input. |
68 Public method to get the user input. |
70 |
69 |
71 @return user input (string) |
70 @return user input (string) |
72 """ |
71 """ |
73 return self.inputEdit.text() |
72 return self.inputEdit.text() |
74 |
73 |
75 def isPassword(self): |
74 def isPassword(self): |
76 """ |
75 """ |
77 Public method to check, if the input was a password. |
76 Public method to check, if the input was a password. |
78 |
77 |
79 @return flag indicating a password |
78 @return flag indicating a password |
80 @rtype bool |
79 @rtype bool |
81 """ |
80 """ |
82 return self.passwordCheckBox.isChecked() |
81 return self.passwordCheckBox.isChecked() |