eric6/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignDialog.py

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

eric ide

mercurial