summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/boxes/qtbox.cpp18
-rw-r--r--demos/boxes/qtbox.h6
-rw-r--r--demos/boxes/scene.cpp3
-rw-r--r--demos/boxes/scene.h2
-rw-r--r--demos/composition/composition.cpp14
-rw-r--r--demos/embedded/digiflip/digiflip.pro6
-rw-r--r--demos/embedded/embedded.pro10
-rw-r--r--demos/embedded/flickable/flickable.pro5
-rw-r--r--demos/embedded/flightinfo/flightinfo.pro2
-rw-r--r--demos/embedded/fluidlauncher/fluidlauncher.pro93
-rw-r--r--demos/embedded/lightmaps/lightmaps.pro2
-rw-r--r--demos/embedded/raycasting/raycasting.pro5
-rw-r--r--demos/embedded/weatherinfo/weatherinfo.pro2
-rw-r--r--demos/qtdemo/xml/examples.xml1
-rw-r--r--demos/sub-attaq/graphicsscene.cpp13
-rw-r--r--demos/sub-attaq/graphicsscene.h2
-rw-r--r--demos/sub-attaq/states.cpp25
-rw-r--r--demos/sub-attaq/states.h2
-rw-r--r--demos/sub-attaq/sub-attaq.pro18
-rw-r--r--demos/sub-attaq/textinformationitem.cpp54
-rw-r--r--demos/sub-attaq/textinformationitem.h55
-rw-r--r--demos/textedit/textedit.doc18
-rw-r--r--demos/textedit/textedit.qdoc59
23 files changed, 333 insertions, 82 deletions
diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp
index 015bc95..7134d63 100644
--- a/demos/boxes/qtbox.cpp
+++ b/demos/boxes/qtbox.cpp
@@ -122,7 +122,7 @@ void ItemBase::duplicateSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y()));
}
@@ -137,7 +137,7 @@ void ItemBase::deleteSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
delete itemBase;
}
@@ -152,7 +152,7 @@ void ItemBase::growSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size *= 2;
@@ -171,7 +171,7 @@ void ItemBase::shrinkSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size /= 2;
@@ -257,6 +257,12 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
m_size = MIN_ITEM_SIZE;
}
+int ItemBase::type() const
+{
+ return Type;
+}
+
+
bool ItemBase::isInResizeArea(const QPointF &pos)
{
return (-pos.y() < pos.x() - m_size + 9);
@@ -313,6 +319,8 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
0.5f * (right + left), 0.5f * (bottom + top), 0.0f, 1.0f
};
+ painter->beginNativePainting();
+
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixf(moveToRectMatrix);
@@ -386,6 +394,8 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
glMatrixMode(GL_PROJECTION);
glPopMatrix();
+ painter->endNativePainting();
+
ItemBase::paint(painter, option, widget);
}
diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h
index 6f39b0d..9465911 100644
--- a/demos/boxes/qtbox.h
+++ b/demos/boxes/qtbox.h
@@ -47,10 +47,11 @@
#include <QtGui/qvector3d.h>
#include "glbuffers.h"
-class ItemBase : public QObject, public QGraphicsItem
+class ItemBase : public QGraphicsItem
{
- Q_OBJECT
public:
+ enum { Type = UserType + 1 };
+
ItemBase(int size, int x, int y);
virtual ~ItemBase();
virtual QRectF boundingRect() const;
@@ -64,6 +65,7 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
+ virtual int type() const;
bool isInResizeArea(const QPointF &pos);
static void duplicateSelectedItems(QGraphicsScene *scene);
diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp
index 016ba17..2a7ca0e 100644
--- a/demos/boxes/scene.cpp
+++ b/demos/boxes/scene.cpp
@@ -894,6 +894,7 @@ void Scene::drawBackground(QPainter *painter, const QRectF &)
float width = float(painter->device()->width());
float height = float(painter->device()->height());
+ painter->beginNativePainting();
setStates();
if (m_dynamicCubemap)
@@ -913,6 +914,8 @@ void Scene::drawBackground(QPainter *painter, const QRectF &)
defaultStates();
++m_frame;
+
+ painter->endNativePainting();
}
QPointF Scene::pixelPosToViewPos(const QPointF& p)
diff --git a/demos/boxes/scene.h b/demos/boxes/scene.h
index efe1e3f..23f17e5 100644
--- a/demos/boxes/scene.h
+++ b/demos/boxes/scene.h
@@ -108,6 +108,8 @@ private:
class GraphicsWidget : public QGraphicsProxyWidget
{
+public:
+ GraphicsWidget() : QGraphicsProxyWidget(0, Qt::Window) {}
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
diff --git a/demos/composition/composition.cpp b/demos/composition/composition.cpp
index bb8a02c..8061908 100644
--- a/demos/composition/composition.cpp
+++ b/demos/composition/composition.cpp
@@ -377,7 +377,9 @@ void CompositionRenderer::paint(QPainter *painter)
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent);
- p.save();
+ p.save(); // Needed when using the GL1 engine
+ p.beginNativePainting(); // Needed when using the GL2 engine
+
glBindTexture(GL_TEXTURE_2D, m_base_tex);
glEnable(GL_TEXTURE_2D);
glColor4f(1.,1.,1.,1.);
@@ -399,16 +401,21 @@ void CompositionRenderer::paint(QPainter *painter)
glEnd();
glDisable(GL_TEXTURE_2D);
- p.restore();
+
+ p.endNativePainting(); // Needed when using the GL2 engine
+ p.restore(); // Needed when using the GL1 engine
drawSource(p);
p.end();
m_pbuffer->updateDynamicTexture(m_compositing_tex);
}
- glWidget()->makeCurrent();
+ painter->beginNativePainting(); // Needed when using the GL2 engine
+ glWidget()->makeCurrent(); // Needed when using the GL1 engine
glBindTexture(GL_TEXTURE_2D, m_compositing_tex);
glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1.,1.,1.,1.);
glBegin(GL_QUADS);
{
@@ -426,6 +433,7 @@ void CompositionRenderer::paint(QPainter *painter)
}
glEnd();
glDisable(GL_TEXTURE_2D);
+ painter->endNativePainting(); // Needed when using the GL2 engine
} else
#endif
{
diff --git a/demos/embedded/digiflip/digiflip.pro b/demos/embedded/digiflip/digiflip.pro
index 6654088..4db5171 100644
--- a/demos/embedded/digiflip/digiflip.pro
+++ b/demos/embedded/digiflip/digiflip.pro
@@ -1 +1,7 @@
SOURCES = digiflip.cpp
+
+symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF72
+}
+
diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro
index 3d814f7..5bd3276 100644
--- a/demos/embedded/embedded.pro
+++ b/demos/embedded/embedded.pro
@@ -7,12 +7,10 @@ contains(QT_CONFIG, svg) {
!vxworks:!qnx:SUBDIRS += fluidlauncher
}
-contains(QT_CONFIG, network) {
- SUBDIRS += lightmaps
- SUBDIRS += flightinfo
- contains(QT_CONFIG, svg) {
- SUBDIRS += weatherinfo
- }
+SUBDIRS += lightmaps
+SUBDIRS += flightinfo
+contains(QT_CONFIG, svg) {
+ SUBDIRS += weatherinfo
}
contains(QT_CONFIG, webkit) {
diff --git a/demos/embedded/flickable/flickable.pro b/demos/embedded/flickable/flickable.pro
index 3c021dd..02e88aa 100644
--- a/demos/embedded/flickable/flickable.pro
+++ b/demos/embedded/flickable/flickable.pro
@@ -1,2 +1,7 @@
SOURCES = flickable.cpp main.cpp
HEADERS = flickable.h
+
+symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF73
+}
diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro
index 5edb175..461c701 100644
--- a/demos/embedded/flightinfo/flightinfo.pro
+++ b/demos/embedded/flightinfo/flightinfo.pro
@@ -6,6 +6,8 @@ RESOURCES = flightinfo.qrc
QT += network
symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF74
HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h
LIBS += -lesock -lconnmon
TARGET.CAPABILITY = NetworkServices
diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro
index 522ccf3..3ed4f31 100644
--- a/demos/embedded/fluidlauncher/fluidlauncher.pro
+++ b/demos/embedded/fluidlauncher/fluidlauncher.pro
@@ -61,7 +61,6 @@ symbian {
TARGET.UID3 = 0xA000A641
executables.sources = \
- embeddedsvgviewer.exe \
styledemo.exe \
deform.exe \
pathstroke.exe \
@@ -71,48 +70,78 @@ symbian {
desktopservices.exe \
fridgemagnets.exe \
drilldown.exe \
- softkeys.exe
-
- contains(QT_CONFIG, webkit): executables.sources += anomaly.exe
- contains(QT_CONFIG, script): executables.sources += context2d.exe
+ softkeys.exe \
+ raycasting.exe \
+ flickable.exe \
+ digiflip.exe \
+ lightmaps.exe \
+ flightinfo.exe
executables.path = /sys/bin
reg_resource.sources = \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/embeddedsvgviewer_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/styledemo_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/deform_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/pathstroke_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/wiggly_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/ftp_reg.rsc\
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/saxbookmarks_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/desktopservices_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc \
- $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc
-
- contains(QT_CONFIG, webkit): reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/anomaly_reg.rsc
- contains(QT_CONFIG, script): reg_resource.sources += $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/context2d_reg.rsc
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/styledemo_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/deform_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/pathstroke_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/wiggly_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/ftp_reg.rsc\
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/saxbookmarks_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/desktopservices_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/fridgemagnets_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/drilldown_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/softkeys_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/raycasting_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/flickable_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/digiflip_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/lightmaps_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/flightinfo_reg.rsc
reg_resource.path = $$REG_RESOURCE_IMPORT_DIR
resource.sources = \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/styledemo.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/deform.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/pathstroke.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/wiggly.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/ftp.rsc\
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/saxbookmarks.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc \
- $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc
- contains(QT_CONFIG, webkit): resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/anomaly.rsc
- contains(QT_CONFIG, script): resource.sources += $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/context2d.rsc
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/styledemo.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/deform.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/pathstroke.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/wiggly.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/ftp.rsc\
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/saxbookmarks.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/desktopservices.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/fridgemagnets.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/drilldown.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/softkeys.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/raycasting.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flickable.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/digiflip.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/lightmaps.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/flightinfo.rsc
+
resource.path = $$APP_RESOURCE_DIR
+ contains(QT_CONFIG, svg) {
+ executables.sources += \
+ embeddedsvgviewer.exe \
+ weatherinfo.exe
+
+ reg_resource.sources += \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/embeddedsvgviewer_reg.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$REG_RESOURCE_IMPORT_DIR/weatherinfo_reg.rsc
+
+ resource.sources += \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/embeddedsvgviewer.rsc \
+ $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/weatherinfo.rsc
+ }
+ 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
+ }
+ 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/0xA000C611.mif
mifs.path = $$APP_RESOURCE_DIR
diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro
index e57d15d..137183a 100644
--- a/demos/embedded/lightmaps/lightmaps.pro
+++ b/demos/embedded/lightmaps/lightmaps.pro
@@ -3,6 +3,8 @@ SOURCES = lightmaps.cpp
QT += network
symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF75
HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h
LIBS += -lesock -lconnmon
TARGET.CAPABILITY = NetworkServices
diff --git a/demos/embedded/raycasting/raycasting.pro b/demos/embedded/raycasting/raycasting.pro
index dae9412..19e0212 100644
--- a/demos/embedded/raycasting/raycasting.pro
+++ b/demos/embedded/raycasting/raycasting.pro
@@ -1,3 +1,8 @@
TEMPLATE = app
SOURCES = raycasting.cpp
RESOURCES += raycasting.qrc
+
+symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF76
+}
diff --git a/demos/embedded/weatherinfo/weatherinfo.pro b/demos/embedded/weatherinfo/weatherinfo.pro
index a89acba..0a579b0 100644
--- a/demos/embedded/weatherinfo/weatherinfo.pro
+++ b/demos/embedded/weatherinfo/weatherinfo.pro
@@ -5,6 +5,8 @@ RESOURCES = weatherinfo.qrc
QT += network svg
symbian {
+ include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
+ TARGET.UID3 = 0xA000CF77
HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h
LIBS += -lesock -lconnmon
TARGET.CAPABILITY = NetworkServices
diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml
index f598780..77006c2 100644
--- a/demos/qtdemo/xml/examples.xml
+++ b/demos/qtdemo/xml/examples.xml
@@ -184,7 +184,6 @@
<category dirname="statemachine" name="State Machine">
<example filename="eventtransitions" name="Event Transitions" />
<example filename="rogue" name="Rogue" />
- <example filename="tankgame" name="Tank Game" />
<example filename="trafficlight" name="Traffic Light" />
<example filename="twowaybutton" name="Two-way Button" />
</category>
diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp
index b4fd0c9..79de011 100644
--- a/demos/sub-attaq/graphicsscene.cpp
+++ b/demos/sub-attaq/graphicsscene.cpp
@@ -51,6 +51,7 @@
#include "animationmanager.h"
#include "qanimationstate.h"
#include "progressitem.h"
+#include "textinformationitem.h"
//Qt
#include <QtCore/QPropertyAnimation>
@@ -112,6 +113,8 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
//The item that display score and level
progressItem = new ProgressItem(backgroundItem);
+ textInformationItem = new TextInformationItem(backgroundItem);
+ textInformationItem->hide();
//We create the boat
boat = new Boat();
addItem(boat);
@@ -244,15 +247,15 @@ void GraphicsScene::setupScene(const QList<QAction *> &actions)
lettersFadingState->setAnimation(lettersGroupFading);
//if new game then we fade out the welcome screen and start playing
- lettersMovingState->addTransition(newAction, SIGNAL(triggered()),lettersFadingState);
- lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()),gameState);
+ lettersMovingState->addTransition(newAction, SIGNAL(triggered()), lettersFadingState);
+ lettersFadingState->addTransition(lettersFadingState, SIGNAL(animationFinished()), gameState);
//New Game is triggered then player start playing
- gameState->addTransition(newAction, SIGNAL(triggered()),gameState);
+ gameState->addTransition(newAction, SIGNAL(triggered()), gameState);
//Wanna quit, then connect to CTRL+Q
- gameState->addTransition(quitAction, SIGNAL(triggered()),final);
- lettersMovingState->addTransition(quitAction, SIGNAL(triggered()),final);
+ gameState->addTransition(quitAction, SIGNAL(triggered()), final);
+ lettersMovingState->addTransition(quitAction, SIGNAL(triggered()), final);
//Welcome screen is the initial state
machine->setInitialState(lettersMovingState);
diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h
index 073ad17..8fa62f7 100644
--- a/demos/sub-attaq/graphicsscene.h
+++ b/demos/sub-attaq/graphicsscene.h
@@ -54,6 +54,7 @@ class Torpedo;
class Bomb;
class PixmapItem;
class ProgressItem;
+class TextInformationItem;
QT_BEGIN_NAMESPACE
class QAction;
QT_END_NAMESPACE
@@ -108,6 +109,7 @@ private:
Mode mode;
PixmapItem *backgroundItem;
ProgressItem *progressItem;
+ TextInformationItem *textInformationItem;
QAction * newAction;
QAction * quitAction;
Boat *boat;
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index 75a2615..5c809cb 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -47,6 +47,7 @@
#include "torpedo.h"
#include "animationmanager.h"
#include "progressitem.h"
+#include "textinformationitem.h"
//Qt
#include <QtGui/QMessageBox>
@@ -226,8 +227,15 @@ void LostState::onEntry(QEvent *)
//We clear the scene
scene->clearScene();
- //we have only one view
- QMessageBox::information(scene->views().at(0),"You lose",message);
+ //We inform the player
+ scene->textInformationItem->setMessage(message);
+ scene->textInformationItem->show();
+}
+
+void LostState::onExit(QEvent *)
+{
+ //we hide the information
+ scene->textInformationItem->hide();
}
/** Win State */
@@ -242,7 +250,7 @@ void WinState::onEntry(QEvent *)
QString message;
if (scene->levelsData.size() - 1 != game->currentLevel) {
- message = QString("You win the level %1. Your score is %2.\nPress Space to continue after closing this dialog.").arg(game->currentLevel+1).arg(game->score);
+ message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score);
//We increment the level number
game->currentLevel++;
} else {
@@ -253,8 +261,15 @@ void WinState::onEntry(QEvent *)
game->score = 0;
}
- //we have only one view
- QMessageBox::information(scene->views().at(0),"You win",message);
+ //We inform the player
+ scene->textInformationItem->setMessage(message);
+ scene->textInformationItem->show();
+}
+
+void WinState::onExit(QEvent *)
+{
+ //we hide the information
+ scene->textInformationItem->hide();
}
/** UpdateScore State */
diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h
index 7635c0c..3176571 100644
--- a/demos/sub-attaq/states.h
+++ b/demos/sub-attaq/states.h
@@ -113,6 +113,7 @@ public:
protected:
void onEntry(QEvent *);
+ void onExit(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
@@ -125,6 +126,7 @@ public:
protected:
void onEntry(QEvent *);
+ void onExit(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro
index ad1327d..ba2b54b 100644
--- a/demos/sub-attaq/sub-attaq.pro
+++ b/demos/sub-attaq/sub-attaq.pro
@@ -1,5 +1,4 @@
contains(QT_CONFIG, opengl):QT += opengl
-
HEADERS += boat.h \
bomb.h \
mainwindow.h \
@@ -13,7 +12,8 @@ HEADERS += boat.h \
submarine_p.h \
custompropertyanimation.h \
qanimationstate.h \
- progressitem.h
+ progressitem.h \
+ textinformationitem.h
SOURCES += boat.cpp \
bomb.cpp \
main.cpp \
@@ -26,12 +26,18 @@ SOURCES += boat.cpp \
states.cpp \
custompropertyanimation.cpp \
qanimationstate.cpp \
- progressitem.cpp
+ progressitem.cpp \
+ textinformationitem.cpp
RESOURCES += subattaq.qrc
# install
target.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sub-attaq.pro pics
+sources.files = $$SOURCES \
+ $$HEADERS \
+ $$RESOURCES \
+ $$FORMS \
+ sub-attaq.pro \
+ pics
sources.path = $$[QT_INSTALL_DEMOS]/animation/sub-attaq
-INSTALLS += target sources
-
+INSTALLS += target \
+ sources
diff --git a/demos/sub-attaq/textinformationitem.cpp b/demos/sub-attaq/textinformationitem.cpp
new file mode 100644
index 0000000..759aa56
--- /dev/null
+++ b/demos/sub-attaq/textinformationitem.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 "textinformationitem.h"
+#include "pixmapitem.h"
+
+TextInformationItem::TextInformationItem (QGraphicsItem * parent)
+ : QGraphicsTextItem(parent)
+{
+ setFont(QFont("Comic Sans MS", 25));
+}
+#include <QDebug>
+void TextInformationItem::setMessage(const QString& text)
+{
+ setHtml(text);
+ setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y());
+}
diff --git a/demos/sub-attaq/textinformationitem.h b/demos/sub-attaq/textinformationitem.h
new file mode 100644
index 0000000..aa7f0be
--- /dev/null
+++ b/demos/sub-attaq/textinformationitem.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 TEXTINFORMATIONITEM_H
+#define TEXTINFORMATIONITEM_H
+
+//Qt
+#include <QtGui/QGraphicsTextItem>
+
+class TextInformationItem : public QGraphicsTextItem
+{
+public:
+ TextInformationItem(QGraphicsItem * parent = 0);
+ void setMessage(const QString& text);
+};
+
+#endif // TEXTINFORMATIONITEM_H
diff --git a/demos/textedit/textedit.doc b/demos/textedit/textedit.doc
deleted file mode 100644
index 53279b9..0000000
--- a/demos/textedit/textedit.doc
+++ /dev/null
@@ -1,18 +0,0 @@
-/*! \page textedit-example.html
-
- \ingroup examples
- \title Text Edit Example
-
- This example displays a text editor with the user interface written
- in pure C++.
-
- A similar example which uses \link designer-manual.book Qt
- Designer\endlink to produce the user interface is in the \link
- designer-manual.book Qt Designer manual\endlink.
-
-
- See \c{$QTDIR/examples/textedit} for the source code.
-
-*/
-
-
diff --git a/demos/textedit/textedit.qdoc b/demos/textedit/textedit.qdoc
new file mode 100644
index 0000000..c9b06e8
--- /dev/null
+++ b/demos/textedit/textedit.qdoc
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation 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$
+**
+****************************************************************************/
+
+/*! \page textedit-example.html
+
+ \ingroup examples
+ \title Text Edit Example
+
+ This example displays a text editor with the user interface written
+ in pure C++.
+
+ A similar example which uses \link designer-manual.book Qt
+ Designer\endlink to produce the user interface is in the \link
+ designer-manual.book Qt Designer manual\endlink.
+
+
+ See \c{$QTDIR/examples/textedit} for the source code.
+
+*/
+
+