|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a tagging operation. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_GitTagDialog import Ui_GitTagDialog |
|
14 |
|
15 |
|
16 class GitTagDialog(QDialog, Ui_GitTagDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter the data for a tagging operation. |
|
19 """ |
|
20 CreateTag = 1 |
|
21 DeleteTag = 2 |
|
22 VerifyTag = 3 |
|
23 |
|
24 AnnotatedTag = 1 |
|
25 SignedTag = 2 |
|
26 LocalTag = 3 |
|
27 |
|
28 def __init__(self, taglist, revision=None, tagName=None, parent=None): |
|
29 """ |
|
30 Constructor |
|
31 |
|
32 @param taglist list of previously entered tags (list of strings) |
|
33 @param revision revision to set tag for (string) |
|
34 @param tagName name of the tag (string) |
|
35 @param parent parent widget (QWidget) |
|
36 """ |
|
37 super().__init__(parent) |
|
38 self.setupUi(self) |
|
39 |
|
40 self.okButton = self.buttonBox.button( |
|
41 QDialogButtonBox.StandardButton.Ok) |
|
42 self.okButton.setEnabled(False) |
|
43 |
|
44 self.tagCombo.clear() |
|
45 self.tagCombo.addItem("") |
|
46 self.tagCombo.addItems(sorted(taglist, reverse=True)) |
|
47 |
|
48 if revision: |
|
49 self.revisionEdit.setText(revision) |
|
50 |
|
51 if tagName: |
|
52 index = self.tagCombo.findText(tagName) |
|
53 if index > -1: |
|
54 self.tagCombo.setCurrentIndex(index) |
|
55 # suggest the most relevant tag action |
|
56 self.verifyTagButton.setChecked(True) |
|
57 else: |
|
58 self.tagCombo.setEditText(tagName) |
|
59 self.createTagButton.setChecked(True) |
|
60 |
|
61 msh = self.minimumSizeHint() |
|
62 self.resize(max(self.width(), msh.width()), msh.height()) |
|
63 |
|
64 @pyqtSlot(str) |
|
65 def on_tagCombo_editTextChanged(self, text): |
|
66 """ |
|
67 Private method used to enable/disable the OK-button. |
|
68 |
|
69 @param text tag name entered in the combo (string) |
|
70 """ |
|
71 self.okButton.setDisabled(text == "") |
|
72 |
|
73 def getParameters(self): |
|
74 """ |
|
75 Public method to retrieve the tag data. |
|
76 |
|
77 @return tuple of two strings, two int and a boolean (tag, revision, |
|
78 tag operation, tag type, enforce operation) |
|
79 """ |
|
80 tag = self.tagCombo.currentText().replace(" ", "_") |
|
81 |
|
82 if self.createTagButton.isChecked(): |
|
83 tagOp = GitTagDialog.CreateTag |
|
84 elif self.deleteTagButton.isChecked(): |
|
85 tagOp = GitTagDialog.DeleteTag |
|
86 else: |
|
87 tagOp = GitTagDialog.VerifyTag |
|
88 |
|
89 if self.globalTagButton.isChecked(): |
|
90 tagType = GitTagDialog.AnnotatedTag |
|
91 elif self.signedTagButton.isChecked(): |
|
92 tagType = GitTagDialog.SignedTag |
|
93 else: |
|
94 tagType = GitTagDialog.LocalTag |
|
95 |
|
96 return (tag, self.revisionEdit.text(), tagOp, tagType, |
|
97 self.forceCheckBox.isChecked()) |