From ea35aa45d60008f0e61639fc8dc11ec6b167c5d6 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Mon, 18 Nov 2024 19:13:43 +0300 Subject: [PATCH] Remove wrong dependency on Main Window Don't depend on upper level widget (Main Window) state. PR #21816. --- src/gui/mainwindow.cpp | 10 ++++++++++ src/gui/search/searchwidget.cpp | 9 +-------- src/gui/search/searchwidget.h | 3 +++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 4798a6800..df33e09fc 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -728,6 +728,16 @@ void MainWindow::displaySearchTab(bool enable) if (!m_searchWidget) { m_searchWidget = new SearchWidget(app(), this); + connect(m_searchWidget, &SearchWidget::activeSearchFinished, this, [this](const bool failed) + { + if (app()->desktopIntegration()->isNotificationsEnabled() && (currentTabWidget() != m_searchWidget)) + { + if (failed) + app()->desktopIntegration()->showNotification(tr("Search Engine"), tr("Search has failed")); + else + app()->desktopIntegration()->showNotification(tr("Search Engine"), tr("Search has finished")); + } + }); m_tabs->insertTab(1, m_searchWidget, #ifndef Q_OS_MACOS UIThemeManager::instance()->getIcon(u"edit-find"_s), diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 6307e99e2..7f94630e2 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -54,7 +54,6 @@ #include "base/utils/foreignapps.h" #include "gui/desktopintegration.h" #include "gui/interfaces/iguiapplication.h" -#include "gui/mainwindow.h" #include "gui/uithememanager.h" #include "pluginselectdialog.h" #include "searchjobwidget.h" @@ -373,13 +372,7 @@ void SearchWidget::tabStatusChanged(QWidget *tab) { Q_ASSERT(m_activeSearchTab->status() != SearchJobWidget::Status::Ongoing); - 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")); - else - app()->desktopIntegration()->showNotification(tr("Search Engine"), tr("Search has finished")); - } + emit activeSearchFinished(m_activeSearchTab->status() == SearchJobWidget::Status::Error); m_activeSearchTab = nullptr; m_ui->searchButton->setText(tr("Search")); diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index 1947378c6..749083bba 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -56,6 +56,9 @@ public: void giveFocusToSearchInput(); +signals: + void activeSearchFinished(bool failed); + private slots: void on_searchButton_clicked(); void on_pluginsButton_clicked();