Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTimedSignalThreshold Class Reference

#include <kis_timed_signal_threshold.h>

+ Inheritance diagram for KisTimedSignalThreshold:

Classes

struct  Private
 

Public Slots

void forceDone ()
 
void setDelayThreshold (int delay, int cancelDelay=-1)
 
void setEnabled (bool value)
 
void start ()
 
void stop ()
 

Signals

void timeout ()
 

Public Member Functions

 KisTimedSignalThreshold (int delay, int cancelDelay=-1, QObject *parent=0)
 
 ~KisTimedSignalThreshold () override
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

Emits the timeout() signal if and only if the flow of start() events has been coming for a consecutive delay of milliseconds. If the events were not coming for cancelDelay of milliseconds the counting is dropped and the new period is started.

Definition at line 21 of file kis_timed_signal_threshold.h.

Constructor & Destructor Documentation

◆ KisTimedSignalThreshold()

KisTimedSignalThreshold::KisTimedSignalThreshold ( int delay,
int cancelDelay = -1,
QObject * parent = 0 )

Definition at line 33 of file kis_timed_signal_threshold.cpp.

34 : QObject(parent),
35 m_d(new Private(delay, cancelDelay))
36{
37}
const QScopedPointer< Private > m_d

◆ ~KisTimedSignalThreshold()

KisTimedSignalThreshold::~KisTimedSignalThreshold ( )
override

Definition at line 39 of file kis_timed_signal_threshold.cpp.

40{
41}

Member Function Documentation

◆ forceDone

void KisTimedSignalThreshold::forceDone ( )
slot

Stops counting and emits the signal forcefully

Definition at line 43 of file kis_timed_signal_threshold.cpp.

References stop(), and timeout().

◆ setDelayThreshold

void KisTimedSignalThreshold::setDelayThreshold ( int delay,
int cancelDelay = -1 )
slot

The period of time, after which the signal will be emitted

Definition at line 75 of file kis_timed_signal_threshold.cpp.

76{
77 m_d->delay = delay;
78 m_d->setCancelDelay(cancelDelay);
79}

References m_d.

◆ setEnabled

void KisTimedSignalThreshold::setEnabled ( bool value)
slot

Enable or disable emitting the signal

Definition at line 67 of file kis_timed_signal_threshold.cpp.

68{
69 m_d->enabled = value;
70 if (!m_d->enabled) {
71 stop();
72 }
73}
float value(const T *src, size_t ch)

References m_d, stop(), and value().

◆ start

void KisTimedSignalThreshold::start ( )
slot

Start/continue counting and if the signal flow is stable enough (longer than delay and shorter than cancelDelay), the timeout signal in emitted.

Definition at line 49 of file kis_timed_signal_threshold.cpp.

50{
51 if (!m_d->enabled) return;
52
53 if (!m_d->timer.isValid()) {
54 m_d->timer.start();
55 } else if (m_d->timer.elapsed() > m_d->cancelDelay) {
56 stop();
57 } else if (m_d->timer.elapsed() > m_d->delay) {
58 forceDone();
59 }
60}

References forceDone(), m_d, and stop().

◆ stop

void KisTimedSignalThreshold::stop ( )
slot

Stops counting the signals flow

Definition at line 62 of file kis_timed_signal_threshold.cpp.

63{
64 m_d->timer.invalidate();
65}

References m_d.

◆ timeout

void KisTimedSignalThreshold::timeout ( )
signal

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisTimedSignalThreshold::m_d
private

Definition at line 62 of file kis_timed_signal_threshold.h.


The documentation for this class was generated from the following files: