diff options
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/common/lazytrigger.h')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/common/lazytrigger.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/common/lazytrigger.h b/SQLiteStudio3/coreSQLiteStudio/common/lazytrigger.h new file mode 100644 index 0000000..9c34395 --- /dev/null +++ b/SQLiteStudio3/coreSQLiteStudio/common/lazytrigger.h @@ -0,0 +1,34 @@ +#ifndef LAZYTRIGGER_H +#define LAZYTRIGGER_H + +#include "coreSQLiteStudio_global.h" +#include <QObject> +#include <functional> + +class QTimer; + +class API_EXPORT LazyTrigger : public QObject +{ + Q_OBJECT + + public: + typedef std::function<bool()> Condition; + + LazyTrigger(int delay, QObject* parent = nullptr, const char* slot = nullptr); + LazyTrigger(int delay, Condition condition, QObject* parent = nullptr, const char* slot = nullptr); + + void setDelay(int delay); + + private: + QTimer* timer = nullptr; + Condition condition = nullptr; + + public slots: + void schedule(); + void cancel(); + + signals: + void triggered(); +}; + +#endif // LAZYTRIGGER_H |
