eric6/Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8176
31965986ecd1
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
36 """ 36 """
37 super(HgDiffDialog, self).__init__(parent) 37 super(HgDiffDialog, self).__init__(parent)
38 self.setupUi(self) 38 self.setupUi(self)
39 39
40 self.refreshButton = self.buttonBox.addButton( 40 self.refreshButton = self.buttonBox.addButton(
41 self.tr("Refresh"), QDialogButtonBox.ActionRole) 41 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
42 self.refreshButton.setToolTip( 42 self.refreshButton.setToolTip(
43 self.tr("Press to refresh the display")) 43 self.tr("Press to refresh the display"))
44 self.refreshButton.setEnabled(False) 44 self.refreshButton.setEnabled(False)
45 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 45 self.buttonBox.button(
46 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 46 QDialogButtonBox.StandardButton.Save).setEnabled(False)
47 self.buttonBox.button(
48 QDialogButtonBox.StandardButton.Close).setDefault(True)
47 49
48 self.searchWidget.attachTextEdit(self.contents) 50 self.searchWidget.attachTextEdit(self.contents)
49 51
50 self.vcs = vcs 52 self.vcs = vcs
51 53
121 if errors: 123 if errors:
122 self.errorGroup.show() 124 self.errorGroup.show()
123 self.errors.setPlainText("".join(errors)) 125 self.errors.setPlainText("".join(errors))
124 self.errors.ensureCursorVisible() 126 self.errors.ensureCursorVisible()
125 127
126 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(bool(diff)) 128 self.buttonBox.button(
127 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 129 QDialogButtonBox.StandardButton.Save).setEnabled(bool(diff))
128 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 130 self.buttonBox.button(
129 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 131 QDialogButtonBox.StandardButton.Close).setEnabled(True)
130 Qt.OtherFocusReason) 132 self.buttonBox.button(
133 QDialogButtonBox.StandardButton.Close).setDefault(True)
134 self.buttonBox.button(
135 QDialogButtonBox.StandardButton.Close).setFocus(
136 Qt.FocusReason.OtherFocusReason)
131 137
132 tc = self.contents.textCursor() 138 tc = self.contents.textCursor()
133 tc.movePosition(QTextCursor.Start) 139 tc.movePosition(QTextCursor.MoveOperation.Start)
134 self.contents.setTextCursor(tc) 140 self.contents.setTextCursor(tc)
135 self.contents.ensureCursorVisible() 141 self.contents.ensureCursorVisible()
136 142
137 self.filesCombo.addItem(self.tr("<Start>"), 0) 143 self.filesCombo.addItem(self.tr("<Start>"), 0)
138 self.filesCombo.addItem(self.tr("<End>"), -1) 144 self.filesCombo.addItem(self.tr("<End>"), -1)
149 """ 155 """
150 Private slot called by a button of the button box clicked. 156 Private slot called by a button of the button box clicked.
151 157
152 @param button button that was clicked (QAbstractButton) 158 @param button button that was clicked (QAbstractButton)
153 """ 159 """
154 if button == self.buttonBox.button(QDialogButtonBox.Save): 160 if button == self.buttonBox.button(
161 QDialogButtonBox.StandardButton.Save
162 ):
155 self.on_saveButton_clicked() 163 self.on_saveButton_clicked()
156 elif button == self.refreshButton: 164 elif button == self.refreshButton:
157 self.on_refreshButton_clicked() 165 self.on_refreshButton_clicked()
158 166
159 @pyqtSlot(int) 167 @pyqtSlot(int)
165 """ 173 """
166 para = self.filesCombo.itemData(index) 174 para = self.filesCombo.itemData(index)
167 175
168 if para == 0: 176 if para == 0:
169 tc = self.contents.textCursor() 177 tc = self.contents.textCursor()
170 tc.movePosition(QTextCursor.Start) 178 tc.movePosition(QTextCursor.MoveOperation.Start)
171 self.contents.setTextCursor(tc) 179 self.contents.setTextCursor(tc)
172 self.contents.ensureCursorVisible() 180 self.contents.ensureCursorVisible()
173 elif para == -1: 181 elif para == -1:
174 tc = self.contents.textCursor() 182 tc = self.contents.textCursor()
175 tc.movePosition(QTextCursor.End) 183 tc.movePosition(QTextCursor.MoveOperation.End)
176 self.contents.setTextCursor(tc) 184 self.contents.setTextCursor(tc)
177 self.contents.ensureCursorVisible() 185 self.contents.ensureCursorVisible()
178 else: 186 else:
179 # step 1: move cursor to end 187 # step 1: move cursor to end
180 tc = self.contents.textCursor() 188 tc = self.contents.textCursor()
181 tc.movePosition(QTextCursor.End) 189 tc.movePosition(QTextCursor.MoveOperation.End)
182 self.contents.setTextCursor(tc) 190 self.contents.setTextCursor(tc)
183 self.contents.ensureCursorVisible() 191 self.contents.ensureCursorVisible()
184 192
185 # step 2: move cursor to desired line 193 # step 2: move cursor to desired line
186 tc = self.contents.textCursor() 194 tc = self.contents.textCursor()
187 delta = tc.blockNumber() - para 195 delta = tc.blockNumber() - para
188 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 196 tc.movePosition(QTextCursor.MoveOperation.PreviousBlock,
197 QTextCursor.MoveMode.MoveAnchor,
189 delta) 198 delta)
190 self.contents.setTextCursor(tc) 199 self.contents.setTextCursor(tc)
191 self.contents.ensureCursorVisible() 200 self.contents.ensureCursorVisible()
192 201
193 @pyqtSlot() 202 @pyqtSlot()
252 @pyqtSlot() 261 @pyqtSlot()
253 def on_refreshButton_clicked(self): 262 def on_refreshButton_clicked(self):
254 """ 263 """
255 Private slot to refresh the display. 264 Private slot to refresh the display.
256 """ 265 """
257 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 266 self.buttonBox.button(
258 267 QDialogButtonBox.StandardButton.Close).setEnabled(False)
259 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 268
269 self.buttonBox.button(
270 QDialogButtonBox.StandardButton.Save).setEnabled(False)
260 self.refreshButton.setEnabled(False) 271 self.refreshButton.setEnabled(False)
261 272
262 self.start(self.filename, refreshable=True) 273 self.start(self.filename, refreshable=True)

eric ide

mercurial