summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/affine/main.cpp4
-rw-r--r--demos/browser/browser.pro2
-rw-r--r--demos/deform/deform.pro2
-rw-r--r--demos/embedded/anomaly/anomaly.pro2
-rw-r--r--demos/embedded/desktopservices/desktopservices.pro2
-rw-r--r--demos/embedded/digiflip/digiflip.pro2
-rw-r--r--demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro2
-rw-r--r--demos/embedded/flickable/flickable.pro2
-rw-r--r--demos/embedded/flightinfo/flightinfo.pro2
-rw-r--r--demos/embedded/fluidlauncher/config_s60/config.xml4
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.pro36
-rw-r--r--demos/embedded/fluidlauncher/screenshots/mediaplayer.pngbin7217 -> 98092 bytes
-rw-r--r--demos/embedded/lightmaps/lightmaps.pro2
-rw-r--r--demos/embedded/raycasting/raycasting.pro2
-rw-r--r--demos/embedded/styledemo/styledemo.pro2
-rw-r--r--demos/embedded/weatherinfo/weatherinfo.pro2
-rw-r--r--demos/gradients/main.cpp4
-rw-r--r--demos/mediaplayer/main.cpp36
-rw-r--r--demos/mediaplayer/mediaplayer.cpp25
-rw-r--r--demos/mediaplayer/mediaplayer.h4
-rw-r--r--demos/mediaplayer/mediaplayer.pro10
-rw-r--r--demos/pathstroke/main.cpp4
-rw-r--r--demos/pathstroke/pathstroke.cpp95
-rw-r--r--demos/pathstroke/pathstroke.h3
-rw-r--r--demos/pathstroke/pathstroke.pro2
-rw-r--r--demos/shared/arthurwidgets.h21
-rw-r--r--demos/shared/hoverpoints.cpp82
-rw-r--r--demos/shared/hoverpoints.h2
-rw-r--r--demos/shared/shared.pro2
-rw-r--r--demos/sub-attaq/animationmanager.cpp6
-rw-r--r--demos/sub-attaq/boat.cpp92
-rw-r--r--demos/sub-attaq/boat.h12
-rw-r--r--demos/sub-attaq/boat_p.h50
-rw-r--r--demos/sub-attaq/bomb.cpp16
-rw-r--r--demos/sub-attaq/bomb.h16
-rw-r--r--demos/sub-attaq/custompropertyanimation.cpp108
-rw-r--r--demos/sub-attaq/custompropertyanimation.h114
-rw-r--r--demos/sub-attaq/graphicsscene.cpp196
-rw-r--r--demos/sub-attaq/graphicsscene.h13
-rw-r--r--demos/sub-attaq/mainwindow.cpp31
-rw-r--r--demos/sub-attaq/mainwindow.h1
-rw-r--r--demos/sub-attaq/pixmapitem.cpp33
-rw-r--r--demos/sub-attaq/pixmapitem.h14
-rw-r--r--demos/sub-attaq/states.cpp39
-rw-r--r--demos/sub-attaq/states.h2
-rw-r--r--demos/sub-attaq/sub-attaq.pro2
-rw-r--r--demos/sub-attaq/submarine.cpp62
-rw-r--r--demos/sub-attaq/submarine.h11
-rw-r--r--demos/sub-attaq/submarine_p.h1
-rw-r--r--demos/sub-attaq/torpedo.cpp20
-rw-r--r--demos/sub-attaq/torpedo.h16
-rw-r--r--demos/symbianpkgrules.pri2
52 files changed, 497 insertions, 718 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
index 1304a19..2d8a637 100644
--- a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png
+++ b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png
Binary files differ
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/sub-attaq/animationmanager.cpp b/demos/sub-attaq/animationmanager.cpp
index 916dd21..eb5a125 100644
--- a/demos/sub-attaq/animationmanager.cpp
+++ b/demos/sub-attaq/animationmanager.cpp
@@ -77,16 +77,14 @@ void AnimationManager::unregisterAllAnimations()
void AnimationManager::pauseAll()
{
- foreach (QAbstractAnimation* animation, animations)
- {
+ foreach (QAbstractAnimation* animation, animations) {
if (animation->state() == QAbstractAnimation::Running)
animation->pause();
}
}
void AnimationManager::resumeAll()
{
- foreach (QAbstractAnimation* animation, animations)
- {
+ foreach (QAbstractAnimation* animation, animations) {
if (animation->state() == QAbstractAnimation::Paused)
animation->resume();
}
diff --git a/demos/sub-attaq/boat.cpp b/demos/sub-attaq/boat.cpp
index 864a099..3b1bac7 100644
--- a/demos/sub-attaq/boat.cpp
+++ b/demos/sub-attaq/boat.cpp
@@ -46,7 +46,6 @@
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
-#include "custompropertyanimation.h"
#include "qanimationstate.h"
//Qt
@@ -60,79 +59,35 @@
static QAbstractAnimation *setupDestroyAnimation(Boat *boat)
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat);
-#if QT_VERSION >=0x040500
- PixmapItem *step1 = new PixmapItem(QString("explosion/boat/step1"),GraphicsScene::Big, boat);
- step1->setZValue(6);
- PixmapItem *step2 = new PixmapItem(QString("explosion/boat/step2"),GraphicsScene::Big, boat);
- step2->setZValue(6);
- PixmapItem *step3 = new PixmapItem(QString("explosion/boat/step3"),GraphicsScene::Big, boat);
- step3->setZValue(6);
- PixmapItem *step4 = new PixmapItem(QString("explosion/boat/step4"),GraphicsScene::Big, boat);
- step4->setZValue(6);
- step1->setOpacity(0);
- step2->setOpacity(0);
- step3->setOpacity(0);
- step4->setOpacity(0);
- CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(boat);
- anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim1->setDuration(100);
- anim1->setEndValue(1);
- CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(boat);
- anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim2->setDuration(100);
- anim2->setEndValue(1);
- CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(boat);
- anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim3->setDuration(100);
- anim3->setEndValue(1);
- CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(boat);
- anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim4->setDuration(100);
- anim4->setEndValue(1);
- CustomPropertyAnimation *anim5 = new CustomPropertyAnimation(boat);
- anim5->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim5->setDuration(100);
- anim5->setEndValue(0);
- CustomPropertyAnimation *anim6 = new CustomPropertyAnimation(boat);
- anim6->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim6->setDuration(100);
- anim6->setEndValue(0);
- CustomPropertyAnimation *anim7 = new CustomPropertyAnimation(boat);
- anim7->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim7->setDuration(100);
- anim7->setEndValue(0);
- CustomPropertyAnimation *anim8 = new CustomPropertyAnimation(boat);
- anim8->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim8->setDuration(100);
- anim8->setEndValue(0);
- group->addAnimation(anim1);
- group->addAnimation(anim2);
- group->addAnimation(anim3);
- group->addAnimation(anim4);
- group->addAnimation(anim5);
- group->addAnimation(anim6);
- group->addAnimation(anim7);
- group->addAnimation(anim8);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
- group->addAnimation(anim);
-#endif
+ for (int i = 1; i <= 4; i++) {
+ PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat);
+ step->setZValue(6);
+ step->setOpacity(0);
+
+ //fade-in
+ QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity");
+ anim->setEndValue(1);
+ anim->setDuration(100);
+ group->insertAnimationAt(i-1, anim);
+
+ //and then fade-out
+ QPropertyAnimation *anim2 = new QPropertyAnimation(step, "opacity");
+ anim2->setEndValue(0);
+ anim2->setDuration(100);
+ group->addAnimation(anim2);
+ }
+
AnimationManager::self()->registerAnimation(group);
return group;
}
-Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0)
+Boat::Boat() : PixmapItem(QString("boat"), GraphicsScene::Big),
+ speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0)
{
- pixmapItem = new PixmapItem(QString("boat"),GraphicsScene::Big, this);
setZValue(4);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable);
- resize(pixmapItem->boundingRect().size());
+ setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable);
//The movement animation used to animate the boat
movementAnimation = new QPropertyAnimation(this, "pos");
@@ -223,13 +178,13 @@ Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags)
destroyedState->setAnimation(destroyAnimation);
//Play a nice animation when the boat is destroyed
- moving->addTransition(this, SIGNAL(boatDestroyed()),destroyedState);
+ moving->addTransition(this, SIGNAL(boatDestroyed()), destroyedState);
//Transition to final state when the destroyed animation is finished
destroyedState->addTransition(destroyedState, SIGNAL(animationFinished()), final);
//The machine has finished to be executed, then the boat is dead
- connect(machine,SIGNAL(finished()),this, SIGNAL(boatExecutionFinished()));
+ connect(machine,SIGNAL(finished()), this, SIGNAL(boatExecutionFinished()));
}
@@ -255,7 +210,6 @@ void Boat::updateBoatMovement()
}
movementAnimation->stop();
- movementAnimation->setStartValue(pos());
if (direction == Boat::Left) {
movementAnimation->setEndValue(QPointF(0,y()));
diff --git a/demos/sub-attaq/boat.h b/demos/sub-attaq/boat.h
index 0fe8ce4..0b4de1e 100644
--- a/demos/sub-attaq/boat.h
+++ b/demos/sub-attaq/boat.h
@@ -42,13 +42,8 @@
#ifndef __BOAT__H__
#define __BOAT__H__
-//Qt
-#include <QtCore/QObject>
-#include <QtGui/QKeyEvent>
+#include "pixmapitem.h"
-#include <QtGui/QGraphicsWidget>
-
-class PixmapItem;
class Bomb;
QT_BEGIN_NAMESPACE
class QVariantAnimation;
@@ -56,7 +51,7 @@ class QAbstractAnimation;
class QStateMachine;
QT_END_NAMESPACE
-class Boat : public QGraphicsWidget
+class Boat : public PixmapItem
{
Q_OBJECT
public:
@@ -66,7 +61,7 @@ public:
Right
};
enum { Type = UserType + 2 };
- Boat(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ Boat();
void destroy();
void run();
void stop();
@@ -95,7 +90,6 @@ private:
QVariantAnimation *movementAnimation;
QAbstractAnimation *destroyAnimation;
QStateMachine *machine;
- PixmapItem *pixmapItem;
};
#endif //__BOAT__H__
diff --git a/demos/sub-attaq/boat_p.h b/demos/sub-attaq/boat_p.h
index 692702b..6eb52b6 100644
--- a/demos/sub-attaq/boat_p.h
+++ b/demos/sub-attaq/boat_p.h
@@ -67,22 +67,16 @@ static const int MAX_BOMB = 5;
class KeyStopTransition : public QKeyEventTransition
{
public:
- KeyStopTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ KeyStopTransition(Boat *b, QEvent::Type t, int k)
+ : QKeyEventTransition(b, t, k), boat(b), key(k)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (boat->currentSpeed() == 1)
- return true;
- else
- return false;
+ return (boat->currentSpeed() == 1);
}
private:
Boat * boat;
@@ -93,23 +87,16 @@ private:
class KeyMoveTransition : public QKeyEventTransition
{
public:
- KeyMoveTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ KeyMoveTransition(Boat *b, QEvent::Type t, int k)
+ : QKeyEventTransition(b, t, k), boat(b), key(k)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (boat->currentSpeed() >= 0)
- return true;
- else
- return false;
-
+ return (boat->currentSpeed() >= 0);
}
void onTransition(QEvent *)
{
@@ -132,22 +119,16 @@ private:
{
public:
KeyLaunchTransition(Boat *boat, QEvent::Type type, int key)
- : QKeyEventTransition(boat, type, key)
+ : QKeyEventTransition(boat, type, key), boat(boat), key(key)
{
- this->boat = boat;
- this->key = key;
}
protected:
virtual bool eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
//We have enough bomb?
- if (boat->bombsLaunched() < MAX_BOMB)
- return true;
- else
- return false;
+ return (boat->bombsLaunched() < MAX_BOMB);
}
private:
Boat * boat;
@@ -158,9 +139,8 @@ private:
class MoveStateRight : public QState
{
public:
- MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent)
+ MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -176,9 +156,8 @@ private:
class MoveStateLeft : public QState
{
public:
- MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent)
+ MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -194,9 +173,8 @@ private:
class StopState : public QState
{
public:
- StopState(Boat *boat,QState *parent = 0) : QState(parent)
+ StopState(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -213,9 +191,8 @@ private:
class LaunchStateRight : public QState
{
public:
- LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent)
+ LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
@@ -235,9 +212,8 @@ private:
class LaunchStateLeft : public QState
{
public:
- LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent)
+ LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent), boat(boat)
{
- this->boat = boat;
}
protected:
void onEntry(QEvent *)
diff --git a/demos/sub-attaq/bomb.cpp b/demos/sub-attaq/bomb.cpp
index d17024f..acc3475 100644
--- a/demos/sub-attaq/bomb.cpp
+++ b/demos/sub-attaq/bomb.cpp
@@ -52,19 +52,14 @@
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
-Bomb::Bomb(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), launchAnimation(0)
+Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big)
{
- pixmapItem = new PixmapItem(QString("bomb"),GraphicsScene::Big, this);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable);
setZValue(2);
- resize(pixmapItem->boundingRect().size());
}
void Bomb::launch(Bomb::Direction direction)
{
- launchAnimation = new QSequentialAnimationGroup();
+ QSequentialAnimationGroup *launchAnimation = new QSequentialAnimationGroup;
AnimationManager::self()->registerAnimation(launchAnimation);
qreal delta = direction == Right ? 20 : - 20;
QPropertyAnimation *anim = new QPropertyAnimation(this, "pos");
@@ -80,7 +75,7 @@ void Bomb::launch(Bomb::Direction direction)
anim->setDuration(y()/2*60);
launchAnimation->addAnimation(anim);
connect(anim,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &)));
-
+ connect(this, SIGNAL(bombExploded()), launchAnimation, SLOT(stop()));
//We setup the state machine of the bomb
QStateMachine *machine = new QStateMachine(this);
@@ -94,7 +89,7 @@ void Bomb::launch(Bomb::Direction direction)
machine->setInitialState(launched);
//### Add a nice animation when the bomb is destroyed
- launched->addTransition(this, SIGNAL(bombExplosed()),final);
+ launched->addTransition(this, SIGNAL(bombExploded()),final);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, SIGNAL(animationFinished()), final);
@@ -119,6 +114,5 @@ void Bomb::onAnimationLaunchValueChanged(const QVariant &)
void Bomb::destroy()
{
- launchAnimation->stop();
- emit bombExplosed();
+ emit bombExploded();
}
diff --git a/demos/sub-attaq/bomb.h b/demos/sub-attaq/bomb.h
index f5b221c..ec059b5 100644
--- a/demos/sub-attaq/bomb.h
+++ b/demos/sub-attaq/bomb.h
@@ -42,13 +42,9 @@
#ifndef __BOMB__H__
#define __BOMB__H__
-//Qt
-#include <QtGui/QGraphicsWidget>
-#include <QtCore/QAnimationGroup>
+#include "pixmapitem.h"
-class PixmapItem;
-
-class Bomb : public QGraphicsWidget
+class Bomb : public PixmapItem
{
Q_OBJECT
public:
@@ -56,20 +52,16 @@ public:
Left = 0,
Right
};
- Bomb(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ Bomb();
void launch(Direction direction);
void destroy();
signals:
- void bombExplosed();
+ void bombExploded();
void bombExecutionFinished();
private slots:
void onAnimationLaunchValueChanged(const QVariant &);
-
-private:
- QAnimationGroup *launchAnimation;
- PixmapItem *pixmapItem;
};
#endif //__BOMB__H__
diff --git a/demos/sub-attaq/custompropertyanimation.cpp b/demos/sub-attaq/custompropertyanimation.cpp
deleted file mode 100644
index 9b435f0..0000000
--- a/demos/sub-attaq/custompropertyanimation.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** 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 QtCore module 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 "custompropertyanimation.h"
-
-// Qt
-#include <QtCore/qdebug.h>
-
-CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) :
- QVariantAnimation(parent), animProp(0)
-{
-}
-
-CustomPropertyAnimation::~CustomPropertyAnimation()
-{
-}
-
-void CustomPropertyAnimation::setProperty(AbstractProperty *_animProp)
-{
- if (animProp == _animProp)
- return;
- delete animProp;
- animProp = _animProp;
-}
-
-/*!
- \reimp
- */
-void CustomPropertyAnimation::updateCurrentValue(const QVariant &value)
-{
- if (!animProp || state() == QAbstractAnimation::Stopped)
- return;
-
- animProp->write(value);
-}
-
-
-/*!
- \reimp
-*/
-void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
-{
- // Initialize start value
- if (oldState == QAbstractAnimation::Stopped) {
- if (!animProp)
- return;
- QVariant def = animProp->read();
- if (def.isValid()) {
- const int t = def.userType();
- KeyValues values = keyValues();
- //this ensures that all the keyValues are of type t
- for (int i = 0; i < values.count(); ++i) {
- QVariantAnimation::KeyValue &pair = values[i];
- if (pair.second.userType() != t)
- pair.second.convert(static_cast<QVariant::Type>(t));
- }
- //let's now update the key values
- setKeyValues(values);
- }
-
- if ((animProp && !startValue().isValid() && currentTime() == 0)
- || (currentTime() == duration() && currentLoop() == (loopCount() - 1))) {
- setStartValue(def);
- }
- }
-
- QVariantAnimation::updateState(oldState, newState);
-}
-
-#include "moc_custompropertyanimation.cpp"
diff --git a/demos/sub-attaq/custompropertyanimation.h b/demos/sub-attaq/custompropertyanimation.h
deleted file mode 100644
index 0c97bf0..0000000
--- a/demos/sub-attaq/custompropertyanimation.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** 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 QtCore module 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 CUSTOMPROPERTYANIMATION_H
-#define CUSTOMPROPERTYANIMATION_H
-
-#include <QtCore/qvariantanimation.h>
-
-QT_BEGIN_NAMESPACE
-class QGraphicsItem;
-QT_END_NAMESPACE
-
-struct AbstractProperty
-{
- virtual QVariant read() const = 0;
- virtual void write(const QVariant &value) = 0;
-};
-
-
-class CustomPropertyAnimation : public QVariantAnimation
-{
- Q_OBJECT
-
- template <typename Target, typename T, typename T2 = T>
- class MemberFunctionProperty : public AbstractProperty
- {
- public:
- typedef T (Target::*Getter)(void) const;
- typedef void (Target::*Setter)(T2);
-
- MemberFunctionProperty(Target* target, Getter getter, Setter setter)
- : m_target(target), m_getter(getter), m_setter(setter) {}
-
- virtual void write(const QVariant &value)
- {
- if (m_setter) (m_target->*m_setter)(qVariantValue<T>(value));
- }
-
- virtual QVariant read() const
- {
- if (m_getter) return qVariantFromValue<T>((m_target->*m_getter)());
- return QVariant();
- }
-
- private:
- Target *m_target;
- Getter m_getter;
- Setter m_setter;
- };
-
-public:
- CustomPropertyAnimation(QObject *parent = 0);
- ~CustomPropertyAnimation();
-
- template<class Target, typename T>
- void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(const T& ))
- {
- setProperty(new MemberFunctionProperty<Target, T, const T&>(target, getter, setter));
- }
-
- template<class Target, typename T>
- void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(T))
- {
- setProperty(new MemberFunctionProperty<Target, T>(target, getter, setter));
- }
-
- void updateCurrentValue(const QVariant &value);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
- void setProperty(AbstractProperty *animProp);
-
-private:
- Q_DISABLE_COPY(CustomPropertyAnimation);
- AbstractProperty *animProp;
-};
-
-#endif // CUSTOMPROPERTYANIMATION_H
diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp
index e5d7aad..812eadf 100644
--- a/demos/sub-attaq/graphicsscene.cpp
+++ b/demos/sub-attaq/graphicsscene.cpp
@@ -47,7 +47,6 @@
#include "torpedo.h"
#include "bomb.h"
#include "pixmapitem.h"
-#include "custompropertyanimation.h"
#include "animationmanager.h"
#include "qanimationstate.h"
#include "progressitem.h"
@@ -68,39 +67,10 @@
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtCore/QXmlStreamReader>
-//helper function that creates an animation for position and inserts it into group
-static CustomPropertyAnimation *addGraphicsItemPosAnimation(QSequentialAnimationGroup *group,
- QGraphicsItem *item, const QPointF &endPos)
-{
- CustomPropertyAnimation *ret = new CustomPropertyAnimation(group);
- ret->setMemberFunctions(item, &QGraphicsItem::pos, &QGraphicsItem::setPos);
- ret->setEndValue(endPos);
- ret->setDuration(200);
- ret->setEasingCurve(QEasingCurve::OutElastic);
- group->addPause(50);
- return ret;
-}
-
-//helper function that creates an animation for opacity and inserts it into group
-static void addGraphicsItemFadeoutAnimation(QAnimationGroup *group, QGraphicsItem *item)
-{
-#if QT_VERSION >=0x040500
- CustomPropertyAnimation *anim = new CustomPropertyAnimation(group);
- anim->setMemberFunctions(item, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim->setDuration(800);
- anim->setEndValue(0);
- anim->setEasingCurve(QEasingCurve::OutQuad);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
-#endif
-}
-
GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
- : QGraphicsScene(x,y,width,height), mode(mode), newAction(0), quitAction(0), boat(0)
+ : QGraphicsScene(x , y, width, height), mode(mode), boat(new Boat)
{
- backgroundItem = new PixmapItem(QString("background"),mode);
+ PixmapItem *backgroundItem = new PixmapItem(QString("background"),mode);
backgroundItem->setZValue(1);
backgroundItem->setPos(0,0);
addItem(backgroundItem);
@@ -116,7 +86,6 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
textInformationItem = new TextInformationItem(backgroundItem);
textInformationItem->hide();
//We create the boat
- boat = new Boat();
addItem(boat);
boat->setPos(this->width()/2, sealLevel() - boat->size().height());
boat->hide();
@@ -130,28 +99,21 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
while (!reader.atEnd()) {
reader.readNext();
if (reader.tokenType() == QXmlStreamReader::StartElement) {
- if (reader.name() == "submarine")
- {
+ if (reader.name() == "submarine") {
SubmarineDescription desc;
desc.name = reader.attributes().value("name").toString();
desc.points = reader.attributes().value("points").toString().toInt();
desc.type = reader.attributes().value("type").toString().toInt();
submarinesData.append(desc);
- }
- if (reader.name() == "level")
- {
+ } else if (reader.name() == "level") {
currentLevel.id = reader.attributes().value("id").toString().toInt();
currentLevel.name = reader.attributes().value("name").toString();
+ } else if (reader.name() == "subinstance") {
+ currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(), reader.attributes().value("nb").toString().toInt()));
}
- if (reader.name() == "subinstance")
- {
- currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(),reader.attributes().value("nb").toString().toInt()));
- }
- }
- if (reader.tokenType() == QXmlStreamReader::EndElement) {
- if (reader.name() == "level")
- {
- levelsData.insert(currentLevel.id,currentLevel);
+ } else if (reader.tokenType() == QXmlStreamReader::EndElement) {
+ if (reader.name() == "level") {
+ levelsData.insert(currentLevel.id, currentLevel);
currentLevel.submarines.clear();
}
}
@@ -160,80 +122,52 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
qreal GraphicsScene::sealLevel() const
{
- if (mode == Big)
- return 220;
- else
- return 160;
+ return (mode == Big) ? 220 : 160;
}
-void GraphicsScene::setupScene(const QList<QAction *> &actions)
+void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction)
{
- newAction = actions.at(0);
- quitAction = actions.at(1);
-
- QGraphicsItem *logo_s = addWelcomeItem(QPixmap(":/logo-s"));
- QGraphicsItem *logo_u = addWelcomeItem(QPixmap(":/logo-u"));
- QGraphicsItem *logo_b = addWelcomeItem(QPixmap(":/logo-b"));
- QGraphicsItem *logo_dash = addWelcomeItem(QPixmap(":/logo-dash"));
- QGraphicsItem *logo_a = addWelcomeItem(QPixmap(":/logo-a"));
- QGraphicsItem *logo_t = addWelcomeItem(QPixmap(":/logo-t"));
- QGraphicsItem *logo_t2 = addWelcomeItem(QPixmap(":/logo-t2"));
- QGraphicsItem *logo_a2 = addWelcomeItem(QPixmap(":/logo-a2"));
- QGraphicsItem *logo_q = addWelcomeItem(QPixmap(":/logo-q"));
- QGraphicsItem *logo_excl = addWelcomeItem(QPixmap(":/logo-excl"));
- logo_s->setZValue(3);
- logo_u->setZValue(4);
- logo_b->setZValue(5);
- logo_dash->setZValue(6);
- logo_a->setZValue(7);
- logo_t->setZValue(8);
- logo_t2->setZValue(9);
- logo_a2->setZValue(10);
- logo_q->setZValue(11);
- logo_excl->setZValue(12);
- logo_s->setPos(QPointF(-1000, -1000));
- logo_u->setPos(QPointF(-800, -1000));
- logo_b->setPos(QPointF(-600, -1000));
- logo_dash->setPos(QPointF(-400, -1000));
- logo_a->setPos(QPointF(1000, 2000));
- logo_t->setPos(QPointF(800, 2000));
- logo_t2->setPos(QPointF(600, 2000));
- logo_a2->setPos(QPointF(400, 2000));
- logo_q->setPos(QPointF(200, 2000));
- logo_excl->setPos(QPointF(0, 2000));
+ static const int nLetters = 10;
+ static struct {
+ char *pix;
+ qreal initX, initY;
+ qreal destX, destY;
+ } logoData[nLetters] = {
+ {"s", -1000, -1000, 300, 150 },
+ {"u", -800, -1000, 350, 150 },
+ {"b", -600, -1000, 400, 120 },
+ {"dash", -400, -1000, 460, 150 },
+ {"a", 1000, 2000, 350, 250 },
+ {"t", 800, 2000, 400, 250 },
+ {"t2", 600, 2000, 430, 250 },
+ {"a2", 400, 2000, 465, 250 },
+ {"q", 200, 2000, 510, 250 },
+ {"excl", 0, 2000, 570, 220 } };
QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this);
QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this);
- //creation of the animations for moving letters
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_s, QPointF(300, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_u, QPointF(350, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_b, QPointF(400, 120));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_dash, QPointF(460, 150));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_a, QPointF(350, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_t, QPointF(400, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_t2, QPointF(430, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_a2, QPointF(465, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_q, QPointF(510, 250));
- addGraphicsItemPosAnimation(lettersGroupMoving, logo_excl, QPointF(570, 220));
-
- //creation of the animations for fading out the letters
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_s);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_u);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_b);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_dash);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t2);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a2);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_q);
- addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_excl);
- connect(lettersGroupFading, SIGNAL(finished()), this, SLOT(onIntroAnimationFinished()));
+ for (int i = 0; i < nLetters; ++i) {
+ PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this);
+ logo->setPos(logoData[i].initX, logoData[i].initY);
+ logo->setZValue(i + 3);
+ //creation of the animations for moving letters
+ QPropertyAnimation *moveAnim = new QPropertyAnimation(logo, "pos", lettersGroupMoving);
+ moveAnim->setEndValue(QPointF(logoData[i].destX, logoData[i].destY));
+ moveAnim->setDuration(200);
+ moveAnim->setEasingCurve(QEasingCurve::OutElastic);
+ lettersGroupMoving->addPause(50);
+ //creation of the animations for fading out the letters
+ QPropertyAnimation *fadeAnim = new QPropertyAnimation(logo, "opacity", lettersGroupFading);
+ fadeAnim->setDuration(800);
+ fadeAnim->setEndValue(0);
+ fadeAnim->setEasingCurve(QEasingCurve::OutQuad);
+ }
QStateMachine *machine = new QStateMachine(this);
//This state is when the player is playing
- PlayState *gameState = new PlayState(this,machine);
+ PlayState *gameState = new PlayState(this, machine);
//Final state
QFinalState *final = new QFinalState(machine);
@@ -263,7 +197,7 @@ void GraphicsScene::setupScene(const QList<QAction *> &actions)
machine->start();
//We reach the final state, then we quit
- connect(machine,SIGNAL(finished()),this, SLOT(onQuitGameTriggered()));
+ connect(machine, SIGNAL(finished()), qApp, SLOT(quit()));
}
void GraphicsScene::addItem(Bomb *bomb)
@@ -292,16 +226,6 @@ void GraphicsScene::addItem(QGraphicsItem *item)
QGraphicsScene::addItem(item);
}
-void GraphicsScene::mousePressEvent (QGraphicsSceneMouseEvent * event)
-{
- event->ignore();
-}
-
-void GraphicsScene::onQuitGameTriggered()
-{
- qApp->closeAllWindows();
-}
-
void GraphicsScene::onBombExecutionFinished()
{
Bomb *bomb = qobject_cast<Bomb *>(sender());
@@ -322,32 +246,26 @@ void GraphicsScene::onSubMarineExecutionFinished()
{
SubMarine *submarine = qobject_cast<SubMarine *>(sender());
submarines.remove(submarine);
- if (submarines.count() == 0) {
+ if (submarines.count() == 0)
emit allSubMarineDestroyed(submarine->points());
- } else {
+ else
emit subMarineDestroyed(submarine->points());
- }
submarine->deleteLater();
}
-int GraphicsScene::remainingSubMarines() const
-{
- return submarines.count();
-}
-
void GraphicsScene::clearScene()
{
- foreach (SubMarine *sub,submarines) {
+ foreach (SubMarine *sub, submarines) {
sub->destroy();
sub->deleteLater();
}
- foreach (Torpedo *torpedo,torpedos) {
+ foreach (Torpedo *torpedo, torpedos) {
torpedo->destroy();
torpedo->deleteLater();
}
- foreach (Bomb *bomb,bombs) {
+ foreach (Bomb *bomb, bombs) {
bomb->destroy();
bomb->deleteLater();
}
@@ -361,17 +279,3 @@ void GraphicsScene::clearScene()
boat->stop();
boat->hide();
}
-
-QGraphicsPixmapItem *GraphicsScene::addWelcomeItem(const QPixmap &pm)
-{
- QGraphicsPixmapItem *item = addPixmap(pm);
- welcomeItems << item;
- return item;
-}
-
-void GraphicsScene::onIntroAnimationFinished()
-{
- qDeleteAll(welcomeItems);
- welcomeItems.clear();
-}
-
diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h
index 7d7252d..ce2c91f 100644
--- a/demos/sub-attaq/graphicsscene.h
+++ b/demos/sub-attaq/graphicsscene.h
@@ -82,41 +82,30 @@ public:
GraphicsScene(int x, int y, int width, int height, Mode mode = Big);
qreal sealLevel() const;
- void setupScene(const QList<QAction *> &actions);
+ void setupScene(QAction *newAction, QAction *quitAction);
void addItem(Bomb *bomb);
void addItem(Torpedo *torpedo);
void addItem(SubMarine *submarine);
void addItem(QGraphicsItem *item);
- int remainingSubMarines() const;
void clearScene();
- QGraphicsPixmapItem *addWelcomeItem(const QPixmap &pm);
signals:
void subMarineDestroyed(int);
void allSubMarineDestroyed(int);
-protected:
- void mousePressEvent (QGraphicsSceneMouseEvent * event);
-
private slots:
- void onQuitGameTriggered();
void onBombExecutionFinished();
void onTorpedoExecutionFinished();
void onSubMarineExecutionFinished();
- void onIntroAnimationFinished();
private:
Mode mode;
- PixmapItem *backgroundItem;
ProgressItem *progressItem;
TextInformationItem *textInformationItem;
- QAction * newAction;
- QAction * quitAction;
Boat *boat;
QSet<SubMarine *> submarines;
QSet<Bomb *> bombs;
QSet<Torpedo *> torpedos;
- QVector<QGraphicsPixmapItem *> welcomeItems;
QVector<SubmarineDescription> submarinesData;
QHash<int, LevelDescription> levelsData;
diff --git a/demos/sub-attaq/mainwindow.cpp b/demos/sub-attaq/mainwindow.cpp
index 37129f8..45e5554 100644
--- a/demos/sub-attaq/mainwindow.cpp
+++ b/demos/sub-attaq/mainwindow.cpp
@@ -56,42 +56,27 @@
MainWindow::MainWindow() : QMainWindow(0)
{
- QMenuBar *menuBar = new QMenuBar;
- QMenu *file = new QMenu(tr("&File"),menuBar);
+ QMenu *file = menuBar()->addMenu(tr("&File"));
- QAction *newAction = new QAction(tr("New Game"),file);
+ QAction *newAction = file->addAction(tr("New Game"));
newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
- file->addAction(newAction);
- QAction *quitAction = new QAction(tr("Quit"),file);
+ QAction *quitAction = file->addAction(tr("Quit"));
quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
- file->addAction(quitAction);
- menuBar->addMenu(file);
- setMenuBar(menuBar);
-
- QStringList list = QApplication::arguments();
- if (list.contains("-fullscreen")) {
- scene = new GraphicsScene(0, 0, 750, 400,GraphicsScene::Small);
+ if (QApplication::arguments().contains("-fullscreen")) {
+ scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small);
setWindowState(Qt::WindowFullScreen);
} else {
scene = new GraphicsScene(0, 0, 880, 630);
layout()->setSizeConstraint(QLayout::SetFixedSize);
}
- view = new QGraphicsView(scene,this);
+ view = new QGraphicsView(scene, this);
view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- QList<QAction *> actions;
- actions << newAction << quitAction;
- scene->setupScene(actions);
+ scene->setupScene(newAction, quitAction);
#ifndef QT_NO_OPENGL
- view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
+ view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
#endif
setCentralWidget(view);
-
-}
-
-MainWindow::~MainWindow()
-{
}
-
diff --git a/demos/sub-attaq/mainwindow.h b/demos/sub-attaq/mainwindow.h
index d626ad7..12a7364 100644
--- a/demos/sub-attaq/mainwindow.h
+++ b/demos/sub-attaq/mainwindow.h
@@ -54,7 +54,6 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
MainWindow();
- ~MainWindow();
private:
GraphicsScene *scene;
diff --git a/demos/sub-attaq/pixmapitem.cpp b/demos/sub-attaq/pixmapitem.cpp
index 9abf745..fcc7ce9 100644
--- a/demos/sub-attaq/pixmapitem.cpp
+++ b/demos/sub-attaq/pixmapitem.cpp
@@ -43,17 +43,34 @@
#include "pixmapitem.h"
//Qt
-#include <QtCore/QDir>
+#include <QPainter>
-PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsPixmapItem(parent),name(fileName)
+PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsObject(parent)
{
- loadPixmap(mode);
+ if (mode == GraphicsScene::Big)
+ pix = ":/big/" + fileName;
+ else
+ pix = ":/small/" + fileName;
}
-void PixmapItem::loadPixmap(GraphicsScene::Mode mode)
+PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) : QGraphicsObject(), pix(fileName)
{
- if (mode == GraphicsScene::Big)
- setPixmap(":/big/" + name);
- else
- setPixmap(":/small/" + name);
+ scene->addItem(this);
}
+
+QSizeF PixmapItem::size() const
+{
+ return pix.size();
+}
+
+QRectF PixmapItem::boundingRect() const
+{
+ return QRectF(QPointF(0, 0), pix.size());
+}
+
+void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ painter->drawPixmap(0, 0, pix);
+}
+
+
diff --git a/demos/sub-attaq/pixmapitem.h b/demos/sub-attaq/pixmapitem.h
index b176215..57f831a 100644
--- a/demos/sub-attaq/pixmapitem.h
+++ b/demos/sub-attaq/pixmapitem.h
@@ -46,18 +46,18 @@
#include "graphicsscene.h"
//Qt
-#include <QtGui/QGraphicsPixmapItem>
+#include <QtGui/QGraphicsObject>
-class PixmapItem : public QGraphicsPixmapItem
+class PixmapItem : public QGraphicsObject
{
public:
PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0);
-
+ PixmapItem(const QString &fileName, QGraphicsScene *scene);
+ QSizeF size() const;
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
private:
- void loadPixmap(GraphicsScene::Mode mode);
-
- QString name;
- QPixmap pixmap;
+ QPixmap pix;
};
#endif //__PIXMAPITEM__H__
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index 7443ae7..742095e 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -67,8 +67,7 @@ PlayState::PlayState(GraphicsScene *scene, QState *parent)
PlayState::~PlayState()
{
- if (machine)
- delete machine;
+ delete machine;
}
void PlayState::onEntry(QEvent *)
@@ -169,7 +168,7 @@ void LevelState::initializeLevel()
scene->boat->setCurrentDirection(Boat::None);
scene->boat->setBombsLaunched(0);
scene->boat->show();
- scene->setFocusItem(scene->boat,Qt::OtherFocusReason);
+ scene->setFocusItem(scene->boat, Qt::OtherFocusReason);
scene->boat->run();
scene->progressItem->setScore(game->score);
@@ -276,13 +275,8 @@ void WinState::onExit(QEvent *)
}
/** UpdateScore State */
-UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QState(parent)
-{
- this->game = game;
-}
-void UpdateScoreState::onEntry(QEvent *e)
+UpdateScoreState::UpdateScoreState(PlayState *g, QState *parent) : QState(parent), game(g)
{
- QState::onEntry(e);
}
/** Win transition */
@@ -297,12 +291,10 @@ bool UpdateScoreTransition::eventTest(QEvent *event)
{
if (!QSignalTransition::eventTest(event))
return false;
- else {
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
- game->score += se->arguments().at(0).toInt();
- scene->progressItem->setScore(game->score);
- return true;
- }
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
+ game->score += se->arguments().at(0).toInt();
+ scene->progressItem->setScore(game->score);
+ return true;
}
/** Win transition */
@@ -317,12 +309,10 @@ bool WinTransition::eventTest(QEvent *event)
{
if (!QSignalTransition::eventTest(event))
return false;
- else {
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
- game->score += se->arguments().at(0).toInt();
- scene->progressItem->setScore(game->score);
- return true;
- }
+ QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(event);
+ game->score += se->arguments().at(0).toInt();
+ scene->progressItem->setScore(game->score);
+ return true;
}
/** Space transition */
@@ -334,12 +324,7 @@ CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, Q
bool CustomSpaceTransition::eventTest(QEvent *event)
{
- Q_UNUSED(event);
if (!QKeyEventTransition::eventTest(event))
return false;
- if (game->currentLevel != 0)
- return true;
- else
- return false;
-
+ return (game->currentLevel != 0);
}
diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h
index 9e78ae4..f588e5d 100644
--- a/demos/sub-attaq/states.h
+++ b/demos/sub-attaq/states.h
@@ -136,8 +136,6 @@ class UpdateScoreState : public QState
{
public:
UpdateScoreState(PlayState *game, QState *parent);
-protected:
- void onEntry(QEvent *);
private:
QPropertyAnimation *scoreAnimation;
PlayState *game;
diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro
index 8677ff5..b5aa465 100644
--- a/demos/sub-attaq/sub-attaq.pro
+++ b/demos/sub-attaq/sub-attaq.pro
@@ -10,7 +10,6 @@ HEADERS += boat.h \
states.h \
boat_p.h \
submarine_p.h \
- custompropertyanimation.h \
qanimationstate.h \
progressitem.h \
textinformationitem.h
@@ -24,7 +23,6 @@ SOURCES += boat.cpp \
graphicsscene.cpp \
animationmanager.cpp \
states.cpp \
- custompropertyanimation.cpp \
qanimationstate.cpp \
progressitem.cpp \
textinformationitem.cpp
diff --git a/demos/sub-attaq/submarine.cpp b/demos/sub-attaq/submarine.cpp
index 3d8490f..f71b81c 100644
--- a/demos/sub-attaq/submarine.cpp
+++ b/demos/sub-attaq/submarine.cpp
@@ -46,7 +46,6 @@
#include "pixmapitem.h"
#include "graphicsscene.h"
#include "animationmanager.h"
-#include "custompropertyanimation.h"
#include "qanimationstate.h"
#include <QtCore/QPropertyAnimation>
@@ -57,62 +56,27 @@
static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub)
{
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub);
-#if QT_VERSION >=0x040500
- PixmapItem *step1 = new PixmapItem(QString("explosion/submarine/step1"),GraphicsScene::Big, sub);
- step1->setZValue(6);
- PixmapItem *step2 = new PixmapItem(QString("explosion/submarine/step2"),GraphicsScene::Big, sub);
- step2->setZValue(6);
- PixmapItem *step3 = new PixmapItem(QString("explosion/submarine/step3"),GraphicsScene::Big, sub);
- step3->setZValue(6);
- PixmapItem *step4 = new PixmapItem(QString("explosion/submarine/step4"),GraphicsScene::Big, sub);
- step4->setZValue(6);
- step1->setOpacity(0);
- step2->setOpacity(0);
- step3->setOpacity(0);
- step4->setOpacity(0);
- CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(sub);
- anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim1->setDuration(100);
- anim1->setEndValue(1);
- CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(sub);
- anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim2->setDuration(100);
- anim2->setEndValue(1);
- CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(sub);
- anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim3->setDuration(100);
- anim3->setEndValue(1);
- CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(sub);
- anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity);
- anim4->setDuration(100);
- anim4->setEndValue(1);
- group->addAnimation(anim1);
- group->addAnimation(anim2);
- group->addAnimation(anim3);
- group->addAnimation(anim4);
-#else
- // work around for a bug where we don't transition if the duration is zero.
- QtPauseAnimation *anim = new QtPauseAnimation(group);
- anim->setDuration(1);
- group->addAnimation(anim);
-#endif
+ for (int i = 1; i <= 4; ++i) {
+ PixmapItem *step = new PixmapItem(QString::fromLatin1("explosion/submarine/step%1").arg(i), GraphicsScene::Big, sub);
+ step->setZValue(6);
+ step->setOpacity(0);
+ QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity", group);
+ anim->setDuration(100);
+ anim->setEndValue(1);
+ }
AnimationManager::self()->registerAnimation(group);
return group;
}
-SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None)
+SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QString("submarine"), GraphicsScene::Big),
+ subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None)
{
- pixmapItem = new PixmapItem(QString("submarine"),GraphicsScene::Big, this);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setZValue(5);
- setFlags(QGraphicsItem::ItemIsMovable);
- resize(pixmapItem->boundingRect().width(),pixmapItem->boundingRect().height());
setTransformOriginPoint(boundingRect().center());
graphicsRotation = new QGraphicsRotation(this);
- graphicsRotation->setAxis(QVector3D(0, 1, 0));
+ graphicsRotation->setAxis(Qt::YAxis);
graphicsRotation->setOrigin(QVector3D(size().width()/2, size().height()/2, 0));
QList<QGraphicsTransform *> r;
r.append(graphicsRotation);
@@ -163,7 +127,7 @@ SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem *
machine->start();
}
-int SubMarine::points()
+int SubMarine::points() const
{
return subPoints;
}
@@ -202,7 +166,7 @@ void SubMarine::launchTorpedo(int speed)
Torpedo * torp = new Torpedo();
GraphicsScene *scene = static_cast<GraphicsScene *>(this->scene());
scene->addItem(torp);
- torp->setPos(x(), y());
+ torp->setPos(pos());
torp->setCurrentSpeed(speed);
torp->launch();
}
diff --git a/demos/sub-attaq/submarine.h b/demos/sub-attaq/submarine.h
index 1a3d2e5..326a1c8 100644
--- a/demos/sub-attaq/submarine.h
+++ b/demos/sub-attaq/submarine.h
@@ -43,15 +43,13 @@
#define __SUBMARINE__H__
//Qt
-#include <QtCore/QVariantAnimation>
-#include <QtGui/QGraphicsWidget>
#include <QtGui/QGraphicsTransform>
-class PixmapItem;
+#include "pixmapitem.h"
class Torpedo;
-class SubMarine : public QGraphicsWidget
+class SubMarine : public PixmapItem
{
Q_OBJECT
public:
@@ -61,9 +59,9 @@ public:
Right
};
enum { Type = UserType + 1 };
- SubMarine(int type, const QString &name, int points, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ SubMarine(int type, const QString &name, int points);
- int points();
+ int points() const;
void setCurrentDirection(Movement direction);
enum Movement currentDirection() const;
@@ -89,7 +87,6 @@ private:
int subPoints;
int speed;
Movement direction;
- PixmapItem *pixmapItem;
QGraphicsRotation *graphicsRotation;
};
diff --git a/demos/sub-attaq/submarine_p.h b/demos/sub-attaq/submarine_p.h
index fa7430b..64a0cf7 100644
--- a/demos/sub-attaq/submarine_p.h
+++ b/demos/sub-attaq/submarine_p.h
@@ -94,7 +94,6 @@ protected:
movementAnimation->setEndValue(QPointF(submarine->scene()->width()-submarine->size().width(),submarine->y()));
movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12);
}
- movementAnimation->setStartValue(submarine->pos());
QAnimationState::onEntry(e);
}
diff --git a/demos/sub-attaq/torpedo.cpp b/demos/sub-attaq/torpedo.cpp
index cce430d..95f88e6 100644
--- a/demos/sub-attaq/torpedo.cpp
+++ b/demos/sub-attaq/torpedo.cpp
@@ -51,24 +51,21 @@
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
-Torpedo::Torpedo(QGraphicsItem * parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(parent,wFlags), currentSpeed(0), launchAnimation(0)
+Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big),
+ currentSpeed(0)
{
- pixmapItem = new PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big, this);
setZValue(2);
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- setFlags(QGraphicsItem::ItemIsMovable);
- resize(pixmapItem->boundingRect().size());
}
void Torpedo::launch()
{
- launchAnimation = new QPropertyAnimation(this, "pos");
+ QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos");
AnimationManager::self()->registerAnimation(launchAnimation);
launchAnimation->setEndValue(QPointF(x(),qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15));
launchAnimation->setEasingCurve(QEasingCurve::InQuad);
launchAnimation->setDuration(y()/currentSpeed*10);
connect(launchAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &)));
+ connect(this,SIGNAL(torpedoExploded()), launchAnimation, SLOT(stop()));
//We setup the state machine of the torpedo
QStateMachine *machine = new QStateMachine(this);
@@ -83,7 +80,7 @@ void Torpedo::launch()
machine->setInitialState(launched);
//### Add a nice animation when the torpedo is destroyed
- launched->addTransition(this, SIGNAL(torpedoExplosed()),final);
+ launched->addTransition(this, SIGNAL(torpedoExploded()),final);
//If the animation is finished, then we move to the final state
launched->addTransition(launched, SIGNAL(animationFinished()), final);
@@ -106,15 +103,12 @@ void Torpedo::setCurrentSpeed(int speed)
void Torpedo::onAnimationLaunchValueChanged(const QVariant &)
{
foreach (QGraphicsItem *item , collidingItems(Qt::IntersectsItemBoundingRect)) {
- if (item->type() == Boat::Type) {
- Boat *b = static_cast<Boat *>(item);
+ if (Boat *b = qgraphicsitem_cast<Boat*>(item))
b->destroy();
- }
}
}
void Torpedo::destroy()
{
- launchAnimation->stop();
- emit torpedoExplosed();
+ emit torpedoExploded();
}
diff --git a/demos/sub-attaq/torpedo.h b/demos/sub-attaq/torpedo.h
index 2e654f4..03f277d 100644
--- a/demos/sub-attaq/torpedo.h
+++ b/demos/sub-attaq/torpedo.h
@@ -42,25 +42,19 @@
#ifndef __TORPEDO__H__
#define __TORPEDO__H__
-//Qt
-#include <QtCore/QObject>
+#include "pixmapitem.h"
-#include <QtCore/QVariantAnimation>
-#include <QtGui/QGraphicsWidget>
-
-class PixmapItem;
-
-class Torpedo : public QGraphicsWidget
+class Torpedo : public PixmapItem
{
Q_OBJECT
public:
- Torpedo(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
+ Torpedo();
void launch();
void setCurrentSpeed(int speed);
void destroy();
signals:
- void torpedoExplosed();
+ void torpedoExploded();
void torpedoExecutionFinished();
private slots:
@@ -68,8 +62,6 @@ private slots:
private:
int currentSpeed;
- PixmapItem *pixmapItem;
- QVariantAnimation *launchAnimation;
};
#endif //__TORPEDO__H__
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