Changeset View
Changeset View
Standalone View
Standalone View
libs/global/kis_signal_compressor.h
Context not available. | |||||
19 | #ifndef __KIS_SIGNAL_COMPRESSOR_H | 19 | #ifndef __KIS_SIGNAL_COMPRESSOR_H | ||
---|---|---|---|---|---|
20 | #define __KIS_SIGNAL_COMPRESSOR_H | 20 | #define __KIS_SIGNAL_COMPRESSOR_H | ||
21 | 21 | | |||
22 | #include <QTimer> | 22 | #include <QObject> | ||
23 | #include <QBasicTimer> | ||||
24 | #include <QElapsedTimer> | ||||
23 | #include "kritaglobal_export.h" | 25 | #include "kritaglobal_export.h" | ||
24 | 26 | | |||
25 | class QTimer; | | |||
26 | | ||||
27 | /** | 27 | /** | ||
28 | * Sets a timer to delay or throttle activation of a Qt slot. One example of | 28 | * Sets a timer to delay or throttle activation of a Qt slot. One example of | ||
29 | * where this is used is to limit the amount of expensive redraw activity on the | 29 | * where this is used is to limit the amount of expensive redraw activity on the | ||
Context not available. | |||||
51 | * delay ms. The compressor becomes inactive and all events are ignored until | 51 | * delay ms. The compressor becomes inactive and all events are ignored until | ||
52 | * the timer has elapsed. | 52 | * the timer has elapsed. | ||
53 | * | 53 | * | ||
54 | * The current implementation allows the timeout() to be delayed by up to 2 times | ||||
55 | * \p delay in certain situations (for details see cpp file). | ||||
54 | */ | 56 | */ | ||
55 | class KRITAGLOBAL_EXPORT KisSignalCompressor : public QObject | 57 | class KRITAGLOBAL_EXPORT KisSignalCompressor : public QObject | ||
56 | { | 58 | { | ||
Context not available. | |||||
76 | void start(); | 78 | void start(); | ||
77 | void stop(); | 79 | void stop(); | ||
78 | 80 | | |||
79 | private Q_SLOTS: | | |||
80 | void slotTimerExpired(); | | |||
81 | | ||||
82 | Q_SIGNALS: | 81 | Q_SIGNALS: | ||
83 | void timeout(); | 82 | void timeout(); | ||
84 | 83 | | |||
84 | protected: | ||||
85 | void timerEvent(QTimerEvent *event) override; | ||||
86 | | ||||
85 | private: | 87 | private: | ||
86 | QTimer *m_timer; | 88 | void startTimer(); | ||
89 | | ||||
90 | QBasicTimer m_monitor; | ||||
91 | int m_idle; | ||||
92 | int m_postpone; | ||||
93 | | ||||
94 | int m_delay; | ||||
87 | Mode m_mode; | 95 | Mode m_mode; | ||
96 | | ||||
88 | bool m_gotSignals; | 97 | bool m_gotSignals; | ||
98 | bool m_active; | ||||
99 | QElapsedTimer m_elapsed; | ||||
89 | }; | 100 | }; | ||
90 | 101 | | |||
91 | #endif /* __KIS_SIGNAL_COMPRESSOR_H */ | 102 | #endif /* __KIS_SIGNAL_COMPRESSOR_H */ | ||
Context not available. |