diff --git a/preditor/gui/find_files.py b/preditor/gui/find_files.py index d31e4cd0..4eb52a84 100644 --- a/preditor/gui/find_files.py +++ b/preditor/gui/find_files.py @@ -3,9 +3,11 @@ from collections import deque from Qt.QtCore import Qt +from Qt.QtGui import QIcon from Qt.QtWidgets import QApplication, QShortcut, QWidget -from ..gui import loadUi +from .. import resourcePath +from . import loadUi class FindFiles(QWidget): @@ -18,11 +20,29 @@ def __init__(self, parent=None, managers=None, console=None): loadUi(__file__, self) + # Set the icons + self.uiCaseSensitiveBTN.setIcon( + QIcon(resourcePath("img/format-letter-case.svg")) + ) + self.uiCloseBTN.setIcon(QIcon(resourcePath('img/close-thick.png'))) + self.uiRegexBTN.setIcon(QIcon(resourcePath("img/regex.svg"))) + + # Create shortcuts self.uiCloseSCT = QShortcut( Qt.Key_Escape, self, context=Qt.WidgetWithChildrenShortcut ) self.uiCloseSCT.activated.connect(self.hide) + self.uiCaseSensitiveSCT = QShortcut( + Qt.AltModifier | Qt.Key_C, self, context=Qt.WidgetWithChildrenShortcut + ) + self.uiCaseSensitiveSCT.activated.connect(self.uiCaseSensitiveBTN.toggle) + + self.uiRegexSCT = QShortcut( + Qt.AltModifier | Qt.Key_R, self, context=Qt.WidgetWithChildrenShortcut + ) + self.uiRegexSCT.activated.connect(self.uiRegexBTN.toggle) + def activate(self): """Called to make this widget ready for the user to interact with.""" self.show() @@ -30,7 +50,8 @@ def activate(self): def find(self): find_text = self.uiFindTXT.text() - self.insert_text("\nFind in workboxs: {}\n\n".format(find_text)) + cs = " (case sensitive)" if self.uiCaseSensitiveBTN.isChecked() else "" + self.insert_text('\nFind in workboxs: "{}"{}\n\n'.format(find_text, cs)) for manager in self.managers: for ( @@ -118,7 +139,14 @@ def search_file_simple(self, editor, path, workbox_id): find_text = self.uiFindTXT.text() # Ensure the editor text is loaded editor.__show__() - raw_lines = editor.__text__().splitlines() + + raw_text = editor.__text__() + # Handle case-insensitive searching + if not self.uiCaseSensitiveBTN.isChecked(): + find_text = find_text.lower() + raw_lines = raw_text.lower() + + raw_lines = raw_text.splitlines() # Add enough padding to cover the number of lines in the file padding = len(str(len(raw_lines))) fmt = " {{num: >{}}}{{split}} {{line}}".format(padding) diff --git a/preditor/gui/ui/find_files.ui b/preditor/gui/ui/find_files.ui index a7a05489..067d1512 100644 --- a/preditor/gui/ui/find_files.ui +++ b/preditor/gui/ui/find_files.ui @@ -25,28 +25,37 @@ + + false + - Regex + Regex (Alt + R) Regex + + true + - Case Sensitive + Case Sensitive (Alt + C) Case Sensitive + + true + - Context Lines + # of lines of context to show QAbstractSpinBox::PlusMinus diff --git a/preditor/gui/ui/loggerwindow.ui b/preditor/gui/ui/loggerwindow.ui index 37000c68..1b26ab25 100644 --- a/preditor/gui/ui/loggerwindow.ui +++ b/preditor/gui/ui/loggerwindow.ui @@ -134,7 +134,7 @@ - &Run + Run diff --git a/preditor/resource/img/README.md b/preditor/resource/img/README.md index 6649bb0b..17711728 100644 --- a/preditor/resource/img/README.md +++ b/preditor/resource/img/README.md @@ -5,3 +5,13 @@ Converted to multi-resolution icon using: https://convertico.com/svg-to-ico/ Most other icons downloaded from https://materialdesignicons.com/. + +Svg icons are preferred as they are plain text files that play nicely with git. +Please make sure to update the sources table when adding or updating images. + +# Sources for resources + +| File | Source | Notes | Author | +|---|---|---|---| +| ![](preditor/resource/img/format-letter-case.svg) [content-save.svg](preditor/resource/img/format-letter-case.svg) | https://pictogrammers.com/library/mdi/icon/format-letter-case/ | | [Austin Andrews](https://pictogrammers.com/contributor/Templarian/) | +| ![](preditor/resource/img/regex.svg) [content-save.svg](preditor/resource/img/regex.svg) | https://pictogrammers.com/library/mdi/icon/regex/ | | [Doug C. Hardester](https://pictogrammers.com/contributor/r3volution11/) | diff --git a/preditor/resource/img/format-letter-case.svg b/preditor/resource/img/format-letter-case.svg new file mode 100644 index 00000000..eaaf7543 --- /dev/null +++ b/preditor/resource/img/format-letter-case.svg @@ -0,0 +1 @@ + diff --git a/preditor/resource/img/regex.svg b/preditor/resource/img/regex.svg new file mode 100644 index 00000000..feea451d --- /dev/null +++ b/preditor/resource/img/regex.svg @@ -0,0 +1 @@ +