Commit b1d67ddc authored by Alvin Wong's avatar Alvin Wong

Make QQuickWidget accept touch events on recent Qt versions

This fixes some issues operating the touch docker and other QML parts
with touchscreen when using Qt LTS later than 5.9.3. See
https://bugreports.qt.io/browse/QTBUG-66718

Differential Revision: https://phabricator.kde.org/D12762
parent bef84207
...@@ -36,6 +36,21 @@ ...@@ -36,6 +36,21 @@
#include "KisUpdateSchedulerConfigNotifier.h" #include "KisUpdateSchedulerConfigNotifier.h"
#include <QVersionNumber>
namespace
{
bool shouldSetAcceptTouchEvents()
{
// See https://bugreports.qt.io/browse/QTBUG-66718
static QVersionNumber qtVersion = QVersionNumber::fromString(qVersion());
static bool retval = qtVersion > QVersionNumber(5, 9, 3) && qtVersion.normalized() != QVersionNumber(5, 10);
return retval;
}
} // namespace
ThreadManager::ThreadManager(QObject *parent) ThreadManager::ThreadManager(QObject *parent)
: QObject(parent), : QObject(parent),
...@@ -81,6 +96,9 @@ void ThreadManager::slotDoUpdateConfig() ...@@ -81,6 +96,9 @@ void ThreadManager::slotDoUpdateConfig()
Throttle::Throttle(QWidget *parent) Throttle::Throttle(QWidget *parent)
: QQuickWidget(parent) : QQuickWidget(parent)
{ {
if (shouldSetAcceptTouchEvents()) {
setAttribute(Qt::WA_AcceptTouchEvents);
}
m_threadManager = new ThreadManager(); m_threadManager = new ThreadManager();
// In % of available cores... // In % of available cores...
engine()->rootContext()->setContextProperty("ThreadManager", m_threadManager); engine()->rootContext()->setContextProperty("ThreadManager", m_threadManager);
......
...@@ -52,6 +52,21 @@ ...@@ -52,6 +52,21 @@
#include <DocumentManager.h> #include <DocumentManager.h>
#include <KisSketchView.h> #include <KisSketchView.h>
#include <QVersionNumber>
namespace
{
bool shouldSetAcceptTouchEvents()
{
// See https://bugreports.qt.io/browse/QTBUG-66718
static QVersionNumber qtVersion = QVersionNumber::fromString(qVersion());
static bool retval = qtVersion > QVersionNumber(5, 9, 3) && qtVersion.normalized() != QVersionNumber(5, 10);
return retval;
}
} // namespace
class TouchDockerDock::Private class TouchDockerDock::Private
{ {
public: public:
...@@ -99,6 +114,9 @@ TouchDockerDock::TouchDockerDock() ...@@ -99,6 +114,9 @@ TouchDockerDock::TouchDockerDock()
} }
m_quickWidget = new QQuickWidget(this); m_quickWidget = new QQuickWidget(this);
if (shouldSetAcceptTouchEvents()) {
m_quickWidget->setAttribute(Qt::WA_AcceptTouchEvents);
}
setWidget(m_quickWidget); setWidget(m_quickWidget);
setEnabled(true); setEnabled(true);
m_quickWidget->engine()->rootContext()->setContextProperty("mainWindow", this); m_quickWidget->engine()->rootContext()->setContextProperty("mainWindow", this);
...@@ -309,6 +327,9 @@ KoDialog *TouchDockerDock::createDialog(const QString qml) ...@@ -309,6 +327,9 @@ KoDialog *TouchDockerDock::createDialog(const QString qml)
dlg->setButtons(KoDialog::None); dlg->setButtons(KoDialog::None);
QQuickWidget *quickWidget = new QQuickWidget(this); QQuickWidget *quickWidget = new QQuickWidget(this);
if (shouldSetAcceptTouchEvents()) {
quickWidget->setAttribute(Qt::WA_AcceptTouchEvents);
}
dlg->setMainWidget(quickWidget); dlg->setMainWidget(quickWidget);
setEnabled(true); setEnabled(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment