|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter data for signing a revision. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgGpgSignDialog import Ui_HgGpgSignDialog |
|
14 |
|
15 |
|
16 class HgGpgSignDialog(QDialog, Ui_HgGpgSignDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter data for signing a revision. |
|
19 """ |
|
20 def __init__(self, tagsList, branchesList, bookmarksList=None, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param tagsList list of tags (list of strings) |
|
25 @param branchesList list of branches (list of strings) |
|
26 @param bookmarksList list of bookmarks (list of strings) |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 QDialog.__init__(self, parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
33 |
|
34 self.tagCombo.addItems(sorted(tagsList)) |
|
35 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
|
36 if bookmarksList is not None: |
|
37 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
|
38 else: |
|
39 self.bookmarkButton.setHidden(True) |
|
40 self.bookmarkCombo.setHidden(True) |
|
41 |
|
42 def __updateOK(self): |
|
43 """ |
|
44 Private slot to update the OK button. |
|
45 """ |
|
46 enabled = True |
|
47 if self.idButton.isChecked(): |
|
48 enabled = enabled and self.idEdit.text() != "" |
|
49 elif self.tagButton.isChecked(): |
|
50 enabled = enabled and self.tagCombo.currentText() != "" |
|
51 elif self.branchButton.isChecked(): |
|
52 enabled = enabled and self.branchCombo.currentText() != "" |
|
53 elif self.bookmarkButton.isChecked(): |
|
54 enabled = enabled and self.bookmarkCombo.currentText() != "" |
|
55 |
|
56 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
|
57 |
|
58 @pyqtSlot(bool) |
|
59 def on_idButton_toggled(self, checked): |
|
60 """ |
|
61 Private slot to handle changes of the ID select button. |
|
62 |
|
63 @param checked state of the button (boolean) |
|
64 """ |
|
65 self.__updateOK() |
|
66 |
|
67 @pyqtSlot(bool) |
|
68 def on_tagButton_toggled(self, checked): |
|
69 """ |
|
70 Private slot to handle changes of the Tag select button. |
|
71 |
|
72 @param checked state of the button (boolean) |
|
73 """ |
|
74 self.__updateOK() |
|
75 |
|
76 @pyqtSlot(bool) |
|
77 def on_branchButton_toggled(self, checked): |
|
78 """ |
|
79 Private slot to handle changes of the Branch select button. |
|
80 |
|
81 @param checked state of the button (boolean) |
|
82 """ |
|
83 self.__updateOK() |
|
84 |
|
85 @pyqtSlot(bool) |
|
86 def on_bookmarkButton_toggled(self, checked): |
|
87 """ |
|
88 Private slot to handle changes of the Bookmark select button. |
|
89 |
|
90 @param checked state of the button (boolean) |
|
91 """ |
|
92 self.__updateOK() |
|
93 |
|
94 @pyqtSlot(str) |
|
95 def on_idEdit_textChanged(self, txt): |
|
96 """ |
|
97 Private slot to handle changes of the ID edit. |
|
98 |
|
99 @param txt text of the edit (string) |
|
100 """ |
|
101 self.__updateOK() |
|
102 |
|
103 @pyqtSlot(str) |
|
104 def on_tagCombo_editTextChanged(self, txt): |
|
105 """ |
|
106 Private slot to handle changes of the Tag combo. |
|
107 |
|
108 @param txt text of the combo (string) |
|
109 """ |
|
110 self.__updateOK() |
|
111 |
|
112 @pyqtSlot(str) |
|
113 def on_branchCombo_editTextChanged(self, txt): |
|
114 """ |
|
115 Private slot to handle changes of the Branch combo. |
|
116 |
|
117 @param txt text of the combo (string) |
|
118 """ |
|
119 self.__updateOK() |
|
120 |
|
121 @pyqtSlot(str) |
|
122 def on_bookmarkCombo_editTextChanged(self, txt): |
|
123 """ |
|
124 Private slot to handle changes of the Bookmark combo. |
|
125 |
|
126 @param txt text of the combo (string) |
|
127 """ |
|
128 self.__updateOK() |
|
129 |
|
130 def getData(self): |
|
131 """ |
|
132 Public method to retrieve the entered data. |
|
133 |
|
134 @return tuple giving the revision, a flag indicating not to commit |
|
135 the signature, a commit message, an ID of the key to be used, |
|
136 a flag indicating a local signature and a flag indicating a forced |
|
137 signature (string, boolean, string, string, boolean, boolean) |
|
138 """ |
|
139 if self.numberButton.isChecked(): |
|
140 rev = str(self.numberSpinBox.value()) |
|
141 elif self.idButton.isChecked(): |
|
142 rev = self.idEdit.text() |
|
143 elif self.tagButton.isChecked(): |
|
144 rev = self.tagCombo.currentText() |
|
145 elif self.branchButton.isChecked(): |
|
146 rev = self.branchCombo.currentText() |
|
147 elif self.bookmarkButton.isChecked(): |
|
148 rev = self.bookmarkCombo.currentText() |
|
149 else: |
|
150 rev = "" |
|
151 |
|
152 return ( |
|
153 rev, |
|
154 self.nocommitCheckBox.isChecked(), |
|
155 self.messageEdit.toPlainText(), |
|
156 self.keyEdit.text(), |
|
157 self.localCheckBox.isChecked(), |
|
158 self.forceCheckBox.isChecked() |
|
159 ) |