From 3da944468887008e0a712722aa4b0e8053345a24 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Nov 2024 13:45:14 +0800 Subject: [PATCH] Reduce dependency on Main Window PR #21753. --- src/gui/search/searchwidget.cpp | 10 +++++----- src/gui/search/searchwidget.h | 6 +----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 0cbaf27d4..6307e99e2 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -41,8 +41,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -84,10 +84,9 @@ namespace } } -SearchWidget::SearchWidget(IGUIApplication *app, MainWindow *mainWindow) - : GUIApplicationComponent(app, mainWindow) +SearchWidget::SearchWidget(IGUIApplication *app, QWidget *parent) + : GUIApplicationComponent(app, parent) , m_ui {new Ui::SearchWidget()} - , m_mainWindow {mainWindow} { m_ui->setupUi(this); m_ui->tabWidget->tabBar()->installEventFilter(this); @@ -175,6 +174,7 @@ bool SearchWidget::eventFilter(QObject *object, QEvent *event) } return false; } + return QWidget::eventFilter(object, event); } @@ -373,7 +373,7 @@ void SearchWidget::tabStatusChanged(QWidget *tab) { Q_ASSERT(m_activeSearchTab->status() != SearchJobWidget::Status::Ongoing); - if (app()->desktopIntegration()->isNotificationsEnabled() && (m_mainWindow->currentTabWidget() != this)) + if (app()->desktopIntegration()->isNotificationsEnabled() && (app()->mainWindow()->currentTabWidget() != this)) { if (m_activeSearchTab->status() == SearchJobWidget::Status::Error) app()->desktopIntegration()->showNotification(tr("Search Engine"), tr("Search has failed")); diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index 610dadf44..1947378c6 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -30,7 +30,6 @@ #pragma once -#include #include #include @@ -38,9 +37,7 @@ class QEvent; class QObject; -class QTabWidget; -class MainWindow; class SearchJobWidget; namespace Ui @@ -54,7 +51,7 @@ class SearchWidget : public GUIApplicationComponent Q_DISABLE_COPY_MOVE(SearchWidget) public: - explicit SearchWidget(IGUIApplication *app, MainWindow *mainWindow); + explicit SearchWidget(IGUIApplication *app, QWidget *parent); ~SearchWidget() override; void giveFocusToSearchInput(); @@ -83,6 +80,5 @@ private: Ui::SearchWidget *m_ui = nullptr; QPointer m_currentSearchTab; // Selected tab QPointer m_activeSearchTab; // Tab with running search - MainWindow *m_mainWindow = nullptr; bool m_isNewQueryString = false; };