Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce delay when searching entries in Auto-Type select dialog #7598

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/autotype/AutoTypeSelectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)

m_ui->search->installEventFilter(this);

m_searchTimer.setInterval(300);
m_searchTimer.setInterval(0);
m_searchTimer.setSingleShot(true);

connect(m_ui->search, SIGNAL(textChanged(QString)), &m_searchTimer, SLOT(start()));
Expand All @@ -71,7 +71,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)

m_ui->searchCheckBox->setShortcut(Qt::CTRL + Qt::Key_F);
connect(m_ui->searchCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
Q_UNUSED(checked);
setDelayedSearch(checked);
performSearch();
});

Expand Down Expand Up @@ -107,6 +107,7 @@ void AutoTypeSelectDialog::setMatches(const QList<AutoTypeMatch>& matches,

// always perform search when updating matches to refresh view
performSearch();
setDelayedSearch(noMatches);
}

void AutoTypeSelectDialog::setSearchString(const QString& search)
Expand All @@ -115,6 +116,11 @@ void AutoTypeSelectDialog::setSearchString(const QString& search)
m_ui->searchCheckBox->setChecked(true);
}

void AutoTypeSelectDialog::setDelayedSearch(bool state)
{
m_searchTimer.setInterval(state ? 150 : 0);
}

void AutoTypeSelectDialog::submitAutoTypeMatch(AutoTypeMatch match)
{
if (match.first) {
Expand Down
1 change: 1 addition & 0 deletions src/autotype/AutoTypeSelectDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private slots:

private:
void buildActionMenu();
void setDelayedSearch(bool state);

QScopedPointer<Ui::AutoTypeSelectDialog> m_ui;

Expand Down