diff --git a/src/core/interface/gui.py b/src/core/interface/gui.py index 50dfbf5..1312728 100644 --- a/src/core/interface/gui.py +++ b/src/core/interface/gui.py @@ -8,11 +8,11 @@ from core.interface.dialogs.downloadlist import download_list_update from core.interface.dialogs.update import get_version, UpdateDialog from core.utils.logging.logs import consoleLog, flush_log_buffer from core.interface.dialogs.downloadmodel import DownloadModel -from core.interface.utils.searchhelper import return_pressed from core.interface.dialogs.settings import settings_dialog from core.interface.assets.base64_icons import logo_base64 from core.interface.dialogs.eventfilter import eventFilter from core.utils.network.download import download_selected +from core.interface.utils.searchhelper import run_search from core.interface.utils.tabhelper import create_tab from core.utils.general.shutdown import closehelper from core.utils.general.wrappers import run_thread @@ -295,7 +295,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget): self.searchbar.setEnabled(False) def _search_thread(): try: - return_pressed(self) + run_search(self) except Exception as e: consoleLog(f"Search error: {e}", True) self.search_results_signal.emit([]) diff --git a/src/core/interface/utils/searchhelper.py b/src/core/interface/utils/searchhelper.py index 118d754..09a49fb 100644 --- a/src/core/interface/utils/searchhelper.py +++ b/src/core/interface/utils/searchhelper.py @@ -5,22 +5,30 @@ from core.data.scrapers.monkrus import init_m0nkrus from core.utils.logging.logs import consoleLog from core.utils.data.state import state +# Call initialization function for each tracker / site init_rutracker() init_uztracker() init_m0nkrus() init_steamrip() -def return_pressed(self): + +def run_search(self) -> None: self.show_empty_results(False) + search_text = self.searchbar.text() + # Check for empty search if search_text == "": consoleLog("Error: Can't search for nothing") return consoleLog(f"User searched for: {search_text}") + # Get current tracker and call its search function tracker = state.trackers[state.currenttracker] scrapefunc = tracker["scrapeFunc"] state.posts = scrapefunc(search_text) - + + # Late to prevent circular import from core.interface.gui import MainWindow + + # Update GUI Headers MainWindow._instance.search_results_signal.emit(tracker["headers"]) diff --git a/src/core/interface/utils/svghelper.py b/src/core/interface/utils/svghelper.py index 393b321..bf4f25f 100644 --- a/src/core/interface/utils/svghelper.py +++ b/src/core/interface/utils/svghelper.py @@ -6,11 +6,10 @@ from PySide6.QtGui import QIcon, QPixmap, QPainter from PySide6.QtSvg import QSvgRenderer import darkdetect - +# Check if darkmode is enabled def _is_dark_mode(): return darkdetect.isDark() - def svg_icon(svg_str, size=20): app = QtWidgets.QApplication.instance() if app: diff --git a/src/core/interface/utils/tabhelper.py b/src/core/interface/utils/tabhelper.py index 74c4dd1..f22304b 100644 --- a/src/core/interface/utils/tabhelper.py +++ b/src/core/interface/utils/tabhelper.py @@ -1,6 +1,6 @@ from PySide6.QtWidgets import QWidget, QVBoxLayout - +# Tab creation helper function def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2): tab = QWidget() layout = QVBoxLayout() @@ -16,9 +16,7 @@ def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2): tabs.addTab(tab, title) return tab -################# -# SETTINGS TABS # -################# +# Settings Tabs def general_tab(title, autoresume, update_checkbox, transparent_window, tabs): tab = QWidget() layout = QVBoxLayout()