From b12f6f07864aeaf2e5fc1a94022c0488c5772f62 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 7 Sep 2025 17:15:41 -0400 Subject: [PATCH] Fix SearchWidget issues with saved searches and "Press Enter to search" option (#12314) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: droidmonkey <2809491+droidmonkey@users.noreply.github.com> --- src/gui/SearchWidget.cpp | 19 ++++++++++++++++++- src/gui/SearchWidget.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/gui/SearchWidget.cpp b/src/gui/SearchWidget.cpp index 5fce8a5aa..d4135ed09 100644 --- a/src/gui/SearchWidget.cpp +++ b/src/gui/SearchWidget.cpp @@ -48,6 +48,7 @@ SearchWidget::SearchWidget(QWidget* parent) new QShortcut(Qt::CTRL + Qt::Key_J, this, SLOT(toggleHelp()), nullptr, Qt::WidgetWithChildrenShortcut); connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(startSearchTimer())); + connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(updateSaveButtonVisibility())); connect(m_ui->helpIcon, SIGNAL(triggered()), SLOT(toggleHelp())); connect(m_ui->searchIcon, SIGNAL(triggered()), SLOT(showSearchMenu())); connect(m_ui->saveIcon, &QAction::triggered, this, [this] { emit saveSearch(m_ui->searchEdit->text()); }); @@ -155,7 +156,7 @@ void SearchWidget::connectSignals(SignalMultiplexer& mx) mx.connect(this, SIGNAL(caseSensitiveChanged(bool)), SLOT(setSearchCaseSensitive(bool))); mx.connect(this, SIGNAL(limitGroupChanged(bool)), SLOT(setSearchLimitGroup(bool))); mx.connect(this, SIGNAL(downPressed()), SLOT(focusOnEntries())); - mx.connect(SIGNAL(requestSearch(QString)), m_ui->searchEdit, SLOT(setText(QString))); + mx.connect(SIGNAL(requestSearch(QString)), this, SLOT(performRequestedSearch(QString))); mx.connect(SIGNAL(clearSearch()), this, SLOT(clearSearch())); mx.connect(SIGNAL(entrySelectionChanged()), this, SLOT(resetSearchClearTimer())); mx.connect(SIGNAL(currentModeChanged(DatabaseWidget::Mode)), this, SLOT(resetSearchClearTimer())); @@ -252,8 +253,24 @@ void SearchWidget::showSearchMenu() void SearchWidget::onReturnPressed() { if (m_actionWaitForEnter->isChecked()) { + m_ui->saveIcon->setVisible(true); emit search(m_ui->searchEdit->text()); } else { emit enterPressed(); } } + +void SearchWidget::performRequestedSearch(const QString& text) +{ + // This method handles saved searches - it should set the text and immediately trigger search + // without any delay, regardless of the "Press Enter to search" setting + m_ui->searchEdit->setText(text); + m_ui->saveIcon->setVisible(!text.isEmpty()); + emit search(text); +} + +void SearchWidget::updateSaveButtonVisibility() +{ + // Show save button whenever there's non-empty text in the search field + m_ui->saveIcon->setVisible(!m_ui->searchEdit->text().isEmpty()); +} diff --git a/src/gui/SearchWidget.h b/src/gui/SearchWidget.h index 1d048d12b..bfc75de67 100644 --- a/src/gui/SearchWidget.h +++ b/src/gui/SearchWidget.h @@ -76,6 +76,8 @@ private slots: void toggleHelp(); void showSearchMenu(); void resetSearchClearTimer(); + void performRequestedSearch(const QString& text); + void updateSaveButtonVisibility(); private: const QScopedPointer m_ui;