diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-12 00:42:22 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-12 00:42:22 (GMT) |
commit | 4e3f88c8b1d74b720bf3e17f9bdedf84a9748b3d (patch) | |
tree | c23b51ac0a1a244a0f18d287f0feebb20268eefb /examples | |
parent | 49cc2d35d7da4a78d696503930720e88a6403722 (diff) | |
parent | a4053a6e7a9a686433dc4814a5b52da3bc96969f (diff) | |
download | Qt-4e3f88c8b1d74b720bf3e17f9bdedf84a9748b3d.zip Qt-4e3f88c8b1d74b720bf3e17f9bdedf84a9748b3d.tar.gz Qt-4e3f88c8b1d74b720bf3e17f9bdedf84a9748b3d.tar.bz2 |
Merge branch '4.6' of git://scm.dev.nokia.troll.no/qt/qt into kinetic-declarativeui
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dialogs/findfiles/window.cpp | 2 | ||||
-rw-r--r-- | examples/multitouch/pinchzoom/graphicsview.cpp | 20 | ||||
-rw-r--r-- | examples/multitouch/pinchzoom/graphicsview.h | 3 |
3 files changed, 19 insertions, 6 deletions
diff --git a/examples/dialogs/findfiles/window.cpp b/examples/dialogs/findfiles/window.cpp index f8fc00b..afe6399 100644 --- a/examples/dialogs/findfiles/window.cpp +++ b/examples/dialogs/findfiles/window.cpp @@ -243,7 +243,7 @@ void Window::openFileOfItem(int row, int /* column */) { QTableWidgetItem *item = filesTable->item(row, 0); - QDesktopServices::openUrl(currentDir.absoluteFilePath(item->text())); + QDesktopServices::openUrl(QUrl::fromLocalFile(currentDir.absoluteFilePath(item->text()))); } //! [12] diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp index 0c79073..00e620a 100644 --- a/examples/multitouch/pinchzoom/graphicsview.cpp +++ b/examples/multitouch/pinchzoom/graphicsview.cpp @@ -45,7 +45,7 @@ #include <QTouchEvent> GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent) - : QGraphicsView(scene, parent) + : QGraphicsView(scene, parent), totalScaleFactor(1) { viewport()->setAttribute(Qt::WA_AcceptTouchEvents); setDragMode(ScrollHandDrag); @@ -58,14 +58,24 @@ bool GraphicsView::viewportEvent(QEvent *event) case QEvent::TouchUpdate: case QEvent::TouchEnd: { - QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints(); + QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); + QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints(); if (touchPoints.count() == 2) { // determine scale factor const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first(); const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last(); - const qreal scaleFactor = QLineF(touchPoint0.pos(), touchPoint1.pos()).length() - / QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length(); - setTransform(QTransform().scale(scaleFactor, scaleFactor)); + qreal currentScaleFactor = + QLineF(touchPoint0.pos(), touchPoint1.pos()).length() + / QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length(); + if (touchEvent->touchPointStates() & Qt::TouchPointReleased) { + // if one of the fingers is released, remember the current scale + // factor so that adding another finger later will continue zooming + // by adding new scale factor to the existing remembered value. + totalScaleFactor *= currentScaleFactor; + currentScaleFactor = 1; + } + setTransform(QTransform().scale(totalScaleFactor * currentScaleFactor, + totalScaleFactor * currentScaleFactor)); } return true; } diff --git a/examples/multitouch/pinchzoom/graphicsview.h b/examples/multitouch/pinchzoom/graphicsview.h index c5195cd..81a115d 100644 --- a/examples/multitouch/pinchzoom/graphicsview.h +++ b/examples/multitouch/pinchzoom/graphicsview.h @@ -50,4 +50,7 @@ public: GraphicsView(QGraphicsScene *scene = 0, QWidget *parent = 0); bool viewportEvent(QEvent *event); + +private: + qreal totalScaleFactor; }; |