Remove wrong dependency on Main Window

Don't depend on upper level widget (Main Window) state.

PR #21816.
This commit is contained in:
Vladimir Golovnev 2024-11-18 19:13:43 +03:00 committed by GitHub
parent e51fcc6ea0
commit ea35aa45d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View file

@ -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),

View file

@ -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"));

View file

@ -56,6 +56,9 @@ public:
void giveFocusToSearchInput();
signals:
void activeSearchFinished(bool failed);
private slots:
void on_searchButton_clicked();
void on_pluginsButton_clicked();