Sun, 09 Mar 2014 19:04:42 +0100
Added capability to commit a new branch directly without the need to select the commit menu entry.
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 | |
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
|
3 | # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de> |
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 | |
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
|
10 | from PyQt4.QtCore import pyqtSlot |
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
|
11 | from PyQt4.QtGui import QDialog, QDialogButtonBox |
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 | """ |
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
|
20 | 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
|
21 | """ |
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 | Constructor |
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 | |
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
|
24 | @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
|
25 | (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
|
26 | @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
|
27 | """ |
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 | super().__init__(parent) |
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
|
29 | self.setupUi(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
|
30 | |
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
|
31 | 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
|
32 | self.branchComboBox.setEditText("") |
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 | |
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
|
34 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
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
|
35 | |
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
|
36 | self.resize(self.width(), self.minimumSizeHint().height()) |
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
|
37 | |
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
|
38 | @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
|
39 | 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
|
40 | """ |
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 | Private slot handling a change of the branch name. |
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 | @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
|
44 | """ |
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 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(bool(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
|
46 | |
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
|
47 | 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
|
48 | """ |
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 | Public method to get the data. |
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 | @return tuple of branch name (string) and a flag indicating to |
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
|
52 | commit the branch (boolean) |
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
|
53 | """ |
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
|
54 | return (self.branchComboBox.currentText(), |
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
|
55 | self.commitCheckBox.isChecked()) |