file search in /

This commit is contained in:
N0\A
2025-10-22 13:43:14 +02:00
parent f0290658c9
commit a853df3371

18
main.py
View File

@@ -129,7 +129,23 @@ class MainWindow(QtWidgets.QMainWindow):
self.results_dialog = SearchResultsDialog(results, self) self.results_dialog = SearchResultsDialog(results, self)
self.results_dialog.show() self.results_dialog.show()
else: else:
QtWidgets.QMessageBox.information(self, "No Results", f"No files found matching '{pattern}'.") reply = QtWidgets.QMessageBox.question(self, "No Results", "Sorry, I couldn't find anything in your home folder. Would you like me to search the root folder?",
QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.No)
if reply == QtWidgets.QMessageBox.StandardButton.Yes:
try:
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) # type: ignore
results = find(pattern, root='/')
except RuntimeError as e:
QtWidgets.QMessageBox.critical(self, "Search Error", str(e))
return
finally:
QtWidgets.QApplication.restoreOverrideCursor()
if results:
self.results_dialog = SearchResultsDialog(results, self)
self.results_dialog.show()
else:
QtWidgets.QMessageBox.information(self, "No Results", "Sorry, I couldn't find anything in the root folder either.")
def restart_application(self): def restart_application(self):
"""Restarts the application.""" """Restarts the application."""