From 6f61d0d7d84bef37505eacd31d85825701dc96b0 Mon Sep 17 00:00:00 2001 From: Jakob Zielinski <60484807+jsz6389@users.noreply.github.com> Date: Sat, 7 May 2022 08:01:10 -0400 Subject: [PATCH] Search button disabled and button text changed while search is occurring (#2928) --- src/widgets/SearchWidget.cpp | 17 +++++++++++++++++ src/widgets/SearchWidget.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/widgets/SearchWidget.cpp b/src/widgets/SearchWidget.cpp index ae3c419b..fc5e5d43 100644 --- a/src/widgets/SearchWidget.cpp +++ b/src/widgets/SearchWidget.cpp @@ -195,14 +195,18 @@ SearchWidget::SearchWidget(MainWindow *main) : CutterDockWidget(main), ui(new Ui QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this); connect(enter_press, &QShortcut::activated, this, [this]() { + disableSearch(); refreshSearch(); checkSearchResultEmpty(); + enableSearch(); }); enter_press->setContext(Qt::WidgetWithChildrenShortcut); connect(ui->searchButton, &QAbstractButton::clicked, this, [this]() { + disableSearch(); refreshSearch(); checkSearchResultEmpty(); + enableSearch(); }); connect(ui->searchspaceCombo, @@ -310,3 +314,16 @@ void SearchWidget::updatePlaceholderText(int index) ui->filterLineEdit->setPlaceholderText("jmp rax"); } } + +void SearchWidget::disableSearch() +{ + ui->searchButton->setEnabled(false); + ui->searchButton->setText("Searching..."); + qApp->processEvents(); +} + +void SearchWidget::enableSearch() +{ + ui->searchButton->setEnabled(true); + ui->searchButton->setText("Search"); +} diff --git a/src/widgets/SearchWidget.h b/src/widgets/SearchWidget.h index 8da8b25b..08a9fc14 100644 --- a/src/widgets/SearchWidget.h +++ b/src/widgets/SearchWidget.h @@ -77,6 +77,8 @@ private: void refreshSearch(); void checkSearchResultEmpty(); + void enableSearch(); + void disableSearch(); void setScrollMode(); void updatePlaceholderText(int index); };