mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 10:56:11 +00:00
Add text debounce to QuickFilterView & ComboQuickFilterView (#3072)
This commit is contained in:
parent
a82d4402f8
commit
93acec9682
@ -6,8 +6,14 @@ ComboQuickFilterView::ComboQuickFilterView(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
debounceTimer = new QTimer(this);
|
||||
debounceTimer->setSingleShot(true);
|
||||
|
||||
connect(debounceTimer, &QTimer::timeout, this,
|
||||
[this]() { emit filterTextChanged(ui->lineEdit->text()); });
|
||||
|
||||
connect(ui->lineEdit, &QLineEdit::textChanged, this,
|
||||
[this](const QString &text) { emit filterTextChanged(text); });
|
||||
[this](const QString &text) { debounceTimer->start(150); });
|
||||
}
|
||||
|
||||
ComboQuickFilterView::~ComboQuickFilterView()
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui {
|
||||
class ComboQuickFilterView;
|
||||
@ -32,6 +33,7 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::ComboQuickFilterView *ui;
|
||||
QTimer *debounceTimer;
|
||||
};
|
||||
|
||||
#endif // COMBOQUICKFILTERVIEW_H
|
||||
|
@ -7,10 +7,16 @@ QuickFilterView::QuickFilterView(QWidget *parent, bool defaultOn)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
debounceTimer = new QTimer(this);
|
||||
debounceTimer->setSingleShot(true);
|
||||
|
||||
connect(ui->closeFilterButton, &QAbstractButton::clicked, this, &QuickFilterView::closeFilter);
|
||||
|
||||
connect(debounceTimer, &QTimer::timeout, this,
|
||||
[this]() { emit filterTextChanged(ui->filterLineEdit->text()); });
|
||||
|
||||
connect(ui->filterLineEdit, &QLineEdit::textChanged, this,
|
||||
[this](const QString &text) { emit filterTextChanged(text); });
|
||||
[this](const QString &text) { debounceTimer->start(150); });
|
||||
|
||||
if (!defaultOn) {
|
||||
closeFilter();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui {
|
||||
class QuickFilterView;
|
||||
@ -31,6 +32,7 @@ signals:
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::QuickFilterView> ui;
|
||||
QTimer *debounceTimer;
|
||||
};
|
||||
|
||||
#endif // QUICKFILTERVIEW_H
|
||||
|
Loading…
Reference in New Issue
Block a user