File indexing completed on 2024-05-12 15:56:59
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_THREAD_SAFE_SIGNAL_COMPRESSOR_H 0008 #define __KIS_THREAD_SAFE_SIGNAL_COMPRESSOR_H 0009 0010 #include <QObject> 0011 #include "kritaglobal_export.h" 0012 0013 #include "kis_signal_compressor.h" 0014 0015 /** 0016 * A special class which works exactly like KisSignalCompressor, but 0017 * supports calling \p start() method from within the context of 0018 * another thread. If it happens, it posts a message to Qt's event 0019 * loop and the \p start() signal is delivered when event loop gets 0020 * executes again. 0021 * 0022 * WARNING: After creation this object moves itself into the main 0023 * thread, so one must *not* delete it explicitly. Use 0024 * deleteLater() instead. Moving into another thread is 0025 * another reason why it cannot have parent QObject. 0026 */ 0027 class KRITAGLOBAL_EXPORT KisThreadSafeSignalCompressor : public QObject 0028 { 0029 Q_OBJECT 0030 public: 0031 KisThreadSafeSignalCompressor(int delay, KisSignalCompressor::Mode mode); 0032 0033 bool isActive() const; 0034 0035 public Q_SLOTS: 0036 void setDelay(int delay); 0037 void start(); 0038 void stop(); 0039 0040 Q_SIGNALS: 0041 void timeout(); 0042 void internalRequestSignal(); 0043 void internalStopSignal(); 0044 void internalSetDelay(int delay); 0045 0046 private: 0047 KisSignalCompressor *m_compressor; 0048 }; 0049 0050 #endif /* __KIS_THREAD_SAFE_SIGNAL_COMPRESSOR_H */