eric6/Plugins/VcsPlugins/vcsMercurial/HgClientPromptDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a prompt dialog for the Mercurial command server.
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4475
dde2aa51ac0b Changed the Mercurial client prompt dialog such, that the input edit has focus initially.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4471
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
11 from PyQt5.QtGui import QTextCursor
4471
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QLineEdit
1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_HgClientPromptDialog import Ui_HgClientPromptDialog
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class HgClientPromptDialog(QDialog, Ui_HgClientPromptDialog):
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a prompt dialog for the Mercurial command server.
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def __init__(self, size, message, parent=None):
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param size maximum length of the requested input (integer)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param message message sent by the server (string)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param parent reference to the parent widget (QWidget)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
29 super(HgClientPromptDialog, self).__init__(parent)
1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 self.setupUi(self)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.inputEdit.setMaxLength(size)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.messageEdit.setPlainText(message)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 tc = self.messageEdit.textCursor()
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 tc.movePosition(QTextCursor.End)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.messageEdit.setTextCursor(tc)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.messageEdit.ensureCursorVisible()
4475
dde2aa51ac0b Changed the Mercurial client prompt dialog such, that the input edit has focus initially.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4471
diff changeset
41
dde2aa51ac0b Changed the Mercurial client prompt dialog such, that the input edit has focus initially.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4471
diff changeset
42 self.inputEdit.setFocus(Qt.OtherFocusReason)
1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @pyqtSlot(str)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 def on_inputEdit_textChanged(self, txt):
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 Private slot to handle changes of the user input.
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 @param txt text entered by the user (string)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt))
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
4471
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
53 @pyqtSlot(bool)
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
54 def on_passwordCheckBox_toggled(self, isOn):
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
55 """
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
56 Private slot to handle the password checkbox toggled.
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
57
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
58 @param isOn flag indicating the status of the check box (boolean)
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
59 """
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
60 if isOn:
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
61 self.inputEdit.setEchoMode(QLineEdit.Password)
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
62 else:
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
63 self.inputEdit.setEchoMode(QLineEdit.Normal)
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
64
1323
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def getInput(self):
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Public method to get the user input.
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @return user input (string)
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
3126121aeb4f Added a prompt window for the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 return self.inputEdit.text()
4471
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
72
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
73 def isPassword(self):
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
74 """
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
75 Public method to check, if the input was a password.
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
76
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
77 @return flag indicating a password
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
78 @rtype bool
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
79 """
2dedc0c4a8fa Fixed an issue causing a password being entered in visible and shown in the output of the Mercurial command server client.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
80 return self.passwordCheckBox.isChecked()

eric ide

mercurial