5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to get the data for a new patch. |
7 Module implementing a dialog to get the data for a new patch. |
8 """ |
8 """ |
9 |
9 |
|
10 import enum |
|
11 |
10 from PyQt6.QtCore import QDateTime, pyqtSlot |
12 from PyQt6.QtCore import QDateTime, pyqtSlot |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
12 |
14 |
13 from eric7.EricWidgets.EricApplication import ericApp |
15 from eric7.EricWidgets.EricApplication import ericApp |
14 |
16 |
15 from .Ui_HgQueuesNewPatchDialog import Ui_HgQueuesNewPatchDialog |
17 from .Ui_HgQueuesNewPatchDialog import Ui_HgQueuesNewPatchDialog |
16 |
18 |
17 |
19 |
|
20 class HgQueuesNewPatchDialogMode(enum.Enum): |
|
21 """ |
|
22 Class defining the dialog modes. |
|
23 """ |
|
24 |
|
25 NEW = 0 |
|
26 REFRESH = 1 |
|
27 |
|
28 |
18 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog): |
29 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog): |
19 """ |
30 """ |
20 Class implementing a dialog to get the data for a new patch. |
31 Class implementing a dialog to get the data for a new patch. |
21 """ |
32 """ |
22 |
33 |
23 # TODO: change this to an enum |
|
24 NEW_MODE = 0 |
|
25 REFRESH_MODE = 1 |
|
26 |
|
27 def __init__(self, mode, message="", parent=None): |
34 def __init__(self, mode, message="", parent=None): |
28 """ |
35 """ |
29 Constructor |
36 Constructor |
30 |
37 |
31 @param mode mode of the dialog (HgQueuesNewPatchDialog.NEW_MODE, |
38 @param mode mode of the dialog |
32 HgQueuesNewPatchDialog.REFRESH_MODE) |
39 @type HgQueuesNewPatchDialogMode |
33 @type int |
|
34 @param message text to set as the commit message |
40 @param message text to set as the commit message |
35 @type str |
41 @type str |
36 @param parent reference to the parent widget |
42 @param parent reference to the parent widget |
37 @type QWidget |
43 @type QWidget |
38 @exception ValueError raised to indicate an invalid dialog mode |
44 @exception ValueError raised to indicate an invalid dialog mode |
39 """ |
45 """ |
40 super().__init__(parent) |
46 super().__init__(parent) |
41 self.setupUi(self) |
47 self.setupUi(self) |
42 |
48 |
43 if mode not in ( |
49 if not isinstance(mode, HgQueuesNewPatchDialogMode): |
44 HgQueuesNewPatchDialog.REFRESH_MODE, |
|
45 HgQueuesNewPatchDialog.NEW_MODE, |
|
46 ): |
|
47 raise ValueError("invalid value for mode") |
50 raise ValueError("invalid value for mode") |
48 |
51 |
49 self.__mode = mode |
52 self.__mode = mode |
50 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE: |
53 if self.__mode == HgQueuesNewPatchDialogMode.REFRESH: |
51 self.nameLabel.hide() |
54 self.nameLabel.hide() |
52 self.nameEdit.hide() |
55 self.nameEdit.hide() |
53 |
56 |
54 project = ericApp().getObject("Project") |
57 project = ericApp().getObject("Project") |
55 pwl, pel = project.getProjectDictionaries() |
58 pwl, pel = project.getProjectDictionaries() |
66 """ |
69 """ |
67 Private slot to update the UI. |
70 Private slot to update the UI. |
68 """ |
71 """ |
69 enable = ( |
72 enable = ( |
70 self.messageEdit.toPlainText() != "" |
73 self.messageEdit.toPlainText() != "" |
71 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE |
74 if self.__mode == HgQueuesNewPatchDialogMode.REFRESH |
72 else (self.nameEdit.text() != "" and self.messageEdit.toPlainText() != "") |
75 else (self.nameEdit.text() != "" and self.messageEdit.toPlainText() != "") |
73 ) |
76 ) |
74 if self.userGroup.isChecked(): |
77 if self.userGroup.isChecked(): |
75 enable = enable and ( |
78 enable = enable and ( |
76 self.currentUserCheckBox.isChecked() or self.userEdit.text() != "" |
79 self.currentUserCheckBox.isChecked() or self.userEdit.text() != "" |