From 170cf2d84158a071f8564c3fa65f6fd6afcada44 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 3 Nov 2009 09:24:55 +1000 Subject: Fix crash. --- doc/src/declarative/tutorial3.qdoc | 2 +- .../webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index c13accf..290b535 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -6,7 +6,7 @@ In this chapter, we make this example a little bit more dynamic by introducing s We want our text to move to the bottom of the screen, rotate and become red when clicked. -\image declarative-tutorial3.gif +\image declarative-tutorial3_animation.gif Here is the QML code: diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index f8403b7..b6823dd 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -145,16 +145,8 @@ RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index) return &frame; } -void ImageDecoderQt::clearFrameBufferCache(size_t index) +void ImageDecoderQt::clearFrameBufferCache(size_t /*index*/) { - // Currently QImageReader will be asked to read everything. This - // might change when we read gif images on demand. For now we - // can have a rather simple implementation. - if (index > m_frameBufferCache.size()) - return; - - for (size_t i = 0; i < index; ++index) - m_frameBufferCache[index].clear(); } void ImageDecoderQt::internalDecodeSize() -- cgit v0.12 table>
summaryrefslogtreecommitdiffstats
path: root/tests/manual/gestures
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/gestures')
-rw-r--r--tests/manual/gestures/graphicsview/gestures.cpp131
-rw-r--r--tests/manual/gestures/graphicsview/gestures.h78
-rw-r--r--tests/manual/gestures/graphicsview/graphicsview.pro17
-rw-r--r--tests/manual/gestures/graphicsview/imageitem.cpp93
-rw-r--r--tests/manual/gestures/graphicsview/imageitem.h (renamed from tests/manual/gestures/pinch/pinchwidget.h)47
-rw-r--r--tests/manual/gestures/graphicsview/main.cpp230
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp112
-rw-r--r--tests/manual/gestures/graphicsview/mousepangesturerecognizer.h (renamed from tests/manual/gestures/pinch/main.cpp)33
-rw-r--r--tests/manual/gestures/pinch/pinch.pro4
-rw-r--r--tests/manual/gestures/pinch/pinch.qrc5
-rw-r--r--tests/manual/gestures/pinch/pinchwidget.cpp118
-rw-r--r--tests/manual/gestures/pinch/qt-logo.pngbin13923 -> 0 bytes
-rw-r--r--tests/manual/gestures/scrollarea/main.cpp229
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp94
-rw-r--r--tests/manual/gestures/scrollarea/mousepangesturerecognizer.h57
-rw-r--r--tests/manual/gestures/scrollarea/scrollarea.pro3
-rw-r--r--tests/manual/gestures/twopanwidgets/main.cpp135
-rw-r--r--tests/manual/gestures/twopanwidgets/twopanwidgets.pro1
18 files changed, 1078 insertions, 309 deletions
diff --git a/tests/manual/gestures/graphicsview/gestures.cpp b/tests/manual/gestures/graphicsview/gestures.cpp
new file mode 100644
index 0000000..5416457
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/gestures.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "gestures.h"
+
+#include <QTouchEvent>
+
+Qt::GestureType ThreeFingerSlideGesture::Type = Qt::CustomGesture;
+
+QGesture *ThreeFingerSlideGestureRecognizer::createGesture(QObject *)
+{
+ return new ThreeFingerSlideGesture;
+}
+
+QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+{
+ ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state);
+ QGestureRecognizer::Result result;
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ result = QGestureRecognizer::MaybeGesture;
+ case QEvent::TouchEnd:
+ if (d->gestureFired)
+ result = QGestureRecognizer::GestureFinished;
+ else
+ result = QGestureRecognizer::NotGesture;
+ case QEvent::TouchUpdate:
+ if (d->state() != Qt::NoGesture) {
+ QTouchEvent *ev = static_cast<QTouchEvent*>(event);
+ if (ev->touchPoints().size() == 3) {
+ d->gestureFired = true;
+ result = QGestureRecognizer::GestureTriggered;
+ } else {
+ result = QGestureRecognizer::MaybeGesture;
+ for (int i = 0; i < ev->touchPoints().size(); ++i) {
+ const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i);
+ const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength();
+ if (distance > 20) {
+ result = QGestureRecognizer::NotGesture;
+ }
+ }
+ }
+ } else {
+ result = QGestureRecognizer::NotGesture;
+ }
+
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ if (d->state() != Qt::NoGesture)
+ result = QGestureRecognizer::Ignore;
+ else
+ result = QGestureRecognizer::NotGesture;
+ break;
+ default:
+ result = QGestureRecognizer::Ignore;
+ break;
+ }
+ return result;
+}
+
+void ThreeFingerSlideGestureRecognizer::reset(QGesture *state)
+{
+ static_cast<ThreeFingerSlideGesture *>(state)->gestureFired = false;
+ QGestureRecognizer::reset(state);
+}
+
+
+QGesture *RotateGestureRecognizer::createGesture(QObject *)
+{
+ return new QGesture;
+}
+
+QGestureRecognizer::Result RotateGestureRecognizer::filterEvent(QGesture *, QObject *, QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchEnd:
+ case QEvent::TouchUpdate:
+ break;
+ default:
+ break;
+ }
+ return QGestureRecognizer::Ignore;
+}
+
+void RotateGestureRecognizer::reset(QGesture *state)
+{
+ QGestureRecognizer::reset(state);
+}
+
+#include "moc_gestures.cpp"
diff --git a/tests/manual/gestures/graphicsview/gestures.h b/tests/manual/gestures/graphicsview/gestures.h
new file mode 100644
index 0000000..6140b12
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/gestures.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GESTURE_H
+#define GESTURE_H
+
+#include <QGestureRecognizer>
+#include <QGesture>
+
+class ThreeFingerSlideGesture : public QGesture
+{
+ Q_OBJECT
+public:
+ static Qt::GestureType Type;
+
+ ThreeFingerSlideGesture(QObject *parent = 0) : QGesture(parent) { }
+
+ bool gestureFired;
+};
+
+class ThreeFingerSlideGestureRecognizer : public QGestureRecognizer
+{
+private:
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
+
+class RotateGestureRecognizer : public QGestureRecognizer
+{
+public:
+ RotateGestureRecognizer();
+
+private:
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
+
+#endif // GESTURE_H
diff --git a/tests/manual/gestures/graphicsview/graphicsview.pro b/tests/manual/gestures/graphicsview/graphicsview.pro
new file mode 100644
index 0000000..a40c323
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/graphicsview.pro
@@ -0,0 +1,17 @@
+# #####################################################################
+# Automatically generated by qmake (2.01a) Mon Sep 7 13:26:43 2009
+# #####################################################################
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+# Input
+SOURCES += main.cpp \
+ imageitem.cpp \
+ gestures.cpp \
+ mousepangesturerecognizer.cpp
+
+HEADERS += imageitem.h \
+ gestures.h \
+ mousepangesturerecognizer.h
diff --git a/tests/manual/gestures/graphicsview/imageitem.cpp b/tests/manual/gestures/graphicsview/imageitem.cpp
new file mode 100644
index 0000000..307d7e4
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/imageitem.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imageitem.h"
+#include "gestures.h"
+
+#include <QPainter>
+#include <QEvent>
+
+ImageItem::ImageItem(const QImage &image)
+{
+ setImage(image);
+}
+
+void ImageItem::setImage(const QImage &image)
+{
+ image_ = image;
+ pixmap_ = QPixmap::fromImage(image.scaled(400, 400, Qt::KeepAspectRatio));
+ update();
+}
+
+QImage ImageItem::image() const
+{
+ return image_;
+}
+
+QRectF ImageItem::boundingRect() const
+{
+ const QSize size = pixmap_.size();
+ return QRectF(0, 0, size.width(), size.height());
+}
+
+void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
+{
+ painter->drawPixmap(0, 0, pixmap_);
+}
+
+
+GestureImageItem::GestureImageItem(const QImage &image)
+ : ImageItem(image)
+{
+ grabGesture(Qt::PanGesture);
+ grabGesture(ThreeFingerSlideGesture::Type);
+}
+
+bool GestureImageItem::event(QEvent *event)
+{
+ if (event->type() == QEvent::Gesture) {
+ qDebug("gestureimageitem: gesture triggered");
+ return true;
+ }
+ return ImageItem::event(event);
+}
+
+#include "moc_imageitem.cpp"
diff --git a/tests/manual/gestures/pinch/pinchwidget.h b/tests/manual/gestures/graphicsview/imageitem.h
index 7628ffc..776c8d1 100644
--- a/tests/manual/gestures/pinch/pinchwidget.h
+++ b/tests/manual/gestures/graphicsview/imageitem.h
@@ -39,40 +39,39 @@
**
****************************************************************************/
-#ifndef PINCHWIDGET_H
-#define PINCHWIDGET_H
+#ifndef IMAGEITEM_H
+#define IMAGEITEM_H
-#include <QWidget>
+#include <QGraphicsItem>
+#include <QImage>
+#include <QPixmap>
#include <QTransform>
-class QPanGesture;
-class QPinchGesture;
-
-class PinchWidget : public QWidget
+class ImageItem : public QGraphicsObject
{
Q_OBJECT
public:
- PinchWidget(const QImage &image, QWidget *parent = 0);
-
-private Q_SLOTS:
- void acceptTouchEvents();
- void onPanTriggered();
- void onPanFinished();
- void onPinchTriggered();
- void onPinchFinished();
+ ImageItem(const QImage &image);
+ void setImage(const QImage &image);
+ QImage image() const;
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
- void paintEvent(QPaintEvent *);
- QSize sizeHint() const;
+ QImage image_;
+ QPixmap pixmap_;
+ QTransform transform;
+};
- QImage image;
+class GestureImageItem : public ImageItem
+{
+ Q_OBJECT
- QPanGesture *pan;
- QPinchGesture *pinch;
+public:
+ GestureImageItem(const QImage &image);
- QTransform worldTransform;
- QTransform currentPanTransform;
- QTransform currentPinchTransform;
+protected:
+ bool event(QEvent *event);
};
-#endif // PINCHWIDGET_H
+#endif // IMAGEITEM_H
diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp
new file mode 100644
index 0000000..e9065eb
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/main.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "imageitem.h"
+#include "gestures.h"
+#include "mousepangesturerecognizer.h"
+
+class GraphicsView : public QGraphicsView
+{
+public:
+ GraphicsView(QGraphicsScene *scene, QWidget *parent = 0)
+ : QGraphicsView(scene, parent)
+ {
+ }
+protected:
+ bool viewportEvent(QEvent *event)
+ {
+ if (event->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent *>(event);
+ if (QPanGesture *pan = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture))) {
+ switch (pan->state()) {
+ case Qt::GestureStarted: qDebug("view: Pan: started"); break;
+ case Qt::GestureFinished: qDebug("view: Pan: finished"); break;
+ case Qt::GestureCanceled: qDebug("view: Pan: canceled"); break;
+ case Qt::GestureUpdated: break;
+ default: qDebug("view: Pan: <unknown state>"); break;
+ }
+
+ const QPointF offset = pan->offset();
+ QScrollBar *vbar = verticalScrollBar();
+ QScrollBar *hbar = horizontalScrollBar();
+ vbar->setValue(vbar->value() - offset.y());
+ hbar->setValue(hbar->value() - offset.x());
+ ge->accept(pan);
+ return true;
+ }
+ }
+ return QGraphicsView::viewportEvent(event);
+ }
+};
+
+class StandardGestures : public QWidget
+{
+public:
+ StandardGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new QGraphicsView(scene, 0);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class GlobalViewGestures : public QWidget
+{
+ Q_OBJECT
+public:
+ GlobalViewGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new GraphicsView(scene, 0);
+ view->viewport()->grabGesture(Qt::PanGesture);
+ view->viewport()->grabGesture(ThreeFingerSlideGesture::Type);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class GraphicsItemGestures : public QWidget
+{
+ Q_OBJECT
+public:
+ GraphicsItemGestures(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ scene = new QGraphicsScene(this);
+ scene->setSceneRect(-2000, -2000, 4000, 4000);
+ view = new QGraphicsView(scene, 0);
+ view->viewport()->grabGesture(Qt::PanGesture);
+ view->viewport()->grabGesture(ThreeFingerSlideGesture::Type);
+ QVBoxLayout *l = new QVBoxLayout(this);
+ l->addWidget(view);
+ }
+
+ QGraphicsScene *scene;
+ QGraphicsView *view;
+};
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+
+ void setDirectory(const QString &path);
+
+private:
+ QTabWidget *tabWidget;
+ StandardGestures *standardGestures;
+ GlobalViewGestures *globalViewGestures;
+ GraphicsItemGestures *graphicsItemGestures;
+};
+
+MainWindow::MainWindow()
+{
+ (void)qApp->registerGestureRecognizer(new MousePanGestureRecognizer);
+ ThreeFingerSlideGesture::Type = qApp->registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer);
+
+ tabWidget = new QTabWidget;
+
+ standardGestures = new StandardGestures;
+ tabWidget->addTab(standardGestures, "Standard gestures");
+
+ globalViewGestures = new GlobalViewGestures;
+ tabWidget->addTab(globalViewGestures , "Global gestures");
+
+ graphicsItemGestures = new GraphicsItemGestures;
+ tabWidget->addTab(graphicsItemGestures, "Graphics item gestures");
+
+ setCentralWidget(tabWidget);
+}
+
+void MainWindow::setDirectory(const QString &path)
+{
+ QDir dir(path);
+ QStringList files = dir.entryList(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
+ foreach(const QString &file, files) {
+ QImageReader img(path + QLatin1String("/")+file);
+ QImage image = img.read();
+ if (!image.isNull()) {
+ {
+ ImageItem *item = new ImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ standardGestures->scene->addItem(item);
+ }
+ {
+ ImageItem *item = new ImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ globalViewGestures->scene->addItem(item);
+ }
+ {
+ GestureImageItem *item = new GestureImageItem(image);
+ item->setPos(0, 0);
+ item->setFlags(QGraphicsItem::ItemIsMovable);
+ graphicsItemGestures->scene->addItem(item);
+ }
+ }
+ }
+
+ {
+ QList<QGraphicsItem*> items = standardGestures->scene->items();
+ if (!items.isEmpty())
+ standardGestures->view->ensureVisible(items.at(0));
+ }
+ {
+ QList<QGraphicsItem*> items = globalViewGestures->scene->items();
+ if (!items.isEmpty())
+ globalViewGestures->view->ensureVisible(items.at(0));
+ }
+ {
+ QList<QGraphicsItem*> items = graphicsItemGestures->scene->items();
+ if (!items.isEmpty())
+ graphicsItemGestures->view->ensureVisible(items.at(0));
+ }
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ MainWindow window;
+ if (QApplication::arguments().size() > 1)
+ window.setDirectory(QApplication::arguments().at(1));
+ else
+ window.setDirectory(QFileDialog::getExistingDirectory(0, "Select image folder"));
+ window.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
new file mode 100644
index 0000000..6cdbe12
--- /dev/null
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mousepangesturerecognizer.h"
+
+#include <QEvent>
+#include <QVariant>
+#include <QGraphicsSceneMouseEvent>
+#include <QMouseEvent>
+#include <QGesture>
+
+MousePanGestureRecognizer::MousePanGestureRecognizer()
+{
+}
+
+QGesture* MousePanGestureRecognizer::createGesture(QObject *)
+{
+ return new QPanGesture;
+}
+
+QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ QPoint globalPos;
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ globalPos = static_cast<QGraphicsSceneMouseEvent *>(event)->screenPos();
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ globalPos = static_cast<QMouseEvent *>(event)->globalPos();
+ break;
+ default:
+ break;
+ }
+ if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick
+ || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
+ g->setHotSpot(globalPos);
+ g->setProperty("lastPos", globalPos);
+ g->setProperty("pressed", QVariant::fromValue<bool>(true));
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) {
+ if (g->property("pressed").toBool()) {
+ QPoint pos = globalPos;
+ QPoint lastPos = g->property("lastPos").toPoint();
+ g->setLastOffset(g->offset());
+ lastPos = pos - lastPos;
+ g->setOffset(QPointF(lastPos.x(), lastPos.y()));
+ g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y()));
+ g->setProperty("lastPos", pos);
+ return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::NotGesture;
+ } else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) {
+ return QGestureRecognizer::GestureFinished | QGestureRecognizer::ConsumeEventHint;
+ }
+ return QGestureRecognizer::Ignore;
+}
+
+void MousePanGestureRecognizer::reset(QGesture *state)
+{
+ QPanGesture *g = static_cast<QPanGesture *>(state);
+ g->setTotalOffset(QPointF());
+ g->setLastOffset(QPointF());
+ g->setOffset(QPointF());
+ g->setAcceleration(0);
+ g->setProperty("lastPos", QVariant());
+ g->setProperty("pressed", QVariant::fromValue<bool>(false));
+ QGestureRecognizer::reset(state);
+}
diff --git a/tests/manual/gestures/pinch/main.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
index 4d9c14c..b062fd0 100644
--- a/tests/manual/gestures/pinch/main.cpp
+++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.h
@@ -39,30 +39,19 @@
**
****************************************************************************/
-#include <QtGui>
-#include "pinchwidget.h"
+#ifndef MOUSEPANGESTURERECOGNIZER_H
+#define MOUSEPANGESTURERECOGNIZER_H
-class MainWindow : public QWidget
+#include <QGestureRecognizer>
+
+class MousePanGestureRecognizer : public QGestureRecognizer
{
public:
- MainWindow();
-};
+ MousePanGestureRecognizer();
-MainWindow::MainWindow()
-{
- QVBoxLayout *l = new QVBoxLayout(this);
- QPushButton *btn = new QPushButton(QLatin1String("AcceptTouchEvents"));
- l->addWidget(btn);
- QImage image(":/images/qt-logo.png");
- PinchWidget *w = new PinchWidget(image);
- l->addWidget(w);
- connect(btn, SIGNAL(clicked()), w, SLOT(acceptTouchEvents()));
-}
+ QGesture* createGesture(QObject *target);
+ QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event);
+ void reset(QGesture *state);
+};
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow w;
- w.show();
- return app.exec();
-}
+#endif // MOUSEPANGESTURERECOGNIZER_H
diff --git a/tests/manual/gestures/pinch/pinch.pro b/tests/manual/gestures/pinch/pinch.pro
deleted file mode 100644