src/eric7/Plugins/VcsPlugins/vcsMercurial/HgCommitDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
16 16
17 17
18 class HgCommitDialog(QWidget, Ui_HgCommitDialog): 18 class HgCommitDialog(QWidget, Ui_HgCommitDialog):
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, mq, merge, parent=None): 29 def __init__(self, vcs, msg, mq, merge, 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 mq flag indicating a queue commit (boolean) 35 @param mq flag indicating a queue commit (boolean)
35 @param merge flag indicating a merge commit (boolean) 36 @param merge flag indicating a merge commit (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 if mq or merge: 50 if mq or merge:
50 self.amendCheckBox.setVisible(False) 51 self.amendCheckBox.setVisible(False)
51 self.subrepoCheckBox.setVisible(False) 52 self.subrepoCheckBox.setVisible(False)
52 else: 53 else:
53 self.subrepoCheckBox.setVisible(vcs.hasSubrepositories()) 54 self.subrepoCheckBox.setVisible(vcs.hasSubrepositories())
54 55
55 def showEvent(self, evt): 56 def showEvent(self, evt):
56 """ 57 """
57 Protected method called when the dialog is about to be shown. 58 Protected method called when the dialog is about to be shown.
58 59
59 @param evt the event (QShowEvent) 60 @param evt the event (QShowEvent)
60 """ 61 """
61 commitMessages = self.__vcs.vcsCommitMessages() 62 commitMessages = self.__vcs.vcsCommitMessages()
62 self.recentComboBox.clear() 63 self.recentComboBox.clear()
63 self.recentComboBox.addItem("") 64 self.recentComboBox.addItem("")
64 for message in commitMessages: 65 for message in commitMessages:
65 abbrMsg = message[:60] 66 abbrMsg = message[:60]
66 if len(message) > 60: 67 if len(message) > 60:
67 abbrMsg += "..." 68 abbrMsg += "..."
68 self.recentComboBox.addItem(abbrMsg, message) 69 self.recentComboBox.addItem(abbrMsg, message)
69 70
70 commitAuthors = self.__vcs.getPlugin().getPreferences('CommitAuthors') 71 commitAuthors = self.__vcs.getPlugin().getPreferences("CommitAuthors")
71 self.authorComboBox.clear() 72 self.authorComboBox.clear()
72 self.authorComboBox.addItem("") 73 self.authorComboBox.addItem("")
73 self.authorComboBox.addItems(commitAuthors) 74 self.authorComboBox.addItems(commitAuthors)
74 75
75 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime()) 76 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
76 77
77 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason) 78 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason)
78 79
79 def on_buttonBox_clicked(self, button): 80 def on_buttonBox_clicked(self, button):
80 """ 81 """
81 Private slot called by a button of the button box clicked. 82 Private slot called by a button of the button box clicked.
82 83
83 @param button button that was clicked (QAbstractButton) 84 @param button button that was clicked (QAbstractButton)
84 """ 85 """
85 if button == self.buttonBox.button( 86 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
86 QDialogButtonBox.StandardButton.Cancel
87 ):
88 self.logEdit.clear() 87 self.logEdit.clear()
89 88
90 def on_buttonBox_accepted(self): 89 def on_buttonBox_accepted(self):
91 """ 90 """
92 Private slot called by the buttonBox accepted signal. 91 Private slot called by the buttonBox accepted signal.
93 """ 92 """
94 self.close() 93 self.close()
95 self.accepted.emit() 94 self.accepted.emit()
96 95
97 def on_buttonBox_rejected(self): 96 def on_buttonBox_rejected(self):
98 """ 97 """
99 Private slot called by the buttonBox rejected signal. 98 Private slot called by the buttonBox rejected signal.
100 """ 99 """
101 self.close() 100 self.close()
102 self.rejected.emit() 101 self.rejected.emit()
103 102
104 @pyqtSlot(int) 103 @pyqtSlot(int)
105 def on_recentComboBox_activated(self, index): 104 def on_recentComboBox_activated(self, index):
106 """ 105 """
107 Private slot to select a commit message from recent ones. 106 Private slot to select a commit message from recent ones.
108 107
109 @param index index of the selected entry 108 @param index index of the selected entry
110 @type int 109 @type int
111 """ 110 """
112 txt = self.recentComboBox.itemText(index) 111 txt = self.recentComboBox.itemText(index)
113 if txt: 112 if txt:
114 self.logEdit.setPlainText(self.recentComboBox.currentData()) 113 self.logEdit.setPlainText(self.recentComboBox.currentData())
115 114
116 def getCommitData(self): 115 def getCommitData(self):
117 """ 116 """
118 Public method to retrieve the entered data for the commit. 117 Public method to retrieve the entered data for the commit.
119 118
120 @return tuple containing the log message, a flag indicating to amend 119 @return tuple containing the log message, a flag indicating to amend
121 the last commit, a flag indicating to commit subrepositories as 120 the last commit, a flag indicating to commit subrepositories as
122 well, name of the author and date/time of the commit 121 well, name of the author and date/time of the commit
123 @rtype tuple of str, bool, bool, str, str 122 @rtype tuple of str, bool, bool, str, str
124 """ 123 """
125 msg = self.logEdit.toPlainText() 124 msg = self.logEdit.toPlainText()
126 if msg: 125 if msg:
127 self.__vcs.vcsAddCommitMessage(msg) 126 self.__vcs.vcsAddCommitMessage(msg)
128 127
129 author = self.authorComboBox.currentText() 128 author = self.authorComboBox.currentText()
130 if author: 129 if author:
131 commitAuthors = self.__vcs.getPlugin().getPreferences( 130 commitAuthors = self.__vcs.getPlugin().getPreferences("CommitAuthors")
132 'CommitAuthors')
133 if author in commitAuthors: 131 if author in commitAuthors:
134 commitAuthors.remove(author) 132 commitAuthors.remove(author)
135 commitAuthors.insert(0, author) 133 commitAuthors.insert(0, author)
136 no = self.__vcs.getPlugin().getPreferences("CommitAuthorsLimit") 134 no = self.__vcs.getPlugin().getPreferences("CommitAuthorsLimit")
137 del commitAuthors[no:] 135 del commitAuthors[no:]
138 self.__vcs.getPlugin().setPreferences( 136 self.__vcs.getPlugin().setPreferences("CommitAuthors", commitAuthors)
139 'CommitAuthors', commitAuthors) 137
140
141 dateTime = ( 138 dateTime = (
142 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm") 139 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm")
143 if self.dateTimeGroup.isChecked() else 140 if self.dateTimeGroup.isChecked()
144 "" 141 else ""
145 ) 142 )
146 143
147 return ( 144 return (
148 msg, 145 msg,
149 self.amendCheckBox.isChecked(), 146 self.amendCheckBox.isChecked(),
150 self.subrepoCheckBox.isChecked(), 147 self.subrepoCheckBox.isChecked(),
151 author, 148 author,

eric ide

mercurial