|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 - 2022 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 PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from EricWidgets.EricApplication import ericApp |
|
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 |
|
28 @type list of str |
|
29 @param branchesList list of branches |
|
30 @type list of str |
|
31 @param bookmarksList list of bookmarks |
|
32 @type list of str |
|
33 @param parent parent widget |
|
34 @type QWidget |
|
35 """ |
|
36 super().__init__(parent) |
|
37 self.setupUi(self) |
|
38 |
|
39 self.buttonBox.button( |
|
40 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
41 |
|
42 project = ericApp().getObject("Project") |
|
43 pwl, pel = project.getProjectDictionaries() |
|
44 language = project.getProjectSpellLanguage() |
|
45 self.messageEdit.setLanguageWithPWL( |
|
46 language, pwl or None, pel or None) |
|
47 |
|
48 self.tagCombo.addItems(sorted(tagsList)) |
|
49 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
|
50 if bookmarksList is not None: |
|
51 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
|
52 else: |
|
53 self.bookmarkButton.setHidden(True) |
|
54 self.bookmarkCombo.setHidden(True) |
|
55 |
|
56 # connect various radio buttons and input fields |
|
57 self.idButton.toggled.connect(self.__updateOK) |
|
58 self.tagButton.toggled.connect(self.__updateOK) |
|
59 self.branchButton.toggled.connect(self.__updateOK) |
|
60 self.bookmarkButton.toggled.connect(self.__updateOK) |
|
61 self.expressionButton.toggled.connect(self.__updateOK) |
|
62 |
|
63 self.idEdit.textChanged.connect(self.__updateOK) |
|
64 self.expressionEdit.textChanged.connect(self.__updateOK) |
|
65 |
|
66 self.tagCombo.editTextChanged.connect(self.__updateOK) |
|
67 self.branchCombo.editTextChanged.connect(self.__updateOK) |
|
68 self.bookmarkCombo.editTextChanged.connect(self.__updateOK) |
|
69 |
|
70 @pyqtSlot() |
|
71 def __updateOK(self): |
|
72 """ |
|
73 Private slot to update the OK button. |
|
74 """ |
|
75 enabled = True |
|
76 if self.idButton.isChecked(): |
|
77 enabled = enabled and self.idEdit.text() != "" |
|
78 elif self.tagButton.isChecked(): |
|
79 enabled = enabled and self.tagCombo.currentText() != "" |
|
80 elif self.branchButton.isChecked(): |
|
81 enabled = enabled and self.branchCombo.currentText() != "" |
|
82 elif self.bookmarkButton.isChecked(): |
|
83 enabled = enabled and self.bookmarkCombo.currentText() != "" |
|
84 elif self.expressionButton.isChecked(): |
|
85 enabled = enabled and bool(self.expressionEdit.text()) |
|
86 |
|
87 self.buttonBox.button( |
|
88 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
|
89 |
|
90 def getData(self): |
|
91 """ |
|
92 Public method to retrieve the entered data. |
|
93 |
|
94 @return tuple giving the revision, a flag indicating not to commit |
|
95 the signature, a commit message, an ID of the key to be used, |
|
96 a flag indicating a local signature and a flag indicating a forced |
|
97 signature |
|
98 @rtype tuple of (str, bool, str, str, bool, bool) |
|
99 """ |
|
100 if self.numberButton.isChecked(): |
|
101 rev = str(self.numberSpinBox.value()) |
|
102 elif self.idButton.isChecked(): |
|
103 rev = self.idEdit.text() |
|
104 elif self.tagButton.isChecked(): |
|
105 rev = self.tagCombo.currentText() |
|
106 elif self.branchButton.isChecked(): |
|
107 rev = self.branchCombo.currentText() |
|
108 elif self.bookmarkButton.isChecked(): |
|
109 rev = self.bookmarkCombo.currentText() |
|
110 elif self.expressionButton.isChecked(): |
|
111 rev = self.expressionEdit.text() |
|
112 else: |
|
113 rev = "" |
|
114 |
|
115 return ( |
|
116 rev, |
|
117 self.nocommitCheckBox.isChecked(), |
|
118 self.messageEdit.toPlainText(), |
|
119 self.keyEdit.text(), |
|
120 self.localCheckBox.isChecked(), |
|
121 self.forceCheckBox.isChecked() |
|
122 ) |