|
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 branch operation. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import pyqtSlot |
|
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgBranchInputDialog import Ui_HgBranchInputDialog |
|
14 |
|
15 |
|
16 class HgBranchInputDialog(QDialog, Ui_HgBranchInputDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter the data for a branch operation. |
|
19 """ |
|
20 def __init__(self, branches, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param branches branch names to populate the branch list with |
|
25 (list of string) |
|
26 @param parent reference to the parent widget (QWidget) |
|
27 """ |
|
28 super().__init__(parent) |
|
29 self.setupUi(self) |
|
30 |
|
31 self.branchComboBox.addItems(sorted(branches)) |
|
32 self.branchComboBox.setEditText("") |
|
33 |
|
34 self.buttonBox.button( |
|
35 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
36 |
|
37 msh = self.minimumSizeHint() |
|
38 self.resize(max(self.width(), msh.width()), msh.height()) |
|
39 |
|
40 @pyqtSlot(str) |
|
41 def on_branchComboBox_editTextChanged(self, txt): |
|
42 """ |
|
43 Private slot handling a change of the branch name. |
|
44 |
|
45 @param txt contents of the branch combo box (string) |
|
46 """ |
|
47 self.buttonBox.button( |
|
48 QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) |
|
49 |
|
50 def getData(self): |
|
51 """ |
|
52 Public method to get the data. |
|
53 |
|
54 @return tuple of branch name (string) and a flag indicating to |
|
55 commit the branch (boolean) |
|
56 """ |
|
57 return (self.branchComboBox.currentText().replace(" ", "_"), |
|
58 self.commitCheckBox.isChecked()) |