diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-10-04 22:53:42 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-10-04 22:53:42 (GMT) |
commit | 276857a52db4640095ede5e7840fabb451b97b85 (patch) | |
tree | dd8f26f85583a99b411bbcd6e5ceb4d280ff4af9 /demos | |
parent | c76bb1dcda7b0339d9de427d155b593b3779bea7 (diff) | |
parent | 34a1438c4184afecc237fe0177ed4a536b2d5e43 (diff) | |
download | Qt-276857a52db4640095ede5e7840fabb451b97b85.zip Qt-276857a52db4640095ede5e7840fabb451b97b85.tar.gz Qt-276857a52db4640095ede5e7840fabb451b97b85.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
configure
Diffstat (limited to 'demos')
30 files changed, 316 insertions, 44 deletions
diff --git a/demos/affine/main.cpp b/demos/affine/main.cpp index 7d3d781..61fde96 100644 --- a/demos/affine/main.cpp +++ b/demos/affine/main.cpp @@ -54,8 +54,10 @@ int main(int argc, char **argv) xformWidget.setStyle(arthurStyle); QList<QWidget *> widgets = qFindChildren<QWidget *>(&xformWidget); - foreach (QWidget *w, widgets) + foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); + w->setAttribute(Qt::WA_AcceptTouchEvents); + } xformWidget.show(); diff --git a/demos/browser/browser.pro b/demos/browser/browser.pro index 407030f..dab9387 100644 --- a/demos/browser/browser.pro +++ b/demos/browser/browser.pro @@ -93,6 +93,6 @@ sources.path = $$[QT_INSTALL_DEMOS]/browser INSTALLS += target sources symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF70 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/deform/deform.pro b/demos/deform/deform.pro index 4cce195..421432d 100644 --- a/demos/deform/deform.pro +++ b/demos/deform/deform.pro @@ -19,6 +19,6 @@ sources.path = $$[QT_INSTALL_DEMOS]/deform INSTALLS += target sources symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000A63D + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/anomaly/anomaly.pro b/demos/embedded/anomaly/anomaly.pro index f7c11b6..06d73fa 100644 --- a/demos/embedded/anomaly/anomaly.pro +++ b/demos/embedded/anomaly/anomaly.pro @@ -22,10 +22,10 @@ SOURCES += src/Main.cpp \ RESOURCES += src/anomaly.qrc symbian { + TARGET.UID3 = 0xA000CF71 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h LIBS += -lesock -linsock -lconnmon TARGET.CAPABILITY = NetworkServices TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 - TARGET.UID3 = 0xA000CF71 } diff --git a/demos/embedded/desktopservices/desktopservices.pro b/demos/embedded/desktopservices/desktopservices.pro index 81fe16d..c160029c 100644 --- a/demos/embedded/desktopservices/desktopservices.pro +++ b/demos/embedded/desktopservices/desktopservices.pro @@ -16,7 +16,7 @@ image.path = /data/images/ DEPLOYMENT += music image symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000C611 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) ICON = ./resources/heart.svg } diff --git a/demos/embedded/digiflip/digiflip.pro b/demos/embedded/digiflip/digiflip.pro index 4db5171..72cdc0f 100644 --- a/demos/embedded/digiflip/digiflip.pro +++ b/demos/embedded/digiflip/digiflip.pro @@ -1,7 +1,7 @@ SOURCES = digiflip.cpp symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF72 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro index 9401871..209ec1a 100644 --- a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro +++ b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro @@ -16,6 +16,6 @@ wince* { } symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000A640 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/flickable/flickable.pro b/demos/embedded/flickable/flickable.pro index 02e88aa..731dcbe 100644 --- a/demos/embedded/flickable/flickable.pro +++ b/demos/embedded/flickable/flickable.pro @@ -2,6 +2,6 @@ SOURCES = flickable.cpp main.cpp HEADERS = flickable.h symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF73 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro index 2f36cb8..5659fa2 100644 --- a/demos/embedded/flightinfo/flightinfo.pro +++ b/demos/embedded/flightinfo/flightinfo.pro @@ -6,8 +6,8 @@ RESOURCES = flightinfo.qrc QT += network symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF74 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h LIBS += -lesock -lconnmon -linsock TARGET.CAPABILITY = NetworkServices diff --git a/demos/embedded/fluidlauncher/config_s60/config.xml b/demos/embedded/fluidlauncher/config_s60/config.xml index acd14cb..fefa3dd 100644 --- a/demos/embedded/fluidlauncher/config_s60/config.xml +++ b/demos/embedded/fluidlauncher/config_s60/config.xml @@ -7,7 +7,7 @@ <example filename="pathstroke" name="Path Stroking" image="screenshots/pathstroke.png" args="-small-screen"/> <example filename="wiggly" name="Wiggly Text" image="screenshots/wiggly_s60.png" args="-small-screen"/> <example filename="ftp" name="Ftp Client" image="screenshots/ftp_s60.png"/> - <example filename="context2d" name="Context2d" image="screenshots/context2d_s60.png"/> + <example filename="context2d" name="Context2d" image="screenshots/context2d_s60.png" args="-small-screen"/> <example filename="saxbookmarks" name="SaxBookmarks" image="screenshots/saxbookmarks_s60.png"/> <example filename="desktopservices" name="Desktop Services" image="screenshots/desktopservices_s60.png"/> <example filename="fridgemagnets" name="Fridge Magnets" image="screenshots/fridgemagnets_s60.png" args="-small-screen"/> @@ -20,7 +20,7 @@ <example filename="weatherinfo" name="Weather Info" image="screenshots/weatherinfo.png"/> <example filename="flickable" name="Kinetic Scrolling" image="screenshots/flickable.png"/> <example filename="digiflip" name="Flipping Clock" image="screenshots/digiflip.png"/> - <example filename="qmediaplayer" name="Media Player" image="screenshots/mediaplayer.png"/> + <example filename="qmediaplayer" name="Media Player" image="screenshots/mediaplayer.png" args="-small-screen"/> </demos> <slideshow timeout="60000" interval="10000"> <imagedir dir="slides"/> diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index 408bf53..d677e9d 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -59,6 +59,7 @@ symbian { load(data_caging_paths) TARGET.UID3 = 0xA000A641 + ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg executables.sources = \ styledemo.exe \ @@ -123,6 +124,25 @@ symbian { resource.path = $$APP_RESOURCE_DIR + mifs.sources = \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A641.mif \ #fluidlauncher + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63F.mif \ #styledemo + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63D.mif \ #deform + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A63E.mif \ #pathstroke + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C607.mif \ #wiggly + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A648.mif \ #ftp + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C60A.mif \ #saxbookmarks + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif \ #desktopservices + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C610.mif \ #fridgemagnets + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C612.mif \ #drilldown + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF6B.mif \ #softkeys + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF76.mif \ #raycasting + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF73.mif \ #flickable + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF72.mif \ #digiflip + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF75.mif \ #lightmaps + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF74.mif #flightinfo + mifs.path = $$APP_RESOURCE_DIR + contains(QT_CONFIG, svg) { executables.sources += \ embeddedsvgviewer.exe \ @@ -135,28 +155,35 @@ symbian { resource.sources += \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/weatherinfo.rsc + + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000A640.mif \ #embeddedsvgviewer + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF77.mif #weatherinfo + } contains(QT_CONFIG, webkit) { executables.sources += anomaly.exe reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000CF71.mif #anomaly } contains(QT_CONFIG, phonon) { executables.sources += qmediaplayer.exe resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/qmediaplayer.rsc + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C613.mif #qmediaplayer } contains(QT_CONFIG, script) { executables.sources += context2d.exe reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.rsc + mifs.sources += \ + $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C608.mif #context2d } - mifs.sources = \ - $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/0xA000C611.mif - mifs.path = $$APP_RESOURCE_DIR - files.sources = $$PWD/screenshots $$PWD/slides files.path = . @@ -166,6 +193,7 @@ symbian { viewerimages.sources = $$PWD/../embeddedsvgviewer/shapes.svg viewerimages.path = /data/images/qt/demos/embeddedsvgviewer + # demos/mediaplayer make also use of these files. desktopservices_music.sources = \ $$PWD/../desktopservices/data/*.mp3 \ $$PWD/../desktopservices/data/*.wav diff --git a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png Binary files differindex 1304a19..2d8a637 100644 --- a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png +++ b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro index d4168b1..122865e 100644 --- a/demos/embedded/lightmaps/lightmaps.pro +++ b/demos/embedded/lightmaps/lightmaps.pro @@ -3,8 +3,8 @@ SOURCES = lightmaps.cpp QT += network symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF75 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h LIBS += -lesock -lconnmon -linsock TARGET.CAPABILITY = NetworkServices diff --git a/demos/embedded/raycasting/raycasting.pro b/demos/embedded/raycasting/raycasting.pro index 19e0212..8dd8a24 100644 --- a/demos/embedded/raycasting/raycasting.pro +++ b/demos/embedded/raycasting/raycasting.pro @@ -3,6 +3,6 @@ SOURCES = raycasting.cpp RESOURCES += raycasting.qrc symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF76 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/styledemo/styledemo.pro b/demos/embedded/styledemo/styledemo.pro index 7107798..2125f3b 100644 --- a/demos/embedded/styledemo/styledemo.pro +++ b/demos/embedded/styledemo/styledemo.pro @@ -12,6 +12,6 @@ sources.path = $$[QT_INSTALL_DEMOS]/embedded/styledemo INSTALLS += target sources symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000A63F + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/embedded/weatherinfo/weatherinfo.pro b/demos/embedded/weatherinfo/weatherinfo.pro index 7bff6e9..5b2f03a 100644 --- a/demos/embedded/weatherinfo/weatherinfo.pro +++ b/demos/embedded/weatherinfo/weatherinfo.pro @@ -5,8 +5,8 @@ RESOURCES = weatherinfo.qrc QT += network svg symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000CF77 + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h LIBS += -lesock -lconnmon -linsock TARGET.CAPABILITY = NetworkServices diff --git a/demos/gradients/main.cpp b/demos/gradients/main.cpp index 9ffcdd1..c70cdb7 100644 --- a/demos/gradients/main.cpp +++ b/demos/gradients/main.cpp @@ -53,8 +53,10 @@ int main(int argc, char **argv) QStyle *arthurStyle = new ArthurStyle(); gradientWidget.setStyle(arthurStyle); QList<QWidget *> widgets = qFindChildren<QWidget *>(&gradientWidget); - foreach (QWidget *w, widgets) + foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); + w->setAttribute(Qt::WA_AcceptTouchEvents); + } gradientWidget.show(); return app.exec(); diff --git a/demos/mediaplayer/main.cpp b/demos/mediaplayer/main.cpp index fd1431d..66aa445 100644 --- a/demos/mediaplayer/main.cpp +++ b/demos/mediaplayer/main.cpp @@ -50,9 +50,39 @@ int main (int argc, char *argv[]) app.setOrganizationName("Qt"); app.setQuitOnLastWindowClosed(true); - QString fileString = app.arguments().value(1); - MediaPlayer player(fileString); - player.show(); + bool hasSmallScreen = +#ifdef Q_OS_SYMBIAN + /* On Symbian, we always want fullscreen. One reason is that it's not + * possible to launch any demos from the fluidlauncher due to a + * limitation in the emulator. */ + true +#else + false +#endif + ; + + QString fileString; + const QStringList args(app.arguments()); + /* We have a minor problem here, we accept two arguments, both are + * optional: + * - A file name + * - the option "-small-screen", so let's try to cope with that. + */ + for (int i = 0; i < args.count(); ++i) { + const QString &at = args.at(i); + + if (at == QLatin1String("-small-screen")) + hasSmallScreen = true; + else if (i > 0) // We don't want the app name. + fileString = at; + } + + MediaPlayer player(fileString, hasSmallScreen); + + if (hasSmallScreen) + player.showMaximized(); + else + player.show(); return app.exec(); } diff --git a/demos/mediaplayer/mediaplayer.cpp b/demos/mediaplayer/mediaplayer.cpp index 8dd0609..baac236 100644 --- a/demos/mediaplayer/mediaplayer.cpp +++ b/demos/mediaplayer/mediaplayer.cpp @@ -147,10 +147,12 @@ private: }; -MediaPlayer::MediaPlayer(const QString &filePath) : +MediaPlayer::MediaPlayer(const QString &filePath, + const bool hasSmallScreen) : playButton(0), nextEffect(0), settingsDialog(0), ui(0), m_AudioOutput(Phonon::VideoCategory), - m_videoWidget(new MediaVideoWidget(this)) + m_videoWidget(new MediaVideoWidget(this)), + m_hasSmallScreen(hasSmallScreen) { setWindowTitle(tr("Media Player")); setContextMenuPolicy(Qt::CustomContextMenu); @@ -341,13 +343,15 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) info->setVisible(!m_MediaObject.hasVideo()); QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); - if (m_MediaObject.hasVideo()){ - // Flush event que so that sizeHint takes the - // recently shown/hidden m_videoWindow into account: - qApp->processEvents(); - resize(sizeHint()); - } else - resize(minimumSize()); + if (!m_hasSmallScreen) { + if (m_MediaObject.hasVideo()) { + // Flush event que so that sizeHint takes the + // recently shown/hidden m_videoWindow into account: + qApp->processEvents(); + resize(sizeHint()); + } else + resize(minimumSize()); + } } switch (newstate) { @@ -648,7 +652,8 @@ void MediaPlayer::setFile(const QString &fileName) void MediaPlayer::openFile() { - QStringList fileNames = QFileDialog::getOpenFileNames(this); + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), + QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); m_MediaObject.clearQueue(); if (fileNames.size() > 0) { QString fileName = fileNames[0]; diff --git a/demos/mediaplayer/mediaplayer.h b/demos/mediaplayer/mediaplayer.h index 38ace26..40ffa40 100644 --- a/demos/mediaplayer/mediaplayer.h +++ b/demos/mediaplayer/mediaplayer.h @@ -72,7 +72,8 @@ class MediaPlayer : { Q_OBJECT public: - MediaPlayer(const QString &); + MediaPlayer(const QString &, + const bool hasSmallScreen); void dragEnterEvent(QDragEnterEvent *e); void dragMoveEvent(QDragMoveEvent *e); @@ -132,6 +133,7 @@ private: Phonon::AudioOutput m_AudioOutput; Phonon::VideoWidget *m_videoWidget; Phonon::Path m_audioOutputPath; + const bool m_hasSmallScreen; }; #endif //MEDIAPLAYER_H diff --git a/demos/mediaplayer/mediaplayer.pro b/demos/mediaplayer/mediaplayer.pro index 8f9ec82..84293f2 100644 --- a/demos/mediaplayer/mediaplayer.pro +++ b/demos/mediaplayer/mediaplayer.pro @@ -16,7 +16,7 @@ RESOURCES += mediaplayer.qrc SOURCES += main.cpp mediaplayer.cpp HEADERS += mediaplayer.h -target.path = $$[QT_INSTALL_DEMOS]/mediaplayer +target.path = $$[QT_INSTALL_DEMOS]/qmediaplayer sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images sources.path = $$[QT_INSTALL_DEMOS]/mediaplayer INSTALLS += target sources @@ -26,6 +26,12 @@ DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout } symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000C613 + + addFiles.sources = ../../tests/auto/mediaobject/media/sax.mp3 + + addFiles.path = /data/sounds/ + DEPLOYMENT += addFiles + + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/pathstroke/main.cpp b/demos/pathstroke/main.cpp index 60520f1..67f4639 100644 --- a/demos/pathstroke/main.cpp +++ b/demos/pathstroke/main.cpp @@ -57,8 +57,10 @@ int main(int argc, char **argv) QStyle *arthurStyle = new ArthurStyle(); pathStrokeWidget.setStyle(arthurStyle); QList<QWidget *> widgets = qFindChildren<QWidget *>(&pathStrokeWidget); - foreach (QWidget *w, widgets) + foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); + w->setAttribute(Qt::WA_AcceptTouchEvents); + } if (smallScreen) pathStrokeWidget.showFullScreen(); diff --git a/demos/pathstroke/pathstroke.cpp b/demos/pathstroke/pathstroke.cpp index fdc7480..e072f0a 100644 --- a/demos/pathstroke/pathstroke.cpp +++ b/demos/pathstroke/pathstroke.cpp @@ -402,6 +402,7 @@ PathStrokeRenderer::PathStrokeRenderer(QWidget *parent, bool smallScreen) m_penStyle = Qt::SolidLine; m_wasAnimated = true; setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setAttribute(Qt::WA_AcceptTouchEvents); } void PathStrokeRenderer::paint(QPainter *painter) @@ -510,10 +511,6 @@ void PathStrokeRenderer::updatePoints() Q_ASSERT(m_points.size() == m_vectors.size()); for (int i=0; i<m_points.size(); ++i) { - - if (i == m_activePoint) - continue; - QPointF pos = m_points.at(i); QPointF vec = m_vectors.at(i); pos += vec; @@ -532,6 +529,8 @@ void PathStrokeRenderer::updatePoints() void PathStrokeRenderer::mousePressEvent(QMouseEvent *e) { + if (!m_fingerPointMapping.isEmpty()) + return; setDescriptionEnabled(false); m_activePoint = -1; qreal distance = -1; @@ -556,6 +555,8 @@ void PathStrokeRenderer::mousePressEvent(QMouseEvent *e) void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e) { + if (!m_fingerPointMapping.isEmpty()) + return; // If we've moved more then 25 pixels, assume user is dragging if (!m_mouseDrag && QPoint(m_mousePress - e->pos()).manhattanLength() > 25) m_mouseDrag = true; @@ -568,6 +569,8 @@ void PathStrokeRenderer::mouseMoveEvent(QMouseEvent *e) void PathStrokeRenderer::mouseReleaseEvent(QMouseEvent *) { + if (!m_fingerPointMapping.isEmpty()) + return; m_activePoint = -1; setAnimation(m_wasAnimated); @@ -586,6 +589,90 @@ void PathStrokeRenderer::timerEvent(QTimerEvent *e) // } } +bool PathStrokeRenderer::event(QEvent *e) +{ + bool touchBegin = false; + switch (e->type()) { + case QEvent::TouchBegin: + touchBegin = true; + case QEvent::TouchUpdate: + { + const QTouchEvent *const event = static_cast<const QTouchEvent*>(e); + const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); + foreach (const QTouchEvent::TouchPoint &touchPoint, points) { + const int id = touchPoint.id(); + switch (touchPoint.state()) { + case Qt::TouchPointPressed: + { + // find the point, move it + QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values()); + int activePoint = -1; + qreal distance = -1; + const int pointsCount = m_points.size(); + for (int i=0; i<pointsCount; ++i) { + if (activePoints.contains(i)) + continue; + + qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); + if ((distance < 0 && d < 12 * m_pointSize) || d < distance) { + distance = d; + activePoint = i; + } + } + if (activePoint != -1) { + m_fingerPointMapping.insert(touchPoint.id(), activePoint); + m_points[activePoint] = touchPoint.pos(); + } + } + break; + case Qt::TouchPointReleased: + { + // move the point and release + QHash<int,int>::iterator it = m_fingerPointMapping.find(id); + m_points[it.value()] = touchPoint.pos(); + m_fingerPointMapping.erase(it); + } + break; + case Qt::TouchPointMoved: + { + // move the point + const int pointIdx = m_fingerPointMapping.value(id, -1); + if (pointIdx >= 0) + m_points[pointIdx] = touchPoint.pos(); + } + break; + default: + break; + } + } + if (m_fingerPointMapping.isEmpty()) { + e->ignore(); + return false; + } else { + if (touchBegin) { + m_wasAnimated = m_timer.isActive(); + setAnimation(false); + } + update(); + return true; + } + } + break; + case QEvent::TouchEnd: + if (m_fingerPointMapping.isEmpty()) { + e->ignore(); + return false; + } + m_fingerPointMapping.clear(); + setAnimation(m_wasAnimated); + return true; + break; + default: + break; + } + return QWidget::event(e); +} + void PathStrokeRenderer::setAnimation(bool animation) { m_timer.stop(); diff --git a/demos/pathstroke/pathstroke.h b/demos/pathstroke/pathstroke.h index 3ff2c55..e869515 100644 --- a/demos/pathstroke/pathstroke.h +++ b/demos/pathstroke/pathstroke.h @@ -60,6 +60,7 @@ public: void mouseMoveEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); void timerEvent(QTimerEvent *e); + bool event(QEvent *e); QSize sizeHint() const { return QSize(500, 500); } @@ -118,6 +119,8 @@ private: bool m_smallScreen; QPoint m_mousePress; bool m_mouseDrag; + + QHash<int, int> m_fingerPointMapping; }; class PathStrokeControls : public QWidget diff --git a/demos/pathstroke/pathstroke.pro b/demos/pathstroke/pathstroke.pro index ac50842..43f20b6 100644 --- a/demos/pathstroke/pathstroke.pro +++ b/demos/pathstroke/pathstroke.pro @@ -19,6 +19,6 @@ sources.path = $$[QT_INSTALL_DEMOS]/pathstroke INSTALLS += target sources symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000A63E + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/shared/arthurwidgets.h b/demos/shared/arthurwidgets.h index aa70002..7b02bcd 100644 --- a/demos/shared/arthurwidgets.h +++ b/demos/shared/arthurwidgets.h @@ -49,13 +49,32 @@ #if defined(QT_OPENGL_SUPPORT) #include <QGLWidget> +#include <QEvent> class GLWidget : public QGLWidget { public: GLWidget(QWidget *parent) - : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) {} + : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) + { + setAttribute(Qt::WA_AcceptTouchEvents); + } void disableAutoBufferSwap() { setAutoBufferSwap(false); } void paintEvent(QPaintEvent *) { parentWidget()->update(); } +protected: + bool event(QEvent *event) + { + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + event->ignore(); + return false; + break; + default: + break; + } + return QGLWidget::event(event); + } }; #endif diff --git a/demos/shared/hoverpoints.cpp b/demos/shared/hoverpoints.cpp index 182f4d8..84f5815 100644 --- a/demos/shared/hoverpoints.cpp +++ b/demos/shared/hoverpoints.cpp @@ -53,6 +53,7 @@ HoverPoints::HoverPoints(QWidget *widget, PointShape shape) { m_widget = widget; widget->installEventFilter(this); + widget->setAttribute(Qt::WA_AcceptTouchEvents); m_connectionType = CurveConnection; m_sortType = NoSort; @@ -86,6 +87,8 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) case QEvent::MouseButtonPress: { + if (!m_fingerPointMapping.isEmpty()) + return true; QMouseEvent *me = (QMouseEvent *) event; QPointF clickPos = me->pos(); @@ -147,13 +150,90 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) break; case QEvent::MouseButtonRelease: + if (!m_fingerPointMapping.isEmpty()) + return true; m_currentIndex = -1; break; case QEvent::MouseMove: + if (!m_fingerPointMapping.isEmpty()) + return true; if (m_currentIndex >= 0) movePoint(m_currentIndex, ((QMouseEvent *)event)->pos()); break; + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + { + const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event); + const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints(); + const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); + foreach (const QTouchEvent::TouchPoint &touchPoint, points) { + const int id = touchPoint.id(); + switch (touchPoint.state()) { + case Qt::TouchPointPressed: + { + // find the point, move it + QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values()); + int activePoint = -1; + qreal distance = -1; + const int pointsCount = m_points.size(); + const int activePointCount = activePoints.size(); + if (pointsCount == 2 && activePointCount == 1) { // only two points + activePoint = activePoints.contains(0) ? 1 : 0; + } else { + for (int i=0; i<pointsCount; ++i) { + if (activePoints.contains(i)) + continue; + + qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length(); + if ((distance < 0 && d < 12 * pointSize) || d < distance) { + distance = d; + activePoint = i; + } + + } + } + if (activePoint != -1) { + m_fingerPointMapping.insert(touchPoint.id(), activePoint); + movePoint(activePoint, touchPoint.pos()); + } + } + break; + case Qt::TouchPointReleased: + { + // move the point and release + QHash<int,int>::iterator it = m_fingerPointMapping.find(id); + movePoint(it.value(), touchPoint.pos()); + m_fingerPointMapping.erase(it); + } + break; + case Qt::TouchPointMoved: + { + // move the point + const int pointIdx = m_fingerPointMapping.value(id, -1); + if (pointIdx >= 0) // do we track this point? + movePoint(pointIdx, touchPoint.pos()); + } + break; + default: + break; + } + } + if (m_fingerPointMapping.isEmpty()) { + event->ignore(); + return false; + } else { + return true; + } + } + break; + case QEvent::TouchEnd: + if (m_fingerPointMapping.isEmpty()) { + event->ignore(); + return false; + } + return true; + break; case QEvent::Resize: { @@ -262,6 +342,8 @@ static QPointF bound_point(const QPointF &point, const QRectF &bounds, int lock) void HoverPoints::setPoints(const QPolygonF &points) { + if (points.size() != m_points.size()) + m_fingerPointMapping.clear(); m_points.clear(); for (int i=0; i<points.size(); ++i) m_points << bound_point(points.at(i), boundingRect(), 0); diff --git a/demos/shared/hoverpoints.h b/demos/shared/hoverpoints.h index 8f6e1b8..23ac8c1 100644 --- a/demos/shared/hoverpoints.h +++ b/demos/shared/hoverpoints.h @@ -133,6 +133,8 @@ private: bool m_editable; bool m_enabled; + QHash<int, int> m_fingerPointMapping; + QPen m_pointPen; QBrush m_pointBrush; QPen m_connectionPen; diff --git a/demos/shared/shared.pro b/demos/shared/shared.pro index de29857..0f7137f 100644 --- a/demos/shared/shared.pro +++ b/demos/shared/shared.pro @@ -33,6 +33,6 @@ INSTALLS += sources !cross_compile:INSTALLS += target symbian { - include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) TARGET.UID3 = 0xA000A63C + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) } diff --git a/demos/symbianpkgrules.pri b/demos/symbianpkgrules.pri index 7e6852b..cf52cb3 100644 --- a/demos/symbianpkgrules.pri +++ b/demos/symbianpkgrules.pri @@ -11,3 +11,5 @@ vendorinfo = \ " " default_deployment.pkg_prerules += vendorinfo + +!isEmpty(TARGET.UID3):ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg |