Skip to content

Commit

Permalink
Remove wrong dependency on Main Window
Browse files Browse the repository at this point in the history
Don't depend on upper level widget (Main Window) state.

PR #21816.
  • Loading branch information
glassez authored Nov 18, 2024
1 parent e51fcc6 commit ea35aa4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 1 addition & 8 deletions src/gui/search/searchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"));
Expand Down
3 changes: 3 additions & 0 deletions src/gui/search/searchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class SearchWidget : public GUIApplicationComponent<QWidget>

void giveFocusToSearchInput();

signals:
void activeSearchFinished(bool failed);

private slots:
void on_searchButton_clicked();
void on_pluginsButton_clicked();
Expand Down

0 comments on commit ea35aa4

Please sign in to comment.