summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-11 11:44:51 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-11 11:44:51 (GMT)
commitf1342b0697705b6424ba201854622f87f22484f7 (patch)
treee7b782e9d439a74754ddc91bf6d4ae6080879798 /examples
parentb111d0bb1f0483d507c758810a0f247cb8dd82c0 (diff)
parent791c4035c28257e5a8426e6519866546faaf5286 (diff)
downloadQt-f1342b0697705b6424ba201854622f87f22484f7.zip
Qt-f1342b0697705b6424ba201854622f87f22484f7.tar.gz
Qt-f1342b0697705b6424ba201854622f87f22484f7.tar.bz2
Merge branch '4.6-platform' into 4.6
Diffstat (limited to 'examples')
-rw-r--r--examples/dialogs/findfiles/window.cpp2
-rw-r--r--examples/multitouch/pinchzoom/graphicsview.cpp20
-rw-r--r--examples/multitouch/pinchzoom/graphicsview.h3
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;
};