CTimedLineEdit: Make use of Qt 5 signals and slots

This commit is contained in:
Lioncash 2020-07-03 07:32:13 -04:00
parent 57e1b272e9
commit d05d767d66
1 changed files with 6 additions and 7 deletions

View File

@ -10,20 +10,19 @@ class CTimedLineEdit : public QLineEdit
Q_OBJECT
QString mCachedText;
float mTimeoutDuration;
float mTimeoutDuration{0.3f};
QTimer mTimer;
public:
CTimedLineEdit(QWidget *pParent = 0)
explicit CTimedLineEdit(QWidget *pParent = nullptr)
: QLineEdit(pParent)
, mTimeoutDuration(0.3f)
{
connect(this, SIGNAL(textChanged(QString)), this, SLOT(OnTextChanged()));
connect(&mTimer, SIGNAL(timeout()), this, SLOT(OnTimeout()));
connect(this, &CTimedLineEdit::textChanged, this, &CTimedLineEdit::OnTextChanged);
connect(&mTimer, &QTimer::timeout, this, &CTimedLineEdit::OnTimeout);
}
inline void SetTimeoutDuration(float Duration) { mTimeoutDuration = Duration; }
inline float TimeoutDuration() const { return mTimeoutDuration; }
void SetTimeoutDuration(float Duration) { mTimeoutDuration = Duration; }
float TimeoutDuration() const { return mTimeoutDuration; }
signals:
void StoppedTyping(const QString& rkText);