Mon, 07 Nov 2022 17:19:58 +0100
Corrected/acknowledged some bad import style and removed some obsolete code.
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8750
diff
changeset
|
3 | # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter the data for a branch operation. |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | from .Ui_HgBranchInputDialog import Ui_HgBranchInputDialog |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | class HgBranchInputDialog(QDialog, Ui_HgBranchInputDialog): |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | Class implementing a dialog to enter the data for a branch operation. |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | def __init__(self, branches, parent=None): |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | @param branches branch names to populate the branch list with |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | (list of string) |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @param parent reference to the parent widget (QWidget) |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
29 | super().__init__(parent) |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
31 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.branchComboBox.addItems(sorted(branches)) |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.branchComboBox.setEditText("") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | |
3366
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3353
diff
changeset
|
37 | msh = self.minimumSizeHint() |
6084bb3c3911
Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3353
diff
changeset
|
38 | self.resize(max(self.width(), msh.width()), msh.height()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @pyqtSlot(str) |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | def on_branchComboBox_editTextChanged(self, txt): |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | Private slot handling a change of the branch name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | @param txt contents of the branch combo box (string) |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
47 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | def getData(self): |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | """ |
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | Public method to get the data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
8750
978bb45ffdcd
Added the '--force' option to the Mercurial branch dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
53 | @return tuple of branch name, a flag indicating to commit the branch |
978bb45ffdcd
Added the '--force' option to the Mercurial branch dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
54 | and a flag indicating to force the branch creation |
978bb45ffdcd
Added the '--force' option to the Mercurial branch dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
55 | @rtype tuple of (str, bool, bool) |
3353
ddc966a494b0
Added capability to commit a new branch directly without the need to select the commit menu entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | return ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | self.branchComboBox.currentText().replace(" ", "_"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | self.commitCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | self.forceCheckBox.isChecked(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | ) |