16 |
16 |
17 |
17 |
18 class GitCommitDialog(QWidget, Ui_GitCommitDialog): |
18 class GitCommitDialog(QWidget, Ui_GitCommitDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to enter the commit message. |
20 Class implementing a dialog to enter the commit message. |
21 |
21 |
22 @signal accepted() emitted, if the dialog was accepted |
22 @signal accepted() emitted, if the dialog was accepted |
23 @signal rejected() emitted, if the dialog was rejected |
23 @signal rejected() emitted, if the dialog was rejected |
24 """ |
24 """ |
|
25 |
25 accepted = pyqtSignal() |
26 accepted = pyqtSignal() |
26 rejected = pyqtSignal() |
27 rejected = pyqtSignal() |
27 |
28 |
28 def __init__(self, vcs, msg, amend, commitAll, parent=None): |
29 def __init__(self, vcs, msg, amend, commitAll, parent=None): |
29 """ |
30 """ |
30 Constructor |
31 Constructor |
31 |
32 |
32 @param vcs reference to the vcs object |
33 @param vcs reference to the vcs object |
33 @param msg initial message (string) |
34 @param msg initial message (string) |
34 @param amend flag indicating to amend the HEAD commit (boolean) |
35 @param amend flag indicating to amend the HEAD commit (boolean) |
35 @param commitAll flag indicating to commit all local changes (boolean) |
36 @param commitAll flag indicating to commit all local changes (boolean) |
36 @param parent parent widget (QWidget) |
37 @param parent parent widget (QWidget) |
37 """ |
38 """ |
38 super().__init__(parent, Qt.WindowType.Window) |
39 super().__init__(parent, Qt.WindowType.Window) |
39 self.setupUi(self) |
40 self.setupUi(self) |
40 |
41 |
41 self.__vcs = vcs |
42 self.__vcs = vcs |
42 |
43 |
43 project = ericApp().getObject("Project") |
44 project = ericApp().getObject("Project") |
44 pwl, pel = project.getProjectDictionaries() |
45 pwl, pel = project.getProjectDictionaries() |
45 language = project.getProjectSpellLanguage() |
46 language = project.getProjectSpellLanguage() |
46 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None) |
47 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None) |
47 self.logEdit.setPlainText(msg) |
48 self.logEdit.setPlainText(msg) |
48 |
49 |
49 self.amendCheckBox.setChecked(amend) |
50 self.amendCheckBox.setChecked(amend) |
50 self.stagedCheckBox.setChecked(not commitAll) |
51 self.stagedCheckBox.setChecked(not commitAll) |
51 |
52 |
52 def showEvent(self, evt): |
53 def showEvent(self, evt): |
53 """ |
54 """ |
54 Protected method called when the dialog is about to be shown. |
55 Protected method called when the dialog is about to be shown. |
55 |
56 |
56 @param evt the event (QShowEvent) |
57 @param evt the event (QShowEvent) |
57 """ |
58 """ |
58 commitMessages = self.__vcs.vcsCommitMessages() |
59 commitMessages = self.__vcs.vcsCommitMessages() |
59 self.recentComboBox.clear() |
60 self.recentComboBox.clear() |
60 self.recentComboBox.addItem("") |
61 self.recentComboBox.addItem("") |
61 for message in commitMessages: |
62 for message in commitMessages: |
62 abbrMsg = message[:60] |
63 abbrMsg = message[:60] |
63 if len(message) > 60: |
64 if len(message) > 60: |
64 abbrMsg += "..." |
65 abbrMsg += "..." |
65 self.recentComboBox.addItem(abbrMsg, message) |
66 self.recentComboBox.addItem(abbrMsg, message) |
66 |
67 |
67 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
68 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
68 |
69 |
69 def logMessage(self): |
70 def logMessage(self): |
70 """ |
71 """ |
71 Public method to retrieve the log message. |
72 Public method to retrieve the log message. |
72 |
73 |
73 @return the log message (string) |
74 @return the log message (string) |
74 """ |
75 """ |
75 msg = self.logEdit.toPlainText() |
76 msg = self.logEdit.toPlainText() |
76 if msg: |
77 if msg: |
77 self.__vcs.vcsAddCommitMessage(msg) |
78 self.__vcs.vcsAddCommitMessage(msg) |
78 |
79 |
79 return msg |
80 return msg |
80 |
81 |
81 def stagedOnly(self): |
82 def stagedOnly(self): |
82 """ |
83 """ |
83 Public method to retrieve the state of the staged only flag. |
84 Public method to retrieve the state of the staged only flag. |
84 |
85 |
85 @return state of the staged only flag (boolean) |
86 @return state of the staged only flag (boolean) |
86 """ |
87 """ |
87 return self.stagedCheckBox.isChecked() |
88 return self.stagedCheckBox.isChecked() |
88 |
89 |
89 def amend(self): |
90 def amend(self): |
90 """ |
91 """ |
91 Public method to retrieve the state of the amend flag. |
92 Public method to retrieve the state of the amend flag. |
92 |
93 |
93 @return state of the amend flag (boolean) |
94 @return state of the amend flag (boolean) |
94 """ |
95 """ |
95 return self.amendCheckBox.isChecked() |
96 return self.amendCheckBox.isChecked() |
96 |
97 |
97 def resetAuthor(self): |
98 def resetAuthor(self): |
98 """ |
99 """ |
99 Public method to retrieve the state of the reset author flag. |
100 Public method to retrieve the state of the reset author flag. |
100 |
101 |
101 @return state of the reset author flag (boolean) |
102 @return state of the reset author flag (boolean) |
102 """ |
103 """ |
103 return self.resetAuthorCheckBox.isChecked() |
104 return self.resetAuthorCheckBox.isChecked() |
104 |
105 |
105 def on_buttonBox_clicked(self, button): |
106 def on_buttonBox_clicked(self, button): |
106 """ |
107 """ |
107 Private slot called by a button of the button box clicked. |
108 Private slot called by a button of the button box clicked. |
108 |
109 |
109 @param button button that was clicked (QAbstractButton) |
110 @param button button that was clicked (QAbstractButton) |
110 """ |
111 """ |
111 if button == self.buttonBox.button( |
112 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel): |
112 QDialogButtonBox.StandardButton.Cancel |
|
113 ): |
|
114 self.logEdit.clear() |
113 self.logEdit.clear() |
115 |
114 |
116 def on_buttonBox_accepted(self): |
115 def on_buttonBox_accepted(self): |
117 """ |
116 """ |
118 Private slot called by the buttonBox accepted signal. |
117 Private slot called by the buttonBox accepted signal. |
119 """ |
118 """ |
120 self.close() |
119 self.close() |
121 self.accepted.emit() |
120 self.accepted.emit() |
122 |
121 |
123 def on_buttonBox_rejected(self): |
122 def on_buttonBox_rejected(self): |
124 """ |
123 """ |
125 Private slot called by the buttonBox rejected signal. |
124 Private slot called by the buttonBox rejected signal. |
126 """ |
125 """ |
127 self.close() |
126 self.close() |
128 self.rejected.emit() |
127 self.rejected.emit() |
129 |
128 |
130 @pyqtSlot(int) |
129 @pyqtSlot(int) |
131 def on_recentComboBox_activated(self, index): |
130 def on_recentComboBox_activated(self, index): |
132 """ |
131 """ |
133 Private slot to select a commit message from recent ones. |
132 Private slot to select a commit message from recent ones. |
134 |
133 |
135 @param index index of the selected entry |
134 @param index index of the selected entry |
136 @type int |
135 @type int |
137 """ |
136 """ |
138 txt = self.recentComboBox.itemText(index) |
137 txt = self.recentComboBox.itemText(index) |
139 if txt: |
138 if txt: |