Search button disabled and button text changed while search is occurring (#2928)

This commit is contained in:
Jakob Zielinski 2022-05-07 08:01:10 -04:00 committed by GitHub
parent 8cb4f867fa
commit 6f61d0d7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -195,14 +195,18 @@ SearchWidget::SearchWidget(MainWindow *main) : CutterDockWidget(main), ui(new Ui
QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this); QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this);
connect(enter_press, &QShortcut::activated, this, [this]() { connect(enter_press, &QShortcut::activated, this, [this]() {
disableSearch();
refreshSearch(); refreshSearch();
checkSearchResultEmpty(); checkSearchResultEmpty();
enableSearch();
}); });
enter_press->setContext(Qt::WidgetWithChildrenShortcut); enter_press->setContext(Qt::WidgetWithChildrenShortcut);
connect(ui->searchButton, &QAbstractButton::clicked, this, [this]() { connect(ui->searchButton, &QAbstractButton::clicked, this, [this]() {
disableSearch();
refreshSearch(); refreshSearch();
checkSearchResultEmpty(); checkSearchResultEmpty();
enableSearch();
}); });
connect(ui->searchspaceCombo, connect(ui->searchspaceCombo,
@ -310,3 +314,16 @@ void SearchWidget::updatePlaceholderText(int index)
ui->filterLineEdit->setPlaceholderText("jmp rax"); 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");
}

View File

@ -77,6 +77,8 @@ private:
void refreshSearch(); void refreshSearch();
void checkSearchResultEmpty(); void checkSearchResultEmpty();
void enableSearch();
void disableSearch();
void setScrollMode(); void setScrollMode();
void updatePlaceholderText(int index); void updatePlaceholderText(int index);
}; };