Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/throttle/Throttle.cpp
Show All 30 Lines | |||||
31 | #include <KoCanvasBase.h> | 31 | #include <KoCanvasBase.h> | ||
32 | #include <KisViewManager.h> | 32 | #include <KisViewManager.h> | ||
33 | #include <kis_canvas2.h> | 33 | #include <kis_canvas2.h> | ||
34 | #include <KisMainWindow.h> | 34 | #include <KisMainWindow.h> | ||
35 | #include "kis_signal_compressor.h" | 35 | #include "kis_signal_compressor.h" | ||
36 | 36 | | |||
37 | #include "KisUpdateSchedulerConfigNotifier.h" | 37 | #include "KisUpdateSchedulerConfigNotifier.h" | ||
38 | 38 | | |||
39 | #include <QVersionNumber> | ||||
40 | | ||||
41 | namespace | ||||
42 | { | ||||
43 | | ||||
44 | bool shouldSetAcceptTouchEvents() | ||||
45 | { | ||||
46 | // See https://bugreports.qt.io/browse/QTBUG-66718 | ||||
47 | static QVersionNumber qtVersion = QVersionNumber::fromString(qVersion()); | ||||
48 | static bool retval = qtVersion > QVersionNumber(5, 9, 3) && qtVersion.normalized() != QVersionNumber(5, 10); | ||||
49 | return retval; | ||||
50 | } | ||||
51 | | ||||
52 | } // namespace | ||||
53 | | ||||
39 | 54 | | |||
40 | ThreadManager::ThreadManager(QObject *parent) | 55 | ThreadManager::ThreadManager(QObject *parent) | ||
41 | : QObject(parent), | 56 | : QObject(parent), | ||
42 | m_configUpdateCompressor(new KisSignalCompressor(500, KisSignalCompressor::POSTPONE, this)) | 57 | m_configUpdateCompressor(new KisSignalCompressor(500, KisSignalCompressor::POSTPONE, this)) | ||
43 | { | 58 | { | ||
44 | connect(m_configUpdateCompressor, SIGNAL(timeout()), SLOT(slotDoUpdateConfig())); | 59 | connect(m_configUpdateCompressor, SIGNAL(timeout()), SLOT(slotDoUpdateConfig())); | ||
45 | } | 60 | } | ||
46 | 61 | | |||
Show All 29 Lines | 88 | { | |||
76 | cfg.setFrameRenderingClones(qCeil(m_threadCount * 0.5)); | 91 | cfg.setFrameRenderingClones(qCeil(m_threadCount * 0.5)); | ||
77 | KisUpdateSchedulerConfigNotifier::instance()->notifyConfigChanged(); | 92 | KisUpdateSchedulerConfigNotifier::instance()->notifyConfigChanged(); | ||
78 | } | 93 | } | ||
79 | 94 | | |||
80 | 95 | | |||
81 | Throttle::Throttle(QWidget *parent) | 96 | Throttle::Throttle(QWidget *parent) | ||
82 | : QQuickWidget(parent) | 97 | : QQuickWidget(parent) | ||
83 | { | 98 | { | ||
99 | if (shouldSetAcceptTouchEvents()) { | ||||
100 | setAttribute(Qt::WA_AcceptTouchEvents); | ||||
101 | } | ||||
84 | m_threadManager = new ThreadManager(); | 102 | m_threadManager = new ThreadManager(); | ||
85 | // In % of available cores... | 103 | // In % of available cores... | ||
86 | engine()->rootContext()->setContextProperty("ThreadManager", m_threadManager); | 104 | engine()->rootContext()->setContextProperty("ThreadManager", m_threadManager); | ||
87 | m_threadManager->setThreadCount(100); | 105 | m_threadManager->setThreadCount(100); | ||
88 | setSource(QUrl("qrc:/slider.qml")); | 106 | setSource(QUrl("qrc:/slider.qml")); | ||
89 | setResizeMode(SizeRootObjectToView); | 107 | setResizeMode(SizeRootObjectToView); | ||
90 | } | 108 | } | ||
91 | 109 | | |||
92 | Throttle::~Throttle() | 110 | Throttle::~Throttle() | ||
93 | { | 111 | { | ||
94 | setSource(QUrl()); | 112 | setSource(QUrl()); | ||
95 | } | 113 | } |