eric7/Plugins/VcsPlugins/vcsMercurial/HgMergeDialog.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) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a merge operation.
8 """
9
10 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgMergeDialog import Ui_HgMergeDialog
14
15
16 class HgMergeDialog(QDialog, Ui_HgMergeDialog):
17 """
18 Class implementing a dialog to enter the data for a merge operation.
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 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 msh = self.minimumSizeHint()
45 self.resize(max(self.width(), msh.width()), msh.height())
46
47 def __updateOK(self):
48 """
49 Private slot to update the OK button.
50 """
51 enabled = True
52 if self.idButton.isChecked():
53 enabled = self.idEdit.text() != ""
54 elif self.tagButton.isChecked():
55 enabled = self.tagCombo.currentText() != ""
56 elif self.branchButton.isChecked():
57 enabled = self.branchCombo.currentText() != ""
58 elif self.bookmarkButton.isChecked():
59 enabled = self.bookmarkCombo.currentText() != ""
60
61 self.buttonBox.button(
62 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
63
64 @pyqtSlot(bool)
65 def on_idButton_toggled(self, checked):
66 """
67 Private slot to handle changes of the ID select button.
68
69 @param checked state of the button (boolean)
70 """
71 self.__updateOK()
72
73 @pyqtSlot(bool)
74 def on_tagButton_toggled(self, checked):
75 """
76 Private slot to handle changes of the Tag select button.
77
78 @param checked state of the button (boolean)
79 """
80 self.__updateOK()
81
82 @pyqtSlot(bool)
83 def on_branchButton_toggled(self, checked):
84 """
85 Private slot to handle changes of the Branch select button.
86
87 @param checked state of the button (boolean)
88 """
89 self.__updateOK()
90
91 @pyqtSlot(bool)
92 def on_bookmarkButton_toggled(self, checked):
93 """
94 Private slot to handle changes of the Bookmark select button.
95
96 @param checked state of the button (boolean)
97 """
98 self.__updateOK()
99
100 @pyqtSlot(str)
101 def on_idEdit_textChanged(self, txt):
102 """
103 Private slot to handle changes of the ID edit.
104
105 @param txt text of the edit (string)
106 """
107 self.__updateOK()
108
109 @pyqtSlot(str)
110 def on_tagCombo_editTextChanged(self, txt):
111 """
112 Private slot to handle changes of the Tag combo.
113
114 @param txt text of the combo (string)
115 """
116 self.__updateOK()
117
118 @pyqtSlot(str)
119 def on_branchCombo_editTextChanged(self, txt):
120 """
121 Private slot to handle changes of the Branch combo.
122
123 @param txt text of the combo (string)
124 """
125 self.__updateOK()
126
127 @pyqtSlot(str)
128 def on_bookmarkCombo_editTextChanged(self, txt):
129 """
130 Private slot to handle changes of the Bookmark combo.
131
132 @param txt text of the combo (string)
133 """
134 self.__updateOK()
135
136 def getParameters(self):
137 """
138 Public method to retrieve the merge data.
139
140 @return tuple naming the revision and a flag indicating a
141 forced merge (string, boolean)
142 """
143 if self.numberButton.isChecked():
144 rev = "rev({0})".format(self.numberSpinBox.value())
145 elif self.idButton.isChecked():
146 rev = "id({0})".format(self.idEdit.text())
147 elif self.tagButton.isChecked():
148 rev = self.tagCombo.currentText()
149 elif self.branchButton.isChecked():
150 rev = self.branchCombo.currentText()
151 elif self.bookmarkButton.isChecked():
152 rev = self.bookmarkCombo.currentText()
153 else:
154 rev = ""
155
156 return rev, self.forceCheckBox.isChecked()

eric ide

mercurial