|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a prompt dialog for the Mercurial command server. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox, QTextCursor |
|
12 |
|
13 from .Ui_HgClientPromptDialog import Ui_HgClientPromptDialog |
|
14 |
|
15 |
|
16 class HgClientPromptDialog(QDialog, Ui_HgClientPromptDialog): |
|
17 """ |
|
18 Class implementing a prompt dialog for the Mercurial command server. |
|
19 """ |
|
20 def __init__(self, size, message, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param size maximum length of the requested input (integer) |
|
25 @param message message sent by the server (string) |
|
26 @param parent reference to the parent widget (QWidget) |
|
27 """ |
|
28 super().__init__(parent) |
|
29 self.setupUi(self) |
|
30 |
|
31 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
32 |
|
33 self.inputEdit.setMaxLength(size) |
|
34 self.messageEdit.setPlainText(message) |
|
35 |
|
36 tc = self.messageEdit.textCursor() |
|
37 tc.movePosition(QTextCursor.End) |
|
38 self.messageEdit.setTextCursor(tc) |
|
39 self.messageEdit.ensureCursorVisible() |
|
40 |
|
41 @pyqtSlot(str) |
|
42 def on_inputEdit_textChanged(self, txt): |
|
43 """ |
|
44 Private slot to handle changes of the user input. |
|
45 |
|
46 @param txt text entered by the user (string) |
|
47 """ |
|
48 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(txt)) |
|
49 |
|
50 def getInput(self): |
|
51 """ |
|
52 Public method to get the user input. |
|
53 |
|
54 @return user input (string) |
|
55 """ |
|
56 return self.inputEdit.text() |