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