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