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

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 - 2021 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 PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets 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,
21 parent=None):
22 """
23 Constructor
24
25 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings)
27 @param bookmarksList list of bookmarks (list of strings)
28 @param parent reference to the parent widget (QWidget)
29 """
30 super().__init__(parent)
31 self.setupUi(self)
32
33 self.buttonBox.button(
34 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
35
36 self.tagCombo.addItems(sorted(tagsList))
37 self.branchCombo.addItems(["default"] + sorted(branchesList))
38 if bookmarksList is not None:
39 self.bookmarkCombo.addItems(sorted(bookmarksList))
40 else:
41 self.bookmarkButton.setHidden(True)
42 self.bookmarkCombo.setHidden(True)
43
44 def __updateOK(self):
45 """
46 Private slot to update the OK button.
47 """
48 enabled = True
49 if self.idButton.isChecked():
50 enabled = enabled and self.idEdit.text() != ""
51 elif self.tagButton.isChecked():
52 enabled = enabled and self.tagCombo.currentText() != ""
53 elif self.branchButton.isChecked():
54 enabled = enabled and self.branchCombo.currentText() != ""
55 elif self.bookmarkButton.isChecked():
56 enabled = enabled and self.bookmarkCombo.currentText() != ""
57
58 self.buttonBox.button(
59 QDialogButtonBox.StandardButton.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