diff --git a/libs/ui/tool/KisStabilizerDelayedPaintHelper.h b/libs/ui/tool/KisStabilizerDelayedPaintHelper.h --- a/libs/ui/tool/KisStabilizerDelayedPaintHelper.h +++ b/libs/ui/tool/KisStabilizerDelayedPaintHelper.h @@ -19,9 +19,9 @@ #ifndef KIS_STABILIZER_DELAYED_PAINT_HELPER_H #define KIS_STABILIZER_DELAYED_PAINT_HELPER_H +#include #include #include -#include #include #include @@ -40,7 +40,7 @@ TimedPaintInfo(int elapsedTime, KisPaintInformation paintInfo); }; - QTimer m_paintTimer; + QBasicTimer m_paintTimer; QQueue m_paintQueue; int m_lastPendingTime; QElapsedTimer m_elapsedTimer; @@ -79,8 +79,11 @@ void end(); void cancel(); -private Q_SLOTS: +private: void stabilizerDelayedPaint(bool isEndStroke = false); + +protected: + virtual void timerEvent(QTimerEvent *event) override; }; #endif // KIS_STABILIZER_DELAYED_PAINT_HELPER_H diff --git a/libs/ui/tool/KisStabilizerDelayedPaintHelper.cpp b/libs/ui/tool/KisStabilizerDelayedPaintHelper.cpp --- a/libs/ui/tool/KisStabilizerDelayedPaintHelper.cpp +++ b/libs/ui/tool/KisStabilizerDelayedPaintHelper.cpp @@ -18,6 +18,8 @@ #include "KisStabilizerDelayedPaintHelper.h" +#include + KisStabilizerDelayedPaintHelper::TimedPaintInfo::TimedPaintInfo(int elapsedTime, KisPaintInformation paintInfo) : elapsedTime(elapsedTime) , paintInfo(paintInfo) @@ -26,15 +28,13 @@ KisStabilizerDelayedPaintHelper::KisStabilizerDelayedPaintHelper() { - connect(&m_paintTimer, SIGNAL(timeout()), SLOT(stabilizerDelayedPaint())); } void KisStabilizerDelayedPaintHelper::start(int paintInterval, const KisPaintInformation &firstPaintInfo) { if (running()) { cancel(); } - m_paintTimer.setInterval(paintInterval); - m_paintTimer.start(); + m_paintTimer.start(paintInterval, Qt::PreciseTimer, this); m_elapsedTimer.start(); m_lastPendingTime = m_elapsedTimer.elapsed(); m_paintQueue.enqueue(TimedPaintInfo(m_lastPendingTime, firstPaintInfo)); @@ -83,3 +83,9 @@ } m_requestUpdateOutline(); } + +void KisStabilizerDelayedPaintHelper::timerEvent(QTimerEvent *event) { + if (event->timerId() == m_paintTimer.timerId()) { + stabilizerDelayedPaint(false); + } +} diff --git a/libs/ui/tool/kis_tool_freehand_helper.h b/libs/ui/tool/kis_tool_freehand_helper.h --- a/libs/ui/tool/kis_tool_freehand_helper.h +++ b/libs/ui/tool/kis_tool_freehand_helper.h @@ -137,6 +137,8 @@ const QPointF &control2, const KisPaintInformation &pi2); + virtual void timerEvent(QTimerEvent *event) override; + private: void paint(KisPaintInformation &info); void paintBezierSegment(KisPaintInformation pi1, KisPaintInformation pi2, diff --git a/libs/ui/tool/kis_tool_freehand_helper.cpp b/libs/ui/tool/kis_tool_freehand_helper.cpp --- a/libs/ui/tool/kis_tool_freehand_helper.cpp +++ b/libs/ui/tool/kis_tool_freehand_helper.cpp @@ -18,6 +18,7 @@ #include "kis_tool_freehand_helper.h" +#include #include #include @@ -97,7 +98,7 @@ // Stabilizer data QQueue stabilizerDeque; - QTimer stabilizerPollTimer; + QBasicTimer stabilizerPollTimer; KisStabilizedEventsSampler stabilizedSampler; KisStabilizerDelayedPaintHelper stabilizerDelayedPaintHelper; @@ -124,7 +125,6 @@ m_d->strokeTimeoutTimer.setSingleShot(true); connect(&m_d->strokeTimeoutTimer, SIGNAL(timeout()), SLOT(finishStroke())); connect(&m_d->airbrushingTimer, SIGNAL(timeout()), SLOT(doAirbrushing())); - connect(&m_d->stabilizerPollTimer, SIGNAL(timeout()), SLOT(stabilizerPollAndPaint())); m_d->stabilizerDelayedPaintHelper.setPaintLineCallback( [this](const KisPaintInformation &pi1, const KisPaintInformation &pi2) { @@ -678,8 +678,7 @@ // Poll and draw regularly KisConfig cfg; int stabilizerSampleSize = cfg.stabilizerSampleSize(); - m_d->stabilizerPollTimer.setInterval(stabilizerSampleSize); - m_d->stabilizerPollTimer.start(); + m_d->stabilizerPollTimer.start(stabilizerSampleSize, Qt::PreciseTimer, this); int delayedPaintInterval = cfg.stabilizerDelayedPaintInterval(); if (delayedPaintInterval < stabilizerSampleSize) { @@ -976,3 +975,9 @@ m_d->canvasMirroredH = mirrored; } +void KisToolFreehandHelper::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_d->stabilizerPollTimer.timerId()) { + stabilizerPollAndPaint(); + } +}