51 sliding widget (defaults to False) |
51 sliding widget (defaults to False) |
52 @type bool (optional) |
52 @type bool (optional) |
53 """ |
53 """ |
54 super().__init__(parent) |
54 super().__init__(parent) |
55 self.setupUi(self) |
55 self.setupUi(self) |
|
56 |
|
57 self.layout().setContentsMargins(1, 1, 1, 1) |
56 |
58 |
57 self.__viewmanager = vm |
59 self.__viewmanager = vm |
58 self.__isMiniEditor = vm is parent |
60 self.__isMiniEditor = vm is parent |
59 self.__sliding = sliding |
61 self.__sliding = sliding |
60 if sliding: |
62 if sliding: |
149 |
151 |
150 self.replacetextCombo.installEventFilter(self) |
152 self.replacetextCombo.installEventFilter(self) |
151 |
153 |
152 self.__findtextComboStyleSheet = self.findtextCombo.styleSheet() |
154 self.__findtextComboStyleSheet = self.findtextCombo.styleSheet() |
153 |
155 |
|
156 self.modeToggleButton.clicked.connect(self.__toggleReplaceMode) |
|
157 |
154 # define actions |
158 # define actions |
|
159 self.modeToggleAct = EricAction( |
|
160 self.tr("Toggle Mode"), |
|
161 self.tr("Toggle Mode"), |
|
162 0, |
|
163 0, |
|
164 self, |
|
165 "search_widget_togle_mode", |
|
166 ) |
|
167 self.modeToggleAct.triggered.connect(self.__toggleReplaceMode) |
|
168 self.modeToggleAct.setShortcutContext( |
|
169 Qt.ShortcutContext.WidgetWithChildrenShortcut |
|
170 ) |
|
171 |
155 self.findNextAct = EricAction( |
172 self.findNextAct = EricAction( |
156 self.tr("Find Next"), |
173 self.tr("Find Next"), |
157 self.tr("Find Next"), |
174 self.tr("Find Next"), |
158 0, |
175 0, |
159 0, |
176 0, |
218 self.replaceAllAct.setEnabled(False) |
235 self.replaceAllAct.setEnabled(False) |
219 self.replaceAllAct.setShortcutContext( |
236 self.replaceAllAct.setShortcutContext( |
220 Qt.ShortcutContext.WidgetWithChildrenShortcut |
237 Qt.ShortcutContext.WidgetWithChildrenShortcut |
221 ) |
238 ) |
222 |
239 |
|
240 self.addAction(self.modeToggleAct) |
223 self.addAction(self.findNextAct) |
241 self.addAction(self.findNextAct) |
224 self.addAction(self.findPrevAct) |
242 self.addAction(self.findPrevAct) |
225 self.addAction(self.replaceAndSearchAct) |
243 self.addAction(self.replaceAndSearchAct) |
226 self.addAction(self.replaceSelectionAct) |
244 self.addAction(self.replaceSelectionAct) |
227 self.addAction(self.replaceAllAct) |
245 self.addAction(self.replaceAllAct) |
278 """ |
296 """ |
279 Private method to set the local action's shortcuts to the same key |
297 Private method to set the local action's shortcuts to the same key |
280 sequences as in the view manager. |
298 sequences as in the view manager. |
281 """ |
299 """ |
282 if not self.__isMiniEditor: |
300 if not self.__isMiniEditor: |
|
301 if self.__replaceMode: |
|
302 self.modeToggleAct.setShortcuts( |
|
303 self.__viewmanager.searchAct.shortcuts() |
|
304 ) |
|
305 else: |
|
306 self.modeToggleAct.setShortcuts( |
|
307 self.__viewmanager.replaceAct.shortcuts() |
|
308 ) |
283 self.findNextAct.setShortcuts(self.__viewmanager.searchNextAct.shortcuts()) |
309 self.findNextAct.setShortcuts(self.__viewmanager.searchNextAct.shortcuts()) |
284 self.findPrevAct.setShortcuts(self.__viewmanager.searchPrevAct.shortcuts()) |
310 self.findPrevAct.setShortcuts(self.__viewmanager.searchPrevAct.shortcuts()) |
285 |
311 |
286 self.replaceAndSearchAct.setShortcuts( |
312 self.replaceAndSearchAct.setShortcuts( |
287 self.__viewmanager.replaceAndSearchAct.shortcuts() |
313 self.__viewmanager.replaceAndSearchAct.shortcuts() |
420 ) |
446 ) |
421 else: |
447 else: |
422 startLine, startIndex, endLine, endIndex = -1, -1, -1, -1 |
448 startLine, startIndex, endLine, endIndex = -1, -1, -1, -1 |
423 |
449 |
424 return startLine, startIndex, endLine, endIndex |
450 return startLine, startIndex, endLine, endIndex |
|
451 |
|
452 @pyqtSlot() |
|
453 def __toggleReplaceMode(self): |
|
454 """ |
|
455 Private slot to toggle the widget mode. |
|
456 """ |
|
457 replaceMode = not self.__replaceMode |
|
458 if self.__sliding: |
|
459 self.__topWidget.show( |
|
460 text=self.findtextCombo.currentText(), replaceMode=replaceMode |
|
461 ) |
|
462 else: |
|
463 self.show(text=self.findtextCombo.currentText(), replaceMode=replaceMode) |
425 |
464 |
426 @pyqtSlot(str) |
465 @pyqtSlot(str) |
427 def on_findtextCombo_editTextChanged(self, txt): |
466 def on_findtextCombo_editTextChanged(self, txt): |
428 """ |
467 """ |
429 Private slot to enable/disable the find buttons. |
468 Private slot to enable/disable the find buttons. |
967 Private method to display this widget in find mode. |
1006 Private method to display this widget in find mode. |
968 |
1007 |
969 @param text text to be shown in the findtext edit (defaults to "") |
1008 @param text text to be shown in the findtext edit (defaults to "") |
970 @type str (optional) |
1009 @type str (optional) |
971 """ |
1010 """ |
|
1011 self.modeToggleButton.setIcon(EricPixmapCache.getIcon("1downarrow")) |
|
1012 |
972 # hide the replace related widgets |
1013 # hide the replace related widgets |
973 for widget in ( |
1014 for widget in ( |
974 self.replaceLabel, |
1015 self.replaceLabel, |
975 self.replacetextCombo, |
1016 self.replacetextCombo, |
976 self.replaceButton, |
1017 self.replaceButton, |
1292 Private slot to display this widget in replace mode. |
1333 Private slot to display this widget in replace mode. |
1293 |
1334 |
1294 @param text text to be shown in the findtext edit (defaults to "") |
1335 @param text text to be shown in the findtext edit (defaults to "") |
1295 @type str (optional) |
1336 @type str (optional) |
1296 """ |
1337 """ |
1297 # hide the replace related widgets |
1338 self.modeToggleButton.setIcon(EricPixmapCache.getIcon("1uparrow")) |
|
1339 |
|
1340 # show the replace related widgets |
1298 for widget in ( |
1341 for widget in ( |
1299 self.replaceLabel, |
1342 self.replaceLabel, |
1300 self.replacetextCombo, |
1343 self.replacetextCombo, |
1301 self.replaceButton, |
1344 self.replaceButton, |
1302 self.replaceSearchButton, |
1345 self.replaceSearchButton, |