|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter data for the Mercurial Phase operation. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgPhaseDialog import Ui_HgPhaseDialog |
|
14 |
|
15 |
|
16 class HgPhaseDialog(QDialog, Ui_HgPhaseDialog): |
|
17 """ |
|
18 Class dimplementing a dialog to enter data for the Mercurial Phase |
|
19 operation. |
|
20 """ |
|
21 def __init__(self, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param parent reference to the parent widget (QWidget) |
|
26 """ |
|
27 super().__init__(parent) |
|
28 self.setupUi(self) |
|
29 |
|
30 self.phaseCombo.addItem("", "") |
|
31 self.phaseCombo.addItem(self.tr("Public"), "p") |
|
32 self.phaseCombo.addItem(self.tr("Draft"), "d") |
|
33 self.phaseCombo.addItem(self.tr("Secret"), "s") |
|
34 |
|
35 self.buttonBox.button( |
|
36 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
37 |
|
38 def __updateOk(self): |
|
39 """ |
|
40 Private slot to update the state of the OK button. |
|
41 """ |
|
42 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
|
43 self.revisionsEdit.toPlainText().strip() != "" and |
|
44 self.phaseCombo.currentText().strip() != "") |
|
45 |
|
46 @pyqtSlot() |
|
47 def on_revisionsEdit_textChanged(self): |
|
48 """ |
|
49 Private slot to react upon changes of revisions. |
|
50 """ |
|
51 self.__updateOk() |
|
52 |
|
53 @pyqtSlot(int) |
|
54 def on_phaseCombo_activated(self, index): |
|
55 """ |
|
56 Private slot to react upon changes of the phase. |
|
57 |
|
58 @param index index of the selected entry |
|
59 @type int |
|
60 """ |
|
61 self.__updateOk() |
|
62 |
|
63 def getData(self): |
|
64 """ |
|
65 Public method to retrieve the entered data. |
|
66 |
|
67 @return tuple with list of revisions, phase and a flag indicating |
|
68 a forced operation (list of strings, string, boolean) |
|
69 """ |
|
70 return ( |
|
71 self.revisionsEdit.toPlainText().strip().splitlines(), |
|
72 self.phaseCombo.itemData(self.phaseCombo.currentIndex()), |
|
73 self.forceCheckBox.isChecked() |
|
74 ) |