From 797d44e7415e8f9d582dd2838957cf309cea9449 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 11 May 2010 09:01:51 +1000 Subject: Temporary work-around for QTBUG-9849. May allow better experimentation and bug fixing. --- tools/qml/main.cpp | 6 ++++++ tools/qml/qmlruntime.cpp | 11 +++++++++++ tools/qml/qmlruntime.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index fb687ac..116ca71 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -231,6 +231,7 @@ int main(int argc, char ** argv) bool stayOnTop = false; bool maximized = false; bool useNativeFileBrowser = true; + bool experimentalGestures = false; WarningsConfig warningsConfig = DefaultWarnings; bool sizeToView = true; @@ -334,6 +335,8 @@ int main(int argc, char ** argv) sizeToView = false; } else if (arg == "-sizerootobjecttoview") { sizeToView = true; + } else if (arg == "-experimentalgestures") { + experimentalGestures = true; } else if (arg[0] != '-') { fileName = arg; } else if (1 || arg == "-help") { @@ -403,6 +406,9 @@ int main(int argc, char ** argv) } #endif + if (experimentalGestures) + viewer->enableExperimentalGestures(); + foreach (QString lib, imports) viewer->addLibraryPath(lib); diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 06fa004..16b0ffb 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -501,6 +501,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) } canvas = new QDeclarativeView(this); + canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); @@ -550,6 +551,16 @@ QDeclarativeViewer::~QDeclarativeViewer() delete namFactory; } +void QDeclarativeViewer::enableExperimentalGestures() +{ + canvas->viewport()->grabGesture(Qt::TapGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::TapAndHoldGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::PanGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::PinchGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->grabGesture(Qt::SwipeGesture,Qt::DontStartGestureOnChildren|Qt::ReceivePartialGestures|Qt::IgnoredGesturesPropagateToParent); + canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); +} + int QDeclarativeViewer::menuBarHeight() const { if (!(windowFlags() & Qt::FramelessWindowHint)) diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 9551090..b021d0d 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -112,6 +112,8 @@ public: QDeclarativeView *view() const; LoggerWidget *warningsWidget() const; + void enableExperimentalGestures(); + public slots: void sceneResized(QSize size); bool open(const QString&); -- cgit v0.12