|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2017 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter cherry-pick data. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import pyqtSlot |
|
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
14 |
|
15 from .Ui_GitCherryPickDialog import Ui_GitCherryPickDialog |
|
16 |
|
17 |
|
18 class GitCherryPickDialog(QDialog, Ui_GitCherryPickDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter cherry-pick data. |
|
21 """ |
|
22 def __init__(self, commits=None, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param commits list of commits to show in the commits pane (list of |
|
27 strings) |
|
28 @param parent reference to the parent widget (QWidget) |
|
29 """ |
|
30 super(GitCherryPickDialog, self).__init__(parent) |
|
31 self.setupUi(self) |
|
32 |
|
33 if commits: |
|
34 self.commitsEdit.setPlainText("\n".join(commits)) |
|
35 |
|
36 self.on_commitsEdit_textChanged() |
|
37 |
|
38 @pyqtSlot() |
|
39 def on_commitsEdit_textChanged(self): |
|
40 """ |
|
41 Private slot to react upon changes of commits. |
|
42 """ |
|
43 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
44 self.commitsEdit.toPlainText() != "") |
|
45 |
|
46 def getData(self): |
|
47 """ |
|
48 Public method to retrieve the entered data. |
|
49 |
|
50 @return tuple with list of commits, a flag indicating to append |
|
51 cherry-pick info to the commit message, a flag indicating to append |
|
52 a signed-off-by line to the commit message and a flag indicating to |
|
53 not commit the action (list of strings, boolean, boolean, boolean) |
|
54 """ |
|
55 return (self.commitsEdit.toPlainText().strip().splitlines(), |
|
56 self.appendCheckBox.isChecked(), |
|
57 self.signoffCheckBox.isChecked(), |
|
58 self.nocommitCheckBox.isChecked()) |