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>
This commit is contained in:
Copilot 2025-09-07 17:15:41 -04:00 committed by GitHub
parent 7e3e2c10d2
commit b12f6f0786
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -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());
}

View file

@ -76,6 +76,8 @@ private slots:
void toggleHelp();
void showSearchMenu();
void resetSearchClearTimer();
void performRequestedSearch(const QString& text);
void updateSaveButtonVisibility();
private:
const QScopedPointer<Ui::SearchWidget> m_ui;