summaryrefslogtreecommitdiffstats
path: root/demos/qtdemo
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 10:18:55 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 10:18:55 +0100
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /demos/qtdemo
Long live Qt 4.5!
Diffstat (limited to 'demos/qtdemo')
-rw-r--r--demos/qtdemo/Info_mac.plist18
-rw-r--r--demos/qtdemo/colors.cpp390
-rw-r--r--demos/qtdemo/colors.h130
-rw-r--r--demos/qtdemo/demoitem.cpp280
-rw-r--r--demos/qtdemo/demoitem.h124
-rw-r--r--demos/qtdemo/demoitemanimation.cpp219
-rw-r--r--demos/qtdemo/demoitemanimation.h101
-rw-r--r--demos/qtdemo/demoscene.cpp54
-rw-r--r--demos/qtdemo/demoscene.h57
-rw-r--r--demos/qtdemo/demotextitem.cpp123
-rw-r--r--demos/qtdemo/demotextitem.h74
-rw-r--r--demos/qtdemo/dockitem.cpp108
-rw-r--r--demos/qtdemo/dockitem.h69
-rw-r--r--demos/qtdemo/examplecontent.cpp158
-rw-r--r--demos/qtdemo/examplecontent.h77
-rw-r--r--demos/qtdemo/guide.cpp144
-rw-r--r--demos/qtdemo/guide.h73
-rw-r--r--demos/qtdemo/guidecircle.cpp88
-rw-r--r--demos/qtdemo/guidecircle.h72
-rw-r--r--demos/qtdemo/guideline.cpp81
-rw-r--r--demos/qtdemo/guideline.h65
-rw-r--r--demos/qtdemo/headingitem.cpp104
-rw-r--r--demos/qtdemo/headingitem.h63
-rw-r--r--demos/qtdemo/imageitem.cpp114
-rw-r--r--demos/qtdemo/imageitem.h66
-rwxr-xr-xdemos/qtdemo/images/demobg.pngbin0 -> 20675 bytes
-rw-r--r--demos/qtdemo/images/qtlogo_small.pngbin0 -> 3546 bytes
-rw-r--r--demos/qtdemo/images/trolltech-logo.pngbin0 -> 23547 bytes
-rw-r--r--demos/qtdemo/itemcircleanimation.cpp507
-rw-r--r--demos/qtdemo/itemcircleanimation.h110
-rw-r--r--demos/qtdemo/letteritem.cpp85
-rw-r--r--demos/qtdemo/letteritem.h62
-rw-r--r--demos/qtdemo/main.cpp74
-rw-r--r--demos/qtdemo/mainwindow.cpp483
-rw-r--r--demos/qtdemo/mainwindow.h109
-rw-r--r--demos/qtdemo/menucontent.cpp140
-rw-r--r--demos/qtdemo/menucontent.h77
-rw-r--r--demos/qtdemo/menumanager.cpp876
-rw-r--r--demos/qtdemo/menumanager.h134
-rw-r--r--demos/qtdemo/qtdemo.icnsbin0 -> 129539 bytes
-rw-r--r--demos/qtdemo/qtdemo.icobin0 -> 355574 bytes
-rw-r--r--demos/qtdemo/qtdemo.pro72
-rw-r--r--demos/qtdemo/qtdemo.qrc8
-rw-r--r--demos/qtdemo/qtdemo.rc2
-rw-r--r--demos/qtdemo/scanitem.cpp80
-rw-r--r--demos/qtdemo/scanitem.h60
-rw-r--r--demos/qtdemo/score.cpp149
-rw-r--r--demos/qtdemo/score.h86
-rw-r--r--demos/qtdemo/textbutton.cpp384
-rw-r--r--demos/qtdemo/textbutton.h100
-rw-r--r--demos/qtdemo/xml/examples.xml227
51 files changed, 6677 insertions, 0 deletions
diff --git a/demos/qtdemo/Info_mac.plist b/demos/qtdemo/Info_mac.plist
new file mode 100644
index 0000000000..71b00591b4
--- /dev/null
+++ b/demos/qtdemo/Info_mac.plist
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>CFBundleIconFile</key>
+ <string>@ICON@</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Qt/QMake</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.trolltech.qt.demo</string>
+ <key>CFBundleExecutable</key>
+ <string>@EXECUTABLE@</string>
+</dict>
+</plist>
diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp
new file mode 100644
index 0000000000..18343cbbf8
--- /dev/null
+++ b/demos/qtdemo/colors.cpp
@@ -0,0 +1,390 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "colors.h"
+
+#ifndef QT_NO_OPENGL
+ #include <QGLWidget>
+#endif
+//#define QT_NO_OPENGL
+
+// Colors:
+QColor Colors::sceneBg1(QColor(91, 91, 91));
+QColor Colors::sceneBg1Line(QColor(114, 108, 104));
+QColor Colors::sceneBg2(QColor(0, 0, 0));
+QColor Colors::sceneLine(255, 255, 255);
+QColor Colors::paperBg(QColor(100, 100, 100));
+QColor Colors::menuTextFg(QColor(255, 0, 0));
+QColor Colors::buttonBgLow(QColor(255, 255, 255, 90));
+QColor Colors::buttonBgHigh(QColor(255, 255, 255, 20));
+QColor Colors::buttonText(QColor(255, 255, 255));
+QColor Colors::tt_green(QColor(166, 206, 57));
+QColor Colors::fadeOut(QColor(206, 246, 117, 0));
+QColor Colors::heading(QColor(190,230,80));
+QString Colors::contentColor("<font color='#eeeeee'>");
+QString Colors::glVersion("Not detected!");
+
+// Guides:
+int Colors::stageStartY = 8;
+int Colors::stageHeight = 536;
+int Colors::stageStartX = 8;
+int Colors::stageWidth = 785;
+int Colors::contentStartY = 22;
+int Colors::contentHeight = 510;
+
+// Properties:
+bool Colors::openGlRendering = false;
+bool Colors::direct3dRendering = false;
+bool Colors::softwareRendering = false;
+bool Colors::openGlAwailable = true;
+bool Colors::direct3dAwailable = true;
+bool Colors::xRenderPresent = true;
+
+bool Colors::noTicker = false;
+bool Colors::noRescale = false;
+bool Colors::noAnimations = false;
+bool Colors::noBlending = false;
+bool Colors::noScreenSync = false;
+bool Colors::fullscreen = false;
+bool Colors::usePixmaps = false;
+bool Colors::useLoop = false;
+bool Colors::showBoundingRect = false;
+bool Colors::showFps = false;
+bool Colors::noAdapt = false;
+bool Colors::noWindowMask = true;
+bool Colors::useButtonBalls = false;
+bool Colors::useEightBitPalette = false;
+bool Colors::noTimerUpdate = false;
+bool Colors::noTickerMorph = false;
+bool Colors::adapted = false;
+bool Colors::verbose = false;
+bool Colors::pause = true;
+int Colors::fps = 100;
+int Colors::menuCount = 18;
+float Colors::animSpeed = 1.0;
+float Colors::animSpeedButtons = 1.0;
+float Colors::benchmarkFps = -1;
+int Colors::tickerLetterCount = 80;
+float Colors::tickerMoveSpeed = 0.4f;
+float Colors::tickerMorphSpeed = 2.5f;
+QString Colors::tickerText = ".EROM ETAERC .SSEL EDOC";
+QString Colors::rootMenuName = "Qt Examples and Demos";
+
+QFont Colors::contentFont()
+{
+ QFont font;
+ font.setStyleStrategy(QFont::PreferAntialias);
+#if defined(Q_OS_MAC)
+ font.setPixelSize(14);
+ font.setFamily("Arial");
+#else
+ font.setPixelSize(13);
+ font.setFamily("Verdana");
+#endif
+ return font;
+}
+
+QFont Colors::headingFont()
+{
+ QFont font;
+ font.setStyleStrategy(QFont::PreferAntialias);
+ font.setPixelSize(23);
+ font.setBold(true);
+ font.setFamily("Verdana");
+ return font;
+}
+
+QFont Colors::buttonFont()
+{
+ QFont font;
+ font.setStyleStrategy(QFont::PreferAntialias);
+#if 0//defined(Q_OS_MAC)
+ font.setPixelSize(11);
+ font.setFamily("Silom");
+#else
+ font.setPixelSize(11);
+ font.setFamily("Verdana");
+#endif
+ return font;
+}
+
+QFont Colors::tickerFont()
+{
+ QFont font;
+ font.setStyleStrategy(QFont::PreferAntialias);
+#if defined(Q_OS_MAC)
+ font.setPixelSize(11);
+ font.setBold(true);
+ font.setFamily("Arial");
+#else
+ font.setPixelSize(10);
+ font.setBold(true);
+ font.setFamily("sans serif");
+#endif
+ return font;
+}
+
+float parseFloat(const QString &argument, const QString &name)
+{
+ if (name.length() == argument.length()){
+ QMessageBox::warning(0, "Arguments",
+ QString("No argument number found for ")
+ + name
+ + ". Remember to put name and value adjacent! (e.g. -fps100)");
+ exit(0);
+ }
+ float value = argument.mid(name.length()).toFloat();
+ return value;
+}
+
+QString parseText(const QString &argument, const QString &name)
+{
+ if (name.length() == argument.length()){
+ QMessageBox::warning(0, "Arguments",
+ QString("No argument number found for ")
+ + name
+ + ". Remember to put name and value adjacent! (e.g. -fps100)");
+ exit(0);
+ }
+ QString value = argument.mid(name.length());
+ return value;
+}
+
+void Colors::parseArgs(int argc, char *argv[])
+{
+ // some arguments should be processed before
+ // others. Handle them now:
+ for (int i=1; i<argc; i++){
+ QString s(argv[i]);
+ if (s == "-verbose")
+ Colors::verbose = true;
+ }
+
+ Colors::detectSystemResources();
+
+ // Handle the rest of the arguments. They may
+ // override attributes already set:
+ for (int i=1; i<argc; i++){
+ QString s(argv[i]);
+ if (s == "-opengl")
+ Colors::openGlRendering = true;
+ else if (s == "-direct3d")
+ Colors::direct3dRendering = true;
+ else if (s == "-software")
+ Colors::softwareRendering = true;
+ else if (s == "-no-opengl") // support old style
+ Colors::softwareRendering = true;
+ else if (s == "-no-ticker") // support old style
+ Colors::noTicker = true;
+ else if (s.startsWith("-ticker"))
+ Colors::noTicker = !bool(parseFloat(s, "-ticker"));
+ else if (s == "-no-animations")
+ Colors::noAnimations = true; // support old style
+ else if (s.startsWith("-animations"))
+ Colors::noAnimations = !bool(parseFloat(s, "-animations"));
+ else if (s == "-no-adapt")
+ Colors::noAdapt = true;
+ else if (s == "-low")
+ Colors::setLowSettings();
+ else if (s == "-no-rescale")
+ Colors::noRescale = true;
+ else if (s == "-use-pixmaps")
+ Colors::usePixmaps = true;
+ else if (s == "-fullscreen")
+ Colors::fullscreen = true;
+ else if (s == "-show-br")
+ Colors::showBoundingRect = true;
+ else if (s == "-show-fps")
+ Colors::showFps = true;
+ else if (s == "-no-blending")
+ Colors::noBlending = true;
+ else if (s == "-no-sync")
+ Colors::noScreenSync = true;
+ else if (s.startsWith("-menu"))
+ Colors::menuCount = int(parseFloat(s, "-menu"));
+ else if (s.startsWith("-use-timer-update"))
+ Colors::noTimerUpdate = !bool(parseFloat(s, "-use-timer-update"));
+ else if (s.startsWith("-pause"))
+ Colors::pause = bool(parseFloat(s, "-pause"));
+ else if (s == "-no-ticker-morph")
+ Colors::noTickerMorph = true;
+ else if (s == "-use-window-mask")
+ Colors::noWindowMask = false;
+ else if (s == "-use-loop")
+ Colors::useLoop = true;
+ else if (s == "-use-8bit")
+ Colors::useEightBitPalette = true;
+ else if (s.startsWith("-8bit"))
+ Colors::useEightBitPalette = bool(parseFloat(s, "-8bit"));
+ else if (s == "-use-balls")
+ Colors::useButtonBalls = true;
+ else if (s.startsWith("-ticker-letters"))
+ Colors::tickerLetterCount = int(parseFloat(s, "-ticker-letters"));
+ else if (s.startsWith("-ticker-text"))
+ Colors::tickerText = parseText(s, "-ticker-text");
+ else if (s.startsWith("-ticker-speed"))
+ Colors::tickerMoveSpeed = parseFloat(s, "-ticker-speed");
+ else if (s.startsWith("-ticker-morph-speed"))
+ Colors::tickerMorphSpeed = parseFloat(s, "-ticker-morph-speed");
+ else if (s.startsWith("-animation-speed"))
+ Colors::animSpeed = parseFloat(s, "-animation-speed");
+ else if (s.startsWith("-fps"))
+ Colors::fps = int(parseFloat(s, "-fps"));
+ else if (s.startsWith("-h") || s.startsWith("-help")){
+ QMessageBox::warning(0, "Arguments",
+ QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-direct3d] [-software] [-fullscreen] [-ticker[0|1]] ")
+ + "[-animations[0|1]] [-no-blending] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] "
+ + "[-use-window-mask] [-no-rescale] "
+ + "[-use-pixmaps] [-show-fps] [-show-br] [-8bit[0|1]] [-menu<int>] [-use-loop] [-use-balls] "
+ + "[-animation-speed<float>] [-fps<int>] "
+ + "[-low] [-ticker-letters<int>] [-ticker-speed<float>] [-no-ticker-morph] "
+ + "[-ticker-morph-speed<float>] [-ticker-text<string>]");
+ exit(0);
+ }
+ }
+
+ Colors::postConfigure();
+}
+
+void Colors::setLowSettings()
+{
+ Colors::openGlRendering = false;
+ Colors::direct3dRendering = false;
+ Colors::softwareRendering = true;
+ Colors::noTicker = true;
+ Colors::noTimerUpdate = true;
+ Colors::fps = 30;
+ Colors::usePixmaps = true;
+ Colors::noAnimations = true;
+ Colors::noBlending = true;
+}
+
+void Colors::detectSystemResources()
+{
+#ifndef QT_NO_OPENGL
+ if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
+ Colors::glVersion = "2.0 or higher";
+ else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
+ Colors::glVersion = "1.5";
+ else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_4)
+ Colors::glVersion = "1.4";
+ else if (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_3)
+ Colors::glVersion = "1.3 or lower";
+ if (Colors::verbose)
+ qDebug() << "- OpenGL version:" << Colors::glVersion;
+
+ QGLWidget glw;
+ if (!QGLFormat::hasOpenGL()
+ || !glw.format().directRendering()
+ || !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_5)
+ || glw.depth() < 24
+ )
+#else
+ if (Colors::verbose)
+ qDebug() << "- OpenGL not supported by current build of Qt";
+#endif
+ {
+ Colors::openGlAwailable = false;
+ if (Colors::verbose)
+ qDebug("- OpenGL not recommended on this system");
+ }
+
+#if defined(Q_WS_WIN)
+ Colors::direct3dAwailable = false; // for now.
+#endif
+
+#if defined(Q_WS_X11)
+ // check if X render is present:
+ QPixmap tmp(1, 1);
+ if (!tmp.x11PictureHandle()){
+ Colors::xRenderPresent = false;
+ if (Colors::verbose)
+ qDebug("- X render not present");
+ }
+
+#endif
+
+ QWidget w;
+ if (Colors::verbose)
+ qDebug() << "- Color depth: " << QString::number(w.depth());
+}
+
+void Colors::postConfigure()
+{
+ if (!Colors::noAdapt){
+ QWidget w;
+ if (w.depth() < 16){
+ Colors::useEightBitPalette = true;
+ Colors::adapted = true;
+ if (Colors::verbose)
+ qDebug() << "- Adapt: Color depth less than 16 bit. Using 8 bit palette";
+ }
+
+ if (!Colors::xRenderPresent){
+ Colors::setLowSettings();
+ Colors::adapted = true;
+ if (Colors::verbose)
+ qDebug() << "- Adapt: X renderer not present. Using low settings";
+ }
+ }
+
+#if !defined(Q_WS_WIN)
+ if (Colors::direct3dRendering){
+ Colors::direct3dRendering = false;
+ qDebug() << "- WARNING: Direct3D specified, but not supported on this platform";
+ }
+#endif
+
+ if (!Colors::openGlRendering && !Colors::direct3dRendering && !Colors::softwareRendering){
+ // The user has not decided rendering system. So we do it instead:
+#if defined(Q_WS_WIN)
+ if (Colors::direct3dAwailable)
+ Colors::direct3dRendering = true;
+ else
+#endif
+ if (Colors::openGlAwailable)
+ Colors::openGlRendering = true;
+ else
+ Colors::softwareRendering = true;
+ }
+}
+
+
diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h
new file mode 100644
index 0000000000..58865c6ec4
--- /dev/null
+++ b/demos/qtdemo/colors.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COLORS_H
+#define COLORS_H
+
+#include <QtGui>
+#include <QBrush>
+
+class Colors
+{
+private:
+ Colors(){};
+
+public:
+ static void parseArgs(int argc, char *argv[]);
+ static void detectSystemResources();
+ static void postConfigure();
+ static void setLowSettings();
+
+ // Colors:
+ static QColor sceneBg1;
+ static QColor sceneBg2;
+ static QColor sceneBg1Line;
+ static QColor paperBg;
+ static QColor menuTextFg;
+ static QColor buttonText;
+ static QColor buttonBgLow;
+ static QColor buttonBgHigh;
+ static QColor tt_green;
+ static QColor fadeOut;
+ static QColor sceneLine;
+ static QColor heading;
+ static QString contentColor;
+ static QString glVersion;
+
+ // Guides:
+ static int stageStartY;
+ static int stageHeight;
+ static int stageStartX;
+ static int stageWidth;
+ static int contentStartY;
+ static int contentHeight;
+
+ // properties:
+ static bool openGlRendering;
+ static bool direct3dRendering;
+ static bool softwareRendering;
+ static bool openGlAwailable;
+ static bool direct3dAwailable;
+ static bool xRenderPresent;
+ static bool noAdapt;
+ static bool noTicker;
+ static bool noRescale;
+ static bool noAnimations;
+ static bool noBlending;
+ static bool noScreenSync;
+ static bool useLoop;
+ static bool noWindowMask;
+ static bool usePixmaps;
+ static bool useEightBitPalette;
+ static bool fullscreen;
+ static bool showBoundingRect;
+ static bool showFps;
+ static bool noTimerUpdate;
+ static bool noTickerMorph;
+ static bool useButtonBalls;
+ static bool adapted;
+ static bool verbose;
+ static bool pause;
+
+ static float animSpeed;
+ static float animSpeedButtons;
+ static float benchmarkFps;
+ static int tickerLetterCount;
+ static int fps;
+ static int menuCount;
+ static float tickerMoveSpeed;
+ static float tickerMorphSpeed;
+ static QString tickerText;
+ static QString rootMenuName;
+
+ // fonts
+ static QFont contentFont();
+ static QFont headingFont();
+ static QFont buttonFont();
+ static QFont tickerFont();
+
+};
+
+#endif // COLORS_H
+
diff --git a/demos/qtdemo/demoitem.cpp b/demos/qtdemo/demoitem.cpp
new file mode 100644
index 0000000000..0335bd3938
--- /dev/null
+++ b/demos/qtdemo/demoitem.cpp
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "demoitem.h"
+#include "menumanager.h"
+#include "guide.h"
+#include "colors.h"
+
+QHash<QString, SharedImage *> DemoItem::sharedImageHash;
+QMatrix DemoItem::matrix;
+
+DemoItem::DemoItem(QGraphicsScene *scene, QGraphicsItem *parent) : QGraphicsItem(parent, scene)
+{
+ this->opacity = 1.0;
+ this->locked = false;
+ this->prepared = false;
+ this->neverVisible = false;
+ this->noSubPixeling = false;
+ this->currentAnimation = 0;
+ this->currGuide = 0;
+ this->guideFrame = 0;
+ this->sharedImage = new SharedImage();
+ ++this->sharedImage->refCount;
+}
+
+DemoItem::~DemoItem()
+{
+ if(--this->sharedImage->refCount == 0){
+ if (!this->hashKey.isEmpty())
+ DemoItem::sharedImageHash.remove(this->hashKey);
+ delete this->sharedImage;
+ }
+}
+
+void DemoItem::setNeverVisible(bool never)
+{
+ Q_UNUSED(never);
+/*
+ this->neverVisible = never;
+ if (never){
+ this->setVisible(false);
+ QList<QGraphicsItem *> c = children();
+ for (int i=0; i<c.size(); i++){
+ DemoItem *d = dynamic_cast<DemoItem *>(c[i]); // Don't use dynamic cast because it needs RTTI support.
+ if (d)
+ d->setNeverVisible(true);
+ else{
+ c[i]->setVisible(false);
+ }
+ }
+ }
+*/
+}
+
+void DemoItem::setRecursiveVisible(bool visible){
+ if (visible && this->neverVisible){
+ this->setVisible(false);
+ return;
+ }
+
+ this->setVisible(visible);
+ QList<QGraphicsItem *> c = children();
+ for (int i=0; i<c.size(); i++){
+ // DemoItem *d = dynamic_cast<DemoItem *>(c[i]);
+ // if (d)
+ // d->setRecursiveVisible(visible);
+ // else{
+ c[i]->setVisible(visible);
+ // }
+ }
+}
+
+void DemoItem::useGuide(Guide *guide, float startFrame)
+{
+ this->startFrame = startFrame;
+ this->guideFrame = startFrame;
+ while (this->guideFrame > guide->startLength + guide->length()){
+ if (guide->nextGuide == guide->firstGuide)
+ break;
+
+ guide = guide->nextGuide;
+ }
+ this->currGuide = guide;
+}
+
+void DemoItem::guideAdvance(float distance)
+{
+ this->guideFrame += distance;
+ while (this->guideFrame > this->currGuide->startLength + this->currGuide->length()){
+ this->currGuide = this->currGuide->nextGuide;
+ if (this->currGuide == this->currGuide->firstGuide)
+ this->guideFrame -= this->currGuide->lengthAll();
+ }
+}
+
+void DemoItem::guideMove(float moveSpeed)
+{
+ this->currGuide->guide(this, moveSpeed);
+}
+
+void DemoItem::setPosUsingSheepDog(const QPointF &dest, const QRectF &sceneFence)
+{
+ this->setPos(dest);
+ if (sceneFence.isNull())
+ return;
+
+ // I agree. This is not the optimal way of doing it.
+ // But don't want for use time on it now....
+ float itemWidth = this->boundingRect().width();
+ float itemHeight = this->boundingRect().height();
+ float fenceRight = sceneFence.x() + sceneFence.width();
+ float fenceBottom = sceneFence.y() + sceneFence.height();
+
+ if (this->scenePos().x() < sceneFence.x()) this->moveBy(this->mapFromScene(QPointF(sceneFence.x(), 0)).x(), 0);
+ if (this->scenePos().x() > fenceRight - itemWidth) this->moveBy(this->mapFromScene(QPointF(fenceRight - itemWidth, 0)).x(), 0);
+ if (this->scenePos().y() < sceneFence.y()) this->moveBy(0, this->mapFromScene(QPointF(0, sceneFence.y())).y());
+ if (this->scenePos().y() > fenceBottom - itemHeight) this->moveBy(0, this->mapFromScene(QPointF(0, fenceBottom - itemHeight)).y());
+}
+
+void DemoItem::setGuidedPos(const QPointF &pos)
+{
+ this->guidedPos = pos;
+}
+
+QPointF DemoItem::getGuidedPos()
+{
+ return this->guidedPos;
+}
+
+void DemoItem::switchGuide(Guide *guide)
+{
+ this->currGuide = guide;
+ this->guideFrame = 0;
+}
+
+bool DemoItem::inTransition()
+{
+ if (this->currentAnimation)
+ return this->currentAnimation->running();
+ else
+ return false;
+}
+
+void DemoItem::setMatrix(const QMatrix &matrix)
+{
+ DemoItem::matrix = matrix;
+}
+
+void DemoItem::useSharedImage(const QString &hashKey)
+{
+ this->hashKey = hashKey;
+ if (!sharedImageHash.contains(hashKey))
+ sharedImageHash.insert(hashKey, this->sharedImage);
+ else {
+ if(--this->sharedImage->refCount == 0)
+ delete this->sharedImage;
+ this->sharedImage = sharedImageHash.value(hashKey);
+ ++this->sharedImage->refCount;
+ }
+}
+
+bool DemoItem::validateImage()
+{
+ if ((this->sharedImage->matrix != DemoItem::matrix && !Colors::noRescale) || !(this->sharedImage->image || this->sharedImage->pixmap)){
+ // (Re)create image according to new matrix
+ delete this->sharedImage->image;
+ this->sharedImage->image = 0;
+ delete this->sharedImage->pixmap;
+ this->sharedImage->pixmap = 0;
+ this->sharedImage->matrix = DemoItem::matrix;
+
+ // Let subclass create and draw a new image according to the new matrix
+ QImage *image = this->createImage(Colors::noRescale ? QMatrix() : DemoItem::matrix);
+ if (image){
+ if (Colors::showBoundingRect){
+ // draw red transparent rect
+ QPainter painter(image);
+ painter.fillRect(image->rect(), QColor(255, 0, 0, 50));
+ painter.end();
+ }
+
+ this->sharedImage->unscaledBoundingRect = this->sharedImage->matrix.inverted().mapRect(image->rect());
+ if (Colors::usePixmaps){
+ if (image->isNull())
+ this->sharedImage->pixmap = new QPixmap(1, 1);
+ else
+ this->sharedImage->pixmap = new QPixmap(image->size());
+ this->sharedImage->pixmap->fill(QColor(0, 0, 0, 0));
+ QPainter painter(this->sharedImage->pixmap);
+ painter.drawImage(0, 0, *image);
+ delete image;
+ } else {
+ this->sharedImage->image = image;
+ }
+ return true;
+ } else
+ return false;
+ }
+ return true;
+}
+
+QRectF DemoItem::boundingRect() const
+{
+ const_cast<DemoItem *>(this)->validateImage();
+ return this->sharedImage->unscaledBoundingRect;
+}
+
+void DemoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ if (this->validateImage()){
+
+ bool wasSmoothPixmapTransform = painter->testRenderHint(QPainter::SmoothPixmapTransform);
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+
+ if (Colors::noRescale){
+ // Let the painter scale the image for us.
+ // This may degrade both quality and performance
+ if (this->sharedImage->image)
+ painter->drawImage(this->pos(), *this->sharedImage->image);
+ else
+ painter->drawPixmap(this->pos(), *this->sharedImage->pixmap);
+ }
+ else {
+ QMatrix m = painter->worldMatrix();
+ painter->setWorldMatrix(QMatrix());
+ float x = this->noSubPixeling ? qRound(m.dx()) : m.dx();
+ float y = this->noSubPixeling ? qRound(m.dy()) : m.dy();
+ if (this->sharedImage->image)
+ painter->drawImage(QPointF(x, y), *this->sharedImage->image);
+ else
+ painter->drawPixmap(QPointF(x, y), *this->sharedImage->pixmap);
+ }
+
+ if (!wasSmoothPixmapTransform) {
+ painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
+ }
+
+ }
+}
diff --git a/demos/qtdemo/demoitem.h b/demos/qtdemo/demoitem.h
new file mode 100644
index 0000000000..e03327b637
--- /dev/null
+++ b/demos/qtdemo/demoitem.h
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEMO_ITEM_H
+#define DEMO_ITEM_H
+
+#include <QtGui>
+
+class DemoItemAnimation;
+class Guide;
+
+class SharedImage
+{
+public:
+ SharedImage() : refCount(0), image(0), pixmap(0){};
+ ~SharedImage()
+ {
+ delete image;
+ delete pixmap;
+ }
+
+ int refCount;
+ QImage *image;
+ QPixmap *pixmap;
+ QMatrix matrix;
+ QRectF unscaledBoundingRect;
+};
+
+class DemoItem : public QGraphicsItem
+{
+
+public:
+ DemoItem(QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ virtual ~DemoItem();
+
+ bool inTransition();
+ virtual void animationStarted(int id = 0){ Q_UNUSED(id); };
+ virtual void animationStopped(int id = 0){ Q_UNUSED(id); };
+ virtual void prepare(){};
+ void setRecursiveVisible(bool visible);
+ void useSharedImage(const QString &hashKey);
+ void setNeverVisible(bool never = true);
+ static void setMatrix(const QMatrix &matrix);
+ virtual QRectF boundingRect() const; // overridden
+ void setPosUsingSheepDog(const QPointF &dest, const QRectF &sceneFence);
+
+ qreal opacity;
+ bool locked;
+ DemoItemAnimation *currentAnimation;
+ bool noSubPixeling;
+
+ // Used if controlled by a guide:
+ void useGuide(Guide *guide, float startFrame = 0);
+ void guideAdvance(float distance);
+ void guideMove(float moveSpeed);
+ void setGuidedPos(const QPointF &position);
+ QPointF getGuidedPos();
+ float startFrame;
+ float guideFrame;
+ Guide *currGuide;
+
+protected:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option = 0, QWidget *widget = 0); // overridden
+ virtual QImage *createImage(const QMatrix &) const { return 0; };
+ virtual bool collidesWithItem(const QGraphicsItem *, Qt::ItemSelectionMode) const { return false; };
+ bool prepared;
+
+private:
+ SharedImage *sharedImage;
+ QString hashKey;
+ bool neverVisible;
+ bool validateImage();
+
+ // Used if controlled by a guide:
+ void switchGuide(Guide *guide);
+ friend class Guide;
+ QPointF guidedPos;
+
+ // The next static hash is shared amongst all demo items, and
+ // has the purpose of reusing images to save memory and time
+ static QHash<QString, SharedImage *> sharedImageHash;
+ static QMatrix matrix;
+};
+
+#endif // DEMO_ITEM_H
+
diff --git a/demos/qtdemo/demoitemanimation.cpp b/demos/qtdemo/demoitemanimation.cpp
new file mode 100644
index 0000000000..92b2d24516
--- /dev/null
+++ b/demos/qtdemo/demoitemanimation.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "demoitemanimation.h"
+#include "demoitem.h"
+#include "colors.h"
+
+DemoItemAnimation::DemoItemAnimation(DemoItem *item, INOROUT inOrOut)
+{
+ this->opacityAt0 = 1.0;
+ this->opacityAt1 = 1.0;
+ this->startDelay = 0;
+ this->inOrOut = inOrOut;
+ this->hideOnFinished = false;
+ this->forcePlay = false;
+ this->timeline = new QTimeLine(5000);
+ this->timeline->setFrameRange(0, 2000);
+ this->timeline->setUpdateInterval(int(1000.0/Colors::fps));
+ this->moveOnPlay = false;
+ setTimeLine(this->timeline);
+ setItem(item);
+}
+
+DemoItemAnimation::~DemoItemAnimation()
+{
+ // Do not delete demoitem. It is not
+ // owned by an animation
+ delete this->timeline;
+}
+
+void DemoItemAnimation::prepare()
+{
+ this->demoItem()->prepare();
+}
+
+void DemoItemAnimation::setStartPos(const QPointF &pos){
+ this->startPos = pos;
+}
+
+void DemoItemAnimation::setDuration(int duration)
+{
+ duration = int(duration * Colors::animSpeed);
+ this->timeline->setDuration(duration);
+ this->moveOnPlay = true;
+}
+
+void DemoItemAnimation::setCurrentTime(int ms)
+{
+ this->timeline->setCurrentTime(ms);
+}
+
+bool DemoItemAnimation::notOwnerOfItem()
+{
+ return this != demoItem()->currentAnimation;
+}
+
+void DemoItemAnimation::play(bool fromStart, bool force)
+{
+ this->fromStart = fromStart;
+ this->forcePlay = force;
+
+ QPointF currPos = this->demoItem()->pos();
+
+ // If the item that this animation controls in currently under the
+ // control of another animation, stop that animation first
+ if (this->demoItem()->currentAnimation)
+ this->demoItem()->currentAnimation->timeline->stop();
+ this->demoItem()->currentAnimation = this;
+ this->timeline->stop();
+
+ if (Colors::noAnimations && !this->forcePlay){
+ this->timeline->setCurrentTime(1);
+ this->demoItem()->setPos(this->posAt(1));
+ }
+ else{
+ if (this->demoItem()->isVisible())
+ // If the item is already visible, start the animation from
+ // the items current position rather than from start.
+ this->setPosAt(0.0, currPos);
+ else
+ this->setPosAt(0.0, this->startPos);
+
+ if (this->fromStart){
+ this->timeline->setCurrentTime(0);
+ this->demoItem()->setPos(this->posAt(0));
+ }
+ }
+
+ if (this->inOrOut == ANIM_IN)
+ this->demoItem()->setRecursiveVisible(true);
+
+ if (this->startDelay){
+ QTimer::singleShot(this->startDelay, this, SLOT(playWithoutDelay()));
+ return;
+ }
+ else
+ this->playWithoutDelay();
+}
+
+void DemoItemAnimation::playWithoutDelay()
+{
+ if (this->moveOnPlay && !(Colors::noAnimations && !this->forcePlay))
+ this->timeline->start();
+ this->demoItem()->animationStarted(this->inOrOut);
+}
+
+void DemoItemAnimation::stop(bool reset)
+{
+ this->timeline->stop();
+ if (reset)
+ this->demoItem()->setPos(this->posAt(0));
+ if (this->hideOnFinished && !this->moveOnPlay)
+ this->demoItem()->setRecursiveVisible(false);
+ this->demoItem()->animationStopped(this->inOrOut);
+}
+
+void DemoItemAnimation::setRepeat(int nr)
+{
+ this->timeline->setLoopCount(nr);
+}
+
+void DemoItemAnimation::playReverse()
+{
+}
+
+bool DemoItemAnimation::running()
+{
+ return (this->timeLine()->state() == QTimeLine::Running);
+}
+
+bool DemoItemAnimation::runningOrItemLocked()
+{
+ return (this->running() || this->demoItem()->locked);
+}
+
+void DemoItemAnimation::lockItem(bool state)
+{
+ this->demoItem()->locked = state;
+}
+
+DemoItem *DemoItemAnimation::demoItem()
+{
+ return (DemoItem *) this->item();
+}
+
+void DemoItemAnimation::setOpacityAt0(qreal opacity)
+{
+ this->opacityAt0 = opacity;
+}
+
+void DemoItemAnimation::setOpacityAt1(qreal opacity)
+{
+ this->opacityAt1 = opacity;
+}
+
+void DemoItemAnimation::setOpacity(qreal step)
+{
+ DemoItem *demoItem = (DemoItem *) item();
+ demoItem->opacity = this->opacityAt0 + step * step * step * (this->opacityAt1 - this->opacityAt0);
+}
+
+void DemoItemAnimation::afterAnimationStep(qreal step)
+{
+ if (step == 1.0f){
+ if (this->timeline->loopCount() > 0){
+ // animation finished.
+ if (this->hideOnFinished)
+ this->demoItem()->setRecursiveVisible(false);
+ this->demoItem()->animationStopped(this->inOrOut);
+ }
+ } else if (Colors::noAnimations && !this->forcePlay){
+ // The animation is not at end, but
+ // the animations should not play, so go to end.
+ this->setStep(1.0f); // will make this method being called recursive.
+ }
+}
+
+
+
+
+
diff --git a/demos/qtdemo/demoitemanimation.h b/demos/qtdemo/demoitemanimation.h
new file mode 100644
index 0000000000..ad89ada84a
--- /dev/null
+++ b/demos/qtdemo/demoitemanimation.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEMO_ITEM_ANIMATION_H
+#define DEMO_ITEM_ANIMATION_H
+
+#include <QtCore>
+#include <QtGui>
+
+class DemoItem;
+
+class DemoItemAnimation : public QGraphicsItemAnimation
+{
+ Q_OBJECT
+
+public:
+ enum INOROUT {ANIM_IN, ANIM_OUT, ANIM_UNSPECIFIED};
+
+ DemoItemAnimation(DemoItem *item, INOROUT inOrOut = ANIM_UNSPECIFIED);
+ virtual ~DemoItemAnimation();
+
+ virtual void play(bool fromStart = true, bool force = false);
+ virtual void playReverse();
+ virtual void stop(bool reset = true);
+ virtual void setRepeat(int nr = 0);
+
+ void setDuration(int duration);
+ void setDuration(float duration){ setDuration(int(duration)); };
+ void setOpacityAt0(qreal opacity);
+ void setOpacityAt1(qreal opacity);
+ void setOpacity(qreal step);
+ void setCurrentTime(int ms);
+ void setStartPos(const QPointF &pos);
+ bool notOwnerOfItem();
+
+ bool running();
+ bool runningOrItemLocked();
+ void lockItem(bool state);
+ void prepare();
+
+ DemoItem *demoItem();
+
+ virtual void afterAnimationStep(qreal step); // overridden
+
+ QTimeLine *timeline;
+ qreal opacityAt0;
+ qreal opacityAt1;
+ int startDelay;
+ QPointF startPos;
+ bool hideOnFinished;
+ bool moveOnPlay;
+ bool forcePlay;
+ bool fromStart;
+ INOROUT inOrOut;
+
+private slots:
+ virtual void playWithoutDelay();
+};
+
+#endif // DEMO_ITEM_ANIMATION_H
+
+
+
diff --git a/demos/qtdemo/demoscene.cpp b/demos/qtdemo/demoscene.cpp
new file mode 100644
index 0000000000..29b73d37fe
--- /dev/null
+++ b/demos/qtdemo/demoscene.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "demoscene.h"
+
+void DemoScene::drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget)
+{
+ for (int i=0; i<numItems; ++i) {
+ painter->save();
+ painter->setMatrix(items[i]->sceneMatrix(), true);
+ items[i]->paint(painter, &options[i], widget);
+ painter->restore();
+ }
+}
+
+
diff --git a/demos/qtdemo/demoscene.h b/demos/qtdemo/demoscene.h
new file mode 100644
index 0000000000..e4838c73e3
--- /dev/null
+++ b/demos/qtdemo/demoscene.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAIN_VIEW_H
+#define MAIN_VIEW_H
+
+#include <QtGui>
+
+class DemoScene : public QGraphicsScene
+{
+public:
+ DemoScene(QObject *parent) : QGraphicsScene(parent){};
+
+protected:
+ void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget);
+};
+
+#endif // MAIN_VIEW_H
+
diff --git a/demos/qtdemo/demotextitem.cpp b/demos/qtdemo/demotextitem.cpp
new file mode 100644
index 0000000000..cd549fcc5f
--- /dev/null
+++ b/demos/qtdemo/demotextitem.cpp
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "demotextitem.h"
+#include "colors.h"
+
+DemoTextItem::DemoTextItem(const QString &text, const QFont &font, const QColor &textColor,
+ float textWidth, QGraphicsScene *scene, QGraphicsItem *parent, TYPE type, const QColor &bgColor)
+ : DemoItem(scene, parent)
+{
+ this->type = type;
+ this->text = text;
+ this->font = font;
+ this->textColor = textColor;
+ this->bgColor = bgColor;
+ this->textWidth = textWidth;
+ this->noSubPixeling = true;
+}
+
+void DemoTextItem::setText(const QString &text)
+{
+ this->text = text;
+ this->update();
+}
+
+QImage *DemoTextItem::createImage(const QMatrix &matrix) const
+{
+ if (this->type == DYNAMIC_TEXT)
+ return 0;
+
+ float sx = qMin(matrix.m11(), matrix.m22());
+ float sy = matrix.m22() < sx ? sx : matrix.m22();
+
+ QGraphicsTextItem textItem(0, 0);
+ textItem.setHtml(this->text);
+ textItem.setTextWidth(this->textWidth);
+ textItem.setFont(this->font);
+ textItem.setDefaultTextColor(this->textColor);
+ textItem.document()->setDocumentMargin(2);
+
+ float w = textItem.boundingRect().width();
+ float h = textItem.boundingRect().height();
+ QImage *image = new QImage(int(w * sx), int(h * sy), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.scale(sx, sy);
+ QStyleOptionGraphicsItem style;
+ textItem.paint(&painter, &style, 0);
+ return image;
+}
+
+
+void DemoTextItem::animationStarted(int)
+{
+ this->noSubPixeling = false;
+}
+
+
+void DemoTextItem::animationStopped(int)
+{
+ this->noSubPixeling = true;
+}
+
+QRectF DemoTextItem::boundingRect() const
+
+{
+ if (this->type == STATIC_TEXT)
+ return DemoItem::boundingRect();
+ return QRectF(0, 0, 50, 20); // Sorry for using magic number
+}
+
+
+void DemoTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ if (this->type == STATIC_TEXT) {
+ DemoItem::paint(painter, option, widget);
+ return;
+ }
+
+ painter->setPen(this->textColor);
+ painter->drawText(0, 0, this->text);
+}
diff --git a/demos/qtdemo/demotextitem.h b/demos/qtdemo/demotextitem.h
new file mode 100644
index 0000000000..679e3fb5a5
--- /dev/null
+++ b/demos/qtdemo/demotextitem.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEMO_TEXT_ITEM_H
+#define DEMO_TEXT_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class DemoTextItem : public DemoItem
+{
+public:
+ enum TYPE {STATIC_TEXT, DYNAMIC_TEXT};
+
+ DemoTextItem(const QString &text, const QFont &font, const QColor &textColor,
+ float textWidth, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0, TYPE type = STATIC_TEXT, const QColor &bgColor = QColor());
+ void setText(const QString &text);
+ QRectF boundingRect() const; // overridden
+ void animationStarted(int id = 0);
+ void animationStopped(int id = 0);
+
+protected:
+ virtual QImage *createImage(const QMatrix &matrix) const; // overridden
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option = 0, QWidget *widget = 0); // overridden
+
+private:
+ float textWidth;
+ QString text;
+ QFont font;
+ QColor textColor;
+ QColor bgColor;
+ TYPE type;
+};
+
+#endif // DEMO_TEXT_ITEM_H
+
diff --git a/demos/qtdemo/dockitem.cpp b/demos/qtdemo/dockitem.cpp
new file mode 100644
index 0000000000..7f26f0420c
--- /dev/null
+++ b/demos/qtdemo/dockitem.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "dockitem.h"
+#include "colors.h"
+
+DockItem::DockItem(ORIENTATION orien, qreal x, qreal y, qreal width, qreal length, QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ this->orientation = orien;
+ this->width = width;
+ this->length = length;
+ this->setPos(x, y);
+ this->setZValue(40);
+ this->setupPixmap();
+}
+
+void DockItem::setupPixmap()
+{
+ this->pixmap = new QPixmap(int(this->boundingRect().width()), int(this->boundingRect().height()));
+ this->pixmap->fill(QColor(0, 0, 0, 0));
+ QPainter painter(this->pixmap);
+ // create brush:
+ QColor background = Colors::sceneBg1;
+ QLinearGradient brush(0, 0, 0, this->boundingRect().height());
+ brush.setSpread(QGradient::PadSpread);
+
+ if (this->orientation == DOWN){
+ brush.setColorAt(0.0, background);
+ brush.setColorAt(0.2, background);
+ background.setAlpha(0);
+ brush.setColorAt(1.0, background);
+ }
+ else
+ if (this->orientation == UP){
+ brush.setColorAt(1.0, background);
+ brush.setColorAt(0.8, background);
+ background.setAlpha(0);
+ brush.setColorAt(0.0, background);
+ }
+ else
+ qWarning("DockItem doesn't support the orientation given!");
+
+ painter.fillRect(0, 0, int(this->boundingRect().width()), int(this->boundingRect().height()), brush);
+
+}
+
+DockItem::~DockItem()
+{
+ delete this->pixmap;
+}
+
+QRectF DockItem::boundingRect() const
+{
+ if (this->orientation == UP || this->orientation == DOWN)
+ return QRectF(0, 0, this->length, this->width);
+ else
+ return QRectF(0, 0, this->width, this->length);
+}
+
+void DockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ painter->drawPixmap(0, 0, *this->pixmap);
+}
+
+
+
diff --git a/demos/qtdemo/dockitem.h b/demos/qtdemo/dockitem.h
new file mode 100644
index 0000000000..13473a3f7e
--- /dev/null
+++ b/demos/qtdemo/dockitem.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOCK_ITEM_H
+#define DOCK_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class DockItem : public DemoItem
+{
+public:
+ enum ORIENTATION {UP, DOWN, LEFT, RIGHT};
+
+ DockItem(ORIENTATION orien, qreal x, qreal y, qreal width, qreal length, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ virtual ~DockItem();
+
+ virtual QRectF boundingRect() const; // overridden
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); // overridden
+
+ qreal length;
+ qreal width;
+ ORIENTATION orientation;
+
+private:
+ void setupPixmap();
+ QPixmap *pixmap;
+};
+
+#endif // DOCK_ITEM_H
+
diff --git a/demos/qtdemo/examplecontent.cpp b/demos/qtdemo/examplecontent.cpp
new file mode 100644
index 0000000000..a568b8cbaa
--- /dev/null
+++ b/demos/qtdemo/examplecontent.cpp
@@ -0,0 +1,158 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "examplecontent.h"
+#include "colors.h"
+#include "menumanager.h"
+#include "imageitem.h"
+#include "headingitem.h"
+
+ExampleContent::ExampleContent(const QString &name, QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ this->name = name;
+ this->heading = 0;
+ this->description = 0;
+ this->screenshot = 0;
+}
+
+void ExampleContent::prepare()
+{
+ if (!this->prepared){
+ this->prepared = true;
+ this->createContent();
+ }
+}
+
+void ExampleContent::animationStopped(int id)
+{
+ if (id == DemoItemAnimation::ANIM_OUT){
+ // Free up some memory:
+ delete this->heading;
+ delete this->description;
+ delete this->screenshot;
+ this->heading = 0;
+ this->description = 0;
+ this->screenshot = 0;
+ this->prepared = false;
+ }
+}
+
+QString ExampleContent::loadDescription()
+{
+ QByteArray ba = MenuManager::instance()->getHtml(this->name);
+
+ QDomDocument exampleDoc;
+ exampleDoc.setContent(ba, false);
+
+ QDomNodeList paragraphs = exampleDoc.elementsByTagName("p");
+ if (paragraphs.length() < 1 && Colors::verbose)
+ qDebug() << "- ExampleContent::loadDescription(): Could not load description:" << MenuManager::instance()->info[this->name]["docfile"];
+ QString description = Colors::contentColor + QLatin1String("Could not load description. Ensure that the documentation for Qt is built.");
+ for (int p = 0; p < int(paragraphs.length()); ++p) {
+ description = this->extractTextFromParagraph(paragraphs.item(p));
+ if (this->isSummary(description)) {
+ break;
+ }
+ }
+ return Colors::contentColor + description;
+}
+
+bool ExampleContent::isSummary(const QString &text)
+{
+ return (!text.contains("[") &&
+ text.indexOf(QRegExp(QString("(In )?((The|This) )?(%1 )?.*(tutorial|example|demo|application)").arg(this->name), Qt::CaseInsensitive)) != -1);
+}
+
+QString ExampleContent::extractTextFromParagraph(const QDomNode &parentNode)
+{
+ QString description;
+ QDomNode node = parentNode.firstChild();
+
+ while (!node.isNull()) {
+ QString beginTag;
+ QString endTag;
+ if (node.isText())
+ description += Colors::contentColor + node.nodeValue();
+ else if (node.hasChildNodes()) {
+ if (node.nodeName() == "b") {
+ beginTag = "<b>";
+ endTag = "</b>";
+ } else if (node.nodeName() == "a") {
+ beginTag = Colors::contentColor;
+ endTag = "</font>";
+ } else if (node.nodeName() == "i") {
+ beginTag = "<i>";
+ endTag = "</i>";
+ } else if (node.nodeName() == "tt") {
+ beginTag = "<tt>";
+ endTag = "</tt>";
+ }
+ description += beginTag + this->extractTextFromParagraph(node) + endTag;
+ }
+ node = node.nextSibling();
+ }
+
+ return description;
+}
+
+void ExampleContent::createContent()
+{
+ // Create the items:
+ this->heading = new HeadingItem(this->name, this->scene(), this);
+ this->description = new DemoTextItem(this->loadDescription(), Colors::contentFont(),
+ Colors::heading, 500, this->scene(), this);
+ int imgHeight = 340 - int(this->description->boundingRect().height()) + 50;
+ this->screenshot = new ImageItem(QImage::fromData(MenuManager::instance()->getImage(this->name)),
+ 550, imgHeight, this->scene(), this);
+
+ // Place the items on screen:
+ this->heading->setPos(0, 3);
+ this->description->setPos(0, this->heading->pos().y() + this->heading->boundingRect().height() + 10);
+ this->screenshot->setPos(0, this->description->pos().y() + this->description->boundingRect().height() + 10);
+}
+
+QRectF ExampleContent::boundingRect() const
+{
+ return QRectF(0, 0, 500, 100);
+}
+
+
diff --git a/demos/qtdemo/examplecontent.h b/demos/qtdemo/examplecontent.h
new file mode 100644
index 0000000000..850d64b78c
--- /dev/null
+++ b/demos/qtdemo/examplecontent.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTENT_ITEM_H
+#define CONTENT_ITEM_H
+
+#include <QtGui>
+#include <QtXml>
+#include "demoitem.h"
+
+class HeadingItem;
+class DemoTextItem;
+class ImageItem;
+
+class ExampleContent : public DemoItem
+{
+
+public:
+ ExampleContent(const QString &name, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+
+ virtual QRectF boundingRect() const;
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0){};
+ void animationStopped(int id);
+ void prepare();
+
+private:
+ QString name;
+ HeadingItem *heading;
+ DemoTextItem *description;
+ ImageItem *screenshot;
+
+ QString loadDescription();
+ QString extractTextFromParagraph(const QDomNode &parentNode);
+ bool isSummary(const QString &text);
+ void createContent();
+};
+
+#endif // CONTENT_ITEM_H
+
diff --git a/demos/qtdemo/guide.cpp b/demos/qtdemo/guide.cpp
new file mode 100644
index 0000000000..1f3c355768
--- /dev/null
+++ b/demos/qtdemo/guide.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <cmath>
+#include "guide.h"
+#include "colors.h"
+
+Guide::Guide(Guide *follows)
+{
+ this->scaleX = 1.0;
+ this->scaleY = 1.0;
+
+ if (follows){
+ while (follows->nextGuide != follows->firstGuide) // append to end
+ follows = follows->nextGuide;
+
+ follows->nextGuide = this;
+ this->prevGuide = follows;
+ this->firstGuide = follows->firstGuide;
+ this->nextGuide = follows->firstGuide;
+ this->startLength = int(follows->startLength + follows->length()) + 1;
+ }
+ else{
+ this->prevGuide = this;
+ this->firstGuide = this;
+ this->nextGuide = this;
+ this->startLength = 0;
+ }
+}
+
+void Guide::setScale(float scaleX, float scaleY, bool all)
+{
+ this->scaleX = scaleX;
+ this->scaleY = scaleY;
+
+ if (all){
+ Guide *next = this->nextGuide;
+ while(next != this){
+ next->scaleX = scaleX;
+ next->scaleY = scaleY;
+ next = next->nextGuide;
+ }
+ }
+}
+
+void Guide::setFence(const QRectF &fence, bool all)
+{
+ this->fence = fence;
+
+ if (all){
+ Guide *next = this->nextGuide;
+ while(next != this){
+ next->fence = fence;
+ next = next->nextGuide;
+ }
+ }
+}
+
+Guide::~Guide()
+{
+ if (this != this->nextGuide && this->nextGuide != this->firstGuide)
+ delete this->nextGuide;
+}
+
+float Guide::lengthAll()
+{
+ float len = length();
+ Guide *next = this->nextGuide;
+ while(next != this){
+ len += next->length();
+ next = next->nextGuide;
+ }
+ return len;
+}
+
+void Guide::move(DemoItem *item, QPointF &dest, float moveSpeed)
+{
+ QLineF walkLine(item->getGuidedPos(), dest);
+ if (moveSpeed >= 0 && walkLine.length() > moveSpeed){
+ // The item is too far away from it's destination point.
+ // So we choose to move it towards it instead.
+ float dx = walkLine.dx();
+ float dy = walkLine.dy();
+
+ if (qAbs(dx) > qAbs(dy)){
+ // walk along x-axis
+ if (dx != 0){
+ float d = moveSpeed * dy / qAbs(dx);
+ float s = dx > 0 ? moveSpeed : -moveSpeed;
+ dest.setX(item->getGuidedPos().x() + s);
+ dest.setY(item->getGuidedPos().y() + d);
+ }
+ }
+ else{
+ // walk along y-axis
+ if (dy != 0){
+ float d = moveSpeed * dx / qAbs(dy);
+ float s = dy > 0 ? moveSpeed : -moveSpeed;
+ dest.setX(item->getGuidedPos().x() + d);
+ dest.setY(item->getGuidedPos().y() + s);
+ }
+ }
+ }
+
+ item->setGuidedPos(dest);
+}
diff --git a/demos/qtdemo/guide.h b/demos/qtdemo/guide.h
new file mode 100644
index 0000000000..51ce6c353e
--- /dev/null
+++ b/demos/qtdemo/guide.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GUIDE_H
+#define GUIDE_H
+
+#include "demoitem.h"
+
+class Guide
+{
+public:
+ Guide(Guide *follows = 0);
+ virtual ~Guide();
+
+ virtual void guide(DemoItem *item, float moveSpeed) = 0;
+ void move(DemoItem *item, QPointF &dest, float moveSpeed);
+ virtual QPointF startPos(){ return QPointF(0, 0); };
+ virtual QPointF endPos(){ return QPointF(0, 0); };
+ virtual float length(){ return 1; };
+ float lengthAll();
+
+ void setScale(float scaleX, float scaleY, bool all = true);
+ void setFence(const QRectF &fence, bool all = true);
+
+ int startLength;
+ Guide *nextGuide;
+ Guide *firstGuide;
+ Guide *prevGuide;
+ float scaleX;
+ float scaleY;
+ QRectF fence;
+};
+
+#endif // GUIDE_H
+
diff --git a/demos/qtdemo/guidecircle.cpp b/demos/qtdemo/guidecircle.cpp
new file mode 100644
index 0000000000..98328dccb7
--- /dev/null
+++ b/demos/qtdemo/guidecircle.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "guidecircle.h"
+
+static float PI2 = 2*3.1415f;
+
+GuideCircle::GuideCircle(const QRectF &rect, float startAngle, float span, DIRECTION dir, Guide *follows) : Guide(follows)
+{
+ this->radiusX = rect.width() / 2.0;
+ this->radiusY = rect.height() / 2.0;
+ this->posX = rect.topLeft().x();
+ this->posY = rect.topLeft().y();
+ this->spanRad = span * PI2 / -360.0;
+ if (dir == CCW){
+ this->startAngleRad = startAngle * PI2 / -360.0;
+ this->endAngleRad = startAngleRad + spanRad;
+ this->stepAngleRad = this->spanRad / this->length();
+ }
+ else{
+ this->startAngleRad = spanRad + (startAngle * PI2 / -360.0);
+ this->endAngleRad = startAngle * PI2 / -360.0;
+ this->stepAngleRad = -this->spanRad / this->length();
+ }
+}
+
+float GuideCircle::length()
+{
+ return qAbs(this->radiusX * spanRad);
+}
+
+QPointF GuideCircle::startPos()
+{
+ return QPointF((posX + radiusX + radiusX * cos(startAngleRad)) * scaleX,
+ (posY + radiusY + radiusY * sin(startAngleRad)) * scaleY);
+}
+
+QPointF GuideCircle::endPos()
+{
+ return QPointF((posX + radiusX + radiusX * cos(endAngleRad)) * scaleX,
+ (posY + radiusY + radiusY * sin(endAngleRad)) * scaleY);
+}
+
+void GuideCircle::guide(DemoItem *item, float moveSpeed)
+{
+ float frame = item->guideFrame - this->startLength;
+ QPointF end((posX + radiusX + radiusX * cos(startAngleRad + (frame * stepAngleRad))) * scaleX,
+ (posY + radiusY + radiusY * sin(startAngleRad + (frame * stepAngleRad))) * scaleY);
+ this->move(item, end, moveSpeed);
+}
diff --git a/demos/qtdemo/guidecircle.h b/demos/qtdemo/guidecircle.h
new file mode 100644
index 0000000000..2179527224
--- /dev/null
+++ b/demos/qtdemo/guidecircle.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GUIDECIRCLE_H
+#define GUIDECIRCLE_H
+
+#include "guide.h"
+#include "demoitem.h"
+
+class GuideCircle : public Guide
+{
+public:
+ enum DIRECTION {CW = 1, CCW = -1};
+
+ GuideCircle(const QRectF &rect, float startAngle = 0, float span = 360, DIRECTION dir = CCW, Guide *follows = 0);
+
+ void guide(DemoItem *item, float moveSpeed); // overridden
+ QPointF startPos();
+ QPointF endPos();
+ float length();
+
+private:
+ float posX;
+ float posY;
+ float radiusX;
+ float radiusY;
+ float startAngleRad;
+ float endAngleRad;
+ float spanRad;
+ float stepAngleRad;
+};
+
+#endif // GUIDECIRCLE_H
+
diff --git a/demos/qtdemo/guideline.cpp b/demos/qtdemo/guideline.cpp
new file mode 100644
index 0000000000..ac013390e6
--- /dev/null
+++ b/demos/qtdemo/guideline.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "guideline.h"
+#include <cmath>
+
+GuideLine::GuideLine(const QLineF &line, Guide *follows) : Guide(follows)
+{
+ this->line = line;
+}
+
+GuideLine::GuideLine(const QPointF &end, Guide *follows) : Guide(follows)
+{
+ if (follows)
+ this->line = QLineF(prevGuide->endPos(), end);
+ else
+ this->line = QLineF(QPointF(0, 0), end);
+}
+
+float GuideLine::length()
+{
+ return line.length();
+}
+
+QPointF GuideLine::startPos()
+{
+ return QPointF(this->line.p1().x() * scaleX, this->line.p1().y() * scaleY);
+}
+
+QPointF GuideLine::endPos()
+{
+ return QPointF(this->line.p2().x() * scaleX, this->line.p2().y() * scaleY);
+}
+
+void GuideLine::guide(DemoItem *item, float moveSpeed)
+{
+ float frame = item->guideFrame - this->startLength;
+ float endX = (this->line.p1().x() + (frame * this->line.dx() / this->length())) * scaleX;
+ float endY = (this->line.p1().y() + (frame * this->line.dy() / this->length())) * scaleY;
+ QPointF pos(endX, endY);
+ this->move(item, pos, moveSpeed);
+}
+
diff --git a/demos/qtdemo/guideline.h b/demos/qtdemo/guideline.h
new file mode 100644
index 0000000000..93daaa8c75
--- /dev/null
+++ b/demos/qtdemo/guideline.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GUIDELINE_H
+#define GUIDELINE_H
+
+#include "guide.h"
+#include "demoitem.h"
+
+class GuideLine : public Guide
+{
+public:
+ GuideLine(const QLineF &line, Guide *follows = 0);
+ GuideLine(const QPointF &end, Guide *follows = 0);
+
+ void guide(DemoItem *item, float moveSpeed); // overridden
+ QPointF startPos();
+ QPointF endPos();
+ float length();
+
+private:
+ QLineF line;
+
+};
+
+#endif // GUIDELINE_H
+
diff --git a/demos/qtdemo/headingitem.cpp b/demos/qtdemo/headingitem.cpp
new file mode 100644
index 0000000000..80a255a16f
--- /dev/null
+++ b/demos/qtdemo/headingitem.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "headingitem.h"
+#include "colors.h"
+
+HeadingItem::HeadingItem(const QString &text, QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ this->text = text;
+ this->noSubPixeling = true;
+}
+
+QImage *HeadingItem::createImage(const QMatrix &matrix) const
+{
+ float sx = qMin(matrix.m11(), matrix.m22());
+ float sy = matrix.m22() < sx ? sx : matrix.m22();
+ QFontMetrics fm(Colors::headingFont());
+
+ float w = fm.width(this->text) + 1;
+ float h = fm.height();
+ float xShadow = 3.0f;
+ float yShadow = 3.0f;
+
+ QImage *image = new QImage(int((w + xShadow) * sx), int((h + yShadow) * sy), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.setFont(Colors::headingFont());
+ painter.scale(sx, sy);
+
+ //draw shadow
+ QLinearGradient brush_shadow(xShadow, yShadow, w, yShadow);
+ brush_shadow.setSpread(QLinearGradient::PadSpread);
+ if (Colors::useEightBitPalette)
+ brush_shadow.setColorAt(0.0f, QColor(0, 0, 0));
+ else
+ brush_shadow.setColorAt(0.0f, QColor(0, 0, 0, 100));
+ QPen pen_shadow;
+ pen_shadow.setBrush(brush_shadow);
+ painter.setPen(pen_shadow);
+ painter.drawText(int(xShadow), int(yShadow), int(w), int(h), Qt::AlignLeft, this->text);
+
+ // draw text
+ QLinearGradient brush_text(0, 0, w, w);
+ brush_text.setSpread(QLinearGradient::PadSpread);
+ brush_text.setColorAt(0.0f, QColor(255, 255, 255));
+ brush_text.setColorAt(0.2f, QColor(255, 255, 255));
+ brush_text.setColorAt(0.5f, QColor(190, 190, 190));
+ QPen pen_text;
+ pen_text.setBrush(brush_text);
+ painter.setPen(pen_text);
+ painter.drawText(0, 0, int(w), int(h), Qt::AlignLeft, this->text);
+ return image;
+}
+
+
+void HeadingItem::animationStarted(int)
+{
+ this->noSubPixeling = false;
+}
+
+
+void HeadingItem::animationStopped(int)
+{
+ this->noSubPixeling = true;
+}
diff --git a/demos/qtdemo/headingitem.h b/demos/qtdemo/headingitem.h
new file mode 100644
index 0000000000..a5cb997258
--- /dev/null
+++ b/demos/qtdemo/headingitem.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HEADING_ITEM_H
+#define HEADING_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class HeadingItem : public DemoItem
+{
+public:
+ HeadingItem(const QString &text, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ void animationStarted(int id = 0);
+ void animationStopped(int id = 0);
+
+protected:
+ virtual QImage *createImage(const QMatrix &matrix) const; // overridden
+
+private:
+ QString text;
+};
+
+#endif // HEADING_ITEM_H
+
diff --git a/demos/qtdemo/imageitem.cpp b/demos/qtdemo/imageitem.cpp
new file mode 100644
index 0000000000..e556011610
--- /dev/null
+++ b/demos/qtdemo/imageitem.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "imageitem.h"
+#include "colors.h"
+
+ImageItem::ImageItem(const QImage &image, int maxWidth, int maxHeight, QGraphicsScene *scene,
+ QGraphicsItem *parent, bool adjustSize, float scale) : DemoItem(scene, parent)
+{
+ this->image = image;
+ this->maxWidth = maxWidth;
+ this->maxHeight = maxHeight;
+ this->adjustSize = adjustSize;
+ this->scale = scale;
+}
+
+QImage *ImageItem::createImage(const QMatrix &matrix) const
+{
+ QImage *original = new QImage(image);
+ if (original->isNull()){
+ return original; // nothing we can do about it...
+ }
+
+ QPoint size = matrix.map(QPoint(this->maxWidth, this->maxHeight));
+ float w = size.x(); // x, y is the used as width, height
+ float h = size.y();
+
+ // Optimization: if image is smaller than maximum allowed size, just return the loaded image
+ if (original->size().height() <= h && original->size().width() <= w && !this->adjustSize && this->scale == 1)
+ return original;
+
+ // Calculate what the size of the final image will be:
+ w = qMin(w, float(original->size().width()) * this->scale);
+ h = qMin(h, float(original->size().height()) * this->scale);
+
+ float adjustx = 1.0f;
+ float adjusty = 1.0f;
+ if (this->adjustSize){
+ adjustx = qMin(matrix.m11(), matrix.m22());
+ adjusty = matrix.m22() < adjustx ? adjustx : matrix.m22();
+ w *= adjustx;
+ h *= adjusty;
+ }
+
+ // Create a new image with correct size, and draw original on it
+ QImage *image = new QImage(int(w+2), int(h+2), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+ if (this->adjustSize)
+ painter.scale(adjustx, adjusty);
+ if (this->scale != 1)
+ painter.scale(this->scale, this->scale);
+ painter.drawImage(0, 0, *original);
+
+ if (!this->adjustSize){
+ // Blur out edges
+ int blur = 30;
+ if (h < original->height()){
+ QLinearGradient brush1(0, h - blur, 0, h);
+ brush1.setSpread(QGradient::PadSpread);
+ brush1.setColorAt(0.0, QColor(0, 0, 0, 0));
+ brush1.setColorAt(1.0, Colors::sceneBg1);
+ painter.fillRect(0, int(h) - blur, original->width(), int(h), brush1);
+ }
+ if (w < original->width()){
+ QLinearGradient brush2(w - blur, 0, w, 0);
+ brush2.setSpread(QGradient::PadSpread);
+ brush2.setColorAt(0.0, QColor(0, 0, 0, 0));
+ brush2.setColorAt(1.0, Colors::sceneBg1);
+ painter.fillRect(int(w) - blur, 0, int(w), original->height(), brush2);
+ }
+ }
+ delete original;
+ return image;
+}
diff --git a/demos/qtdemo/imageitem.h b/demos/qtdemo/imageitem.h
new file mode 100644
index 0000000000..e73079a017
--- /dev/null
+++ b/demos/qtdemo/imageitem.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IMAGE_ITEM_H
+#define IMAGE_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class ImageItem : public DemoItem
+{
+public:
+ ImageItem(const QImage &image, int maxWidth, int maxHeight, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0,
+ bool adjustSize = false, float scale = 1.0f);
+
+ bool adjustSize;
+ float scale;
+protected:
+ QImage *createImage(const QMatrix &matrix) const;
+
+private:
+ QImage image;
+ int maxWidth;
+ int maxHeight;
+};
+
+#endif // DOCK_ITEM_H
+
diff --git a/demos/qtdemo/images/demobg.png b/demos/qtdemo/images/demobg.png
new file mode 100755
index 0000000000..3280afaa3e
--- /dev/null
+++ b/demos/qtdemo/images/demobg.png
Binary files differ
diff --git a/demos/qtdemo/images/qtlogo_small.png b/demos/qtdemo/images/qtlogo_small.png
new file mode 100644
index 0000000000..21b17dfa04
--- /dev/null
+++ b/demos/qtdemo/images/qtlogo_small.png
Binary files differ
diff --git a/demos/qtdemo/images/trolltech-logo.png b/demos/qtdemo/images/trolltech-logo.png
new file mode 100644
index 0000000000..186c69c767
--- /dev/null
+++ b/demos/qtdemo/images/trolltech-logo.png
Binary files differ
diff --git a/demos/qtdemo/itemcircleanimation.cpp b/demos/qtdemo/itemcircleanimation.cpp
new file mode 100644
index 0000000000..fff52bbd03
--- /dev/null
+++ b/demos/qtdemo/itemcircleanimation.cpp
@@ -0,0 +1,507 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "itemcircleanimation.h"
+#include "demoitemanimation.h"
+#include "colors.h"
+#include "menumanager.h"
+#include "mainwindow.h"
+#include "menumanager.h"
+
+static QGraphicsScene *sscene;
+
+//////////////////// POST EFFECT STUFF ////////////////////////////////////////
+
+class TickerPostEffect
+{
+public:
+ virtual ~TickerPostEffect(){};
+ virtual void tick(float){};
+ virtual void transform(DemoItem *, QPointF &){};
+};
+
+class PostRotateXY : public TickerPostEffect
+{
+public:
+ float currRotX, currRotY;
+ float speedx, speedy, curvx, curvy;
+
+ PostRotateXY(float speedx, float speedy, float curvx, float curvy)
+ : currRotX(0), currRotY(0),
+ speedx(speedx), speedy(speedy),
+ curvx(curvx), curvy(curvy){};
+
+ void tick(float adjust)
+ {
+ currRotX += speedx * adjust;
+ currRotY += speedy * adjust;
+ }
+
+ void transform(DemoItem *item, QPointF &pos)
+ {
+ DemoItem *parent = (DemoItem *) item->parentItem();
+ QPointF center = parent->boundingRect().center();
+ pos.setX(center.x() + (pos.x() - center.x()) * cos(currRotX + pos.x() * curvx));
+ pos.setY(center.y() + (pos.y() - center.y()) * cos(currRotY + pos.y() * curvy));
+ }
+};
+
+class PostRotateXYTwist : public TickerPostEffect
+{
+public:
+ float currRotX, currRotY;
+ float speedx, speedy, curvx, curvy;
+
+ PostRotateXYTwist(float speedx, float speedy, float curvx, float curvy)
+ : currRotX(0), currRotY(0),
+ speedx(speedx), speedy(speedy),
+ curvx(curvx), curvy(curvy){};
+
+ void tick(float adjust)
+ {
+ currRotX += speedx * adjust;
+ currRotY += speedy * adjust;
+ }
+
+ void transform(DemoItem *item, QPointF &pos)
+ {
+ DemoItem *parent = (DemoItem *) item->parentItem();
+ QPointF center = parent->boundingRect().center();
+ pos.setX(center.x() + (pos.x() - center.x()) * cos(currRotX + pos.y() * curvx));
+ pos.setY(center.y() + (pos.y() - center.y()) * cos(currRotY + pos.x() * curvy));
+ }
+};
+
+//////////////////// TICKER EFFECT STUFF //////////////////////////////////////
+
+class TickerEffect
+{
+ TickerPostEffect *postEffect;
+public:
+ enum EffectStatus{Normal, Intro, Outro} status;
+ LetterList *letters;
+ float morphSpeed, moveSpeed;
+ float normalMorphSpeed, normalMoveSpeed;
+ bool useSheepDog, morphBetweenModels;
+
+ TickerEffect(LetterList *letters)
+ : postEffect(new TickerPostEffect()), status(Intro), letters(letters),
+ morphSpeed(Colors::tickerMorphSpeed), moveSpeed(Colors::tickerMoveSpeed),
+ normalMorphSpeed(Colors::tickerMorphSpeed), normalMoveSpeed(Colors::tickerMoveSpeed),
+ useSheepDog(true), morphBetweenModels(!Colors::noTickerMorph){}
+
+ void setPostEffect(TickerPostEffect *effect)
+ {
+ delete postEffect;
+ postEffect = effect;
+ }
+
+ virtual ~TickerEffect()
+ {
+ delete postEffect;
+ }
+
+ void slowDownAfterIntro(float adjust)
+ {
+ if (morphBetweenModels){
+ if (status == Intro){
+ float dec = 0.1 * adjust;
+ moveSpeed -= dec;
+ if (moveSpeed < Colors::tickerMoveSpeed){
+ moveSpeed = normalMoveSpeed;
+ morphSpeed = normalMorphSpeed;
+ status = Normal;
+ }
+ }
+ }
+ }
+
+ void moveLetters(float adjust)
+ {
+ float adaptedMoveSpeed = this->moveSpeed * adjust;
+ float adaptedMorphSpeed = this->morphSpeed * adjust;
+ postEffect->tick(adjust);
+
+ for (int i=0; i<letters->size(); i++){
+ LetterItem *letter = letters->at(i);
+ letter->guideAdvance(this->morphBetweenModels ? adaptedMoveSpeed : Colors::tickerMoveSpeed);
+ letter->guideMove(this->morphBetweenModels ? adaptedMorphSpeed : -1);
+
+ QPointF pos = letter->getGuidedPos();
+ postEffect->transform(letter, pos);
+
+ if (useSheepDog)
+ letter->setPosUsingSheepDog(pos, QRectF(0, 0, 800, 600));
+ else
+ letter->setPos(pos);
+ }
+ }
+
+ virtual void tick(float adjust)
+ {
+ slowDownAfterIntro(adjust);
+ moveLetters(adjust);
+ }
+
+};
+
+class EffectWhirlWind : public TickerEffect
+{
+public:
+ EffectWhirlWind(LetterList *letters) : TickerEffect(letters)
+ {
+ moveSpeed = 50;
+ for (int i=0; i<this->letters->size(); i++){
+ LetterItem *letter = this->letters->at(i);
+ letter->setGuidedPos(QPointF(0, 100));
+ }
+ }
+};
+
+class EffectSnake : public TickerEffect
+{
+public:
+ EffectSnake(LetterList *letters) : TickerEffect(letters)
+ {
+ moveSpeed = 40;
+ for (int i=0; i<this->letters->size(); i++){
+ LetterItem *letter = this->letters->at(i);
+ letter->setGuidedPos(QPointF(0, -250 - (i * 5)));
+ }
+ }
+};
+
+class EffectScan : public TickerEffect
+{
+public:
+ EffectScan(LetterList *letters) : TickerEffect(letters)
+ {
+ for (int i=0; i<this->letters->size(); i++){
+ LetterItem *letter = this->letters->at(i);
+ letter->setGuidedPos(QPointF(100, -300));
+ }
+ }
+};
+
+class EffectRaindrops : public TickerEffect
+{
+public:
+ EffectRaindrops(LetterList *letters) : TickerEffect(letters)
+ {
+ for (int i=0; i<this->letters->size(); i++){
+ LetterItem *letter = this->letters->at(i);
+ letter->setGuidedPos(QPointF(-100 + rand() % 200, - 200.0f - rand() % 1300));
+ }
+ }
+};
+
+class EffectLine : public TickerEffect
+{
+public:
+ EffectLine(LetterList *letters) : TickerEffect(letters)
+ {
+ for (int i=0; i<this->letters->size(); i++){
+ LetterItem *letter = this->letters->at(i);
+ letter->setGuidedPos(QPointF(100, 500.0f + i * 20));
+ }
+ }
+};
+
+//////////////////// TICKER STUFF /////////////////////////////////////////////
+
+ItemCircleAnimation::ItemCircleAnimation(QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ sscene = scene;
+ this->letterCount = Colors::tickerLetterCount;
+ this->scale = 1;
+ this->showCount = -1;
+ this->tickOnPaint = false;
+ this->paused = false;
+ this->doIntroTransitions = true;
+ this->setAcceptsHoverEvents(true);
+ this->setCursor(Qt::OpenHandCursor);
+ this->setupGuides();
+ this->setupLetters();
+ this->useGuideQt();
+ this->effect = 0;//new TickerEffect(this->letterList);
+}
+
+ItemCircleAnimation::~ItemCircleAnimation()
+{
+ delete this->letterList;
+ delete this->qtGuide1;
+ delete this->qtGuide2;
+ delete this->qtGuide3;
+ delete this->effect;
+}
+
+void ItemCircleAnimation::createLetter(char c)
+{
+ LetterItem *letter = new LetterItem(c, sscene, this);
+ this->letterList->append(letter);
+}
+
+void ItemCircleAnimation::setupLetters()
+{
+ this->letterList = new LetterList();
+
+ QString s = Colors::tickerText;
+ int len = s.length();
+ int i = 0;
+ for (; i < this->letterCount - len; i += len)
+ for (int l=0; l<len; l++)
+ createLetter(s[l].toLatin1());
+
+ // Fill inn with blanks:
+ for (; i < this->letterCount; ++i)
+ createLetter(' ');
+}
+
+void ItemCircleAnimation::setupGuides()
+{
+ int x = 0;
+ int y = 20;
+
+ this->qtGuide1 = new GuideCircle(QRectF(x, y, 260, 260), -36, 342);
+ new GuideLine(QPointF(x + 240, y + 268), this->qtGuide1);
+ new GuideLine(QPointF(x + 265, y + 246), this->qtGuide1);
+ new GuideLine(QPointF(x + 158, y + 134), this->qtGuide1);
+ new GuideLine(QPointF(x + 184, y + 109), this->qtGuide1);
+ new GuideLine(QPointF(x + 160, y + 82), this->qtGuide1);
+ new GuideLine(QPointF(x + 77, y + 163), this->qtGuide1); // T-top
+ new GuideLine(QPointF(x + 100, y + 190), this->qtGuide1);
+ new GuideLine(QPointF(x + 132, y + 159), this->qtGuide1);
+ new GuideLine(QPointF(x + 188, y + 211), this->qtGuide1);
+ new GuideCircle(QRectF(x + 30, y + 30, 200, 200), -30, 336, GuideCircle::CW, this->qtGuide1);
+ new GuideLine(QPointF(x + 238, y + 201), this->qtGuide1);
+
+ y = 30;
+ this->qtGuide2 = new GuideCircle(QRectF(x + 30, y + 30, 200, 200), 135, 270, GuideCircle::CCW);
+ new GuideLine(QPointF(x + 222, y + 38), this->qtGuide2);
+ new GuideCircle(QRectF(x, y, 260, 260), 135, 270, GuideCircle::CW, this->qtGuide2);
+ new GuideLine(QPointF(x + 59, y + 59), this->qtGuide2);
+
+ x = 115;
+ y = 10;
+ this->qtGuide3 = new GuideLine(QLineF(x, y, x + 30, y));
+ new GuideLine(QPointF(x + 30, y + 170), this->qtGuide3);
+ new GuideLine(QPointF(x, y + 170), this->qtGuide3);
+ new GuideLine(QPointF(x, y), this->qtGuide3);
+
+ this->qtGuide1->setFence(QRectF(0, 0, 800, 600));
+ this->qtGuide2->setFence(QRectF(0, 0, 800, 600));
+ this->qtGuide3->setFence(QRectF(0, 0, 800, 600));
+}
+
+void ItemCircleAnimation::useGuide(Guide *guide, int firstLetter, int lastLetter)
+{
+ float padding = guide->lengthAll() / float(lastLetter - firstLetter);
+ for (int i=firstLetter; i<lastLetter; i++){
+ LetterItem *letter = this->letterList->at(i);
+ letter->useGuide(guide, (i - firstLetter) * padding);
+ }
+}
+
+void ItemCircleAnimation::useGuideQt()
+{
+ if (this->currGuide != this->qtGuide1){
+ this->useGuide(qtGuide1, 0, this->letterCount);
+ this->currGuide = qtGuide1;
+ }
+}
+
+void ItemCircleAnimation::useGuideTt()
+{
+ if (this->currGuide != this->qtGuide2){
+ int split = int(this->letterCount * 5.0 / 7.0);
+ this->useGuide(qtGuide2, 0, split);
+ this->useGuide(qtGuide3, split, this->letterCount);
+ this->currGuide = qtGuide2;
+ }
+}
+
+QRectF ItemCircleAnimation::boundingRect() const
+{
+ return QRectF(0, 0, 300, 320);
+}
+
+void ItemCircleAnimation::prepare()
+{
+}
+
+void ItemCircleAnimation::switchToNextEffect()
+{
+ ++this->showCount;
+ delete this->effect;
+
+ switch (this->showCount){
+ case 1:
+ this->effect = new EffectSnake(this->letterList);
+ break;
+ case 2:
+ this->effect = new EffectLine(this->letterList);
+ this->effect->setPostEffect(new PostRotateXYTwist(0.01f, 0.0f, 0.003f, 0.0f));
+ break;
+ case 3:
+ this->effect = new EffectRaindrops(this->letterList);
+ this->effect->setPostEffect(new PostRotateXYTwist(0.01f, 0.005f, 0.003f, 0.003f));
+ break;
+ case 4:
+ this->effect = new EffectScan(this->letterList);
+ this->effect->normalMoveSpeed = 0;
+ this->effect->setPostEffect(new PostRotateXY(0.008f, 0.0f, 0.005f, 0.0f));
+ break;
+ default:
+ this->showCount = 0;
+ this->effect = new EffectWhirlWind(this->letterList);
+ }
+}
+
+void ItemCircleAnimation::animationStarted(int id)
+{
+ if (id == DemoItemAnimation::ANIM_IN){
+ if (this->doIntroTransitions){
+ // Make all letters dissapear
+ for (int i=0; i<this->letterList->size(); i++){
+ LetterItem *letter = this->letterList->at(i);
+ letter->setPos(1000, 0);
+ }
+ this->switchToNextEffect();
+ this->useGuideQt();
+ this->scale = 1;
+ // The first time we run, we have a rather large
+ // delay to perform benchmark before the ticker shows.
+ // But now, since we are showing, use a more appropriate value:
+ this->currentAnimation->startDelay = 1500;
+ }
+ }
+ else if (this->effect)
+ this->effect->useSheepDog = false;
+
+ this->tickTimer = QTime::currentTime();
+}
+
+void ItemCircleAnimation::animationStopped(int)
+{
+ // Nothing to do.
+}
+
+void ItemCircleAnimation::swapModel(){
+ if (this->currGuide == this->qtGuide2)
+ this->useGuideQt();
+ else
+ this->useGuideTt();
+}
+
+void ItemCircleAnimation::hoverEnterEvent(QGraphicsSceneHoverEvent *)
+{
+// Skip swap here to enhance ticker dragging
+// this->swapModel();
+}
+
+void ItemCircleAnimation::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
+{
+ this->swapModel();
+}
+
+void ItemCircleAnimation::setTickerScale(float s)
+{
+ this->scale = s;
+ qtGuide1->setScale(this->scale, this->scale);
+ qtGuide2->setScale(this->scale, this->scale);
+ qtGuide3->setScale(this->scale, this->scale);
+}
+
+void ItemCircleAnimation::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ this->mouseMoveLastPosition = event->scenePos();
+ if (event->button() == Qt::LeftButton)
+ this->setCursor(Qt::ClosedHandCursor);
+ else
+ this->switchToNextEffect();
+}
+
+void ItemCircleAnimation::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ this->setCursor(Qt::OpenHandCursor);
+}
+
+void ItemCircleAnimation::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ QPointF newPosition = event->scenePos();
+ this->setPosUsingSheepDog(this->pos() + newPosition - this->mouseMoveLastPosition, QRectF(-260, -280, 1350, 1160));
+ this->mouseMoveLastPosition = newPosition;
+}
+
+void ItemCircleAnimation::wheelEvent(QGraphicsSceneWheelEvent *event)
+{
+ this->effect->moveSpeed = this->effect->moveSpeed + (event->delta() > 0 ? -0.20 : 0.20);
+ if (this->effect->moveSpeed < 0)
+ this->effect->moveSpeed = 0;
+}
+
+void ItemCircleAnimation::pause(bool on)
+{
+ this->paused = on;
+ this->tickTimer = QTime::currentTime();
+}
+
+void ItemCircleAnimation::tick()
+{
+ if (this->paused || !this->effect)
+ return;
+
+ float t = this->tickTimer.msecsTo(QTime::currentTime());
+ this->tickTimer = QTime::currentTime();
+ this->effect->tick(t/10.0f);
+}
+
+void ItemCircleAnimation::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ if (this->tickOnPaint)
+ tick();
+}
+
+
+
+
diff --git a/demos/qtdemo/itemcircleanimation.h b/demos/qtdemo/itemcircleanimation.h
new file mode 100644
index 0000000000..27e399cbd8
--- /dev/null
+++ b/demos/qtdemo/itemcircleanimation.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ITEM_CIRCLE_ANIMATION_H
+#define ITEM_CIRCLE_ANIMATION_H
+
+#include <QtCore>
+#include <QObject>
+#include <QtGui>
+#include <QTimeLine>
+#include <QList>
+#include "demoitem.h"
+#include "letteritem.h"
+#include "guideline.h"
+#include "guidecircle.h"
+
+typedef QList<LetterItem *> LetterList;
+class TickerEffect;
+
+class ItemCircleAnimation : public QObject, public DemoItem
+{
+public:
+ ItemCircleAnimation(QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ virtual ~ItemCircleAnimation();
+
+ // overidden methods:
+ QRectF boundingRect() const;
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void wheelEvent(QGraphicsSceneWheelEvent *event);
+ void animationStarted(int id = 0);
+ void animationStopped(int id = 0);
+ void prepare();
+ void tick();
+ void switchToNextEffect();
+ void useGuideQt();
+ void useGuideTt();
+ void pause(bool on);
+
+ bool tickOnPaint;
+ bool paused;
+ bool doIntroTransitions;
+
+private:
+ void setupLetters();
+ void createLetter(char c);
+ void setupGuides();
+ void useGuide(Guide *guide, int firstLetter, int lastLetter);
+ void swapModel();
+ void setTickerScale(float s);
+
+ int showCount;
+ float scale;
+ QPointF mouseMoveLastPosition;
+ int letterCount;
+ LetterList *letterList;
+ Guide *qtGuide1;
+ Guide *qtGuide2;
+ Guide *qtGuide3;
+ Guide *currGuide;
+ TickerEffect *effect;
+ QTime tickTimer;
+};
+
+#endif // ITEM_CIRCLE_ANIMATION_H
+
+
+
diff --git a/demos/qtdemo/letteritem.cpp b/demos/qtdemo/letteritem.cpp
new file mode 100644
index 0000000000..7b814b1d63
--- /dev/null
+++ b/demos/qtdemo/letteritem.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <cmath>
+#include "letteritem.h"
+#include "colors.h"
+
+LetterItem::LetterItem(char letter, QGraphicsScene *scene, QGraphicsItem *parent) : DemoItem(scene, parent), letter(letter)
+{
+ useSharedImage(QString(__FILE__) + letter);
+}
+
+LetterItem::~LetterItem()
+{
+}
+
+QImage *LetterItem::createImage(const QMatrix &matrix) const
+{
+ QRect scaledRect = matrix.mapRect(QRect(0, 0, 25, 25));
+ QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
+ image->fill(0);
+ QPainter painter(image);
+ painter.scale(matrix.m11(), matrix.m22());
+ painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
+ painter.setPen(Qt::NoPen);
+ if (Colors::useEightBitPalette){
+ painter.setBrush(QColor(102, 175, 54));
+ painter.drawEllipse(0, 0, 25, 25);
+ painter.setFont(Colors::tickerFont());
+ painter.setPen(QColor(255, 255, 255));
+ painter.drawText(10, 15, QString(this->letter));
+ }
+ else {
+ QLinearGradient brush(0, 0, 0, 25);
+ brush.setSpread(QLinearGradient::PadSpread);
+ brush.setColorAt(0.0, QColor(102, 175, 54, 200));
+ brush.setColorAt(1.0, QColor(102, 175, 54, 60));
+ painter.setBrush(brush);
+ painter.drawEllipse(0, 0, 25, 25);
+ painter.setFont(Colors::tickerFont());
+ painter.setPen(QColor(255, 255, 255, 255));
+ painter.drawText(10, 15, QString(this->letter));
+ }
+ return image;
+}
+
+
diff --git a/demos/qtdemo/letteritem.h b/demos/qtdemo/letteritem.h
new file mode 100644
index 0000000000..8c3f16e31f
--- /dev/null
+++ b/demos/qtdemo/letteritem.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LETTER_ITEM_H
+#define LETTER_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class LetterItem : public DemoItem
+{
+public:
+ LetterItem(char letter, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ virtual ~LetterItem();
+
+protected:
+ QImage *createImage(const QMatrix &matrix) const;
+
+private:
+ char letter;
+};
+
+#endif // LETTER_ITEM_H
+
diff --git a/demos/qtdemo/main.cpp b/demos/qtdemo/main.cpp
new file mode 100644
index 0000000000..bf2028dd2c
--- /dev/null
+++ b/demos/qtdemo/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include "mainwindow.h"
+#include "menumanager.h"
+#include "colors.h"
+
+static void artisticSleep(int sleepTime)
+{
+ QTime time;
+ time.restart();
+ while (time.elapsed() < sleepTime)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+}
+
+int main(int argc, char *argv[])
+{
+ Q_INIT_RESOURCE(qtdemo);
+ QApplication app(argc, argv);
+ Colors::parseArgs(argc, argv);
+ MainWindow mainWindow;
+ MenuManager::instance()->init(&mainWindow);
+ mainWindow.setFocus();
+
+ if (Colors::fullscreen)
+ mainWindow.showFullScreen();
+ else {
+ mainWindow.enableMask(true);
+ mainWindow.show();
+ }
+
+ artisticSleep(500);
+ mainWindow.start();
+ return app.exec();
+}
diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp
new file mode 100644
index 0000000000..8723823526
--- /dev/null
+++ b/demos/qtdemo/mainwindow.cpp
@@ -0,0 +1,483 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "menumanager.h"
+#include "colors.h"
+#include "dockitem.h"
+#include "demotextitem.h"
+#include "imageitem.h"
+#include "demoitem.h"
+#include "demoscene.h"
+
+#ifndef QT_NO_OPENGL
+ #include <QGLWidget>
+#endif
+//#define QT_NO_OPENGL
+
+MainWindow::MainWindow(QWidget *parent) : QGraphicsView(parent), updateTimer(this)
+{
+ this->currentFps = Colors::fps;
+ this->loop = false;
+ this->fpsMedian = -1;
+ this->fpsLabel = 0;
+ this->pausedLabel = 0;
+ this->doneAdapt = false;
+ this->useTimer = false;
+ this->updateTimer.setSingleShot(true);
+ this->trolltechLogo = 0;
+ this->qtLogo = 0;
+ this->setupWidget();
+ this->setupScene();
+ this->setupSceneItems();
+ this->drawBackgroundToPixmap();
+}
+
+MainWindow::~MainWindow()
+{
+ delete this->trolltechLogo;
+ delete this->qtLogo;
+}
+
+void MainWindow::setupWidget()
+{
+ QRect screenRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
+ QRect windowRect(0, 0, 800, 600);
+ if (screenRect.width() < 800)
+ windowRect.setWidth(screenRect.width());
+ if (screenRect.height() < 600)
+ windowRect.setHeight(screenRect.height());
+ windowRect.moveCenter(screenRect.center());
+ this->setGeometry(windowRect);
+ this->setMinimumSize(80, 60);
+ setWindowTitle(tr("Qt Examples and Demos"));
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setFrameStyle(QFrame::NoFrame);
+ this->setRenderingSystem();
+ connect(&this->updateTimer, SIGNAL(timeout()), this, SLOT(tick()));
+}
+
+void MainWindow::setRenderingSystem()
+{
+ QWidget *viewport = 0;
+
+ if (Colors::direct3dRendering){
+ viewport->setAttribute(Qt::WA_MSWindowsUseDirect3D);
+ setCacheMode(QGraphicsView::CacheNone);
+ if (Colors::verbose)
+ qDebug() << "- using Direct3D";
+ }
+#ifndef QT_NO_OPENGL
+ else if (Colors::openGlRendering){
+ QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
+ if (Colors::noScreenSync)
+ glw->format().setSwapInterval(0);
+ glw->setAutoFillBackground(false);
+ viewport = glw;
+ setCacheMode(QGraphicsView::CacheNone);
+ if (Colors::verbose)
+ qDebug() << "- using OpenGL";
+ }
+#endif
+ else{ // software rendering
+ viewport = new QWidget;
+ setCacheMode(QGraphicsView::CacheBackground);
+ if (Colors::verbose)
+ qDebug() << "- using software rendering";
+ }
+
+ setViewport(viewport);
+}
+
+void MainWindow::start()
+{
+ this->switchTimerOnOff(true);
+ this->demoStartTime.restart();
+ MenuManager::instance()->itemSelected(MenuManager::ROOT, Colors::rootMenuName);
+ if (Colors::verbose)
+ qDebug("- starting demo");
+}
+
+void MainWindow::enableMask(bool enable)
+{
+ if (!enable || Colors::noWindowMask)
+ this->clearMask();
+ else {
+ QPolygon region;
+ region.setPoints(9,
+ // north side:
+ 0, 0,
+ 800, 0,
+ // east side:
+ // 800, 70,
+ // 790, 90,
+ // 790, 480,
+ // 800, 500,
+ 800, 600,
+ // south side:
+ 700, 600,
+ 670, 590,
+ 130, 590,
+ 100, 600,
+ 0, 600,
+ // west side:
+ // 0, 550,
+ // 10, 530,
+ // 10, 520,
+ // 0, 520,
+ 0, 0);
+ this->setMask(QRegion(region));
+ }
+}
+
+void MainWindow::setupScene()
+{
+ this->scene = new DemoScene(this);
+ this->scene->setSceneRect(0, 0, 800, 600);
+ setScene(this->scene);
+ this->scene->setItemIndexMethod(QGraphicsScene::NoIndex);
+}
+
+void MainWindow::drawItems(QPainter *painter, int numItems, QGraphicsItem **items, const QStyleOptionGraphicsItem* options)
+{
+ QGraphicsView::drawItems(painter, numItems, items, options);
+}
+
+void MainWindow::switchTimerOnOff(bool on)
+{
+ bool ticker = MenuManager::instance()->ticker && MenuManager::instance()->ticker->scene();
+ if (ticker)
+ MenuManager::instance()->ticker->tickOnPaint = !on || Colors::noTimerUpdate;
+
+ if (on && !Colors::noTimerUpdate){
+ this->useTimer = true;
+ this->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
+ this->fpsTime = QTime::currentTime();
+ this->updateTimer.start(int(1000 / Colors::fps));
+ }
+ else{
+ this->useTimer = false;
+ this->updateTimer.stop();
+ if (Colors::softwareRendering)
+ if (Colors::noTicker)
+ this->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);
+ else
+ this->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ else
+ this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
+ }
+}
+
+bool MainWindow::measureFps()
+{
+ // Calculate time diff:
+ float t = this->fpsTime.msecsTo(QTime::currentTime());
+ if (t == 0)
+ t = 0.01f;
+ this->currentFps = (1000.0f / t);
+ this->fpsHistory += this->currentFps;
+ this->fpsTime = QTime::currentTime();
+
+ // Calculate median:
+ int size = this->fpsHistory.size();
+ if (size == 10){
+ qSort(this->fpsHistory.begin(), this->fpsHistory.end());
+ this->fpsMedian = this->fpsHistory.at(int(size/2));
+ if (this->fpsMedian == 0)
+ this->fpsMedian = 0.01f;
+ this->fpsHistory.clear();
+ return true;
+ }
+ return false;
+}
+
+/**
+ Used for adaption in case things are so slow
+ that no median yet has been calculated
+*/
+void MainWindow::forceFpsMedianCalculation()
+{
+ if (this->fpsMedian != -1)
+ return;
+
+ int size = this->fpsHistory.size();
+ if (size == 0){
+ this->fpsMedian = 0.01f;
+ return;
+ }
+
+ qSort(this->fpsHistory.begin(), this->fpsHistory.end());
+ this->fpsMedian = this->fpsHistory.at(int(size/2));
+ if (this->fpsMedian == 0)
+ this->fpsMedian = 0.01f;
+}
+
+void MainWindow::tick()
+{
+ bool medianChanged = this->measureFps();
+ this->checkAdapt();
+
+ if (medianChanged && this->fpsLabel && Colors::showFps)
+ this->fpsLabel->setText(QString("FPS: ") + QString::number(int(this->currentFps)));
+
+ if (MenuManager::instance()->ticker)
+ MenuManager::instance()->ticker->tick();
+
+ this->viewport()->update();
+ if (Colors::softwareRendering)
+ QApplication::syncX();
+
+ if (this->useTimer)
+ this->updateTimer.start(int(1000 / Colors::fps));
+}
+
+void MainWindow::setupSceneItems()
+{
+ if (Colors::showFps){
+ this->fpsLabel = new DemoTextItem(QString("FPS: --"), Colors::buttonFont(), Qt::white, -1, this->scene, 0, DemoTextItem::DYNAMIC_TEXT);
+ this->fpsLabel->setZValue(100);
+ this->fpsLabel->setPos(Colors::stageStartX, 600 - QFontMetricsF(Colors::buttonFont()).height() - 5);
+ }
+
+ this->trolltechLogo = new ImageItem(QImage(":/images/trolltech-logo.png"), 1000, 1000, this->scene, 0, true, 0.5f);
+ this->qtLogo = new ImageItem(QImage(":/images/qtlogo_small.png"), 1000, 1000, this->scene, 0, true, 0.5f);
+ this->trolltechLogo->setZValue(100);
+ this->qtLogo->setZValue(100);
+ this->pausedLabel = new DemoTextItem(QString("PAUSED"), Colors::buttonFont(), Qt::white, -1, this->scene, 0);
+ this->pausedLabel->setZValue(100);
+ QFontMetricsF fm(Colors::buttonFont());
+ this->pausedLabel->setPos(Colors::stageWidth - fm.width("PAUSED"), 590 - fm.height());
+ this->pausedLabel->setRecursiveVisible(false);
+}
+
+void MainWindow::checkAdapt()
+{
+ if (this->doneAdapt
+ || Colors::noTimerUpdate
+ || this->demoStartTime.elapsed() < 2000)
+ return;
+
+ this->doneAdapt = true;
+ this->forceFpsMedianCalculation();
+ Colors::benchmarkFps = this->fpsMedian;
+ if (Colors::verbose)
+ qDebug() << "- benchmark:" << QString::number(Colors::benchmarkFps) << "FPS";
+
+ if (Colors::noAdapt)
+ return;
+
+ if (this->fpsMedian < 30){
+ if (MenuManager::instance()->ticker && MenuManager::instance()->ticker->scene()){
+ this->scene->removeItem(MenuManager::instance()->ticker);
+ Colors::noTimerUpdate = true;
+ this->switchTimerOnOff(false);
+ if (this->fpsLabel)
+ this->fpsLabel->setText(QString("FPS: (") + QString::number(this->fpsMedian) + QString(")"));
+ if (Colors::verbose)
+ qDebug() << "- benchmark adaption: removed ticker (fps < 30)";
+ }
+
+ if (this->fpsMedian < 20){
+ Colors::noAnimations = true;
+ if (Colors::verbose)
+ qDebug() << "- benchmark adaption: animations switched off (fps < 20)";
+ }
+
+ Colors::adapted = true;
+ }
+}
+
+int MainWindow::performBenchmark()
+{
+/*
+ QTime time;
+ time.restart();
+ while (time.elapsed() < 2000)
+ QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
+*/
+ return 0;
+}
+
+void MainWindow::drawBackgroundToPixmap()
+{
+ const QRectF r = this->scene->sceneRect();
+ this->background = QPixmap(qRound(r.width()), qRound(r.height()));
+ this->background.fill(Qt::black);
+ QPainter painter(&this->background);
+
+ if (false && Colors::useEightBitPalette){
+ painter.fillRect(r, Colors::sceneBg1);
+ } else {
+ QImage bg(":/images/demobg.png");
+ painter.drawImage(0, 0, bg);
+ }
+}
+
+void MainWindow::drawBackground(QPainter *painter, const QRectF &rect)
+{
+ Q_UNUSED(rect);
+ painter->drawPixmap(QPoint(0, 0), this->background);
+}
+
+void MainWindow::showEvent(QShowEvent * event)
+{
+ Q_UNUSED(event);
+ QGraphicsView::showEvent(event);
+}
+
+void MainWindow::toggleFullscreen()
+{
+ if (this->isFullScreen()){
+ this->enableMask(true);
+ this->showNormal();
+ if (MenuManager::instance()->ticker)
+ MenuManager::instance()->ticker->pause(false);
+ }
+ else {
+ this->enableMask(false);
+ this->showFullScreen();
+ }
+}
+
+void MainWindow::keyPressEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_Escape){
+ this->loop = false;
+ QApplication::quit();
+ }
+ else if (event->key() == Qt::Key_1){
+ QString s("");
+ s += "Rendering system: ";
+ if (Colors::openGlRendering)
+ s += "OpenGL";
+ else if (Colors::direct3dRendering)
+ s += "Direct3D";
+ else
+ s += "software";
+
+ s += "\nAdapt: ";
+ s += Colors::noAdapt ? "off" : "on";
+ s += "\nAdaption occured: ";
+ s += Colors::adapted ? "yes" : "no";
+ s += "\nOpenGL version: ";
+ s += Colors::glVersion;
+ QWidget w;
+ s += "\nColor bit depth: ";
+ s += QString::number(w.depth());
+ s += "\nWanted FPS: ";
+ s += QString::number(Colors::fps);
+ s += "\nBenchmarked FPS: ";
+ s += Colors::benchmarkFps != -1 ? QString::number(Colors::benchmarkFps) : "not calculated";
+ s += "\nAnimations: ";
+ s += Colors::noAnimations ? "off" : "on";
+ s += "\nBlending: ";
+ s += Colors::useEightBitPalette ? "off" : "on";
+ s += "\nTicker: ";
+ s += Colors::noTicker ? "off" : "on";
+ s += "\nPixmaps: ";
+ s += Colors::usePixmaps ? "on" : "off";
+ s += "\nRescale images on resize: ";
+ s += Colors::noRescale ? "off" : "on";
+ s += "\nTimer based updates: ";
+ s += Colors::noTimerUpdate ? "off" : "on";
+ s += "\nSeparate loop: ";
+ s += Colors::useLoop ? "yes" : "no";
+ s += "\nScreen sync: ";
+ s += Colors::noScreenSync ? "no" : "yes";
+ QMessageBox::information(0, QString("Current configuration"), s);
+ }
+}
+
+void MainWindow::focusInEvent(QFocusEvent *)
+{
+ if (!Colors::pause)
+ return;
+
+ if (MenuManager::instance()->ticker)
+ MenuManager::instance()->ticker->pause(false);
+
+ int code = MenuManager::instance()->currentMenuCode;
+ if (code == MenuManager::ROOT || code == MenuManager::MENU1)
+ this->switchTimerOnOff(true);
+
+ this->pausedLabel->setRecursiveVisible(false);
+}
+
+void MainWindow::focusOutEvent(QFocusEvent *)
+{
+ if (!Colors::pause)
+ return;
+
+ if (MenuManager::instance()->ticker)
+ MenuManager::instance()->ticker->pause(true);
+
+ int code = MenuManager::instance()->currentMenuCode;
+ if (code == MenuManager::ROOT || code == MenuManager::MENU1)
+ this->switchTimerOnOff(false);
+
+ this->pausedLabel->setRecursiveVisible(true);
+}
+
+void MainWindow::resizeEvent(QResizeEvent *event)
+{
+ Q_UNUSED(event);
+
+ this->resetMatrix();
+ this->scale(event->size().width() / 800.0, event->size().height() / 600.0);
+ QGraphicsView::resizeEvent(event);
+ DemoItem::setMatrix(this->matrix());
+
+ if (this->trolltechLogo){
+ const QRectF r = this->scene->sceneRect();
+ QRectF ttb = this->trolltechLogo->boundingRect();
+ this->trolltechLogo->setPos(int((r.width() - ttb.width()) / 2), 595 - ttb.height());
+ QRectF qtb = this->qtLogo->boundingRect();
+ this->qtLogo->setPos(802 - qtb.width(), 0);
+ }
+
+ // Changing size will almost always
+ // hurt FPS during the changing. So
+ // ignore it.
+ this->fpsHistory.clear();
+}
+
+
diff --git a/demos/qtdemo/mainwindow.h b/demos/qtdemo/mainwindow.h
new file mode 100644
index 0000000000..388a392543
--- /dev/null
+++ b/demos/qtdemo/mainwindow.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAIN_WINDOW_H
+#define MAIN_WINDOW_H
+
+#include <QtGui>
+#include <QPixmap>
+
+class DemoTextItem;
+class ImageItem;
+
+class MainWindow : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+ void enableMask(bool enable);
+ void toggleFullscreen();
+ int performBenchmark();
+ void switchTimerOnOff(bool on);
+ void start();
+
+ QGraphicsScene *scene;
+ bool loop;
+
+ // FPS stuff:
+ QList<QTime> frameTimeList;
+ QList<float> fpsHistory;
+ float currentFps;
+ float fpsMedian;
+ DemoTextItem *fpsLabel;
+
+protected:
+ // Overidden methods:
+ void showEvent(QShowEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void drawBackground(QPainter *painter, const QRectF &rect);
+ void drawItems(QPainter *painter, int numItems, QGraphicsItem ** items, const QStyleOptionGraphicsItem* options);
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+
+private slots:
+ void tick();
+
+private:
+ void setupWidget();
+ void setupSceneItems();
+ void drawBackgroundToPixmap();
+ void setupScene();
+ bool measureFps();
+ void forceFpsMedianCalculation();
+ void checkAdapt();
+ void setRenderingSystem();
+
+ QTimer updateTimer;
+ QTime demoStartTime;
+ QTime fpsTime;
+ QPixmap background;
+ ImageItem *trolltechLogo;
+ ImageItem *qtLogo;
+ bool doneAdapt;
+ bool useTimer;
+ DemoTextItem *pausedLabel;
+};
+
+#endif // MAIN_WINDOW_H
+
diff --git a/demos/qtdemo/menucontent.cpp b/demos/qtdemo/menucontent.cpp
new file mode 100644
index 0000000000..a74cfe4214
--- /dev/null
+++ b/demos/qtdemo/menucontent.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "menucontent.h"
+#include "colors.h"
+#include "menumanager.h"
+#include "demotextitem.h"
+#include "headingitem.h"
+
+MenuContentItem::MenuContentItem(const QDomElement &el, QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ this->name = el.attribute("name");
+ this->heading = 0;
+ this->description1 = 0;
+ this->description2 = 0;
+
+ if (el.tagName() == "demos")
+ this->readmePath = QLibraryInfo::location(QLibraryInfo::DemosPath) + "/README";
+ else
+ this->readmePath = QLibraryInfo::location(QLibraryInfo::ExamplesPath) + "/" + el.attribute("dirname") + "/README";
+
+}
+
+void MenuContentItem::prepare()
+{
+ if (!this->prepared){
+ this->prepared= true;
+ this->createContent();
+ }
+}
+
+void MenuContentItem::animationStopped(int id)
+{
+ if (this->name == Colors::rootMenuName)
+ return; // Optimization hack.
+
+ if (id == DemoItemAnimation::ANIM_OUT){
+ // Free up some memory:
+ delete this->heading;
+ delete this->description1;
+ delete this->description2;
+ this->heading = 0;
+ this->description1 = 0;
+ this->description2 = 0;
+ this->prepared = false;
+ }
+}
+
+QString MenuContentItem::loadDescription(int startPara, int nrPara)
+{
+ QString result;
+ QFile readme(this->readmePath);
+ if (!readme.open(QFile::ReadOnly)){
+ if (Colors::verbose)
+ qDebug() << "- MenuContentItem::loadDescription: Could not load:" << this->readmePath;
+ return "";
+ }
+
+ QTextStream in(&readme);
+ // Skip a certain number of paragraphs:
+ while (startPara)
+ if (in.readLine().isEmpty()) --startPara;
+
+ // Read in the number of wanted paragraphs:
+ QString line = in.readLine();
+ do {
+ result += line + " ";
+ line = in.readLine();
+ if (line.isEmpty()){
+ --nrPara;
+ line = "<br><br>" + in.readLine();
+ }
+ } while (nrPara && !in.atEnd());
+
+ return Colors::contentColor + result;
+}
+
+void MenuContentItem::createContent()
+{
+ // Create the items:
+ this->heading = new HeadingItem(this->name, this->scene(), this);
+ QString para1 = this->loadDescription(0, 1);
+ if (para1.isEmpty())
+ para1 = Colors::contentColor + QLatin1String("Could not load description. Ensure that the documentation for Qt is built.");
+ QColor bgcolor = Colors::sceneBg1.darker(200);
+ bgcolor.setAlpha(100);
+ this->description1 = new DemoTextItem(para1, Colors::contentFont(), Colors::heading, 500, this->scene(), this, DemoTextItem::STATIC_TEXT);
+ this->description2 = new DemoTextItem(this->loadDescription(1, 2), Colors::contentFont(), Colors::heading, 250, this->scene(), this, DemoTextItem::STATIC_TEXT);
+
+ // Place the items on screen:
+ this->heading->setPos(0, 3);
+ this->description1->setPos(0, this->heading->pos().y() + this->heading->boundingRect().height() + 10);
+ this->description2->setPos(0, this->description1->pos().y() + this->description1->boundingRect().height() + 15);
+}
+
+QRectF MenuContentItem::boundingRect() const
+{
+ return QRectF(0, 0, 500, 350);
+}
+
+
diff --git a/demos/qtdemo/menucontent.h b/demos/qtdemo/menucontent.h
new file mode 100644
index 0000000000..737492d3ea
--- /dev/null
+++ b/demos/qtdemo/menucontent.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MENU_CONTENT_ITEM_H
+#define MENU_CONTENT_ITEM_H
+
+#include <QtGui>
+#include <QtXml>
+#include "demoitem.h"
+
+class HeadingItem;
+class DemoTextItem;
+
+class MenuContentItem : public DemoItem
+{
+
+public:
+ MenuContentItem(const QDomElement &el, QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+
+ virtual QRectF boundingRect() const; // overridden
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0){}; // overridden
+ void animationStopped(int id);
+ void prepare();
+
+private:
+ QString name;
+ QString readmePath;
+ HeadingItem *heading;
+ DemoTextItem *description1;
+ DemoTextItem *description2;
+
+ QString loadDescription(int startPara, int nrPara);
+ QString extractTextFromParagraph(const QDomNode &parentNode);
+
+ void createContent();
+};
+
+#endif // MENU_CONTENT_ITEM_H
+
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
new file mode 100644
index 0000000000..bfa2e3faae
--- /dev/null
+++ b/demos/qtdemo/menumanager.cpp
@@ -0,0 +1,876 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "menumanager.h"
+#include "colors.h"
+#include "menucontent.h"
+#include "examplecontent.h"
+
+MenuManager *MenuManager::pInstance = 0;
+
+MenuManager * MenuManager::instance()
+{
+ if (!MenuManager::pInstance)
+ MenuManager::pInstance = new MenuManager();
+ return MenuManager::pInstance;
+}
+
+MenuManager::MenuManager()
+{
+ this->ticker = 0;
+ this->tickerInAnim = 0;
+ this->upButton = 0;
+ this->downButton = 0;
+ this->helpEngine = 0;
+ this->score = new Score();
+ this->currentMenu = QLatin1String("[no menu visible]");
+ this->currentCategory = QLatin1String("[no category visible]");
+ this->currentMenuButtons = QLatin1String("[no menu buttons visible]");
+ this->currentInfo = QLatin1String("[no info visible]");
+ this->currentMenuCode = -1;
+ this->readXmlDocument();
+ this->initHelpEngine();
+}
+
+MenuManager::~MenuManager()
+{
+ delete this->score;
+ delete this->contentsDoc;
+ delete this->helpEngine;
+}
+
+QByteArray MenuManager::getResource(const QString &name)
+{
+ QByteArray ba = this->helpEngine->fileData(name);
+ if (Colors::verbose && ba.isEmpty())
+ qDebug() << " - WARNING: Could not get " << name;
+ return ba;
+}
+
+void MenuManager::readXmlDocument()
+{
+ this->contentsDoc = new QDomDocument();
+ QString errorStr;
+ int errorLine;
+ int errorColumn;
+
+ QFile file(":/xml/examples.xml");
+ bool statusOK = this->contentsDoc->setContent(&file, true, &errorStr, &errorLine, &errorColumn);
+ if (!statusOK){
+ QMessageBox::critical(0,
+ QObject::tr("DOM Parser"),
+ QObject::tr("Could not read or find the contents document. Error at line %1, column %2:\n%3")
+ .arg(errorLine).arg(errorColumn).arg(errorStr)
+ );
+ exit(-1);
+ }
+}
+
+void MenuManager::initHelpEngine()
+{
+ this->helpRootUrl = QString("qthelp://com.trolltech.qt.%1%2%3/qdoc/")
+ .arg(QT_VERSION >> 16).arg((QT_VERSION >> 8) & 0xFF)
+ .arg(QT_VERSION & 0xFF);
+
+ // Store help collection file in cache dir of assistant
+ QString cacheDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+ + QLatin1String("/Trolltech/Assistant/");
+ QString helpDataFile = QString(QLatin1String("qtdemo_%1.qhc")).arg(QLatin1String(QT_VERSION_STR));
+
+ QDir dir;
+ if (!dir.exists(cacheDir))
+ dir.mkpath(cacheDir);
+
+ // Create help engine (and new
+ // helpDataFile if it does not exist):
+ this->helpEngine = new QHelpEngineCore(cacheDir + helpDataFile);
+ this->helpEngine->setupData();
+
+ QString qtDocRoot = QLibraryInfo::location(QLibraryInfo::DocumentationPath) + QLatin1String("/qch");
+ qtDocRoot = QDir(qtDocRoot).absolutePath();
+
+ QStringList qchFiles;
+ qchFiles << QLatin1String("/qt.qch")
+ << QLatin1String("/designer.qch")
+ << QLatin1String("/linguist.qch");
+
+ QString oldDir = helpEngine->customValue(QLatin1String("docDir"), QString()).toString();
+ if (oldDir != qtDocRoot) {
+ foreach (const QString &qchFile, qchFiles)
+ helpEngine->unregisterDocumentation(QHelpEngineCore::namespaceName(qtDocRoot + qchFile));
+ }
+
+ // If the data that the engine will work
+ // on is not yet registered, do it now:
+ foreach (const QString &qchFile, qchFiles)
+ helpEngine->registerDocumentation(qtDocRoot + qchFile);
+
+ helpEngine->setCustomValue(QLatin1String("docDir"), qtDocRoot);
+}
+
+void MenuManager::itemSelected(int userCode, const QString &menuName)
+{
+ switch (userCode){
+ case LAUNCH:
+ this->launchExample(this->currentInfo);
+ break;
+ case DOCUMENTATION:
+ this->showDocInAssistant(this->currentInfo);
+ break;
+ case QUIT:
+ this->window->loop = false;
+ QCoreApplication::quit();
+ break;
+ case FULLSCREEN:
+ this->window->toggleFullscreen();
+ break;
+ case ROOT:
+ // out:
+ this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(this->currentInfo + " -out");
+ this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
+ this->score->queueMovie("back -out", Score::ONLY_IF_VISIBLE);
+ // book-keeping:
+ this->currentMenuCode = ROOT;
+ this->currentMenu = menuName + " -menu1";
+ this->currentMenuButtons = menuName + " -buttons";
+ this->currentInfo = menuName + " -info";
+ // in:
+ this->score->queueMovie("upndown -shake");
+ this->score->queueMovie(this->currentMenu, Score::FROM_START, Score::UNLOCK_ITEMS);
+ this->score->queueMovie(this->currentMenuButtons, Score::FROM_START, Score::UNLOCK_ITEMS);
+ this->score->queueMovie(this->currentInfo);
+ if (!Colors::noTicker){
+ this->ticker->doIntroTransitions = true;
+ this->tickerInAnim->startDelay = 2000;
+ this->ticker->useGuideQt();
+ this->score->queueMovie("ticker", Score::NEW_ANIMATION_ONLY);
+ this->window->switchTimerOnOff(true);
+ }
+ break;
+ case MENU1:
+ // out:
+ this->score->queueMovie(this->currentMenu + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(this->currentMenuButtons + " -out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(this->currentInfo + " -out");
+ // book-keeping:
+ this->currentMenuCode = MENU1;
+ this->currentCategory = menuName;
+ this->currentMenu = menuName + " -menu1";
+ this->currentInfo = menuName + " -info";
+ // in:
+ this->score->queueMovie("upndown -shake");
+ this->score->queueMovie("back -in");
+ this->score->queueMovie(this->currentMenu, Score::FROM_START, Score::UNLOCK_ITEMS);
+ this->score->queueMovie(this->currentInfo);
+ if (!Colors::noTicker)
+ this->ticker->useGuideTt();
+ break;
+ case MENU2:
+ // out:
+ this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY);
+ this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
+ // book-keeping:
+ this->currentMenuCode = MENU2;
+ this->currentInfo = menuName;
+ // in / shake:
+ this->score->queueMovie("upndown -shake");
+ this->score->queueMovie("back -shake");
+ this->score->queueMovie(this->currentMenu + " -shake");
+ this->score->queueMovie(this->currentInfo, Score::NEW_ANIMATION_ONLY);
+ this->score->queueMovie(this->currentInfo + " -buttons", Score::NEW_ANIMATION_ONLY);
+ if (!Colors::noTicker){
+ this->score->queueMovie("ticker -out", Score::NEW_ANIMATION_ONLY);
+ this->window->switchTimerOnOff(false);
+ }
+ break;
+ case UP:{
+ QString backMenu = this->info[this->currentMenu]["back"];
+ if (!backMenu.isNull()){
+ this->score->queueMovie(this->currentMenu + " -top_out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(backMenu + " -bottom_in", Score::FROM_START, Score::UNLOCK_ITEMS);
+ this->currentMenu = backMenu;
+ }
+ break; }
+ case DOWN:{
+ QString moreMenu = this->info[this->currentMenu]["more"];
+ if (!moreMenu.isNull()){
+ this->score->queueMovie(this->currentMenu + " -bottom_out", Score::FROM_START, Score::LOCK_ITEMS);
+ this->score->queueMovie(moreMenu + " -top_in", Score::FROM_START, Score::UNLOCK_ITEMS);
+ this->currentMenu = moreMenu;
+ }
+ break; }
+ case BACK:{
+ if (this->currentMenuCode == MENU2){
+ // out:
+ this->score->queueMovie(this->currentInfo + " -out", Score::NEW_ANIMATION_ONLY);
+ this->score->queueMovie(this->currentInfo + " -buttons -out", Score::NEW_ANIMATION_ONLY);
+ // book-keeping:
+ this->currentMenuCode = MENU1;
+ this->currentMenuButtons = this->currentCategory + " -buttons";
+ this->currentInfo = this->currentCategory + " -info";
+ // in / shake:
+ this->score->queueMovie("upndown -shake");
+ this->score->queueMovie(this->currentMenu + " -shake");
+ this->score->queueMovie(this->currentInfo, Score::NEW_ANIMATION_ONLY);
+ this->score->queueMovie(this->currentInfo + " -buttons", Score::NEW_ANIMATION_ONLY);
+ if (!Colors::noTicker){
+ this->ticker->doIntroTransitions = false;
+ this->tickerInAnim->startDelay = 500;
+ this->score->queueMovie("ticker", Score::NEW_ANIMATION_ONLY);
+ this->window->switchTimerOnOff(true);
+ }
+ } else if (this->currentMenuCode != ROOT)
+ itemSelected(ROOT, Colors::rootMenuName);
+ break; }
+ }
+
+ // update back- and more buttons
+ bool noBackMenu = this->info[this->currentMenu]["back"].isNull();
+ bool noMoreMenu = this->info[this->currentMenu]["more"].isNull();
+ this->upButton->setState(noBackMenu ? TextButton::DISABLED : TextButton::OFF);
+ this->downButton->setState(noMoreMenu ? TextButton::DISABLED : TextButton::OFF);
+
+ if (this->score->hasQueuedMovies()){
+ this->score->playQue();
+ // Playing new movies might include
+ // loading etc. So ignore the FPS
+ // at this point
+ this->window->fpsHistory.clear();
+ }
+}
+
+void MenuManager::showDocInAssistant(const QString &name)
+{
+ QString url = this->resolveDocUrl(name);
+ if (Colors::verbose)
+ qDebug() << "Sending URL to Assistant:" << url;
+
+ // Start assistant if it's not already running:
+ if (this->assistantProcess.state() != QProcess::Running){
+ QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
+#if !defined(Q_OS_MAC)
+ app += QLatin1String("assistant");
+#else
+ app += QLatin1String("Assistant.app/Contents/MacOS/Assistant");
+#endif
+ QStringList args;
+ args << QLatin1String("-enableRemoteControl");
+ this->assistantProcess.start(app, args);
+ if (!this->assistantProcess.waitForStarted()) {
+ QMessageBox::critical(0, tr("Qt Demo"), tr("Could not start Qt Assistant.").arg(app));
+ return;
+ }
+ }
+
+ // Send command through remote control even if the process
+ // was started to activate assistant and bring it to front:
+ QTextStream str(&this->assistantProcess);
+ str << "SetSource " << url << QLatin1Char('\0') << endl;
+}
+
+void MenuManager::launchExample(const QString &name)
+{
+ QString executable = this->resolveExeFile(name);
+#ifdef Q_OS_MAC
+ if (Colors::verbose)
+ qDebug() << "Launching:" << executable;
+ bool success = QDesktopServices::openUrl(QUrl::fromLocalFile(executable));
+ if (!success){
+ QMessageBox::critical(0, tr("Failed to launch the example"),
+ tr("Could not launch the example. Ensure that it has been built."),
+ QMessageBox::Cancel);
+ }
+#else // Not mac. To not break anything regarding dll's etc, keep it the way it was before:
+ QProcess *process = new QProcess(this);
+ connect(process, SIGNAL(finished(int)), this, SLOT(exampleFinished()));
+ connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(exampleError(QProcess::ProcessError)));
+
+#ifdef Q_OS_WIN
+ //make sure it finds the dlls on windows
+ QString curpath = QString::fromLocal8Bit(qgetenv("PATH").constData());
+ QString newpath = QString("PATH=%1;%2").arg(QLibraryInfo::location(QLibraryInfo::BinariesPath), curpath);
+ process->setEnvironment(QStringList(newpath));
+#endif
+
+ if (info[name]["changedirectory"] != "false"){
+ QString workingDirectory = resolveDataDir(name);
+ process->setWorkingDirectory(workingDirectory);
+ if (Colors::verbose)
+ qDebug() << "Setting working directory:" << workingDirectory;
+ }
+
+ if (Colors::verbose)
+ qDebug() << "Launching:" << executable;
+ process->start(executable);
+#endif
+}
+
+void MenuManager::exampleFinished()
+{
+}
+
+void MenuManager::exampleError(QProcess::ProcessError error)
+{
+ if (error != QProcess::Crashed)
+ QMessageBox::critical(0, tr("Failed to launch the example"),
+ tr("Could not launch the example. Ensure that it has been built."),
+ QMessageBox::Cancel);
+}
+
+void MenuManager::init(MainWindow *window)
+{
+ this->window = window;
+
+ // Create div:
+ this->createTicker();
+ this->createUpnDownButtons();
+ this->createBackButton();
+
+ // Create first level menu:
+ QDomElement rootElement = this->contentsDoc->documentElement();
+ this->createRootMenu(rootElement);
+
+ // Create second level menus:
+ QDomNode level2MenuNode = rootElement.firstChild();
+ while (!level2MenuNode.isNull()){
+ QDomElement level2MenuElement = level2MenuNode.toElement();
+ this->createSubMenu(level2MenuElement);
+
+ // create leaf menu and example info:
+ QDomNode exampleNode = level2MenuElement.firstChild();
+ while (!exampleNode.isNull()){
+ QDomElement exampleElement = exampleNode.toElement();
+ this->readInfoAboutExample(exampleElement);
+ this->createLeafMenu(exampleElement);
+ exampleNode = exampleNode.nextSibling();
+ }
+
+ level2MenuNode = level2MenuNode.nextSibling();
+ }
+}
+
+void MenuManager::readInfoAboutExample(const QDomElement &example)
+{
+ QString name = example.attribute("name");
+ if (this->info.contains(name))
+ qWarning() << "__WARNING: MenuManager::readInfoAboutExample: Demo/example with name"
+ << name << "appears twize in the xml-file!__";
+
+ this->info[name]["filename"] = example.attribute("filename");
+ this->info[name]["category"] = example.parentNode().toElement().tagName();
+ this->info[name]["dirname"] = example.parentNode().toElement().attribute("dirname");
+ this->info[name]["changedirectory"] = example.attribute("changedirectory");
+ this->info[name]["image"] = example.attribute("image");
+}
+
+QString MenuManager::resolveDataDir(const QString &name)
+{
+ QString dirName = this->info[name]["dirname"];
+ QString category = this->info[name]["category"];
+ QString fileName = this->info[name]["filename"];
+
+ QDir dir;
+ if (category == "demos")
+ dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
+ else
+ dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
+
+ dir.cd(dirName);
+ dir.cd(fileName);
+ return dir.absolutePath();
+}
+
+QString MenuManager::resolveExeFile(const QString &name)
+{
+ QString dirName = this->info[name]["dirname"];
+ QString category = this->info[name]["category"];
+ QString fileName = this->info[name]["filename"];
+
+ QDir dir;
+ if (category == "demos")
+ dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
+ else
+ dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
+
+ dir.cd(dirName);
+ dir.cd(fileName);
+
+ QFile unixFile(dir.path() + "/" + fileName);
+ if (unixFile.exists()) return unixFile.fileName();
+ QFile winR(dir.path() + "\\release\\" + fileName + ".exe");
+ if (winR.exists()) return winR.fileName();
+ QFile winD(dir.path() + "\\debug\\" + fileName + ".exe");
+ if (winD.exists()) return winD.fileName();
+ QFile mac(dir.path() + "/" + fileName + ".app");
+ if (mac.exists()) return mac.fileName();
+
+ if (Colors::verbose)
+ qDebug() << "- WARNING: Could not resolve executable:" << dir.path() << fileName;
+ return "__executable not found__";
+}
+
+QString MenuManager::resolveDocUrl(const QString &name)
+{
+ QString dirName = this->info[name]["dirname"];
+ QString category = this->info[name]["category"];
+ QString fileName = this->info[name]["filename"];
+
+ if (category == "demos")
+ return this->helpRootUrl + "demos-" + fileName + ".html";
+ else
+ return this->helpRootUrl + dirName.replace("/", "-") + "-" + fileName + ".html";
+}
+
+QString MenuManager::resolveImageUrl(const QString &name)
+{
+ return this->helpRootUrl + "images/" + name;
+}
+
+QByteArray MenuManager::getHtml(const QString &name)
+{
+ return getResource(this->resolveDocUrl(name));
+}
+
+QByteArray MenuManager::getImage(const QString &name)
+{
+ QString imageName = this->info[name]["image"];
+ QString category = this->info[name]["category"];
+ QString fileName = this->info[name]["filename"];
+
+ if (imageName.isEmpty()){
+ if (category == "demos")
+ imageName = fileName + "-demo.png";
+ else
+ imageName = fileName + "-example.png";
+ if ((getResource(resolveImageUrl(imageName))).isEmpty())
+ imageName = fileName + ".png";
+ if ((getResource(resolveImageUrl(imageName))).isEmpty())
+ imageName = fileName + "example.png";
+ }
+ return getResource(resolveImageUrl(imageName));
+}
+
+
+void MenuManager::createRootMenu(const QDomElement &el)
+{
+ QString name = el.attribute("name");
+ createMenu(el, MENU1);
+ createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info");
+
+ Movie *menuButtonsIn = this->score->insertMovie(name + " -buttons");
+ Movie *menuButtonsOut = this->score->insertMovie(name + " -buttons -out");
+ createLowLeftButton(QLatin1String("Quit"), QUIT, menuButtonsIn, menuButtonsOut, 0);
+ createLowRightButton("Toggle fullscreen", FULLSCREEN, menuButtonsIn, menuButtonsOut, 0);
+}
+
+void MenuManager::createSubMenu(const QDomElement &el)
+{
+ QString name = el.attribute("name");
+ createMenu(el, MENU2);
+ createInfo(new MenuContentItem(el, this->window->scene, 0), name + " -info");
+}
+
+void MenuManager::createLeafMenu(const QDomElement &el)
+{
+ QString name = el.attribute("name");
+ createInfo(new ExampleContent(name, this->window->scene, 0), name);
+
+ Movie *infoButtonsIn = this->score->insertMovie(name + " -buttons");
+ Movie *infoButtonsOut = this->score->insertMovie(name + " -buttons -out");
+ createLowRightLeafButton("Documentation", 600, DOCUMENTATION, infoButtonsIn, infoButtonsOut, 0);
+ if (el.attribute("executable") != "false")
+ createLowRightLeafButton("Launch", 405, LAUNCH, infoButtonsIn, infoButtonsOut, 0);
+}
+
+void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type)
+{
+ qreal sw = this->window->scene->sceneRect().width();
+ int xOffset = 15;
+ int yOffset = 10;
+ int maxExamples = Colors::menuCount;
+ int menuIndex = 1;
+ QString name = category.attribute("name");
+ QDomNode currentNode = category.firstChild();
+ QString currentMenu = name + QLatin1String(" -menu") + QString::number(menuIndex);
+
+ while (!currentNode.isNull()){
+ Movie *movieIn = this->score->insertMovie(currentMenu);
+ Movie *movieOut = this->score->insertMovie(currentMenu + " -out");
+ Movie *movieNextTopOut = this->score->insertMovie(currentMenu + " -top_out");
+ Movie *movieNextBottomOut = this->score->insertMovie(currentMenu + " -bottom_out");
+ Movie *movieNextTopIn = this->score->insertMovie(currentMenu + " -top_in");
+ Movie *movieNextBottomIn = this->score->insertMovie(currentMenu + " -bottom_in");
+ Movie *movieShake = this->score->insertMovie(currentMenu + " -shake");
+
+ int i = 0;
+ while (!currentNode.isNull() && i < maxExamples){
+ TextButton *item;
+
+ // create normal menu button
+ QString label = currentNode.toElement().attribute("name");
+ item = new TextButton(label, TextButton::LEFT, type, this->window->scene, 0);
+ currentNode = currentNode.nextSibling();
+
+#ifndef QT_OPENGL_SUPPORT
+ if (currentNode.toElement().attribute("dirname") == "opengl")
+ currentNode = currentNode.nextSibling();
+#endif
+
+ item->setRecursiveVisible(false);
+ item->setZValue(10);
+ qreal ih = item->sceneBoundingRect().height();
+ qreal iw = item->sceneBoundingRect().width();
+ qreal ihp = ih + 3;
+
+ // create in-animation:
+ DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ anim->setDuration(float(1000 + (i * 20)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, -ih));
+ anim->setPosAt(0.20, QPointF(xOffset, -ih));
+ anim->setPosAt(0.50, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (10 * float(i / 4.0f))));
+ anim->setPosAt(0.60, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.70, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (5 * float(i / 4.0f))));
+ anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.90, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY + (2 * float(i / 4.0f))));
+ anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ movieIn->append(anim);
+
+ // create out-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ anim->hideOnFinished = true;
+ anim->setDuration((700 + (30 * i)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.60, QPointF(xOffset, 600 - ih - ih));
+ anim->setPosAt(0.65, QPointF(xOffset + 20, 600 - ih));
+ anim->setPosAt(1.00, QPointF(sw + iw, 600 - ih));
+ movieOut->append(anim);
+
+ // create shake-animation:
+ anim = new DemoItemAnimation(item);
+ anim->setDuration(700 * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.55, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*2.0));
+ anim->setPosAt(0.70, QPointF(xOffset - 10, (i * ihp) + yOffset + Colors::contentStartY - i*1.5));
+ anim->setPosAt(0.80, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY - i*1.0));
+ anim->setPosAt(0.90, QPointF(xOffset - 2, (i * ihp) + yOffset + Colors::contentStartY - i*0.5));
+ anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ movieShake->append(anim);
+
+ // create next-menu top-out-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ anim->hideOnFinished = true;
+ anim->setDuration((200 + (30 * i)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.70, QPointF(xOffset, yOffset + Colors::contentStartY));
+ anim->setPosAt(1.00, QPointF(-iw, yOffset + Colors::contentStartY));
+ movieNextTopOut->append(anim);
+
+ // create next-menu bottom-out-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ anim->hideOnFinished = true;
+ anim->setDuration((200 + (30 * i)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.70, QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(1.00, QPointF(-iw, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ movieNextBottomOut->append(anim);
+
+ // create next-menu top-in-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ anim->setDuration((700 - (30 * i)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(-iw, yOffset + Colors::contentStartY));
+ anim->setPosAt(0.30, QPointF(xOffset, yOffset + Colors::contentStartY));
+ anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ movieNextTopIn->append(anim);
+
+ // create next-menu bottom-in-animation:
+ int reverse = maxExamples - i;
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ anim->setDuration((1000 - (30 * reverse)) * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(-iw, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(0.30, QPointF(xOffset, (maxExamples * ihp) + yOffset + Colors::contentStartY));
+ anim->setPosAt(1.00, QPointF(xOffset, (i * ihp) + yOffset + Colors::contentStartY));
+ movieNextBottomIn->append(anim);
+
+ i++;
+ }
+
+ if (!currentNode.isNull() && i == maxExamples){
+ // We need another menu, so register for 'more' and 'back' buttons
+ ++menuIndex;
+ this->info[currentMenu]["more"] = name + QLatin1String(" -menu") + QString::number(menuIndex);
+ currentMenu = name + QLatin1String(" -menu") + QString::number(menuIndex);
+ this->info[currentMenu]["back"] = name + QLatin1String(" -menu") + QString::number(menuIndex - 1);
+ }
+ }
+}
+
+
+void MenuManager::createLowLeftButton(const QString &label, BUTTON_TYPE type,
+ Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString)
+{
+ TextButton *button = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL);
+ if (!menuString.isNull())
+ button->setMenuString(menuString);
+ button->setRecursiveVisible(false);
+ button->setZValue(10);
+
+ qreal iw = button->sceneBoundingRect().width();
+ int xOffset = 15;
+
+ // create in-animation:
+ DemoItemAnimation *buttonIn = new DemoItemAnimation(button, DemoItemAnimation::ANIM_IN);
+ buttonIn->setDuration(1800 * Colors::animSpeedButtons);
+ buttonIn->setStartPos(QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35));
+ buttonIn->setPosAt(0.5, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 35));
+ buttonIn->setPosAt(0.7, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ buttonIn->setPosAt(1.0, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ movieIn->append(buttonIn);
+
+ // create out-animation:
+ DemoItemAnimation *buttonOut = new DemoItemAnimation(button, DemoItemAnimation::ANIM_OUT);
+ buttonOut->hideOnFinished = true;
+ buttonOut->setDuration(400 * Colors::animSpeedButtons);
+ buttonOut->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ buttonOut->setPosAt(1.0, QPointF(-iw, Colors::contentStartY + Colors::contentHeight - 26));
+ movieOut->append(buttonOut);
+
+ if (movieShake){
+ DemoItemAnimation *shakeAnim = new DemoItemAnimation(button, DemoItemAnimation::ANIM_UNSPECIFIED);
+ shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ shakeAnim->setDuration(650);
+ shakeAnim->setStartPos(buttonIn->posAt(1.0f));
+ shakeAnim->setPosAt(0.60, buttonIn->posAt(1.0f));
+ shakeAnim->setPosAt(0.70, buttonIn->posAt(1.0f) + QPointF(-3, 0));
+ shakeAnim->setPosAt(0.80, buttonIn->posAt(1.0f) + QPointF(2, 0));
+ shakeAnim->setPosAt(0.90, buttonIn->posAt(1.0f) + QPointF(-1, 0));
+ shakeAnim->setPosAt(1.00, buttonIn->posAt(1.0f));
+ movieShake->append(shakeAnim);
+ }
+}
+
+void MenuManager::createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/)
+{
+ TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL);
+ item->setRecursiveVisible(false);
+ item->setZValue(10);
+
+ qreal sw = this->window->scene->sceneRect().width();
+ int xOffset = 70;
+
+ // create in-animation:
+ DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ anim->setDuration(1800 * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.5, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.7, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(1.0, QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26));
+ movieIn->append(anim);
+
+ // create out-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ anim->hideOnFinished = true;
+ anim->setDuration(400 * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset + 535, Colors::contentStartY + Colors::contentHeight - 26));
+ anim->setPosAt(1.0, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 26));
+ movieOut->append(anim);
+}
+
+void MenuManager::createLowRightLeafButton(const QString &label, int xOffset, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/)
+{
+ TextButton *item = new TextButton(label, TextButton::RIGHT, type, this->window->scene, 0, TextButton::PANEL);
+ item->setRecursiveVisible(false);
+ item->setZValue(10);
+
+ qreal sw = this->window->scene->sceneRect().width();
+ qreal sh = this->window->scene->sceneRect().height();
+
+ // create in-animation:
+ DemoItemAnimation *anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ anim->setDuration(1050 * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.10, QPointF(sw, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.30, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.35, QPointF(xOffset + 30, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.40, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.45, QPointF(xOffset + 5, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(0.50, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 35));
+ anim->setPosAt(1.00, QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ movieIn->append(anim);
+
+ // create out-animation:
+ anim = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ anim->hideOnFinished = true;
+ anim->setDuration(300 * Colors::animSpeedButtons);
+ anim->setStartPos(QPointF(xOffset, Colors::contentStartY + Colors::contentHeight - 26));
+ anim->setPosAt(1.0, QPointF(xOffset, sh));
+ movieOut->append(anim);
+}
+
+void MenuManager::createInfo(DemoItem *item, const QString &name)
+{
+ Movie *movie_in = this->score->insertMovie(name);
+ Movie *movie_out = this->score->insertMovie(name + " -out");
+ item->setZValue(8);
+ item->setRecursiveVisible(false);
+
+ float xOffset = 230.0f;
+ DemoItemAnimation *infoIn = new DemoItemAnimation(item, DemoItemAnimation::ANIM_IN);
+ infoIn->timeline->setCurveShape(QTimeLine::LinearCurve);
+ infoIn->setDuration(650);
+ infoIn->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY));
+ infoIn->setPosAt(0.60, QPointF(xOffset, Colors::contentStartY));
+ infoIn->setPosAt(0.70, QPointF(xOffset + 20, Colors::contentStartY));
+ infoIn->setPosAt(0.80, QPointF(xOffset, Colors::contentStartY));
+ infoIn->setPosAt(0.90, QPointF(xOffset + 7, Colors::contentStartY));
+ infoIn->setPosAt(1.00, QPointF(xOffset, Colors::contentStartY));
+ movie_in->append(infoIn);
+
+ DemoItemAnimation *infoOut = new DemoItemAnimation(item, DemoItemAnimation::ANIM_OUT);
+ infoOut->timeline->setCurveShape(QTimeLine::EaseInCurve);
+ infoOut->setDuration(300);
+ infoOut->hideOnFinished = true;
+ infoOut->setStartPos(QPointF(xOffset, Colors::contentStartY));
+ infoOut->setPosAt(1.0, QPointF(-600, Colors::contentStartY));
+ movie_out->append(infoOut);
+}
+
+void MenuManager::createTicker()
+{
+ if (!Colors::noTicker){
+ Movie *movie_in = this->score->insertMovie("ticker");
+ Movie *movie_out = this->score->insertMovie("ticker -out");
+ Movie *movie_activate = this->score->insertMovie("ticker -activate");
+ Movie *movie_deactivate = this->score->insertMovie("ticker -deactivate");
+
+ this->ticker = new ItemCircleAnimation(this->window->scene, 0);
+ this->ticker->setZValue(50);
+ this->ticker->hide();
+
+ // Move ticker in:
+ int qtendpos = 485;
+ int qtPosY = 120;
+ this->tickerInAnim = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_IN);
+ this->tickerInAnim->setDuration(500);
+ this->tickerInAnim->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY + qtPosY));
+ this->tickerInAnim->setPosAt(0.60, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ this->tickerInAnim->setPosAt(0.70, QPointF(qtendpos + 30, Colors::contentStartY + qtPosY));
+ this->tickerInAnim->setPosAt(0.80, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ this->tickerInAnim->setPosAt(0.90, QPointF(qtendpos + 5, Colors::contentStartY + qtPosY));
+ this->tickerInAnim->setPosAt(1.00, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ movie_in->append(this->tickerInAnim);
+
+ // Move ticker out:
+ DemoItemAnimation *qtOut = new DemoItemAnimation(this->ticker, DemoItemAnimation::ANIM_OUT);
+ qtOut->hideOnFinished = true;
+ qtOut->setDuration(500);
+ qtOut->setStartPos(QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ qtOut->setPosAt(1.00, QPointF(this->window->scene->sceneRect().width() + 700, Colors::contentStartY + qtPosY));
+ movie_out->append(qtOut);
+
+ // Move ticker in on activate:
+ DemoItemAnimation *qtActivate = new DemoItemAnimation(this->ticker);
+ qtActivate->setDuration(400);
+ qtActivate->setStartPos(QPointF(this->window->scene->sceneRect().width(), Colors::contentStartY + qtPosY));
+ qtActivate->setPosAt(0.60, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ qtActivate->setPosAt(0.70, QPointF(qtendpos + 30, Colors::contentStartY + qtPosY));
+ qtActivate->setPosAt(0.80, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ qtActivate->setPosAt(0.90, QPointF(qtendpos + 5, Colors::contentStartY + qtPosY));
+ qtActivate->setPosAt(1.00, QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ movie_activate->append(qtActivate);
+
+ // Move ticker out on deactivate:
+ DemoItemAnimation *qtDeactivate = new DemoItemAnimation(this->ticker);
+ qtDeactivate->hideOnFinished = true;
+ qtDeactivate->setDuration(400);
+ qtDeactivate->setStartPos(QPointF(qtendpos, Colors::contentStartY + qtPosY));
+ qtDeactivate->setPosAt(1.00, QPointF(qtendpos, 800));
+ movie_deactivate->append(qtDeactivate);
+ }
+}
+
+void MenuManager::createUpnDownButtons()
+{
+ float xOffset = 15.0f;
+ float yOffset = 450.0f;
+
+ this->upButton = new TextButton("", TextButton::LEFT, MenuManager::UP, this->window->scene, 0, TextButton::UP);
+ this->upButton->prepare();
+ this->upButton->setPos(xOffset, yOffset);
+ this->upButton->setState(TextButton::DISABLED);
+
+ this->downButton = new TextButton("", TextButton::LEFT, MenuManager::DOWN, this->window->scene, 0, TextButton::DOWN);
+ this->downButton->prepare();
+ this->downButton->setPos(xOffset + 10 + this->downButton->sceneBoundingRect().width(), yOffset);
+
+ Movie *movieShake = this->score->insertMovie("upndown -shake");
+
+ DemoItemAnimation *shakeAnim = new DemoItemAnimation(this->upButton, DemoItemAnimation::ANIM_UNSPECIFIED);
+ shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ shakeAnim->setDuration(650);
+ shakeAnim->setStartPos(this->upButton->pos());
+ shakeAnim->setPosAt(0.60, this->upButton->pos());
+ shakeAnim->setPosAt(0.70, this->upButton->pos() + QPointF(-2, 0));
+ shakeAnim->setPosAt(0.80, this->upButton->pos() + QPointF(1, 0));
+ shakeAnim->setPosAt(0.90, this->upButton->pos() + QPointF(-1, 0));
+ shakeAnim->setPosAt(1.00, this->upButton->pos());
+ movieShake->append(shakeAnim);
+
+ shakeAnim = new DemoItemAnimation(this->downButton, DemoItemAnimation::ANIM_UNSPECIFIED);
+ shakeAnim->timeline->setCurveShape(QTimeLine::LinearCurve);
+ shakeAnim->setDuration(650);
+ shakeAnim->setStartPos(this->downButton->pos());
+ shakeAnim->setPosAt(0.60, this->downButton->pos());
+ shakeAnim->setPosAt(0.70, this->downButton->pos() + QPointF(-5, 0));
+ shakeAnim->setPosAt(0.80, this->downButton->pos() + QPointF(-3, 0));
+ shakeAnim->setPosAt(0.90, this->downButton->pos() + QPointF(-1, 0));
+ shakeAnim->setPosAt(1.00, this->downButton->pos());
+ movieShake->append(shakeAnim);
+}
+
+void MenuManager::createBackButton()
+{
+ Movie *backIn = this->score->insertMovie("back -in");
+ Movie *backOut = this->score->insertMovie("back -out");
+ Movie *backShake = this->score->insertMovie("back -shake");
+ createLowLeftButton(QLatin1String("Back"), ROOT, backIn, backOut, backShake, Colors::rootMenuName);
+}
diff --git a/demos/qtdemo/menumanager.h b/demos/qtdemo/menumanager.h
new file mode 100644
index 0000000000..3a12c54215
--- /dev/null
+++ b/demos/qtdemo/menumanager.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MENU_MANAGER_H
+#define MENU_MANAGER_H
+
+#include <QtGui>
+#include <QtXml>
+#include <QtHelp/QHelpEngineCore>
+
+#include "score.h"
+#include "textbutton.h"
+#include "mainwindow.h"
+#include "itemcircleanimation.h"
+
+typedef QHash<QString, QString> StringHash;
+typedef QHash<QString, StringHash> HashHash;
+
+class TextButton;
+
+class MenuManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum BUTTON_TYPE {ROOT, MENU1, MENU2, LAUNCH, DOCUMENTATION, QUIT, FULLSCREEN, UP, DOWN, BACK};
+
+ // singleton pattern:
+ static MenuManager *instance();
+ virtual ~MenuManager();
+
+ void init(MainWindow *window);
+ void itemSelected(int userCode, const QString &menuName = "");
+
+ QByteArray getHtml(const QString &name);
+ QByteArray getImage(const QString &name);
+ QString resolveExeFile(const QString &name);
+ QString resolveDocUrl(const QString &name);
+ QString resolveImageUrl(const QString &name);
+ QString resolveDataDir(const QString &name);
+
+ HashHash info;
+ ItemCircleAnimation *ticker;
+ MainWindow *window;
+ Score *score;
+ int currentMenuCode;
+
+private slots:
+ void exampleFinished();
+ void exampleError(QProcess::ProcessError error);
+
+private:
+ // singleton pattern:
+ MenuManager();
+ static MenuManager *pInstance;
+
+ QByteArray getResource(const QString &name);
+
+ void readXmlDocument();
+ void initHelpEngine();
+ void getDocumentationDir();
+ void readInfoAboutExample(const QDomElement &example);
+ void showDocInAssistant(const QString &docFile);
+ void launchExample(const QString &uniqueName);
+
+ void createMenu(const QDomElement &category, BUTTON_TYPE type);
+ void createLowLeftButton(const QString &label, BUTTON_TYPE type,
+ Movie *movieIn, Movie *movieOut, Movie *movieShake, const QString &menuString = QString());
+ void createLowRightButton(const QString &label, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie *movieShake);
+ void createLowRightLeafButton(const QString &label, int pos, BUTTON_TYPE type, Movie *movieIn, Movie *movieOut, Movie * /*movieShake*/);
+ void createRootMenu(const QDomElement &el);
+ void createSubMenu(const QDomElement &el);
+ void createLeafMenu(const QDomElement &el);
+ void createInfo(DemoItem *item, const QString &name);
+ void createTicker();
+ void createUpnDownButtons();
+ void createBackButton();
+
+ QDomDocument *contentsDoc;
+ QProcess assistantProcess;
+ QString currentMenu;
+ QString currentCategory;
+ QString currentMenuButtons;
+ QString currentInfo;
+ QString helpRootUrl;
+ DemoItemAnimation *tickerInAnim;
+ QDir docDir;
+ QDir imgDir;
+ QHelpEngineCore *helpEngine;
+
+ TextButton *upButton;
+ TextButton *downButton;
+};
+
+#endif // MENU_MANAGER_H
+
diff --git a/demos/qtdemo/qtdemo.icns b/demos/qtdemo/qtdemo.icns
new file mode 100644
index 0000000000..def5f0e1bc
--- /dev/null
+++ b/demos/qtdemo/qtdemo.icns
Binary files differ
diff --git a/demos/qtdemo/qtdemo.ico b/demos/qtdemo/qtdemo.ico
new file mode 100644
index 0000000000..016c77f018
--- /dev/null
+++ b/demos/qtdemo/qtdemo.ico
Binary files differ
diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro
new file mode 100644
index 0000000000..2534b752c9
--- /dev/null
+++ b/demos/qtdemo/qtdemo.pro
@@ -0,0 +1,72 @@
+CONFIG += assistant help x11inc
+TARGET = qtdemo
+DESTDIR = $$QT_BUILD_TREE/bin
+OBJECTS_DIR = .obj
+MOC_DIR = .moc
+INSTALLS += target sources
+QT += xml network
+
+contains(QT_CONFIG, opengl) {
+ DEFINES += QT_OPENGL_SUPPORT
+ QT += opengl
+}
+
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+
+RESOURCES = qtdemo.qrc
+HEADERS = mainwindow.h \
+ demoscene.h \
+ demoitem.h \
+ score.h \
+ demoitemanimation.h \
+ itemcircleanimation.h \
+ demotextitem.h \
+ headingitem.h \
+ dockitem.h \
+ scanitem.h \
+ letteritem.h \
+ examplecontent.h \
+ menucontent.h \
+ guide.h \
+ guideline.h \
+ guidecircle.h \
+ menumanager.h \
+ colors.h \
+ textbutton.h \
+ imageitem.h
+SOURCES = main.cpp \
+ demoscene.cpp \
+ mainwindow.cpp \
+ demoitem.cpp \
+ score.cpp \
+ demoitemanimation.cpp \
+ itemcircleanimation.cpp \
+ demotextitem.cpp \
+ headingitem.cpp \
+ dockitem.cpp \
+ scanitem.cpp \
+ letteritem.cpp \
+ examplecontent.cpp \
+ menucontent.cpp \
+ guide.cpp \
+ guideline.cpp \
+ guidecircle.cpp \
+ menumanager.cpp \
+ colors.cpp \
+ textbutton.cpp \
+ imageitem.cpp
+
+win32:RC_FILE = qtdemo.rc
+mac {
+ICON = qtdemo.icns
+QMAKE_INFO_PLIST = Info_mac.plist
+}
+
+# install
+target.path = $$[QT_INSTALL_BINS]
+sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES qtdemo.pro images xml *.ico *.icns *.rc *.plist
+sources.path = $$[QT_INSTALL_DEMOS]/qtdemo
+
diff --git a/demos/qtdemo/qtdemo.qrc b/demos/qtdemo/qtdemo.qrc
new file mode 100644
index 0000000000..b30dd5894e
--- /dev/null
+++ b/demos/qtdemo/qtdemo.qrc
@@ -0,0 +1,8 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>xml/examples.xml</file>
+ <file>images/qtlogo_small.png</file>
+ <file>images/trolltech-logo.png</file>
+ <file>images/demobg.png</file>
+</qresource>
+</RCC>
diff --git a/demos/qtdemo/qtdemo.rc b/demos/qtdemo/qtdemo.rc
new file mode 100644
index 0000000000..4cf2a63aca
--- /dev/null
+++ b/demos/qtdemo/qtdemo.rc
@@ -0,0 +1,2 @@
+IDI_ICON1 ICON DISCARDABLE "qtdemo.ico"
+
diff --git a/demos/qtdemo/scanitem.cpp b/demos/qtdemo/scanitem.cpp
new file mode 100644
index 0000000000..0eab840b92
--- /dev/null
+++ b/demos/qtdemo/scanitem.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "scanitem.h"
+#include "colors.h"
+
+#define ITEM_WIDTH 16
+#define ITEM_HEIGHT 16
+
+ScanItem::ScanItem(QGraphicsScene *scene, QGraphicsItem *parent)
+ : DemoItem(scene, parent)
+{
+ useSharedImage(QString(__FILE__));
+}
+
+ScanItem::~ScanItem()
+{
+}
+
+QImage *ScanItem::createImage(const QMatrix &matrix) const
+{
+ QRect scaledRect = matrix.mapRect(QRect(0, 0, ITEM_WIDTH, ITEM_HEIGHT));
+ QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.setRenderHint(QPainter::Antialiasing);
+
+ if (Colors::useEightBitPalette){
+ painter.setPen(QPen(QColor(100, 100, 100), 2));
+ painter.setBrush(QColor(206, 246, 117));
+ painter.drawEllipse(1, 1, scaledRect.width()-2, scaledRect.height()-2);
+ }
+ else {
+ painter.setPen(QPen(QColor(0, 0, 0, 15), 1));
+// painter.setBrush(QColor(206, 246, 117, 150));
+ painter.setBrush(QColor(0, 0, 0, 15));
+ painter.drawEllipse(1, 1, scaledRect.width()-2, scaledRect.height()-2);
+ }
+ return image;
+}
+
+
diff --git a/demos/qtdemo/scanitem.h b/demos/qtdemo/scanitem.h
new file mode 100644
index 0000000000..b0b5ffcb27
--- /dev/null
+++ b/demos/qtdemo/scanitem.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SCAN_ITEM_H
+#define SCAN_ITEM_H
+
+#include <QtGui>
+#include "demoitem.h"
+
+class ScanItem : public DemoItem
+{
+public:
+ ScanItem(QGraphicsScene *scene = 0, QGraphicsItem *parent = 0);
+ virtual ~ScanItem();
+
+protected:
+ QImage *createImage(const QMatrix &matrix) const;
+
+};
+
+#endif // SCAN_ITEM_H
+
diff --git a/demos/qtdemo/score.cpp b/demos/qtdemo/score.cpp
new file mode 100644
index 0000000000..f45ba0d790
--- /dev/null
+++ b/demos/qtdemo/score.cpp
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "score.h"
+#include "colors.h"
+#include "demoitem.h"
+
+Score::Score()
+{
+}
+
+Score::~Score()
+{
+ // NB! Deleting all movies.
+ qDeleteAll(this->index);
+}
+
+void Score::prepare(Movie *movie, RUN_MODE runMode, LOCK_MODE lockMode)
+{
+ if (lockMode == LOCK_ITEMS){
+ for (int i=0; i<movie->size(); ++i){
+ if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->demoItem()->isVisible())
+ continue;
+ movie->at(i)->lockItem(true);
+ movie->at(i)->prepare();
+ }
+ }
+ else if (lockMode == UNLOCK_ITEMS){
+ for (int i=0; i<movie->size(); ++i){
+ if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->demoItem()->isVisible())
+ continue;
+ movie->at(i)->lockItem(false);
+ movie->at(i)->prepare();
+ }
+ }
+ else {
+ for (int i=0; i<movie->size(); ++i){
+ if (runMode == ONLY_IF_VISIBLE && !movie->at(i)->demoItem()->isVisible())
+ continue;
+ movie->at(i)->prepare();
+ }
+ }
+}
+
+void Score::play(Movie *movie, RUN_MODE runMode)
+{
+ if (runMode == NEW_ANIMATION_ONLY){
+ for (int i=0; i<movie->size(); ++i)
+ if (movie->at(i)->notOwnerOfItem())
+ movie->at(i)->play(true);
+ }
+ else if (runMode == ONLY_IF_VISIBLE){
+ for (int i=0; i<movie->size(); ++i)
+ if (movie->at(i)->demoItem()->isVisible())
+ movie->at(i)->play(runMode == FROM_START);
+ }
+ else {
+ for (int i=0; i<movie->size(); ++i)
+ movie->at(i)->play(runMode == FROM_START);
+ }
+}
+
+void Score::playMovie(const QString &indexName, RUN_MODE runMode, LOCK_MODE lockMode)
+{
+ MovieIndex::iterator movieIterator = this->index.find(indexName);
+ if (movieIterator == this->index.end())
+ return;
+
+ Movie *movie = *movieIterator;
+ this->prepare(movie, runMode, lockMode);
+ this->play(movie, runMode);
+}
+
+void Score::queueMovie(const QString &indexName, RUN_MODE runMode, LOCK_MODE lockMode)
+{
+ MovieIndex::iterator movieIterator = this->index.find(indexName);
+ if (movieIterator == this->index.end()){
+ if (Colors::verbose)
+ qDebug() << "Queuing movie:" << indexName << "(does not exist)";
+ return;
+ }
+
+ Movie *movie = *movieIterator;
+ this->prepare(movie, runMode, lockMode);
+ this->playList.append(PlayListMember(movie, int(runMode)));
+ if (Colors::verbose)
+ qDebug() << "Queuing movie:" << indexName;
+}
+
+void Score::playQue()
+{
+ int movieCount = this->playList.size();
+ for (int i=0; i<movieCount; i++)
+ this->play(this->playList.at(i).movie, RUN_MODE(this->playList.at(i).runMode));
+ this->playList.clear();
+ if (Colors::verbose)
+ qDebug() << "********* Playing que *********";
+}
+
+void Score::insertMovie(const QString &indexName, Movie *movie)
+{
+ this->index.insert(indexName, movie);
+}
+
+Movie *Score::insertMovie(const QString &indexName)
+{
+ Movie *movie = new Movie();
+ insertMovie(indexName, movie);
+ return movie;
+}
+
diff --git a/demos/qtdemo/score.h b/demos/qtdemo/score.h
new file mode 100644
index 0000000000..bfed5d2888
--- /dev/null
+++ b/demos/qtdemo/score.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SCORE_H
+#define SCORE_H
+
+#include <QList>
+#include <QHash>
+#include "demoitemanimation.h"
+
+typedef QList<DemoItemAnimation *> Movie;
+typedef QHash<QString, Movie*> MovieIndex;
+
+class PlayListMember
+{
+public:
+ PlayListMember(Movie *movie, int runMode) : movie(movie), runMode(runMode){};
+ Movie *movie;
+ int runMode;
+};
+typedef QList<PlayListMember> PlayList;
+
+class Score
+{
+public:
+ enum LOCK_MODE {LOCK_ITEMS, UNLOCK_ITEMS, SKIP_LOCK};
+ enum RUN_MODE {FROM_CURRENT, FROM_START, NEW_ANIMATION_ONLY, ONLY_IF_VISIBLE};
+
+ Score();
+ virtual ~Score();
+
+ void playMovie(const QString &indexName, RUN_MODE runMode = FROM_START, LOCK_MODE lockMode = SKIP_LOCK);
+ void insertMovie(const QString &indexName, Movie *movie);
+ Movie *insertMovie(const QString &indexName);
+ void queueMovie(const QString &indexName, RUN_MODE runMode = FROM_START, LOCK_MODE lockMode = SKIP_LOCK);
+ void playQue();
+ bool hasQueuedMovies(){ return this->playList.size() > 0; };
+
+ MovieIndex index;
+ PlayList playList;
+
+private:
+ void prepare(Movie *movie, RUN_MODE runMode, LOCK_MODE lockMode);
+ void play(Movie *movie, RUN_MODE runMode);
+};
+
+#endif // SCORE_H
+
diff --git a/demos/qtdemo/textbutton.cpp b/demos/qtdemo/textbutton.cpp
new file mode 100644
index 0000000000..96e1a23085
--- /dev/null
+++ b/demos/qtdemo/textbutton.cpp
@@ -0,0 +1,384 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textbutton.h"
+#include "demoitemanimation.h"
+#include "demotextitem.h"
+#include "colors.h"
+#include "menumanager.h"
+
+#define BUTTON_WIDTH 180
+#define BUTTON_HEIGHT 19
+
+class ButtonBackground : public DemoItem
+{
+public:
+ TextButton::BUTTONTYPE type;
+ bool highlighted;
+ bool pressed;
+ QSize logicalSize;
+
+ ButtonBackground(TextButton::BUTTONTYPE type, bool highlighted, bool pressed, QSize logicalSize,
+ QGraphicsScene *scene, QGraphicsItem *parent) : DemoItem(scene, parent)
+ {
+ this->type = type;
+ this->highlighted = highlighted;
+ this->pressed = pressed;
+ this->logicalSize = logicalSize;
+ useSharedImage(QString(__FILE__) + static_cast<int>(type) + highlighted + pressed);
+ }
+
+protected:
+ QImage *createImage(const QMatrix &matrix) const
+ {
+ if (type == TextButton::SIDEBAR || type == TextButton::PANEL)
+ return createRoundButtonBackground(matrix);
+ else
+ return createArrowBackground(matrix);
+ }
+
+ QImage *createRoundButtonBackground(const QMatrix &matrix) const
+ {
+ QRect scaledRect;
+ scaledRect = matrix.mapRect(QRect(0, 0, this->logicalSize.width(), this->logicalSize.height()));
+
+ QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.setRenderHint(QPainter::SmoothPixmapTransform);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::NoPen);
+
+ if (Colors::useEightBitPalette){
+ painter.setPen(QColor(120, 120, 120));
+ if (this->pressed)
+ painter.setBrush(QColor(60, 60, 60));
+ else if (this->highlighted)
+ painter.setBrush(QColor(100, 100, 100));
+ else
+ painter.setBrush(QColor(80, 80, 80));
+ }
+ else {
+ QLinearGradient outlinebrush(0, 0, 0, scaledRect.height());
+ QLinearGradient brush(0, 0, 0, scaledRect.height());
+
+ brush.setSpread(QLinearGradient::PadSpread);
+ QColor highlight(255, 255, 255, 70);
+ QColor shadow(0, 0, 0, 70);
+ QColor sunken(220, 220, 220, 30);
+ QColor normal1(255, 255, 245, 60);
+ QColor normal2(255, 255, 235, 10);
+
+ if (this->type == TextButton::PANEL){
+ normal1 = QColor(200, 170, 160, 50);
+ normal2 = QColor(50, 10, 0, 50);
+ }
+
+ if (pressed) {
+ outlinebrush.setColorAt(0.0f, shadow);
+ outlinebrush.setColorAt(1.0f, highlight);
+ brush.setColorAt(0.0f, sunken);
+ painter.setPen(Qt::NoPen);
+ } else {
+ outlinebrush.setColorAt(1.0f, shadow);
+ outlinebrush.setColorAt(0.0f, highlight);
+ brush.setColorAt(0.0f, normal1);
+ if (!this->highlighted)
+ brush.setColorAt(1.0f, normal2);
+ painter.setPen(QPen(outlinebrush, 1));
+ }
+ painter.setBrush(brush);
+ }
+
+ if (this->type == TextButton::PANEL)
+ painter.drawRect(0, 0, scaledRect.width(), scaledRect.height());
+ else
+ painter.drawRoundedRect(0, 0, scaledRect.width(), scaledRect.height(), 10, 90, Qt::RelativeSize);
+ return image;
+ }
+
+ QImage *createArrowBackground(const QMatrix &matrix) const
+ {
+ QRect scaledRect;
+ scaledRect = matrix.mapRect(QRect(0, 0, this->logicalSize.width(), this->logicalSize.height()));
+
+ QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
+ image->fill(QColor(0, 0, 0, 0).rgba());
+ QPainter painter(image);
+ painter.setRenderHint(QPainter::SmoothPixmapTransform);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::NoPen);
+
+ if (Colors::useEightBitPalette){
+ painter.setPen(QColor(120, 120, 120));
+ if (this->pressed)
+ painter.setBrush(QColor(60, 60, 60));
+ else if (this->highlighted)
+ painter.setBrush(QColor(100, 100, 100));
+ else
+ painter.setBrush(QColor(80, 80, 80));
+ }
+ else {
+ QLinearGradient outlinebrush(0, 0, 0, scaledRect.height());
+ QLinearGradient brush(0, 0, 0, scaledRect.height());
+
+ brush.setSpread(QLinearGradient::PadSpread);
+ QColor highlight(255, 255, 255, 70);
+ QColor shadow(0, 0, 0, 70);
+ QColor sunken(220, 220, 220, 30);
+ QColor normal1 = QColor(200, 170, 160, 50);
+ QColor normal2 = QColor(50, 10, 0, 50);
+
+ if (pressed) {
+ outlinebrush.setColorAt(0.0f, shadow);
+ outlinebrush.setColorAt(1.0f, highlight);
+ brush.setColorAt(0.0f, sunken);
+ painter.setPen(Qt::NoPen);
+ } else {
+ outlinebrush.setColorAt(1.0f, shadow);
+ outlinebrush.setColorAt(0.0f, highlight);
+ brush.setColorAt(0.0f, normal1);
+ if (!this->highlighted)
+ brush.setColorAt(1.0f, normal2);
+ painter.setPen(QPen(outlinebrush, 1));
+ }
+ painter.setBrush(brush);
+ }
+
+ painter.drawRect(0, 0, scaledRect.width(), scaledRect.height());
+
+ float xOff = scaledRect.width() / 2;
+ float yOff = scaledRect.height() / 2;
+ float sizex = 3.0f * matrix.m11();
+ float sizey = 1.5f * matrix.m22();
+ if (this->type == TextButton::UP)
+ sizey *= -1;
+ QPainterPath path;
+ path.moveTo(xOff, yOff + (5 * sizey));
+ path.lineTo(xOff - (4 * sizex), yOff - (3 * sizey));
+ path.lineTo(xOff + (4 * sizex), yOff - (3 * sizey));
+ path.lineTo(xOff, yOff + (5 * sizey));
+ painter.drawPath(path);
+
+ return image;
+ }
+
+};
+
+TextButton::TextButton(const QString &text, ALIGNMENT align, int userCode,
+ QGraphicsScene *scene, QGraphicsItem *parent, BUTTONTYPE type)
+ : DemoItem(scene, parent)
+{
+ this->menuString = text;
+ this->buttonLabel = text;
+ this->alignment = align;
+ this->buttonType = type;
+ this->userCode = userCode;
+ this->bgOn = 0;
+ this->bgOff = 0;
+ this->bgHighlight = 0;
+ this->bgDisabled = 0;
+ this->state = OFF;
+
+ this->setAcceptsHoverEvents(true);
+ this->setCursor(Qt::PointingHandCursor);
+
+ // Calculate button size:
+ const int w = 180;
+ const int h = 19;
+ if (type == SIDEBAR || type == PANEL)
+ this->logicalSize = QSize(w, h);
+ else
+ this->logicalSize = QSize(int((w / 2.0f) - 5), int(h * 1.5f));
+}
+
+void TextButton::setMenuString(const QString &menu)
+{
+ this->menuString = menu;
+}
+
+void TextButton::prepare()
+{
+ if (!this->prepared){
+ this->prepared = true;
+ this->setupHoverText();
+ this->setupScanItem();
+ this->setupButtonBg();
+ }
+}
+
+TextButton::~TextButton()
+{
+ if (this->prepared){
+ if (Colors::useButtonBalls)
+ delete this->scanAnim;
+ }
+}
+
+QRectF TextButton::boundingRect() const
+{
+ return QRectF(0, 0, this->logicalSize.width(), this->logicalSize.height());
+};
+
+void TextButton::setupHoverText()
+{
+ if (this->buttonLabel.isEmpty())
+ return;
+
+ DemoTextItem *textItem = new DemoTextItem(this->buttonLabel, Colors::buttonFont(), Colors::buttonText, -1, this->scene(), this);
+ textItem->setZValue(zValue() + 2);
+ textItem->setPos(16, 0);
+}
+
+void TextButton::setupScanItem()
+{
+ if (Colors::useButtonBalls){
+ ScanItem *scanItem = new ScanItem(0, this);
+ scanItem->setZValue(zValue() + 1);
+
+ this->scanAnim = new DemoItemAnimation(scanItem);
+ this->scanAnim->timeline->setLoopCount(1);
+
+ float x = 1;
+ float y = 1.5f;
+ float stop = BUTTON_WIDTH - scanItem->boundingRect().width() - x;
+ if (this->alignment == LEFT){
+ this->scanAnim->setDuration(2500);
+ this->scanAnim->setPosAt(0.0, QPointF(x, y));
+ this->scanAnim->setPosAt(0.5, QPointF(x, y));
+ this->scanAnim->setPosAt(0.7, QPointF(stop, y));
+ this->scanAnim->setPosAt(1.0, QPointF(x, y));
+ scanItem->setPos(QPointF(x, y));
+ }
+ else {
+ this->scanAnim->setPosAt(0.0, QPointF(stop, y));
+ this->scanAnim->setPosAt(0.5, QPointF(x, y));
+ this->scanAnim->setPosAt(1.0, QPointF(stop, y));
+ scanItem->setPos(QPointF(stop, y));
+ }
+ }
+}
+
+void TextButton::setState(STATE state)
+{
+ this->state = state;
+ this->bgOn->setRecursiveVisible(state == ON);
+ this->bgOff->setRecursiveVisible(state == OFF);
+ this->bgHighlight->setRecursiveVisible(state == HIGHLIGHT);
+ this->bgDisabled->setRecursiveVisible(state == DISABLED);
+ this->setCursor(state == DISABLED ? Qt::ArrowCursor : Qt::PointingHandCursor);
+
+}
+
+void TextButton::setupButtonBg()
+{
+ this->bgOn = new ButtonBackground(this->buttonType, true, true, this->logicalSize, this->scene(), this);
+ this->bgOff = new ButtonBackground(this->buttonType, false, false, this->logicalSize, this->scene(), this);
+ this->bgHighlight = new ButtonBackground(this->buttonType, true, false, this->logicalSize, this->scene(), this);
+ this->bgDisabled = new ButtonBackground(this->buttonType, true, true, this->logicalSize, this->scene(), this);
+ this->setState(OFF);
+}
+
+void TextButton::hoverEnterEvent(QGraphicsSceneHoverEvent *)
+{
+ if (this->locked || this->state == DISABLED)
+ return;
+
+ if (this->state == OFF){
+ this->setState(HIGHLIGHT);
+
+ if (Colors::noAnimations && Colors::useButtonBalls){
+ // wait a bit in the beginning
+ // to enhance the effect. Have to this here
+ // so that the adaption can be dynamic
+ this->scanAnim->setDuration(1000);
+ this->scanAnim->setPosAt(0.2, this->scanAnim->posAt(0));
+ }
+
+ if (MenuManager::instance()->window->fpsMedian > 10
+ || Colors::noAdapt
+ || Colors::noTimerUpdate){
+ if (Colors::useButtonBalls)
+ this->scanAnim->play(true, true);
+ }
+ }
+}
+
+void TextButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+ if (this->state == DISABLED)
+ return;
+
+ this->setState(OFF);
+
+ if (Colors::noAnimations && Colors::useButtonBalls)
+ this->scanAnim->stop();
+}
+
+void TextButton::mousePressEvent(QGraphicsSceneMouseEvent *)
+{
+ if (this->state == DISABLED)
+ return;
+
+ if (this->state == HIGHLIGHT || this->state == OFF)
+ this->setState(ON);
+}
+
+void TextButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (this->state == ON){
+ this->setState(OFF);
+ if (!this->locked && this->boundingRect().contains(event->pos())){
+ MenuManager::instance()->itemSelected(this->userCode, this->menuString);
+ }
+ }
+}
+
+void TextButton::animationStarted(int)
+{
+ if (this->state == DISABLED)
+ return;
+ this->setState(OFF);
+}
+
+
+
diff --git a/demos/qtdemo/textbutton.h b/demos/qtdemo/textbutton.h
new file mode 100644
index 0000000000..b7c91fb23a
--- /dev/null
+++ b/demos/qtdemo/textbutton.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the demonstration applications 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXT_BUTTON_H
+#define TEXT_BUTTON_H
+
+#include <QtGui>
+#include "demoitem.h"
+#include "demotextitem.h"
+#include "scanitem.h"
+
+class DemoItemAnimation;
+class ButtonBackground;
+
+class TextButton : public DemoItem
+{
+public:
+ enum ALIGNMENT {LEFT, RIGHT};
+ enum BUTTONTYPE {SIDEBAR, PANEL, UP, DOWN};
+ enum STATE {ON, OFF, HIGHLIGHT, DISABLED};
+
+ TextButton(const QString &text, ALIGNMENT align = LEFT, int userCode = 0,
+ QGraphicsScene *scene = 0, QGraphicsItem *parent = 0, BUTTONTYPE color = SIDEBAR);
+ virtual ~TextButton();
+
+ // overidden methods:
+ virtual QRectF boundingRect() const;
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0){};
+ virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+ void animationStarted(int id = 0);
+ void prepare();
+ void setState(STATE state);
+ void setMenuString(const QString &menu);
+ void setDisabled(bool disabled);
+
+private:
+ void setupButtonBg();
+ void setupScanItem();
+ void setupHoverText();
+
+ DemoItemAnimation *scanAnim;
+ ButtonBackground *bgOn;
+ ButtonBackground *bgOff;
+ ButtonBackground *bgHighlight;
+ ButtonBackground *bgDisabled;
+
+ BUTTONTYPE buttonType;
+ ALIGNMENT alignment;
+ QString buttonLabel;
+ QString menuString;
+ int userCode;
+ QSize logicalSize;
+
+ STATE state;
+};
+
+#endif // TEXT_BUTTON_H
+
diff --git a/demos/qtdemo/xml/examples.xml b/demos/qtdemo/xml/examples.xml
new file mode 100644
index 0000000000..df2d93ba76
--- /dev/null
+++ b/demos/qtdemo/xml/examples.xml
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<categories name="Qt Examples and Demos">
+ <demos dirname="." docname="demos" name="Demonstrations">
+ <example filename="affine" name="Affine Transformations" />
+ <example filename="arthurplugin" name="Arthur Plugin" executable="false" />
+ <example filename="composition" name="Composition Modes" />
+ <example filename="gradients" name="Gradients" />
+ <example filename="pathstroke" name="Path Stroking" />
+ <example filename="deform" name="Vector Deformation" />
+ <example filename="books" name="Books" />
+ <example filename="mainwindow" name="Main Window" />
+ <example filename="spreadsheet" name="Spreadsheet" />
+ <example filename="sqlbrowser" name="SQL Browser" />
+ <example filename="textedit" name="Text Edit" />
+ <example filename="chip" name="40000 Chips" />
+ <example filename="embeddeddialogs" name="Embedded Dialogs" />
+ <example filename="interview" name="Interview" />
+ <example filename="browser" name="Browser" />
+ <example filename="mediaplayer" name="Media Player" />
+ <example filename="boxes" name="Boxes" />
+ </demos>
+ <category dirname="qtconcurrent" name="Concurrent Programming">
+ <example filename="map" name="Map" executable="false" />
+ <example filename="progressdialog" name="Progress Dialog" />
+ <example filename="runfunction" name="Run Function" executable="false"/>
+ <example filename="wordcount" name="Word Count" executable="false" />
+ </category>
+ <category dirname="designer" name="Qt Designer">
+ <example filename="calculatorbuilder" name="Calculator Builder" />
+ <example filename="calculatorform" name="Calculator Form" />
+ <example filename="containerextension" name="Container Extension" executable="false"/>
+ <example filename="customwidgetplugin" name="Custom Widget Plugin" executable="false" />
+ <example filename="taskmenuextension" name="Task Menu Extension" executable="false" />
+ <example filename="worldtimeclockbuilder" name="World Time Clock Builder" />
+ <example filename="worldtimeclockplugin" name="World Time Clock Plugin" executable="false"/>
+ </category>
+ <category dirname="desktop" name="Desktop">
+ <example filename="systray" name="System Tray" image="systemtray-example.png"/>
+ <example filename="screenshot" name="Screenshot" />
+ </category>
+ <category dirname="dialogs" name="Dialogs">
+ <example filename="configdialog" name="Configuration Dialog" />
+ <example filename="extension" name="Extension Dialog" />
+ <example filename="findfiles" name="Find Files Dialog" />
+ <example filename="standarddialogs" name="Standard Dialogs" />
+ <example filename="tabdialog" name="Tab Dialog" />
+ <example filename="trivialwizard" name="Trivial Wizard" image="trivialwizard-example-introduction.png"/>
+ <example filename="licensewizard" name="License Wizard" />
+ <example filename="classwizard" name="Class Wizard" />
+ </category>
+ <category dirname="draganddrop" name="Drag and Drop">
+ <example filename="draggableicons" name="Draggable Icons" />
+ <example filename="draggabletext" name="Draggable Text" />
+ <example filename="dropsite" name="Drop Site" />
+ <example filename="fridgemagnets" name="Fridge Magnets" />
+ <example filename="puzzle" name="Puzzle" image="draganddroppuzzle-example.png"/>
+ </category>
+ <category dirname="graphicsview" name="Graphics View">
+ <example filename="elasticnodes" name="Elastic Nodes" />
+ <example filename="collidingmice" name="Colliding Mice" />
+ <example filename="diagramscene" name="Diagram Scene" />
+ <example filename="dragdroprobot" name="Drag and Drop Robot" />
+ <example filename="portedcanvas" name="Ported Canvas" />
+ <example filename="portedasteroids" name="Ported Asteroids" />
+ <example filename="padnavigator" name="Pad Navigator Example" />
+ </category>
+ <category dirname="ipc" name="IPC">
+ <example filename="sharedmemory" name="Shared Memory" image="sharedmemory-example_1.png"/>
+ <example filename="localfortuneclient" name="Local Fortune Client" image="localfortuneclient-example.png"/>
+ <example filename="localfortuneserver" name="Local Fortune Server" image="localfortuneserver-example.png"/>
+ </category>
+ <category dirname="itemviews" name="Item Views">
+ <example filename="addressbook" name="Address Book" />
+ <example filename="basicsortfiltermodel" name="Basic Sort/Filter Model" />
+ <example filename="chart" name="Chart" />
+ <example filename="customsortfiltermodel" name="Custom Sort/Filter Model" />
+ <example filename="coloreditorfactory" name="Color Editor Factory" image="coloreditorfactoryimage.png"/>
+ <example filename="combowidgetmapper" name="Combo Widget Mapper" />
+ <example filename="dirview" name="Directory View" />
+ <example filename="fetchmore" name="Fetch More" />
+ <example filename="pixelator" name="Pixelator" />
+ <example filename="puzzle" name="Puzzle " image="itemviewspuzzle-example.png"/>
+ <example filename="simpledommodel" name="Simple DOM Model" />
+ <example filename="simpletreemodel" name="Simple Tree Model" />
+ <example filename="simplewidgetmapper" name="Simple Widget Mapper" />
+ <example filename="spinboxdelegate" name="Spin Box Delegate" />
+ <example filename="stardelegate" name="Star Delegate" />
+ </category>
+ <category dirname="layouts" name="Layouts">
+ <example filename="basiclayouts" name="Basic Layouts" />
+ <example filename="borderlayout" name="Border Layout" />
+ <example filename="dynamiclayouts" name="Dynamic Layouts" />
+ <example filename="flowlayout" name="Flow Layout" />
+ </category>
+ <category dirname="linguist" name="Qt Linguist">
+ <example filename="arrowpad" name="Arrow Pad" image="linguist-arrowpad_en.png"/>
+ <example filename="hellotr" name="Hello World" image="linguist-hellotr_en.png"/>
+ <example filename="trollprint" name="Troll Print" image="linguist-trollprint_10_en.png"/>
+ </category>
+ <category dirname="mainwindows" name="Main Windows">
+ <example filename="application" name="Application" />
+ <example filename="dockwidgets" name="Dock Widgets" />
+ <example filename="mdi" name="MDI" />
+ <example filename="sdi" name="SDI" />
+ <example filename="menus" name="Menus" />
+ <example filename="recentfiles" name="Recent Files" />
+ </category>
+ <category dirname="network" name="Networking">
+ <example filename="blockingfortuneclient" name="Blocking Fortune Client" />
+ <example filename="broadcastreceiver" name="Broadcast Receiver" />
+ <example filename="broadcastsender" name="Broadcast Sender" />
+ <example filename="network-chat" name="Network Chat Client" />
+ <example filename="fortuneclient" name="Fortune Client" />
+ <example filename="fortuneserver" name="Fortune Server" />
+ <example filename="ftp" changedirectory="false" name="FTP Client" />
+ <example filename="http" changedirectory="false" name="HTTP Client" />
+ <example filename="loopback" name="Loopback" />
+ <example filename="threadedfortuneserver" name="Threaded Fort. Server" />
+ <example filename="torrent" name="Torrent Client" />
+ <example filename="securesocketclient" name="Secure Socket Client" />
+ </category>
+ <category dirname="opengl" name="OpenGL">
+ <example filename="2dpainting" name="2D Painting" />
+ <example filename="framebufferobject" name="Framebuffer Object" />
+ <example filename="framebufferobject2" name="Framebuffer Object 2" />
+ <example filename="grabber" name="Grabber" />
+ <example filename="hellogl" name="Hello GL" />
+ <example filename="overpainting" name="Overpainting" />
+ <example filename="pbuffers" name="Pixel Buffers" />
+ <example filename="pbuffers2" name="Pixel Buffers 2" />
+ <example filename="samplebuffers" name="Sample Buffers" />
+ <example filename="textures" name="Textures" />
+ </category>
+ <category dirname="painting" name="Painting">
+ <example filename="basicdrawing" name="Basic Drawing" />
+ <example filename="concentriccircles" name="Concentric Circles" />
+ <example filename="fontsampler" name="Font Sampler" />
+ <example filename="imagecomposition" name="Image Composition" />
+ <example filename="painterpaths" name="Painter Paths" />
+ <example filename="svgviewer" name="SVG Viewer" />
+ <example filename="transformations" name="Transformations" />
+ </category>
+ <category dirname="phonon" name="Phonon">
+ <example filename="musicplayer" name="Music Player" />
+ </category>
+ <category dirname="richtext" name="Rich Text">
+ <example filename="calendar" name="Calendar" />
+ <example filename="orderform" name="Order Form" />
+ <example filename="syntaxhighlighter" name="Syntax Highlighter" />
+ <example filename="textobject" name="Text Object" />
+ </category>
+ <category dirname="script" name="QtScript">
+ <example filename="calculator" name="Calculator" />
+ <example filename="context2d" name="Context2D" />
+ <example filename="defaultprototypes" name="Default Prototypes" />
+ <example filename="helloscript" name="Hello Script" image="t1.png"/>
+ <example filename="qstetrix" name="QSTetrix" image="tetrix-example.png" />
+ </category>
+ <category dirname="sql" name="SQL">
+ <example filename="cachedtable" name="Cached Table" />
+ <example filename="drilldown" name="Drill Down" />
+ <example filename="querymodel" name="Query Model" />
+ <example filename="relationaltablemodel" name="Relational Table Model" />
+ <example filename="tablemodel" name="Table Model" />
+ <example filename="masterdetail" name="Music Archive" />
+ <example filename="sqlwidgetmapper" name="SQL Widget Mapper" />
+ </category>
+ <category dirname="threads" name="Threading">
+ <example filename="mandelbrot" name="Mandelbrot" />
+ </category>
+ <category dirname="tools" name="Tools">
+ <example filename="codecs" name="Codecs" />
+ <example filename="completer" name="Completer" />
+ <example filename="customcompleter" name="Custom Completer" />
+ <example filename="i18n" name="Internationalization" />
+ <example filename="plugandpaint" name="Plug and Paint" />
+ <example filename="regexp" name="Regular Expressions" />
+ <example filename="settingseditor" name="Settings Editor" />
+ <example filename="treemodelcompleter" name="Tree Model Completer" />
+ <example filename="undoframework" name="Undo Framework"/>
+ </category>
+ <category dirname="tutorials/addressbook" name="Address Book Tutorial">
+ <example filename="part1" name="Part 1" image="addressbook-tutorial-part1-screenshot.png" />
+ <example filename="part2" name="Part 2" image="addressbook-tutorial-part2-add-contact.png" />
+ <example filename="part3" name="Part 3" image="addressbook-tutorial-part3-screenshot.png" />
+ <example filename="part4" name="Part 4" image="addressbook-tutorial-screenshot.png" />
+ <example filename="part5" name="Part 5" image="addressbook-tutorial-part5-screenshot.png" />
+ <example filename="part6" name="Part 6" image="addressbook-tutorial-part6-screenshot.png" />
+ <example filename="part7" name="Part 7" image="addressbook-tutorial-part7-screenshot.png" />
+ </category>
+ <category dirname="widgets" name="Widgets">
+ <example filename="analogclock" name="Analog Clock" />
+ <example filename="calculator" name="Calculator " />
+ <example filename="calendarwidget" name="Calendar Widget" />
+ <example filename="charactermap" name="Character Map" />
+ <example filename="codeeditor" name="Code Editor" />
+ <example filename="digitalclock" name="Digital Clock" />
+ <example filename="groupbox" name="Group Box" />
+ <example filename="icons" name="Icons" />
+ <example filename="imageviewer" name="Image Viewer" />
+ <example filename="lineedits" name="Line Edits" />
+ <example filename="movie" name="Movie Player" />
+ <example filename="scribble" name="Scribble" />
+ <example filename="shapedclock" name="Shaped Clock" />
+ <example filename="sliders" name="Sliders" />
+ <example filename="spinboxes" name="Spin Boxes" />
+ <example filename="styles" name="Styles" image="styles-enabledwood.png"/>
+ <example filename="stylesheet" name="Style Sheet" image="stylesheet-coffee-plastique.png"/>
+ <example filename="tablet" name="Tablet" />
+ <example filename="tetrix" name="Tetrix " />
+ <example filename="tooltips" name="Tool Tips" />
+ <example filename="wiggly" name="Wiggly" />
+ <example filename="windowflags" name="Window Flags" />
+ </category>
+ <category dirname="xml" name="XML">
+ <example filename="saxbookmarks" name="SAX Bookmarks" />
+ <example filename="dombookmarks" name="DOM Bookmarks" />
+ <example filename="rsslisting" name="RSS-Listing" />
+ <example filename="streambookmarks" name="QXmlStream Bookmarks" image="xmlstreamexample-screenshot.png"/>
+ </category>
+ <category dirname="xmlpatterns" name="XML Patterns">
+ <example filename="recipes" name="Recipes" />
+ <example filename="qobjectxmlmodel" name="QObjectXmlModel" />
+ <example filename="filetree" name="File Tree" />
+ <example filename="trafficinfo" name="Traffic Info" />
+ </category>
+</categories>