diff --git a/preditor/gui/find_files.py b/preditor/gui/find_files.py index 2c1e8cd2..355592fa 100644 --- a/preditor/gui/find_files.py +++ b/preditor/gui/find_files.py @@ -2,20 +2,32 @@ from collections import deque -from Qt.QtWidgets import QWidget +from Qt.QtCore import Qt +from Qt.QtWidgets import QApplication, QShortcut, QWidget from ..gui import loadUi class FindFiles(QWidget): - def __init__(self, managers=None, parent=None): + def __init__(self, parent=None, managers=None, console=None): super(FindFiles, self).__init__(parent=parent) if managers is None: managers = [] self.managers = managers + self.console = console loadUi(__file__, self) + self.uiCloseSCT = QShortcut( + Qt.Key_Escape, self, context=Qt.WidgetWithChildrenShortcut + ) + self.uiCloseSCT.activated.connect(self.hide) + + def activate(self): + """Called to make this widget ready for the user to interact with.""" + self.show() + self.uiFindTXT.setFocus() + def insert_found_text(self, found_text, href, tool_tip): cursor = self.console.textCursor() # Insert hyperlink @@ -25,6 +37,8 @@ def insert_found_text(self, found_text, href, tool_tip): fmt.setFontUnderline(True) fmt.setToolTip(tool_tip) cursor.insertText(found_text, fmt) + # Show the updated text output + QApplication.instance().processEvents() def insert_text(self, text): cursor = self.console.textCursor() @@ -34,6 +48,8 @@ def insert_text(self, text): fmt.setFontUnderline(False) fmt.setToolTip('') cursor.insertText(text, fmt) + # Show the updated text output + QApplication.instance().processEvents() def indicate_results( self, @@ -44,7 +60,7 @@ def indicate_results( workbox_id="undefined", fmt="", ): - href = '{}, {}, {}'.format(path, workbox_id, line_num) + href = ', {}, {}'.format(workbox_id, line_num) tool_tip = "Open {} at line number {}".format(path, line_num) find_len = len(find_text) diff --git a/preditor/gui/loggerwindow.py b/preditor/gui/loggerwindow.py index dbc9c0c5..7e9232d5 100644 --- a/preditor/gui/loggerwindow.py +++ b/preditor/gui/loggerwindow.py @@ -106,6 +106,11 @@ def __init__(self, parent, name=None, run_workbox=False, standalone=False): ) self.uiConsoleTOOLBAR.insertSeparator(self.uiRunSelectedACT) + # Configure Find in Workboxes + self.uiFindInWorkboxesWGT.hide() + self.uiFindInWorkboxesWGT.managers.append(self.uiWorkboxTAB) + self.uiFindInWorkboxesWGT.console = self.console() + # Initial configuration of the logToFile feature self._logToFilePath = None self._stds = None @@ -1022,6 +1027,11 @@ def showEvent(self, event): def show_workbox_options(self): self.uiWorkboxSTACK.setCurrentIndex(WorkboxPages.Options) + @Slot() + def show_find_in_workboxes(self): + """Ensure the find workboxes widget is visible and has focus.""" + self.uiFindInWorkboxesWGT.activate() + @Slot() def show_focus_name(self): model = WorkboxListItemModel(manager=self.uiWorkboxTAB) diff --git a/preditor/gui/ui/find_files.ui b/preditor/gui/ui/find_files.ui index 37873848..a7a05489 100644 --- a/preditor/gui/ui/find_files.ui +++ b/preditor/gui/ui/find_files.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 300 + 636 + 41 @@ -21,13 +21,6 @@ - - - - Find - - - @@ -68,13 +61,18 @@ - - - - - 1 - - + + + + Find + + + + + + + x + @@ -88,8 +86,8 @@ find() - 382 - 25 + 601 + 31 421 @@ -97,6 +95,38 @@ + + uiFindTXT + returnPressed() + uiFindFilesWGT + find() + + + 488 + 23 + + + 501 + 65 + + + + + uiCloseBTN + released() + uiFindFilesWGT + hide() + + + 620 + 19 + + + 676 + 24 + + + find() diff --git a/preditor/gui/ui/loggerwindow.ui b/preditor/gui/ui/loggerwindow.ui index 4fc142c3..15028804 100644 --- a/preditor/gui/ui/loggerwindow.ui +++ b/preditor/gui/ui/loggerwindow.ui @@ -81,6 +81,9 @@ + + + @@ -323,6 +326,8 @@ + + @@ -951,6 +956,14 @@ at the indicated line in the specified text editor. Ctrl+Alt+Shift+R + + + Find in Workboxes + + + Ctrl+Shift+F + + @@ -969,6 +982,12 @@ at the indicated line in the specified text editor. QWidget
preditor.gui.editor_chooser.h
+ + FindFiles + QWidget +
preditor.gui.find_files.h
+ 1 +
@@ -1011,8 +1030,8 @@ at the indicated line in the specified text editor. update_workbox_stack() - 754 - 377 + 763 + 371 747 @@ -1020,11 +1039,28 @@ at the indicated line in the specified text editor. + + uiFindInWorkboxesACT + triggered() + PrEditorWindow + show_find_in_workboxes() + + + -1 + -1 + + + 397 + 202 + + + apply_options() reset_options() show_workbox_options() update_workbox_stack() + show_find_in_workboxes()