src/eric7/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
17 17
18 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog): 18 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog):
19 """ 19 """
20 Class implementing a dialog to get the data for a new patch. 20 Class implementing a dialog to get the data for a new patch.
21 """ 21 """
22
22 NEW_MODE = 0 23 NEW_MODE = 0
23 REFRESH_MODE = 1 24 REFRESH_MODE = 1
24 25
25 def __init__(self, mode, message="", parent=None): 26 def __init__(self, mode, message="", parent=None):
26 """ 27 """
27 Constructor 28 Constructor
28 29
29 @param mode mode of the dialog (HgQueuesNewPatchDialog.NEW_MODE, 30 @param mode mode of the dialog (HgQueuesNewPatchDialog.NEW_MODE,
30 HgQueuesNewPatchDialog.REFRESH_MODE) 31 HgQueuesNewPatchDialog.REFRESH_MODE)
31 @param message text to set as the commit message (string) 32 @param message text to set as the commit message (string)
32 @param parent reference to the parent widget (QWidget) 33 @param parent reference to the parent widget (QWidget)
33 @exception ValueError raised to indicate an invalid dialog mode 34 @exception ValueError raised to indicate an invalid dialog mode
34 """ 35 """
35 super().__init__(parent) 36 super().__init__(parent)
36 self.setupUi(self) 37 self.setupUi(self)
37 38
38 if mode not in (HgQueuesNewPatchDialog.REFRESH_MODE, 39 if mode not in (
39 HgQueuesNewPatchDialog.NEW_MODE): 40 HgQueuesNewPatchDialog.REFRESH_MODE,
41 HgQueuesNewPatchDialog.NEW_MODE,
42 ):
40 raise ValueError("invalid value for mode") 43 raise ValueError("invalid value for mode")
41 44
42 self.__mode = mode 45 self.__mode = mode
43 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE: 46 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE:
44 self.nameLabel.hide() 47 self.nameLabel.hide()
45 self.nameEdit.hide() 48 self.nameEdit.hide()
46 49
47 project = ericApp().getObject("Project") 50 project = ericApp().getObject("Project")
48 pwl, pel = project.getProjectDictionaries() 51 pwl, pel = project.getProjectDictionaries()
49 language = project.getProjectSpellLanguage() 52 language = project.getProjectSpellLanguage()
50 self.messageEdit.setLanguageWithPWL( 53 self.messageEdit.setLanguageWithPWL(language, pwl or None, pel or None)
51 language, pwl or None, pel or None)
52 if message: 54 if message:
53 self.messageEdit.setPlainText(message) 55 self.messageEdit.setPlainText(message)
54 56
55 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime()) 57 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
56 58
57 self.__updateUI() 59 self.__updateUI()
58 60
59 def __updateUI(self): 61 def __updateUI(self):
60 """ 62 """
61 Private slot to update the UI. 63 Private slot to update the UI.
62 """ 64 """
63 enable = ( 65 enable = (
64 self.messageEdit.toPlainText() != "" 66 self.messageEdit.toPlainText() != ""
65 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE else 67 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE
66 (self.nameEdit.text() != "" and 68 else (self.nameEdit.text() != "" and self.messageEdit.toPlainText() != "")
67 self.messageEdit.toPlainText() != "")
68 ) 69 )
69 if self.userGroup.isChecked(): 70 if self.userGroup.isChecked():
70 enable = ( 71 enable = enable and (
71 enable and 72 self.currentUserCheckBox.isChecked() or self.userEdit.text() != ""
72 (self.currentUserCheckBox.isChecked() or
73 self.userEdit.text() != "")
74 ) 73 )
75 74
76 self.buttonBox.button( 75 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
77 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) 76
78
79 @pyqtSlot(str) 77 @pyqtSlot(str)
80 def on_nameEdit_textChanged(self, txt): 78 def on_nameEdit_textChanged(self, txt):
81 """ 79 """
82 Private slot to handle changes of the patch name. 80 Private slot to handle changes of the patch name.
83 81
84 @param txt text of the edit (string) 82 @param txt text of the edit (string)
85 """ 83 """
86 self.__updateUI() 84 self.__updateUI()
87 85
88 @pyqtSlot() 86 @pyqtSlot()
89 def on_messageEdit_textChanged(self): 87 def on_messageEdit_textChanged(self):
90 """ 88 """
91 Private slot to handle changes of the patch message. 89 Private slot to handle changes of the patch message.
92 """ 90 """
93 self.__updateUI() 91 self.__updateUI()
94 92
95 @pyqtSlot(bool) 93 @pyqtSlot(bool)
96 def on_userGroup_toggled(self, checked): 94 def on_userGroup_toggled(self, checked):
97 """ 95 """
98 Private slot to handle changes of the user group state. 96 Private slot to handle changes of the user group state.
99 97
100 @param checked flag giving the checked state (boolean) 98 @param checked flag giving the checked state (boolean)
101 """ 99 """
102 self.__updateUI() 100 self.__updateUI()
103 101
104 @pyqtSlot(bool) 102 @pyqtSlot(bool)
105 def on_currentUserCheckBox_toggled(self, checked): 103 def on_currentUserCheckBox_toggled(self, checked):
106 """ 104 """
107 Private slot to handle changes of the currentuser state. 105 Private slot to handle changes of the currentuser state.
108 106
109 @param checked flag giving the checked state (boolean) 107 @param checked flag giving the checked state (boolean)
110 """ 108 """
111 self.__updateUI() 109 self.__updateUI()
112 110
113 @pyqtSlot(str) 111 @pyqtSlot(str)
114 def on_userEdit_textChanged(self, txt): 112 def on_userEdit_textChanged(self, txt):
115 """ 113 """
116 Private slot to handle changes of the user name. 114 Private slot to handle changes of the user name.
117 115
118 @param txt text of the edit (string) 116 @param txt text of the edit (string)
119 """ 117 """
120 self.__updateUI() 118 self.__updateUI()
121 119
122 def getData(self): 120 def getData(self):
123 """ 121 """
124 Public method to retrieve the entered data. 122 Public method to retrieve the entered data.
125 123
126 @return tuple giving the patch name and message, a tuple giving a 124 @return tuple giving the patch name and message, a tuple giving a
127 flag indicating to set the user, a flag indicating to use the 125 flag indicating to set the user, a flag indicating to use the
128 current user and the user name and another tuple giving a flag 126 current user and the user name and another tuple giving a flag
129 indicating to set the date, a flag indicating to use the 127 indicating to set the date, a flag indicating to use the
130 current date and the date (string, string, (boolean, boolean, 128 current date and the date (string, string, (boolean, boolean,
131 string), (boolean, boolean, string)) 129 string), (boolean, boolean, string))
132 """ 130 """
133 userData = (self.userGroup.isChecked(), 131 userData = (
134 self.currentUserCheckBox.isChecked(), 132 self.userGroup.isChecked(),
135 self.userEdit.text()) 133 self.currentUserCheckBox.isChecked(),
136 dateData = (self.dateGroup.isChecked(), 134 self.userEdit.text(),
137 self.currentDateCheckBox.isChecked(), 135 )
138 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm")) 136 dateData = (
139 return (self.nameEdit.text().replace(" ", "_"), 137 self.dateGroup.isChecked(),
140 self.messageEdit.toPlainText(), userData, dateData) 138 self.currentDateCheckBox.isChecked(),
139 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"),
140 )
141 return (
142 self.nameEdit.text().replace(" ", "_"),
143 self.messageEdit.toPlainText(),
144 userData,
145 dateData,
146 )

eric ide

mercurial