diff options
Diffstat (limited to 'examples')
626 files changed, 20674 insertions, 849 deletions
diff --git a/examples/activeqt/activeqt.pro b/examples/activeqt/activeqt.pro index 262e1a1..db63104 100644 --- a/examples/activeqt/activeqt.pro +++ b/examples/activeqt/activeqt.pro @@ -18,3 +18,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS activeqt.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/comapp/comapp.pro b/examples/activeqt/comapp/comapp.pro index 84ce072..99b8933 100644 --- a/examples/activeqt/comapp/comapp.pro +++ b/examples/activeqt/comapp/comapp.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/comapp sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS comapp.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/comapp INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/dotnet/wrapper/lib/tools.cpp b/examples/activeqt/dotnet/wrapper/lib/tools.cpp index fa3d31b..34ce69c 100644 --- a/examples/activeqt/dotnet/wrapper/lib/tools.cpp +++ b/examples/activeqt/dotnet/wrapper/lib/tools.cpp @@ -56,6 +56,6 @@ String *QStringToString(const QString &qstring) QString StringToQString(String *string) { const wchar_t __pin *chars = PtrToStringChars(string); - return QString::fromUtf16((const ushort *)chars); + return QString::fromWCharArray(chars); } //! [1] diff --git a/examples/activeqt/hierarchy/hierarchy.pro b/examples/activeqt/hierarchy/hierarchy.pro index abe5f1b..cd1d754 100644 --- a/examples/activeqt/hierarchy/hierarchy.pro +++ b/examples/activeqt/hierarchy/hierarchy.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/hierarchy sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hierarchy.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/hierarchy INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/menus/menus.pro b/examples/activeqt/menus/menus.pro index c962b6b..f197833 100644 --- a/examples/activeqt/menus/menus.pro +++ b/examples/activeqt/menus/menus.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/menus sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS menus.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/menus INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/multiple/multiple.pro b/examples/activeqt/multiple/multiple.pro index 7b86950..9c95921 100644 --- a/examples/activeqt/multiple/multiple.pro +++ b/examples/activeqt/multiple/multiple.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/multiple sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multiple.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/multiple INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/opengl/opengl.pro b/examples/activeqt/opengl/opengl.pro index 8eb81be..978bd66 100644 --- a/examples/activeqt/opengl/opengl.pro +++ b/examples/activeqt/opengl/opengl.pro @@ -17,3 +17,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/opengl sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS opengl.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/opengl INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/qutlook/qutlook.pro b/examples/activeqt/qutlook/qutlook.pro index c1154e0..0387735 100644 --- a/examples/activeqt/qutlook/qutlook.pro +++ b/examples/activeqt/qutlook/qutlook.pro @@ -21,3 +21,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/qutlook sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qutlook.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/qutlook INSTALLS += target sources + +include($$QT_SOURCE_TREE/examples/examplebase.pri) diff --git a/examples/activeqt/simple/simple.pro b/examples/activeqt/simple/simple.pro index d0f2019..243d06a 100644 --- a/examples/activeqt/simple/simple.pro +++ b/examples/activeqt/simple/simple.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/simple sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS simple.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/simple INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/webbrowser/main.cpp b/examples/activeqt/webbrowser/main.cpp index f5507519..64c3db4 100644 --- a/examples/activeqt/webbrowser/main.cpp +++ b/examples/activeqt/webbrowser/main.cpp @@ -46,8 +46,8 @@ #include <QMainWindow> #include <QAbstractEventDispatcher> -#if defined(Q_OS_WINCE) -#include "ui_wincemainwindow.h" +#if defined(Q_WS_WINCE_WM) +#include "ui_mainwindow_windowsmobile.h" #include <windows.h> #else #include "ui_mainwindow.h" diff --git a/examples/activeqt/webbrowser/wincemainwindow.ui b/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui index 98a9ddb..98a9ddb 100644 --- a/examples/activeqt/webbrowser/wincemainwindow.ui +++ b/examples/activeqt/webbrowser/mainwindow_windowsmobile.ui diff --git a/examples/activeqt/webbrowser/webbrowser.pro b/examples/activeqt/webbrowser/webbrowser.pro index 992d871..13b1983 100644 --- a/examples/activeqt/webbrowser/webbrowser.pro +++ b/examples/activeqt/webbrowser/webbrowser.pro @@ -7,7 +7,7 @@ QTDIR_build:REQUIRES = shared HEADERS = webaxwidget.h SOURCES = main.cpp FORMS = mainwindow.ui -wince*: FORMS = wincemainwindow.ui +wincewm*: FORMS = mainwindow_windowsmobile.ui # install @@ -15,3 +15,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/webbrowser sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS webbrowser.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/webbrowser INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/activeqt/wrapper/wrapper.pro b/examples/activeqt/wrapper/wrapper.pro index 4eb6baf..a207f2e 100644 --- a/examples/activeqt/wrapper/wrapper.pro +++ b/examples/activeqt/wrapper/wrapper.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/activeqt/wrapper sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS wrapper.pro sources.path = $$[QT_INSTALL_EXAMPLES]/activeqt/wrapper INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/animation/README b/examples/animation/README new file mode 100644 index 0000000..6a892f8 --- /dev/null +++ b/examples/animation/README @@ -0,0 +1,38 @@ +The animation framework aims to provide an easy way for creating animated and +smooth GUI's. By animating Qt properties, the framework provides great freedom +for animating widgets and other QObjects. The framework can also be used with +the Graphics View framework. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/animation/animatedtiles/animatedtiles.pro b/examples/animation/animatedtiles/animatedtiles.pro new file mode 100644 index 0000000..1840b17 --- /dev/null +++ b/examples/animation/animatedtiles/animatedtiles.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp +RESOURCES = animatedtiles.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/animatedtiles +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animatedtiles.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/animatedtiles +INSTALLS += target sources diff --git a/examples/animation/animatedtiles/animatedtiles.qrc b/examples/animation/animatedtiles/animatedtiles.qrc new file mode 100644 index 0000000..c43a979 --- /dev/null +++ b/examples/animation/animatedtiles/animatedtiles.qrc @@ -0,0 +1,11 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>images/Time-For-Lunch-2.jpg</file> + <file>images/centered.png</file> + <file>images/ellipse.png</file> + <file>images/figure8.png</file> + <file>images/kinetic.png</file> + <file>images/random.png</file> + <file>images/tile.png</file> +</qresource> +</RCC> diff --git a/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg b/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg Binary files differnew file mode 100644 index 0000000..c57a555 --- /dev/null +++ b/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg diff --git a/examples/animation/animatedtiles/images/centered.png b/examples/animation/animatedtiles/images/centered.png Binary files differnew file mode 100644 index 0000000..e416156 --- /dev/null +++ b/examples/animation/animatedtiles/images/centered.png diff --git a/examples/animation/animatedtiles/images/ellipse.png b/examples/animation/animatedtiles/images/ellipse.png Binary files differnew file mode 100644 index 0000000..2c3ba88 --- /dev/null +++ b/examples/animation/animatedtiles/images/ellipse.png diff --git a/examples/animation/animatedtiles/images/figure8.png b/examples/animation/animatedtiles/images/figure8.png Binary files differnew file mode 100644 index 0000000..6b05804 --- /dev/null +++ b/examples/animation/animatedtiles/images/figure8.png diff --git a/examples/animation/animatedtiles/images/kinetic.png b/examples/animation/animatedtiles/images/kinetic.png Binary files differnew file mode 100644 index 0000000..55cfa55 --- /dev/null +++ b/examples/animation/animatedtiles/images/kinetic.png diff --git a/examples/animation/animatedtiles/images/random.png b/examples/animation/animatedtiles/images/random.png Binary files differnew file mode 100644 index 0000000..415d96f --- /dev/null +++ b/examples/animation/animatedtiles/images/random.png diff --git a/examples/animation/animatedtiles/images/tile.png b/examples/animation/animatedtiles/images/tile.png Binary files differnew file mode 100644 index 0000000..c8f39d8 --- /dev/null +++ b/examples/animation/animatedtiles/images/tile.png diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp new file mode 100644 index 0000000..53a6875 --- /dev/null +++ b/examples/animation/animatedtiles/main.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtCore/qstate.h> + +class Pixmap : public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + Pixmap(const QPixmap &pix) + : QObject(), QGraphicsPixmapItem(pix) + { + setCacheMode(DeviceCoordinateCache); + } +}; + +class Button : public QGraphicsWidget +{ + Q_OBJECT +public: + Button(const QPixmap &pixmap, QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), _pix(pixmap) + { + setAcceptHoverEvents(true); + setCacheMode(DeviceCoordinateCache); + } + + QRectF boundingRect() const + { + return QRectF(-65, -65, 130, 130); + } + + QPainterPath shape() const + { + QPainterPath path; + path.addEllipse(boundingRect()); + return path; + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) + { + bool down = option->state & QStyle::State_Sunken; + QRectF r = boundingRect(); + QLinearGradient grad(r.topLeft(), r.bottomRight()); + grad.setColorAt(down ? 1 : 0, option->state & QStyle::State_MouseOver ? Qt::white : Qt::lightGray); + grad.setColorAt(down ? 0 : 1, Qt::darkGray); + painter->setPen(Qt::darkGray); + painter->setBrush(grad); + painter->drawEllipse(r); + QLinearGradient grad2(r.topLeft(), r.bottomRight()); + grad.setColorAt(down ? 1 : 0, Qt::darkGray); + grad.setColorAt(down ? 0 : 1, Qt::lightGray); + painter->setPen(Qt::NoPen); + painter->setBrush(grad); + if (down) + painter->translate(2, 2); + painter->drawEllipse(r.adjusted(5, 5, -5, -5)); + painter->drawPixmap(-_pix.width()/2, -_pix.height()/2, _pix); + } + +signals: + void pressed(); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *) + { + emit pressed(); + update(); + } + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *) + { + update(); + } + +private: + QPixmap _pix; +}; + +class View : public QGraphicsView +{ +public: + View(QGraphicsScene *scene) : QGraphicsView(scene) { } + +protected: + void resizeEvent(QResizeEvent *event) + { + QGraphicsView::resizeEvent(event); + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +}; + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(animatedtiles); + + QApplication app(argc, argv); + + QPixmap kineticPix(":/images/kinetic.png"); + QPixmap bgPix(":/images/Time-For-Lunch-2.jpg"); + + QGraphicsScene scene(-350, -350, 700, 700); + + QList<Pixmap *> items; + for (int i = 0; i < 64; ++i) { + Pixmap *item = new Pixmap(kineticPix); + item->setOffset(-kineticPix.width()/2, -kineticPix.height()/2); + item->setZValue(i); + items << item; + scene.addItem(item); + } + + // Buttons + QGraphicsItem *buttonParent = new QGraphicsRectItem; + Button *ellipseButton = new Button(QPixmap(":/images/ellipse.png"), buttonParent); + Button *figure8Button = new Button(QPixmap(":/images/figure8.png"), buttonParent); + Button *randomButton = new Button(QPixmap(":/images/random.png"), buttonParent); + Button *tiledButton = new Button(QPixmap(":/images/tile.png"), buttonParent); + Button *centeredButton = new Button(QPixmap(":/images/centered.png"), buttonParent); + + ellipseButton->setPos(-100, -100); + figure8Button->setPos(100, -100); + randomButton->setPos(0, 0); + tiledButton->setPos(-100, 100); + centeredButton->setPos(100, 100); + + scene.addItem(buttonParent); + buttonParent->scale(0.75, 0.75); + buttonParent->setPos(200, 200); + buttonParent->setZValue(65); + + // States + QState *rootState = new QState; + QState *ellipseState = new QState(rootState); + QState *figure8State = new QState(rootState); + QState *randomState = new QState(rootState); + QState *tiledState = new QState(rootState); + QState *centeredState = new QState(rootState); + + // Values + for (int i = 0; i < items.count(); ++i) { + Pixmap *item = items.at(i); + // Ellipse + ellipseState->assignProperty(item, "pos", + QPointF(cos((i / 63.0) * 6.28) * 250, + sin((i / 63.0) * 6.28) * 250)); + + // Figure 8 + figure8State->assignProperty(item, "pos", + QPointF(sin((i / 63.0) * 6.28) * 250, + sin(((i * 2)/63.0) * 6.28) * 250)); + + // Random + randomState->assignProperty(item, "pos", + QPointF(-250 + qrand() % 500, + -250 + qrand() % 500)); + + // Tiled + tiledState->assignProperty(item, "pos", + QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, + ((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2)); + + // Centered + centeredState->assignProperty(item, "pos", QPointF()); + } + + // Ui + View *view = new View(&scene); + view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Animated Tiles")); + view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + view->setBackgroundBrush(bgPix); + view->setCacheMode(QGraphicsView::CacheBackground); + view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + view->show(); + + QStateMachine states; + states.addState(rootState); + states.setInitialState(rootState); + rootState->setInitialState(centeredState); + + QParallelAnimationGroup *group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + QAbstractTransition *trans = rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState); + trans->addAnimation(group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + trans = rootState->addTransition(figure8Button, SIGNAL(pressed()), figure8State); + trans->addAnimation(group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + trans = rootState->addTransition(randomButton, SIGNAL(pressed()), randomState); + trans->addAnimation(group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + trans = rootState->addTransition(tiledButton, SIGNAL(pressed()), tiledState); + trans->addAnimation(group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < items.count(); ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + trans = rootState->addTransition(centeredButton, SIGNAL(pressed()), centeredState); + trans->addAnimation(group); + + states.start(); + QTimer timer; + timer.start(125); + timer.setSingleShot(true); + rootState->addTransition(&timer, SIGNAL(timeout()), ellipseState); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/animation.pro b/examples/animation/animation.pro new file mode 100644 index 0000000..c72c532 --- /dev/null +++ b/examples/animation/animation.pro @@ -0,0 +1,15 @@ +TEMPLATE = \ + subdirs +SUBDIRS += \ + animatedtiles \ + appchooser \ + easing \ + moveblocks \ + states \ + stickman \ + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animation.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/animation +INSTALLS += target sources diff --git a/examples/animation/appchooser/accessories-dictionary.png b/examples/animation/appchooser/accessories-dictionary.png Binary files differnew file mode 100644 index 0000000..e9bd55d --- /dev/null +++ b/examples/animation/appchooser/accessories-dictionary.png diff --git a/examples/animation/appchooser/akregator.png b/examples/animation/appchooser/akregator.png Binary files differnew file mode 100644 index 0000000..a086f45 --- /dev/null +++ b/examples/animation/appchooser/akregator.png diff --git a/examples/animation/appchooser/appchooser.pro b/examples/animation/appchooser/appchooser.pro new file mode 100644 index 0000000..847b60a --- /dev/null +++ b/examples/animation/appchooser/appchooser.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp +RESOURCES = appchooser.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS appchooser.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser +INSTALLS += target sources diff --git a/examples/animation/appchooser/appchooser.qrc b/examples/animation/appchooser/appchooser.qrc new file mode 100644 index 0000000..28a3e1c --- /dev/null +++ b/examples/animation/appchooser/appchooser.qrc @@ -0,0 +1,8 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>accessories-dictionary.png</file> + <file>akregator.png</file> + <file>digikam.png</file> + <file>k3b.png</file> +</qresource> +</RCC> diff --git a/examples/animation/appchooser/digikam.png b/examples/animation/appchooser/digikam.png Binary files differnew file mode 100644 index 0000000..9de9fb2 --- /dev/null +++ b/examples/animation/appchooser/digikam.png diff --git a/examples/animation/appchooser/k3b.png b/examples/animation/appchooser/k3b.png Binary files differnew file mode 100644 index 0000000..bbcafcf --- /dev/null +++ b/examples/animation/appchooser/k3b.png diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp new file mode 100644 index 0000000..11a6fd6 --- /dev/null +++ b/examples/animation/appchooser/main.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtGui> + + +class Pixmap : public QGraphicsWidget +{ + Q_OBJECT + +public: + Pixmap(const QPixmap &pix, QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), orig(pix), p(pix) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + + virtual void mousePressEvent(QGraphicsSceneMouseEvent * ) + { + emit clicked(); + } + + virtual void setGeometry(const QRectF &rect) + { + QGraphicsWidget::setGeometry(rect); + + if (rect.size().width() > orig.size().width()) + p = orig.scaled(rect.size().toSize()); + else + p = orig; + } + +Q_SIGNALS: + void clicked(); + +private: + QPixmap orig; + QPixmap p; +}; + +void createStates(const QObjectList &objects, + const QRect &selectedRect, QState *parent) +{ + for (int i = 0; i < objects.size(); ++i) { + QState *state = new QState(parent); + state->assignProperty(objects.at(i), "geometry", selectedRect); + parent->addTransition(objects.at(i), SIGNAL(clicked()), state); + } +} + +void createAnimations(const QObjectList &objects, QStateMachine *machine) +{ + for (int i=0; i<objects.size(); ++i) + machine->addDefaultAnimation(new QPropertyAnimation(objects.at(i), "geometry")); +} + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(appchooser); + + QApplication app(argc, argv); + + Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); + Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); + Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); + Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); + + p1->setObjectName("p1"); + p2->setObjectName("p2"); + p3->setObjectName("p3"); + p4->setObjectName("p4"); + + p1->setGeometry(QRectF(0.0, 0.0, 64.0, 64.0)); + p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0)); + p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0)); + p4->setGeometry(QRectF(0.0, 236.0, 64.0, 64.0)); + + QGraphicsScene scene(0, 0, 300, 300); + scene.setBackgroundBrush(Qt::white); + scene.addItem(p1); + scene.addItem(p2); + scene.addItem(p3); + scene.addItem(p4); + + QGraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QStateMachine machine; + machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); + + QState *group = new QState(&machine); + group->setObjectName("group"); + QRect selectedRect(86, 86, 128, 128); + + QState *idleState = new QState(group); + group->setInitialState(idleState); + + QObjectList objects; + objects << p1 << p2 << p3 << p4; + createStates(objects, selectedRect, group); + createAnimations(objects, &machine); + + machine.setInitialState(group); + machine.start(); + + window.resize(300, 300); + window.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h new file mode 100644 index 0000000..3f4a61b --- /dev/null +++ b/examples/animation/easing/animation.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATION_H +#define ANIMATION_H + +#include <QtGui> + +#include <QtCore/qpropertyanimation.h> + +class Animation : public QPropertyAnimation { +public: + enum PathType { + LinearPath, + CirclePath, + NPathTypes + }; + Animation(QObject *target, const QByteArray &prop) + : QPropertyAnimation(target, prop) + { + setPathType(LinearPath); + } + + void setPathType(PathType pathType) + { + if (pathType >= NPathTypes) + qWarning("Unknown pathType %d", pathType); + + m_pathType = pathType; + m_path = QPainterPath(); + } + + void updateCurrentTime(int msecs) + { + if (m_pathType == CirclePath) { + if (m_path.isEmpty()) { + QPointF to = endValue().toPointF(); + QPointF from = startValue().toPointF(); + m_path.moveTo(from); + m_path.addEllipse(QRectF(from, to)); + } + int dura = duration(); + const qreal progress = ((dura == 0) ? 1 : ((((currentTime() - 1) % dura) + 1) / qreal(dura))); + + qreal easedProgress = easingCurve().valueForProgress(progress); + if (easedProgress > 1.0) { + easedProgress -= 1.0; + } else if (easedProgress < 0) { + easedProgress += 1.0; + } + QPointF pt = m_path.pointAtPercent(easedProgress); + updateCurrentValue(pt); + emit valueChanged(pt); + } else { + QPropertyAnimation::updateCurrentTime(msecs); + } + } + + QPainterPath m_path; + PathType m_pathType; +}; + +#endif // ANIMATION_H diff --git a/examples/animation/easing/easing.pro b/examples/animation/easing/easing.pro new file mode 100644 index 0000000..8e8a35f --- /dev/null +++ b/examples/animation/easing/easing.pro @@ -0,0 +1,14 @@ +HEADERS = window.h \ + animation.h +SOURCES = main.cpp \ + window.cpp + +FORMS = form.ui + +RESOURCES = easing.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/easing +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS easing.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/easing +INSTALLS += target sources diff --git a/examples/animation/easing/easing.qrc b/examples/animation/easing/easing.qrc new file mode 100644 index 0000000..7e112d3 --- /dev/null +++ b/examples/animation/easing/easing.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> + <qresource> + <file>images/qt-logo.png</file> + </qresource> + </RCC>
\ No newline at end of file diff --git a/examples/animation/easing/form.ui b/examples/animation/easing/form.ui new file mode 100644 index 0000000..b60ade8 --- /dev/null +++ b/examples/animation/easing/form.ui @@ -0,0 +1,201 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>545</width> + <height>471</height> + </rect> + </property> + <property name="windowTitle"> + <string>Easing curves</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QListWidget" name="easingCurvePicker"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>120</height> + </size> + </property> + <property name="verticalScrollBarPolicy"> + <enum>Qt::ScrollBarAlwaysOff</enum> + </property> + <property name="movement"> + <enum>QListView::Static</enum> + </property> + <property name="isWrapping" stdset="0"> + <bool>false</bool> + </property> + <property name="viewMode"> + <enum>QListView::IconMode</enum> + </property> + <property name="selectionRectVisible"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Path type</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QRadioButton" name="lineRadio"> + <property name="text"> + <string>Line</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string>buttonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QRadioButton" name="circleRadio"> + <property name="text"> + <string>Circle</string> + </property> + <attribute name="buttonGroup"> + <string>buttonGroup</string> + </attribute> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Properties</string> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Period</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDoubleSpinBox" name="periodSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <double>-1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + <property name="value"> + <double>-1.000000000000000</double> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Amplitude</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDoubleSpinBox" name="amplitudeSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <double>-1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + <property name="value"> + <double>-1.000000000000000</double> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Overshoot</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDoubleSpinBox" name="overshootSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="minimum"> + <double>-1.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + <property name="value"> + <double>-1.000000000000000</double> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="1" column="1"> + <widget class="QGraphicsView" name="graphicsView"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> + <buttongroups> + <buttongroup name="buttonGroup"/> + </buttongroups> +</ui> diff --git a/examples/animation/easing/images/qt-logo.png b/examples/animation/easing/images/qt-logo.png Binary files differnew file mode 100644 index 0000000..14ddf2a --- /dev/null +++ b/examples/animation/easing/images/qt-logo.png diff --git a/examples/animation/easing/main.cpp b/examples/animation/easing/main.cpp new file mode 100644 index 0000000..48766eb --- /dev/null +++ b/examples/animation/easing/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include "window.h" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(easing); + QApplication app(argc, argv); + Window w; + w.resize(400, 400); + w.show(); + return app.exec(); +} diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp new file mode 100644 index 0000000..f6f3165 --- /dev/null +++ b/examples/animation/easing/window.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "window.h" + +Window::Window(QWidget *parent) + : QWidget(parent), m_iconSize(64, 64) +{ + m_ui.setupUi(this); + QButtonGroup *buttonGroup = qFindChild<QButtonGroup *>(this); // ### workaround for uic in 4.4 + m_ui.easingCurvePicker->setIconSize(m_iconSize); + m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); + buttonGroup->setId(m_ui.lineRadio, 0); + buttonGroup->setId(m_ui.circleRadio, 1); + + QEasingCurve dummy; + m_ui.periodSpinBox->setValue(dummy.period()); + m_ui.amplitudeSpinBox->setValue(dummy.amplitude()); + m_ui.overshootSpinBox->setValue(dummy.overshoot()); + + connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int))); + connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int))); + connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double))); + connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double))); + connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double))); + createCurveIcons(); + + QPixmap pix(QLatin1String(":/images/qt-logo.png")); + m_item = new PixmapItem(pix); + m_scene.addItem(m_item); + m_ui.graphicsView->setScene(&m_scene); + + m_anim = new Animation(m_item, "pos"); + m_anim->setEasingCurve(QEasingCurve::OutBounce); + m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); + + startAnimation(); +} + +void Window::createCurveIcons() +{ + QPixmap pix(m_iconSize); + QPainter painter(&pix); + QLinearGradient gradient(0,0, 0, m_iconSize.height()); + gradient.setColorAt(0.0, QColor(240, 240, 240)); + gradient.setColorAt(1.0, QColor(224, 224, 224)); + QBrush brush(gradient); + const QMetaObject &mo = QEasingCurve::staticMetaObject; + QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type")); + // Skip QEasingCurve::Custom + for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { + painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); + QEasingCurve curve((QEasingCurve::Type)i); + painter.setPen(QColor(0, 0, 255, 64)); + qreal xAxis = m_iconSize.height()/1.5; + qreal yAxis = m_iconSize.width()/3; + painter.drawLine(0, xAxis, m_iconSize.width(), xAxis); + painter.drawLine(yAxis, 0, yAxis, m_iconSize.height()); + + qreal curveScale = m_iconSize.height()/2; + + painter.setPen(Qt::NoPen); + + // start point + painter.setBrush(Qt::red); + QPoint start(yAxis, xAxis - curveScale * curve.valueForProgress(0)); + painter.drawRect(start.x() - 1, start.y() - 1, 3, 3); + + // end point + painter.setBrush(Qt::blue); + QPoint end(yAxis + curveScale, xAxis - curveScale * curve.valueForProgress(1)); + painter.drawRect(end.x() - 1, end.y() - 1, 3, 3); + + QPainterPath curvePath; + curvePath.moveTo(start); + for (qreal t = 0; t <= 1.0; t+=1.0/curveScale) { + QPoint to; + to.setX(yAxis + curveScale * t); + to.setY(xAxis - curveScale * curve.valueForProgress(t)); + curvePath.lineTo(to); + } + painter.setRenderHint(QPainter::Antialiasing, true); + painter.strokePath(curvePath, QColor(32, 32, 32)); + painter.setRenderHint(QPainter::Antialiasing, false); + QListWidgetItem *item = new QListWidgetItem; + item->setIcon(QIcon(pix)); + item->setText(metaEnum.key(i)); + m_ui.easingCurvePicker->addItem(item); + } +} + +void Window::startAnimation() +{ + m_anim->setStartValue(QPointF(0, 0)); + m_anim->setEndValue(QPointF(100, 100)); + m_anim->setDuration(2000); + m_anim->setLoopCount(-1); // forever + m_anim->start(); +} + +void Window::curveChanged(int row) +{ + QEasingCurve::Type curveType = (QEasingCurve::Type)row; + m_anim->setEasingCurve(curveType); + m_anim->setCurrentTime(0); + + bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic; + bool isBounce = curveType >= QEasingCurve::InBounce && curveType <= QEasingCurve::OutInBounce; + m_ui.periodSpinBox->setEnabled(isElastic); + m_ui.amplitudeSpinBox->setEnabled(isElastic || isBounce); + m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack); +} + +void Window::pathChanged(int index) +{ + m_anim->setPathType((Animation::PathType)index); +} + +void Window::periodChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setPeriod(value); + m_anim->setEasingCurve(curve); +} + +void Window::amplitudeChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setAmplitude(value); + m_anim->setEasingCurve(curve); +} + +void Window::overshootChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setOvershoot(value); + m_anim->setEasingCurve(curve); +} + diff --git a/examples/animation/easing/window.h b/examples/animation/easing/window.h new file mode 100644 index 0000000..1f4cec2 --- /dev/null +++ b/examples/animation/easing/window.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "ui_form.h" +#include "animation.h" + +class PixmapItem : public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + PixmapItem(const QPixmap &pix) : QGraphicsPixmapItem(pix) + { + } +}; + +class Window : public QWidget { + Q_OBJECT +public: + Window(QWidget *parent = 0); +private slots: + void curveChanged(int row); + void pathChanged(int index); + void periodChanged(double); + void amplitudeChanged(double); + void overshootChanged(double); + +private: + void createCurveIcons(); + void startAnimation(); + + Ui::Form m_ui; + QGraphicsScene m_scene; + PixmapItem *m_item; + Animation *m_anim; + QSize m_iconSize; + + +}; diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp new file mode 100644 index 0000000..65f4ee2 --- /dev/null +++ b/examples/animation/moveblocks/main.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <QtGui> + +//![15] +class StateSwitchEvent: public QEvent +{ +public: + StateSwitchEvent() + : QEvent(Type(StateSwitchType)) + { + } + + StateSwitchEvent(int rand) + : QEvent(Type(StateSwitchType)), + m_rand(rand) + { + } + + enum { StateSwitchType = QEvent::User + 256 }; + + int rand() const { return m_rand; } + +private: + int m_rand; +}; +//![15] + +//![16] +class QGraphicsRectWidget : public QGraphicsWidget +{ +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, + QWidget *) + { + painter->fillRect(rect(), Qt::blue); + } +}; +//![16] + +class StateSwitchTransition: public QAbstractTransition +{ +public: + StateSwitchTransition(int rand) + : QAbstractTransition(), + m_rand(rand) + { + } + +protected: +//![14] + virtual bool eventTest(QEvent *event) + { + return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) + && (static_cast<StateSwitchEvent *>(event)->rand() == m_rand); + } +//![14] + + virtual void onTransition(QEvent *) {} + +private: + int m_rand; +}; + +//![10] +class StateSwitcher : public QState +{ + Q_OBJECT +public: + StateSwitcher(QStateMachine *machine) + : QState(machine), m_stateCount(0), m_lastIndex(0) + { } +//![10] + +//![11] + virtual void onEntry(QEvent *) + { + int n; + while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex) + { } + m_lastIndex = n; + machine()->postEvent(new StateSwitchEvent(n)); + } + virtual void onExit(QEvent *) {} +//![11] + +//![12] + void addState(QState *state, QAbstractAnimation *animation) { + StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount); + trans->setTargetState(state); + addTransition(trans); + trans->addAnimation(animation); + } +//![12] + +private: + int m_stateCount; + int m_lastIndex; +}; + +//![13] +QState *createGeometryState(QObject *w1, const QRect &rect1, + QObject *w2, const QRect &rect2, + QObject *w3, const QRect &rect3, + QObject *w4, const QRect &rect4, + QState *parent) +{ + QState *result = new QState(parent); + result->assignProperty(w1, "geometry", rect1); + result->assignProperty(w1, "geometry", rect1); + result->assignProperty(w2, "geometry", rect2); + result->assignProperty(w3, "geometry", rect3); + result->assignProperty(w4, "geometry", rect4); + + return result; +} +//![13] + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + +#if 0 + QWidget window; + QPalette palette; + palette.setBrush(QPalette::Window, Qt::black); + window.setPalette(palette); + QPushButton *button1 = new QPushButton("A", &window); + QPushButton *button2 = new QPushButton("B", &window); + QPushButton *button3 = new QPushButton("C", &window); + QPushButton *button4 = new QPushButton("D", &window); + + button1->setObjectName("button1"); + button2->setObjectName("button2"); + button3->setObjectName("button3"); + button4->setObjectName("button4"); +#else +//![1] + QGraphicsRectWidget *button1 = new QGraphicsRectWidget; + QGraphicsRectWidget *button2 = new QGraphicsRectWidget; + QGraphicsRectWidget *button3 = new QGraphicsRectWidget; + QGraphicsRectWidget *button4 = new QGraphicsRectWidget; + button2->setZValue(1); + button3->setZValue(2); + button4->setZValue(3); + QGraphicsScene scene(0, 0, 300, 300); + scene.setBackgroundBrush(Qt::black); + scene.addItem(button1); + scene.addItem(button2); + scene.addItem(button3); + scene.addItem(button4); +//![1] + QGraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +#endif +//![2] + QStateMachine machine; + + QState *group = new QState(); + group->setObjectName("group"); + QTimer timer; + timer.setInterval(1250); + timer.setSingleShot(true); + QObject::connect(group, SIGNAL(entered()), &timer, SLOT(start())); +//![2] + +//![3] + QState *state1; + QState *state2; + QState *state3; + QState *state4; + QState *state5; + QState *state6; + QState *state7; + + state1 = createGeometryState(button1, QRect(100, 0, 50, 50), + button2, QRect(150, 0, 50, 50), + button3, QRect(200, 0, 50, 50), + button4, QRect(250, 0, 50, 50), + group); +//![3] + state2 = createGeometryState(button1, QRect(250, 100, 50, 50), + button2, QRect(250, 150, 50, 50), + button3, QRect(250, 200, 50, 50), + button4, QRect(250, 250, 50, 50), + group); + state3 = createGeometryState(button1, QRect(150, 250, 50, 50), + button2, QRect(100, 250, 50, 50), + button3, QRect(50, 250, 50, 50), + button4, QRect(0, 250, 50, 50), + group); + state4 = createGeometryState(button1, QRect(0, 150, 50, 50), + button2, QRect(0, 100, 50, 50), + button3, QRect(0, 50, 50, 50), + button4, QRect(0, 0, 50, 50), + group); + state5 = createGeometryState(button1, QRect(100, 100, 50, 50), + button2, QRect(150, 100, 50, 50), + button3, QRect(100, 150, 50, 50), + button4, QRect(150, 150, 50, 50), + group); + state6 = createGeometryState(button1, QRect(50, 50, 50, 50), + button2, QRect(200, 50, 50, 50), + button3, QRect(50, 200, 50, 50), + button4, QRect(200, 200, 50, 50), + group); +//![4] + state7 = createGeometryState(button1, QRect(0, 0, 50, 50), + button2, QRect(250, 0, 50, 50), + button3, QRect(0, 250, 50, 50), + button4, QRect(250, 250, 50, 50), + group); + group->setInitialState(state1); +//![4] + +//![5] + QParallelAnimationGroup animationGroup; + QSequentialAnimationGroup *subGroup; + + QPropertyAnimation *anim = new QPropertyAnimation(button4, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + animationGroup.addAnimation(anim); +//![5] + +//![6] + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(100); + anim = new QPropertyAnimation(button3, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); +//![6] + + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(150); + anim = new QPropertyAnimation(button2, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); + + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(200); + anim = new QPropertyAnimation(button1, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); + +//![7] + StateSwitcher *stateSwitcher = new StateSwitcher(&machine); + stateSwitcher->setObjectName("stateSwitcher"); + group->addTransition(&timer, SIGNAL(timeout()), stateSwitcher); + stateSwitcher->addState(state1, &animationGroup); + stateSwitcher->addState(state2, &animationGroup); +//![7] + stateSwitcher->addState(state3, &animationGroup); + stateSwitcher->addState(state4, &animationGroup); + stateSwitcher->addState(state5, &animationGroup); + stateSwitcher->addState(state6, &animationGroup); +//![8] + stateSwitcher->addState(state7, &animationGroup); +//![8] + +//![9] + machine.addState(group); + machine.setInitialState(group); + machine.start(); +//![9] + + window.resize(300, 300); + window.show(); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/moveblocks/moveblocks.pro b/examples/animation/moveblocks/moveblocks.pro new file mode 100644 index 0000000..b8e88b2 --- /dev/null +++ b/examples/animation/moveblocks/moveblocks.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS moveblocks.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks +INSTALLS += target sources diff --git a/examples/animation/states/accessories-dictionary.png b/examples/animation/states/accessories-dictionary.png Binary files differnew file mode 100644 index 0000000..e9bd55d --- /dev/null +++ b/examples/animation/states/accessories-dictionary.png diff --git a/examples/animation/states/akregator.png b/examples/animation/states/akregator.png Binary files differnew file mode 100644 index 0000000..a086f45 --- /dev/null +++ b/examples/animation/states/akregator.png diff --git a/examples/animation/states/digikam.png b/examples/animation/states/digikam.png Binary files differnew file mode 100644 index 0000000..9de9fb2 --- /dev/null +++ b/examples/animation/states/digikam.png diff --git a/examples/animation/states/help-browser.png b/examples/animation/states/help-browser.png Binary files differnew file mode 100644 index 0000000..db92faa --- /dev/null +++ b/examples/animation/states/help-browser.png diff --git a/examples/animation/states/k3b.png b/examples/animation/states/k3b.png Binary files differnew file mode 100644 index 0000000..bbcafcf --- /dev/null +++ b/examples/animation/states/k3b.png diff --git a/examples/animation/states/kchart.png b/examples/animation/states/kchart.png Binary files differnew file mode 100644 index 0000000..1dd115b --- /dev/null +++ b/examples/animation/states/kchart.png diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp new file mode 100644 index 0000000..a9eebbc --- /dev/null +++ b/examples/animation/states/main.cpp @@ -0,0 +1,283 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +class Pixmap : public QGraphicsWidget +{ + Q_OBJECT +public: + Pixmap(const QPixmap &pix) : QGraphicsWidget(), p(pix) + { + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + +protected: + QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) + { + return QSizeF(p.width(), p.height()); + } + +private: + QPixmap p; +}; + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(states); + + QApplication app(argc, argv); + + // Text edit and button + QTextEdit *edit = new QTextEdit; + edit->setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " + "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!"); + + QPushButton *button = new QPushButton; + QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; + buttonProxy->setWidget(button); + QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; + editProxy->setWidget(edit); + + QGroupBox *box = new QGroupBox; + box->setFlat(true); + box->setTitle("Options"); + + QVBoxLayout *layout2 = new QVBoxLayout; + box->setLayout(layout2); + layout2->addWidget(new QRadioButton("Herring")); + layout2->addWidget(new QRadioButton("Blue Parrot")); + layout2->addWidget(new QRadioButton("Petunias")); + layout2->addStretch(); + + QGraphicsProxyWidget *boxProxy = new QGraphicsProxyWidget; + boxProxy->setWidget(box); + + // Parent widget + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget); + layout->addItem(editProxy); + layout->addItem(buttonProxy); + widget->setLayout(layout); + + Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); + Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); + Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); + Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); + Pixmap *p5 = new Pixmap(QPixmap(":/help-browser.png")); + Pixmap *p6 = new Pixmap(QPixmap(":/kchart.png")); + + QGraphicsScene scene(0, 0, 400, 300); + scene.setBackgroundBrush(scene.palette().window()); + scene.addItem(widget); + scene.addItem(boxProxy); + scene.addItem(p1); + scene.addItem(p2); + scene.addItem(p3); + scene.addItem(p4); + scene.addItem(p5); + scene.addItem(p6); + + QStateMachine machine; + QState *state1 = new QState(&machine); + QState *state2 = new QState(&machine); + QState *state3 = new QState(&machine); + machine.setInitialState(state1); + + // State 1 + state1->assignProperty(button, "text", "Switch to state 2"); + state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150)); + state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150)); + state1->assignProperty(p1, "geometry", QRectF(68, 185, 64, 64)); + state1->assignProperty(p2, "geometry", QRectF(168, 185, 64, 64)); + state1->assignProperty(p3, "geometry", QRectF(268, 185, 64, 64)); + state1->assignProperty(p4, "geometry", QRectF(68-150, 48-150, 64, 64)); + state1->assignProperty(p5, "geometry", QRectF(168, 48-150, 64, 64)); + state1->assignProperty(p6, "geometry", QRectF(268+150, 48-150, 64, 64)); + state1->assignProperty(p1, "rotation", qreal(0)); + state1->assignProperty(p2, "rotation", qreal(0)); + state1->assignProperty(p3, "rotation", qreal(0)); + state1->assignProperty(p4, "rotation", qreal(-270)); + state1->assignProperty(p5, "rotation", qreal(-90)); + state1->assignProperty(p6, "rotation", qreal(270)); + state1->assignProperty(boxProxy, "opacity", qreal(0)); + state1->assignProperty(p1, "opacity", qreal(1)); + state1->assignProperty(p2, "opacity", qreal(1)); + state1->assignProperty(p3, "opacity", qreal(1)); + state1->assignProperty(p4, "opacity", qreal(0)); + state1->assignProperty(p5, "opacity", qreal(0)); + state1->assignProperty(p6, "opacity", qreal(0)); + + // State 2 + state2->assignProperty(button, "text", "Switch to state 3"); + state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150)); + state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150)); + state2->assignProperty(p1, "geometry", QRectF(68-150, 185+150, 64, 64)); + state2->assignProperty(p2, "geometry", QRectF(168, 185+150, 64, 64)); + state2->assignProperty(p3, "geometry", QRectF(268+150, 185+150, 64, 64)); + state2->assignProperty(p4, "geometry", QRectF(64, 48, 64, 64)); + state2->assignProperty(p5, "geometry", QRectF(168, 48, 64, 64)); + state2->assignProperty(p6, "geometry", QRectF(268, 48, 64, 64)); + state2->assignProperty(p1, "rotation", qreal(-270)); + state2->assignProperty(p2, "rotation", qreal(90)); + state2->assignProperty(p3, "rotation", qreal(270)); + state2->assignProperty(p4, "rotation", qreal(0)); + state2->assignProperty(p5, "rotation", qreal(0)); + state2->assignProperty(p6, "rotation", qreal(0)); + state2->assignProperty(boxProxy, "opacity", qreal(1)); + state2->assignProperty(p1, "opacity", qreal(0)); + state2->assignProperty(p2, "opacity", qreal(0)); + state2->assignProperty(p3, "opacity", qreal(0)); + state2->assignProperty(p4, "opacity", qreal(1)); + state2->assignProperty(p5, "opacity", qreal(1)); + state2->assignProperty(p6, "opacity", qreal(1)); + + // State 3 + state3->assignProperty(button, "text", "Switch to state 1"); + state3->assignProperty(p1, "geometry", QRectF(5, 5, 64, 64)); + state3->assignProperty(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64)); + state3->assignProperty(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64)); + state3->assignProperty(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64)); + state3->assignProperty(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64)); + state3->assignProperty(p6, "geometry", QRectF(5 + 64 + 5, 5 + (64 + 5) + 64, 64, 64)); + state3->assignProperty(widget, "geometry", QRectF(138, 5, 400 - 138, 200)); + state3->assignProperty(box, "geometry", QRect(5, 205, 400, 90)); + state3->assignProperty(p1, "opacity", qreal(1)); + state3->assignProperty(p2, "opacity", qreal(1)); + state3->assignProperty(p3, "opacity", qreal(1)); + state3->assignProperty(p4, "opacity", qreal(1)); + state3->assignProperty(p5, "opacity", qreal(1)); + state3->assignProperty(p6, "opacity", qreal(1)); + + QParallelAnimationGroup animation1; + + QSequentialAnimationGroup *animation1SubGroup; + animation1SubGroup = new QSequentialAnimationGroup(&animation1); + animation1SubGroup->addPause(250); + animation1SubGroup->addAnimation(new QPropertyAnimation(box, "geometry")); + + animation1.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p1, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p2, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p3, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p4, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p5, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p6, "rotation")); + animation1.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p6, "opacity")); + + QParallelAnimationGroup animation2; + animation2.addAnimation(new QPropertyAnimation(box, "geometry")); + animation2.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p1, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p2, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p3, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p4, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p5, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p6, "rotation")); + animation2.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p6, "opacity")); + + QParallelAnimationGroup animation3; + animation3.addAnimation(new QPropertyAnimation(box, "geometry")); + animation3.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p1, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p2, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p3, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p4, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p5, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p6, "rotation")); + animation3.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p6, "opacity")); + + QAbstractTransition *t1 = state1->addTransition(button, SIGNAL(clicked()), state2); + t1->addAnimation(&animation1); + QAbstractTransition *t2 = state2->addTransition(button, SIGNAL(clicked()), state3); + t2->addAnimation(&animation2); + QAbstractTransition *t3 = state3->addTransition(button, SIGNAL(clicked()), state1); + t3->addAnimation(&animation3); + + machine.start(); + + QGraphicsView view(&scene); + view.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/states/states.pro b/examples/animation/states/states.pro new file mode 100644 index 0000000..f4d1e0b --- /dev/null +++ b/examples/animation/states/states.pro @@ -0,0 +1,8 @@ +SOURCES += main.cpp +RESOURCES += states.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/states +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/states +INSTALLS += target sources diff --git a/examples/animation/states/states.qrc b/examples/animation/states/states.qrc new file mode 100644 index 0000000..60ab3f7 --- /dev/null +++ b/examples/animation/states/states.qrc @@ -0,0 +1,10 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>accessories-dictionary.png</file> + <file>akregator.png</file> + <file>digikam.png</file> + <file>help-browser.png</file> + <file>k3b.png</file> + <file>kchart.png</file> +</qresource> +</RCC> diff --git a/examples/animation/stickman/animation.cpp b/examples/animation/stickman/animation.cpp new file mode 100644 index 0000000..9e99434 --- /dev/null +++ b/examples/animation/stickman/animation.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "animation.h" + +#include <QPointF> +#include <QIODevice> +#include <QDataStream> + +class Frame +{ +public: + Frame() { + } + + int nodeCount() const + { + return m_nodePositions.size(); + } + + void setNodeCount(int nodeCount) + { + while (nodeCount > m_nodePositions.size()) + m_nodePositions.append(QPointF()); + + while (nodeCount < m_nodePositions.size()) + m_nodePositions.removeLast(); + } + + QPointF nodePos(int idx) const + { + return m_nodePositions.at(idx); + } + + void setNodePos(int idx, const QPointF &pos) + { + m_nodePositions[idx] = pos; + } + +private: + QList<QPointF> m_nodePositions; +}; + +Animation::Animation() +{ + m_currentFrame = 0; + m_frames.append(new Frame); +} + +Animation::~Animation() +{ + qDeleteAll(m_frames); +} + +void Animation::setTotalFrames(int totalFrames) +{ + while (m_frames.size() < totalFrames) + m_frames.append(new Frame); + + while (totalFrames < m_frames.size()) + delete m_frames.takeLast(); +} + +int Animation::totalFrames() const +{ + return m_frames.size(); +} + +void Animation::setCurrentFrame(int currentFrame) +{ + m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0); +} + +int Animation::currentFrame() const +{ + return m_currentFrame; +} + +void Animation::setNodeCount(int nodeCount) +{ + Frame *frame = m_frames.at(m_currentFrame); + frame->setNodeCount(nodeCount); +} + +int Animation::nodeCount() const +{ + Frame *frame = m_frames.at(m_currentFrame); + return frame->nodeCount(); +} + +void Animation::setNodePos(int idx, const QPointF &pos) +{ + Frame *frame = m_frames.at(m_currentFrame); + frame->setNodePos(idx, pos); +} + +QPointF Animation::nodePos(int idx) const +{ + Frame *frame = m_frames.at(m_currentFrame); + return frame->nodePos(idx); +} + +QString Animation::name() const +{ + return m_name; +} + +void Animation::setName(const QString &name) +{ + m_name = name; +} + +void Animation::save(QIODevice *device) const +{ + QDataStream stream(device); + stream << m_name; + stream << m_frames.size(); + foreach (Frame *frame, m_frames) { + stream << frame->nodeCount(); + for (int i=0; i<frame->nodeCount(); ++i) + stream << frame->nodePos(i); + } +} + +void Animation::load(QIODevice *device) +{ + if (!m_frames.isEmpty()) + qDeleteAll(m_frames); + + m_frames.clear(); + + QDataStream stream(device); + stream >> m_name; + + int frameCount; + stream >> frameCount; + + for (int i=0; i<frameCount; ++i) { + + int nodeCount; + stream >> nodeCount; + + Frame *frame = new Frame; + frame->setNodeCount(nodeCount); + + for (int j=0; j<nodeCount; ++j) { + QPointF pos; + stream >> pos; + + frame->setNodePos(j, pos); + } + + m_frames.append(frame); + } +} diff --git a/examples/animation/stickman/animation.h b/examples/animation/stickman/animation.h new file mode 100644 index 0000000..8fa2e2a --- /dev/null +++ b/examples/animation/stickman/animation.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATION_H +#define ANIMATION_H + +#include <QPointF> +#include <QList> +#include <QString> + +class Frame; +QT_BEGIN_NAMESPACE +class QIODevice; +QT_END_NAMESPACE +class Animation +{ +public: + Animation(); + ~Animation(); + + void setTotalFrames(int totalFrames); + int totalFrames() const; + + void setCurrentFrame(int currentFrame); + int currentFrame() const; + + void setNodeCount(int nodeCount); + int nodeCount() const; + + void setNodePos(int idx, const QPointF &pos); + QPointF nodePos(int idx) const; + + QString name() const; + void setName(const QString &name); + + void save(QIODevice *device) const; + void load(QIODevice *device); + +private: + QString m_name; + QList<Frame *> m_frames; + int m_currentFrame; +}; + +#endif diff --git a/examples/animation/stickman/animations/chilling b/examples/animation/stickman/animations/chilling Binary files differnew file mode 100644 index 0000000..a81fc7a --- /dev/null +++ b/examples/animation/stickman/animations/chilling diff --git a/examples/animation/stickman/animations/dancing b/examples/animation/stickman/animations/dancing Binary files differnew file mode 100644 index 0000000..462f66f --- /dev/null +++ b/examples/animation/stickman/animations/dancing diff --git a/examples/animation/stickman/animations/dead b/examples/animation/stickman/animations/dead Binary files differnew file mode 100644 index 0000000..9859b4b --- /dev/null +++ b/examples/animation/stickman/animations/dead diff --git a/examples/animation/stickman/animations/jumping b/examples/animation/stickman/animations/jumping Binary files differnew file mode 100644 index 0000000..12661a1 --- /dev/null +++ b/examples/animation/stickman/animations/jumping diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp new file mode 100644 index 0000000..93eacb5 --- /dev/null +++ b/examples/animation/stickman/graphicsview.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "graphicsview.h" +#include "stickman.h" + +#include <QtGui/QKeyEvent> +#include <QtGui/QGraphicsScene> +#include <QtGui/QGraphicsView> + +GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {} + +void GraphicsView::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Escape) + close(); + emit keyPressed(Qt::Key(e->key())); +} + + diff --git a/examples/animation/stickman/graphicsview.h b/examples/animation/stickman/graphicsview.h new file mode 100644 index 0000000..accc88f --- /dev/null +++ b/examples/animation/stickman/graphicsview.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSVIEW_H +#define GRAPHICSVIEW + +#include <QtGui/QGraphicsView> + +class MainWindow; +class GraphicsView: public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(QWidget *parent = 0); + +protected: + void keyPressEvent(QKeyEvent *); + +signals: + void keyPressed(int key); + +private: + MainWindow *m_editor; +}; + +#endif diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp new file mode 100644 index 0000000..a964e67 --- /dev/null +++ b/examples/animation/stickman/lifecycle.cpp @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "lifecycle.h" +#include "stickman.h" +#include "node.h" +#include "animation.h" +#include "graphicsview.h" + +#include <QtCore> +#include <QtGui> + +class KeyPressTransition: public QSignalTransition +{ +public: + KeyPressTransition(GraphicsView *receiver, Qt::Key key) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + { + } + KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + { + setTargetState(target); + } + + virtual bool eventTest(QEvent *e) + { + if (QSignalTransition::eventTest(e)) { + QVariant key = static_cast<QSignalEvent*>(e)->arguments().at(0); + return (key.toInt() == int(m_key)); + } + + return false; + } +private: + Qt::Key m_key; +}; + +//! [4] +class LightningStrikesTransition: public QEventTransition +{ +public: + LightningStrikesTransition(QAbstractState *target) + : QEventTransition(this, QEvent::Timer) + { + setTargetState(target); + qsrand((uint)QDateTime::currentDateTime().toTime_t()); + startTimer(1000); + } + + virtual bool eventTest(QEvent *e) + { + return QEventTransition::eventTest(e) && ((qrand() % 50) == 0); + } +}; +//! [4] + +LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) + : m_stickMan(stickMan), m_keyReceiver(keyReceiver) +{ + // Create animation group to be used for all transitions + m_animationGroup = new QParallelAnimationGroup(); + const int stickManNodeCount = m_stickMan->nodeCount(); + for (int i=0; i<stickManNodeCount; ++i) { + QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "position"); + m_animationGroup->addAnimation(pa); + } + + // Set up intial state graph +//! [3] + m_machine = new QStateMachine(); + m_machine->addDefaultAnimation(m_animationGroup); +//! [3] + + m_alive = new QState(m_machine); + m_alive->setObjectName("alive"); + + // Make it blink when lightning strikes before entering dead animation + QState *lightningBlink = new QState(m_machine); + lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white); + lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black); + lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white); + lightningBlink->assignProperty(m_stickMan, "isDead", true); + +//! [5] + QTimer *timer = new QTimer(lightningBlink); + timer->setSingleShot(true); + timer->setInterval(100); + QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start())); + QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop())); +//! [5] + + m_dead = new QState(m_machine); + m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black); + m_dead->assignProperty(m_stickMan, "penColor", Qt::white); + m_dead->assignProperty(m_stickMan, "fillColor", Qt::black); + m_dead->setObjectName("dead"); + + // Idle state (sets no properties) + m_idle = new QState(m_alive); + m_idle->setObjectName("idle"); + + m_alive->setInitialState(m_idle); + + // Lightning strikes at random + m_alive->addTransition(new LightningStrikesTransition(lightningBlink)); +//! [0] + lightningBlink->addTransition(timer, SIGNAL(timeout()), m_dead); +//! [0] + + m_machine->setInitialState(m_alive); +} + +void LifeCycle::setDeathAnimation(const QString &fileName) +{ + QState *deathAnimation = makeState(m_dead, fileName); + m_dead->setInitialState(deathAnimation); +} + +void LifeCycle::start() +{ + m_machine->start(); +} + +void LifeCycle::addActivity(const QString &fileName, Qt::Key key) +{ + QState *state = makeState(m_alive, fileName); + m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state)); +} + +QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName) +{ + QState *topLevel = new QState(parentState); + + Animation animation; + { + QFile file(animationFileName); + if (file.open(QIODevice::ReadOnly)) + animation.load(&file); + } + + const int frameCount = animation.totalFrames(); + QState *previousState = 0; + for (int i=0; i<frameCount; ++i) { + animation.setCurrentFrame(i); + +//! [1] + QState *frameState = new QState(topLevel); + const int nodeCount = animation.nodeCount(); + for (int j=0; j<nodeCount; ++j) + frameState->assignProperty(m_stickMan->node(j), "position", animation.nodePos(j)); +//! [1] + + frameState->setObjectName(QString::fromLatin1("frame %0").arg(i)); + if (previousState == 0) + topLevel->setInitialState(frameState); + else +//! [2] + previousState->addTransition(previousState, SIGNAL(polished()), frameState); +//! [2] + + previousState = frameState; + } + + // Loop + previousState->addTransition(previousState, SIGNAL(polished()), topLevel->initialState()); + + return topLevel; + +} + +LifeCycle::~LifeCycle() +{ + delete m_machine; + delete m_animationGroup; +} diff --git a/examples/animation/stickman/lifecycle.h b/examples/animation/stickman/lifecycle.h new file mode 100644 index 0000000..15aae8b --- /dev/null +++ b/examples/animation/stickman/lifecycle.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIFECYCLE_H +#define LIFECYCLE_H + +#include <Qt> + +class StickMan; +QT_BEGIN_NAMESPACE +class QStateMachine; +class QAnimationGroup; +class QState; +class QAbstractState; +class QAbstractTransition; +QT_END_NAMESPACE +class GraphicsView; +class LifeCycle +{ +public: + LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver); + ~LifeCycle(); + + void setDeathAnimation(const QString &fileName); + void addActivity(const QString &fileName, Qt::Key key); + + void start(); + +private: + QState *makeState(QState *parentState, const QString &animationFileName); + + StickMan *m_stickMan; + QStateMachine *m_machine; + QAnimationGroup *m_animationGroup; + GraphicsView *m_keyReceiver; + + QState *m_alive; + QState *m_dead; + QState *m_idle; +}; + +#endif diff --git a/examples/animation/stickman/main.cpp b/examples/animation/stickman/main.cpp new file mode 100644 index 0000000..f23c8b8 --- /dev/null +++ b/examples/animation/stickman/main.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "animation.h" +#include "node.h" +#include "lifecycle.h" +#include "stickman.h" +#include "graphicsview.h" + +#include <QtCore> +#include <QtGui> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + StickMan *stickMan = new StickMan; + stickMan->setDrawSticks(false); + + QGraphicsTextItem *textItem = new QGraphicsTextItem(); + textItem->setHtml("<font color=\"white\"><b>Stickman</b>" + "<p>" + "Tell the stickman what to do!" + "</p>" + "<p><i>" + "<li>Press <font color=\"purple\">J</font> to make the stickman jump.</li>" + "<li>Press <font color=\"purple\">D</font> to make the stickman dance.</li>" + "<li>Press <font color=\"purple\">C</font> to make him chill out.</li>" + "<li>When you are done, press <font color=\"purple\">Escape</font>.</li>" + "</i></p>" + "<p>If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again." + "</p></font>"); + qreal w = textItem->boundingRect().width(); + QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect(); + textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0); + + QGraphicsScene *scene = new QGraphicsScene(); + scene->addItem(stickMan); + scene->addItem(textItem); + scene->setBackgroundBrush(Qt::black); + + GraphicsView *view = new GraphicsView(); + view->setRenderHints(QPainter::Antialiasing); + view->setTransformationAnchor(QGraphicsView::NoAnchor); + view->setScene(scene); + view->showFullScreen(); + view->setFocus(); + view->setSceneRect(scene->sceneRect()); + + LifeCycle *cycle = new LifeCycle(stickMan, view); + cycle->setDeathAnimation("animations/dead"); + + cycle->addActivity("animations/jumping", Qt::Key_J); + cycle->addActivity("animations/dancing", Qt::Key_D); + cycle->addActivity("animations/chilling", Qt::Key_C); + cycle->start(); + + return app.exec(); +} diff --git a/examples/animation/stickman/node.cpp b/examples/animation/stickman/node.cpp new file mode 100644 index 0000000..5d826a7 --- /dev/null +++ b/examples/animation/stickman/node.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "node.h" +#include "stickman.h" + +#include <QRectF> +#include <QPainter> +#include <QGraphicsSceneMouseEvent> + +Node::Node(const QPointF &pos, QGraphicsItem *parent) + : QGraphicsItem(parent), m_dragging(false) +{ + setPos(pos); +} + +Node::~Node() +{ +} + +QRectF Node::boundingRect() const +{ + return QRectF(-6.0, -6.0, 12.0, 12.0); +} + +void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + painter->setPen(Qt::white); + painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0); +} + +QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemPositionChange) + emit positionChanged(); + + return QGraphicsItem::itemChange(change, value); +} + +void Node::mousePressEvent(QGraphicsSceneMouseEvent *) +{ + m_dragging = true; +} + +void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (m_dragging) + setPos(mapToParent(event->pos())); +} + +void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *) +{ + m_dragging = false; +} diff --git a/examples/animation/stickman/node.h b/examples/animation/stickman/node.h new file mode 100644 index 0000000..66ee565 --- /dev/null +++ b/examples/animation/stickman/node.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef NODE_H +#define NODE_H + +#include <QGraphicsItem> + +class Node: public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_PROPERTY(QPointF position READ pos WRITE setPos) +public: + Node(const QPointF &pos, QGraphicsItem *parent = 0); + ~Node(); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +signals: + void positionChanged(); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + void mousePressEvent(QGraphicsSceneMouseEvent *); + void mouseMoveEvent(QGraphicsSceneMouseEvent *); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *); + +private: + bool m_dragging; +}; + +#endif diff --git a/examples/animation/stickman/stickman.cpp b/examples/animation/stickman/stickman.cpp new file mode 100644 index 0000000..3ca9d75 --- /dev/null +++ b/examples/animation/stickman/stickman.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "stickman.h" +#include "node.h" + +#include <QPainter> +#include <QTimer> + +#define _USE_MATH_DEFINES +#include <math.h> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +static const int NodeCount = 16; +static const qreal Coords[NodeCount * 2] = { + 0.0, -150.0, // head, #0 + + 0.0, -100.0, // body pentagon, top->bottom, left->right, #1 - 5 + -50.0, -50.0, + 50.0, -50.0, + -25.0, 50.0, + 25.0, 50.0, + + -100.0, 0.0, // right arm, #6 - 7 + -125.0, 50.0, + + 100.0, 0.0, // left arm, #8 - 9 + 125.0, 50.0, + + -35.0, 75.0, // lower body, #10 - 11 + 35.0, 75.0, + + -25.0, 200.0, // right leg, #12 - 13 + -30.0, 300.0, + + 25.0, 200.0, // left leg, #14 - 15 + 30.0, 300.0 + +}; + +static const int BoneCount = 24; +static const int Bones[BoneCount * 2] = { + 0, 1, // neck + + 1, 2, // body + 1, 3, + 1, 4, + 1, 5, + 2, 3, + 2, 4, + 2, 5, + 3, 4, + 3, 5, + 4, 5, + + 2, 6, // right arm + 6, 7, + + 3, 8, // left arm + 8, 9, + + 4, 10, // lower body + 4, 11, + 5, 10, + 5, 11, + 10, 11, + + 10, 12, // right leg + 12, 13, + + 11, 14, // left leg + 14, 15 + +}; + +StickMan::StickMan() +{ + m_nodes = new Node*[NodeCount]; + m_sticks = true; + m_isDead = false; + m_pixmap = QPixmap("images/head.png"); + m_penColor = Qt::white; + m_fillColor = Qt::black; + + // Set up start position of limbs + for (int i=0; i<NodeCount; ++i) { + m_nodes[i] = new Node(QPointF(Coords[i * 2], Coords[i * 2 + 1]), this); + connect(m_nodes[i], SIGNAL(positionChanged()), this, SLOT(childPositionChanged())); + } + + m_perfectBoneLengths = new qreal[BoneCount]; + for (int i=0; i<BoneCount; ++i) { + int n1 = Bones[i * 2]; + int n2 = Bones[i * 2 + 1]; + + Node *node1 = m_nodes[n1]; + Node *node2 = m_nodes[n2]; + + QPointF dist = node1->pos() - node2->pos(); + m_perfectBoneLengths[i] = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); + } + + startTimer(10); +} + +StickMan::~StickMan() +{ + delete m_nodes; +} + +void StickMan::childPositionChanged() +{ + prepareGeometryChange(); +} + +void StickMan::setDrawSticks(bool on) +{ + m_sticks = on; + for (int i=0;i<nodeCount();++i) { + Node *node = m_nodes[i]; + node->setVisible(on); + } +} + +QRectF StickMan::boundingRect() const +{ + // account for head radius=50.0 plus pen which is 5.0 + return childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0); +} + +int StickMan::nodeCount() const +{ + return NodeCount; +} + +Node *StickMan::node(int idx) const +{ + if (idx >= 0 && idx < NodeCount) + return m_nodes[idx]; + else + return 0; +} + +void StickMan::timerEvent(QTimerEvent *) +{ + update(); +} + +void StickMan::stabilize() +{ + static const qreal threshold = 0.001; + + for (int i=0; i<BoneCount; ++i) { + int n1 = Bones[i * 2]; + int n2 = Bones[i * 2 + 1]; + + Node *node1 = m_nodes[n1]; + Node *node2 = m_nodes[n2]; + + QPointF pos1 = node1->pos(); + QPointF pos2 = node2->pos(); + + QPointF dist = pos1 - pos2; + qreal length = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); + qreal diff = (length - m_perfectBoneLengths[i]) / length; + + QPointF p = dist * (0.5 * diff); + if (p.x() > threshold && p.y() > threshold) { + pos1 -= p; + pos2 += p; + + node1->setPos(pos1); + node2->setPos(pos2); + } + } +} + +QPointF StickMan::posFor(int idx) const +{ + return m_nodes[idx]->pos(); +} + +//#include <QTime> +void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + /* static int frames = 0; + static QTime time; + if (frames++ % 100 == 0) { + frames = 1; + time.restart(); + } + + if (time.elapsed() > 0) { + painter->setPen(Qt::white); + painter->drawText(0, 0, QString::number(frames / (time.elapsed() / 1000.0))); + }*/ + + stabilize(); + if (m_sticks) { + painter->setPen(Qt::white); + for (int i=0; i<BoneCount; ++i) { + int n1 = Bones[i * 2]; + int n2 = Bones[i * 2 + 1]; + + Node *node1 = m_nodes[n1]; + Node *node2 = m_nodes[n2]; + + painter->drawLine(node1->pos(), node2->pos()); + } + } else { + // first bone is neck and will be used for head + + QPainterPath path; + path.moveTo(posFor(0)); + path.lineTo(posFor(1)); + + // right arm + path.lineTo(posFor(2)); + path.lineTo(posFor(6)); + path.lineTo(posFor(7)); + + // left arm + path.moveTo(posFor(3)); + path.lineTo(posFor(8)); + path.lineTo(posFor(9)); + + // body + path.moveTo(posFor(2)); + path.lineTo(posFor(4)); + path.lineTo(posFor(10)); + path.lineTo(posFor(11)); + path.lineTo(posFor(5)); + path.lineTo(posFor(3)); + path.lineTo(posFor(1)); + + // right leg + path.moveTo(posFor(10)); + path.lineTo(posFor(12)); + path.lineTo(posFor(13)); + + // left leg + path.moveTo(posFor(11)); + path.lineTo(posFor(14)); + path.lineTo(posFor(15)); + + painter->setPen(QPen(m_penColor, 5.0, Qt::SolidLine, Qt::RoundCap)); + painter->drawPath(path); + + { + int n1 = Bones[0]; + int n2 = Bones[1]; + Node *node1 = m_nodes[n1]; + Node *node2 = m_nodes[n2]; + + QPointF dist = node2->pos() - node1->pos(); + + qreal sinAngle = dist.x() / sqrt(pow(dist.x(), 2) + pow(dist.y(), 2)); + qreal angle = asin(sinAngle) * 180.0 / M_PI; + + QPointF headPos = node1->pos(); + painter->translate(headPos); + painter->rotate(-angle); + + painter->setBrush(m_fillColor); + painter->drawEllipse(QPointF(0,0), 50.0, 50.0); + + painter->setBrush(m_penColor); + painter->setPen(QPen(m_penColor, 2.5, Qt::SolidLine, Qt::RoundCap)); + + // eyes + if (m_isDead) { + painter->drawLine(-30.0, -30.0, -20.0, -20.0); + painter->drawLine(-20.0, -30.0, -30.0, -20.0); + + painter->drawLine(20.0, -30.0, 30.0, -20.0); + painter->drawLine(30.0, -30.0, 20.0, -20.0); + } else { + painter->drawChord(QRectF(-30.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); + painter->drawChord(QRectF(5.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16); + } + + // mouth + if (m_isDead) { + painter->drawLine(-28.0, 2.0, 29.0, 2.0); + } else { + painter->setBrush(QColor(128, 0, 64 )); + painter->drawChord(QRectF(-28.0, 2.0-55.0/2.0, 57.0, 55.0), 0.0, -180.0*16); + } + + // pupils + if (!m_isDead) { + painter->setPen(QPen(m_fillColor, 1.0, Qt::SolidLine, Qt::RoundCap)); + painter->setBrush(m_fillColor); + painter->drawEllipse(QPointF(-12.0, -25.0), 5.0, 5.0); + painter->drawEllipse(QPointF(22.0, -25.0), 5.0, 5.0); + } + } + } +} + + + diff --git a/examples/animation/stickman/stickman.h b/examples/animation/stickman/stickman.h new file mode 100644 index 0000000..fa74af4 --- /dev/null +++ b/examples/animation/stickman/stickman.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STICKMAN_H +#define STICKMAN_H + +#include <QGraphicsItem> + +const int LimbCount = 16; + +class Node; +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE +class StickMan: public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_PROPERTY(QColor penColor WRITE setPenColor READ penColor) + Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor) + Q_PROPERTY(bool isDead WRITE setIsDead READ isDead) +public: + StickMan(); + ~StickMan(); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + int nodeCount() const; + Node *node(int idx) const; + + void setDrawSticks(bool on); + bool drawSticks() const { return m_sticks; } + + QColor penColor() const { return m_penColor; } + void setPenColor(const QColor &color) { m_penColor = color; } + + QColor fillColor() const { return m_fillColor; } + void setFillColor(const QColor &color) { m_fillColor = color; } + + bool isDead() const { return m_isDead; } + void setIsDead(bool isDead) { m_isDead = isDead; } + +public slots: + void stabilize(); + void childPositionChanged(); + +protected: + void timerEvent(QTimerEvent *e); + +private: + QPointF posFor(int idx) const; + + Node **m_nodes; + qreal *m_perfectBoneLengths; + + uint m_sticks : 1; + uint m_isDead : 1; + uint m_reserved : 30; + + QPixmap m_pixmap; + QColor m_penColor; + QColor m_fillColor; +}; + +#endif // STICKMAN_H diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro new file mode 100644 index 0000000..7f8be33 --- /dev/null +++ b/examples/animation/stickman/stickman.pro @@ -0,0 +1,19 @@ +HEADERS += stickman.h \ + animation.h \ + node.h \ + lifecycle.h \ + graphicsview.h +SOURCES += main.cpp \ + stickman.cpp \ + animation.cpp \ + node.cpp \ + lifecycle.cpp \ + graphicsview.cpp + +INCLUDEPATH += $$PWD + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/stickman +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stickman.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/stickman +INSTALLS += target sources diff --git a/examples/assistant/assistant.pro b/examples/assistant/assistant.pro index 1477178..ff1f947 100644 --- a/examples/assistant/assistant.pro +++ b/examples/assistant/assistant.pro @@ -6,3 +6,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/assistant sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS assistant.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/assistant INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/assistant/simpletextviewer/mainwindow.cpp b/examples/assistant/simpletextviewer/mainwindow.cpp index 59f185a..6046571 100644 --- a/examples/assistant/simpletextviewer/mainwindow.cpp +++ b/examples/assistant/simpletextviewer/mainwindow.cpp @@ -101,11 +101,11 @@ void MainWindow::open() void MainWindow::createActions() { assistantAct = new QAction(tr("Help Contents"), this); - assistantAct->setShortcut(tr("F1")); + assistantAct->setShortcuts(QKeySequence::HelpContents); connect(assistantAct, SIGNAL(triggered()), this, SLOT(assistant())); openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); clearAct = new QAction(tr("&Clear"), this); @@ -113,7 +113,7 @@ void MainWindow::createActions() connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/assistant/simpletextviewer/simpletextviewer.pro b/examples/assistant/simpletextviewer/simpletextviewer.pro index 4b66edb..2c0eada 100644 --- a/examples/assistant/simpletextviewer/simpletextviewer.pro +++ b/examples/assistant/simpletextviewer/simpletextviewer.pro @@ -14,3 +14,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES documentation *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/assistant/simpletextviewer INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/dbus/complexpingpong/complexping.pro b/examples/dbus/complexpingpong/complexping.pro index 4b37b03..a01aed6 100644 --- a/examples/dbus/complexpingpong/complexping.pro +++ b/examples/dbus/complexpingpong/complexping.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/complexpingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/complexpingpong INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/complexpingpong/complexpong.pro b/examples/dbus/complexpingpong/complexpong.pro index e62fb85..f60863f 100644 --- a/examples/dbus/complexpingpong/complexpong.pro +++ b/examples/dbus/complexpingpong/complexpong.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/complexpingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/complexpingpong INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/dbus-chat/dbus-chat.pro b/examples/dbus/dbus-chat/dbus-chat.pro index a094048..1316f64 100644 --- a/examples/dbus/dbus-chat/dbus-chat.pro +++ b/examples/dbus/dbus-chat/dbus-chat.pro @@ -17,3 +17,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/chat sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/chat INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/dbus.pro b/examples/dbus/dbus.pro index 36bdc1a..f365829 100644 --- a/examples/dbus/dbus.pro +++ b/examples/dbus/dbus.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus sources.files = *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/listnames/listnames.pro b/examples/dbus/listnames/listnames.pro index e2096a7..4b484a5 100644 --- a/examples/dbus/listnames/listnames.pro +++ b/examples/dbus/listnames/listnames.pro @@ -15,3 +15,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/listnames INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/dbus/pingpong/ping.pro b/examples/dbus/pingpong/ping.pro index 5e5f07a..4b1affe 100644 --- a/examples/dbus/pingpong/ping.pro +++ b/examples/dbus/pingpong/ping.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/pingpong/pong.pro b/examples/dbus/pingpong/pong.pro index f377a71..bd824e1 100644 --- a/examples/dbus/pingpong/pong.pro +++ b/examples/dbus/pingpong/pong.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/pingpong INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro index d4a97fa..9b426d3 100644 --- a/examples/dbus/remotecontrolledcar/car/car.pro +++ b/examples/dbus/remotecontrolledcar/car/car.pro @@ -18,3 +18,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/car sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/car INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro index 3015127..159e3b1 100644 --- a/examples/dbus/remotecontrolledcar/controller/controller.pro +++ b/examples/dbus/remotecontrolledcar/controller/controller.pro @@ -19,3 +19,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/controller sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar/controller INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro index 73bfa37..6f29977 100644 --- a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro +++ b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro @@ -6,3 +6,5 @@ SUBDIRS = car \ sources.files = *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dbus/remotecontrolledcar INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/calculatorbuilder/calculatorbuilder.pro b/examples/designer/calculatorbuilder/calculatorbuilder.pro index 1d69cc8..cd8ac2c 100644 --- a/examples/designer/calculatorbuilder/calculatorbuilder.pro +++ b/examples/designer/calculatorbuilder/calculatorbuilder.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorbuilder sources.files = $$SOURCES $$HEADERS $$RESOURCES *.ui *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorbuilder INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/calculatorform/calculatorform.pro b/examples/designer/calculatorform/calculatorform.pro index 73f4351..87e9eb9 100644 --- a/examples/designer/calculatorform/calculatorform.pro +++ b/examples/designer/calculatorform/calculatorform.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorform sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/calculatorform INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/containerextension/containerextension.pro b/examples/designer/containerextension/containerextension.pro index 6a2cb58..8183f2d 100644 --- a/examples/designer/containerextension/containerextension.pro +++ b/examples/designer/containerextension/containerextension.pro @@ -24,3 +24,5 @@ target.path = $$[QT_INSTALL_PLUGINS]/designer sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/containerextension INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/customwidgetplugin/customwidgetplugin.pro b/examples/designer/customwidgetplugin/customwidgetplugin.pro index 4feee59..dc9281d 100644 --- a/examples/designer/customwidgetplugin/customwidgetplugin.pro +++ b/examples/designer/customwidgetplugin/customwidgetplugin.pro @@ -19,3 +19,5 @@ target.path = $$[QT_INSTALL_PLUGINS]/designer sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/customwidgetplugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/designer.pro b/examples/designer/designer.pro index 0f30421..8f9553b 100644 --- a/examples/designer/designer.pro +++ b/examples/designer/designer.pro @@ -17,3 +17,5 @@ solaris-cc*:SUBDIRS -= calculatorbuilder \ sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/taskmenuextension/taskmenuextension.pro b/examples/designer/taskmenuextension/taskmenuextension.pro index 83dd878..d0e76e8 100644 --- a/examples/designer/taskmenuextension/taskmenuextension.pro +++ b/examples/designer/taskmenuextension/taskmenuextension.pro @@ -23,3 +23,5 @@ target.path = $$[QT_INSTALL_PLUGINS]/designer sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/taskmenuextension INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/taskmenuextension/tictactoeplugin.cpp b/examples/designer/taskmenuextension/tictactoeplugin.cpp index 0ab11ce..8f11c49 100644 --- a/examples/designer/taskmenuextension/tictactoeplugin.cpp +++ b/examples/designer/taskmenuextension/tictactoeplugin.cpp @@ -124,6 +124,14 @@ QString TicTacToePlugin::domXml() const return QLatin1String("\ <ui language=\"c++\">\ <widget class=\"TicTacToe\" name=\"ticTacToe\"/>\ + <customwidgets>\ + <customwidget>\ + <class>TicTacToe</class>\ + <propertyspecifications>\ + <stringpropertyspecification name=\"state\" notr=\"true\" type=\"singleline\"/>\ + </propertyspecifications>\ + </customwidget>\ + </customwidgets>\ </ui>"); } diff --git a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro index 2690921..369cdff 100644 --- a/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro +++ b/examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockbuilder sources.files = $$SOURCES $$HEADERS $$RESOURCES *.ui *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockbuilder INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro index cd117dc..44500cb 100644 --- a/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro +++ b/examples/designer/worldtimeclockplugin/worldtimeclockplugin.pro @@ -19,3 +19,5 @@ target.path = $$[QT_INSTALL_PLUGINS]/designer sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/worldtimeclockplugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/desktop/desktop.pro b/examples/desktop/desktop.pro index b65f4f2..1c4e05b 100644 --- a/examples/desktop/desktop.pro +++ b/examples/desktop/desktop.pro @@ -2,10 +2,12 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = screenshot -contains(QT_CONFIG, svg): SUBDIRS += systray +!symbian:contains(QT_CONFIG, svg): SUBDIRS += systray # install target.path = $$[QT_INSTALL_EXAMPLES]/desktop sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS desktop.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/desktop INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/desktop/screenshot/screenshot.pro b/examples/desktop/screenshot/screenshot.pro index 3ecbf8f..ad743a0 100644 --- a/examples/desktop/screenshot/screenshot.pro +++ b/examples/desktop/screenshot/screenshot.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/desktop/screenshot sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS screenshot.pro sources.path = $$[QT_INSTALL_EXAMPLES]/desktop/screenshot INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/desktop/systray/systray.pro b/examples/desktop/systray/systray.pro index c73a48e..9b25916 100644 --- a/examples/desktop/systray/systray.pro +++ b/examples/desktop/systray/systray.pro @@ -10,6 +10,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS systray.pro resources im sources.path = $$[QT_INSTALL_EXAMPLES]/desktop/systray INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince* { CONFIG(debug, release|debug) { addPlugins.sources = $$QT_BUILD_TREE/plugins/imageformats/qsvgd4.dll diff --git a/examples/dialogs/classwizard/classwizard.pro b/examples/dialogs/classwizard/classwizard.pro index 15b6029..7d2e491 100644 --- a/examples/dialogs/classwizard/classwizard.pro +++ b/examples/dialogs/classwizard/classwizard.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/classwizard sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/classwizard INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dialogs/configdialog/configdialog.pro b/examples/dialogs/configdialog/configdialog.pro index 344a394..3785718 100644 --- a/examples/dialogs/configdialog/configdialog.pro +++ b/examples/dialogs/configdialog/configdialog.pro @@ -10,5 +10,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/configdialog sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/configdialog INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/dialogs/dialogs.pro b/examples/dialogs/dialogs.pro index b9f029a..ed41166 100644 --- a/examples/dialogs/dialogs.pro +++ b/examples/dialogs/dialogs.pro @@ -5,7 +5,7 @@ SUBDIRS = classwizard \ tabdialog \ trivialwizard -!wince*: SUBDIRS += licensewizard \ +!symbian:!wince*: SUBDIRS += licensewizard \ extension \ findfiles @@ -15,3 +15,5 @@ wince*: SUBDIRS += sipdialog sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dialogs/extension/extension.pro b/examples/dialogs/extension/extension.pro index 3e56cb9..f064dc2 100644 --- a/examples/dialogs/extension/extension.pro +++ b/examples/dialogs/extension/extension.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/extension sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/extension INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dialogs/findfiles/findfiles.pro b/examples/dialogs/findfiles/findfiles.pro index 99be394..2d97b3d 100644 --- a/examples/dialogs/findfiles/findfiles.pro +++ b/examples/dialogs/findfiles/findfiles.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/findfiles sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/findfiles INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dialogs/licensewizard/licensewizard.pro b/examples/dialogs/licensewizard/licensewizard.pro index fd5e37c..b76ae14 100644 --- a/examples/dialogs/licensewizard/licensewizard.pro +++ b/examples/dialogs/licensewizard/licensewizard.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/licensewizard INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/dialogs/sipdialog/sipdialog.pro b/examples/dialogs/sipdialog/sipdialog.pro index 69667eb..01ef411 100644 --- a/examples/dialogs/sipdialog/sipdialog.pro +++ b/examples/dialogs/sipdialog/sipdialog.pro @@ -7,6 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/sipdialog sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/sipdialog INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/dialogs/standarddialogs/standarddialogs.pro b/examples/dialogs/standarddialogs/standarddialogs.pro index 6bfa6bf..86ae1d1 100644 --- a/examples/dialogs/standarddialogs/standarddialogs.pro +++ b/examples/dialogs/standarddialogs/standarddialogs.pro @@ -7,5 +7,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/standarddialogs sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/standarddialogs INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/dialogs/tabdialog/tabdialog.pro b/examples/dialogs/tabdialog/tabdialog.pro index 3239a72..d716b64 100644 --- a/examples/dialogs/tabdialog/tabdialog.pro +++ b/examples/dialogs/tabdialog/tabdialog.pro @@ -7,4 +7,6 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/tabdialog sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/tabdialog INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) wince50standard-x86-msvc2005: LIBS += libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib ws2.lib diff --git a/examples/dialogs/trivialwizard/trivialwizard.pro b/examples/dialogs/trivialwizard/trivialwizard.pro index 970e12f..f17fe37 100644 --- a/examples/dialogs/trivialwizard/trivialwizard.pro +++ b/examples/dialogs/trivialwizard/trivialwizard.pro @@ -5,3 +5,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/dialogs/trivialwizard INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/draganddrop/delayedencoding/delayedencoding.pro b/examples/draganddrop/delayedencoding/delayedencoding.pro index c7b95b6..7315ac5 100644 --- a/examples/draganddrop/delayedencoding/delayedencoding.pro +++ b/examples/draganddrop/delayedencoding/delayedencoding.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/delayedencoding sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/delayedencoding INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000C614
\ No newline at end of file diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro index 0cd881a..fa857db 100644 --- a/examples/draganddrop/draganddrop.pro +++ b/examples/draganddrop/draganddrop.pro @@ -8,7 +8,7 @@ SUBDIRS = draggableicons \ contains(QT_CONFIG, svg): SUBDIRS += delayedencoding wince*: SUBDIRS -= dropsite - +symbian: SUBDIRS -= dropsite # install sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop diff --git a/examples/draganddrop/draggableicons/draggableicons.pro b/examples/draganddrop/draggableicons/draggableicons.pro index 74cfda9..f177bd6 100644 --- a/examples/draganddrop/draggableicons/draggableicons.pro +++ b/examples/draganddrop/draggableicons/draggableicons.pro @@ -8,3 +8,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/draggableicons sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/draggableicons INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C615 +} diff --git a/examples/draganddrop/draggabletext/draggabletext.pro b/examples/draganddrop/draggabletext/draggabletext.pro index 07c7c24..19fee2d 100644 --- a/examples/draganddrop/draggabletext/draggabletext.pro +++ b/examples/draganddrop/draggabletext/draggabletext.pro @@ -10,3 +10,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/draggabletext sources.files = $$SOURCES $$HEADERS $$RESOURCES *.txt *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/draggabletext INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF64 +} diff --git a/examples/draganddrop/dropsite/dropsite.pro b/examples/draganddrop/dropsite/dropsite.pro index 29dd0fd..5f81b09 100644 --- a/examples/draganddrop/dropsite/dropsite.pro +++ b/examples/draganddrop/dropsite/dropsite.pro @@ -10,3 +10,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/dropsite INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/draganddrop/dropsite/dropsitewindow.cpp b/examples/draganddrop/dropsite/dropsitewindow.cpp index 51fd8ff..d4227f9 100644 --- a/examples/draganddrop/dropsite/dropsitewindow.cpp +++ b/examples/draganddrop/dropsite/dropsitewindow.cpp @@ -119,10 +119,8 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData) text = mimeData->html().simplified(); } else if (format == "text/uri-list") { QList<QUrl> urlList = mimeData->urls(); - for (int i = 0; i < urlList.size() && i < 32; ++i) { - QString url = urlList.at(i).path(); - text.append(url + " "); - } + for (int i = 0; i < urlList.size() && i < 32; ++i) + text.append(urlList[i].toString() + " "); } else { QByteArray data = mimeData->data(format); for (int i = 0; i < data.size() && i < 32; ++i) { diff --git a/examples/draganddrop/fridgemagnets/dragwidget.cpp b/examples/draganddrop/fridgemagnets/dragwidget.cpp index a50bdb0..a619d5c 100644 --- a/examples/draganddrop/fridgemagnets/dragwidget.cpp +++ b/examples/draganddrop/fridgemagnets/dragwidget.cpp @@ -75,9 +75,12 @@ DragWidget::DragWidget(QWidget *parent) //! [1] //! [2] + #ifndef Q_WS_S60 + //Fridge magnets is used for demoing Qt on S60 and themed backgrounds look better than white QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); setPalette(newPalette); + #endif setMinimumSize(400, qMax(200, y)); setWindowTitle(tr("Fridge Magnets")); diff --git a/examples/draganddrop/fridgemagnets/fridgemagnets.pro b/examples/draganddrop/fridgemagnets/fridgemagnets.pro index f1baaef..b8388cf 100644 --- a/examples/draganddrop/fridgemagnets/fridgemagnets.pro +++ b/examples/draganddrop/fridgemagnets/fridgemagnets.pro @@ -10,3 +10,10 @@ target.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/fridgemagnets sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.txt sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/fridgemagnets INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C610 +} + + diff --git a/examples/draganddrop/fridgemagnets/main.cpp b/examples/draganddrop/fridgemagnets/main.cpp index 69ea367..959f303 100644 --- a/examples/draganddrop/fridgemagnets/main.cpp +++ b/examples/draganddrop/fridgemagnets/main.cpp @@ -45,9 +45,16 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(fridgemagnets); + bool smallScreen = false; + for (int i=0; i<argc; i++) + if (QString(argv[i]) == "-small-screen") + smallScreen = true; QApplication app(argc, argv); DragWidget window; - window.show(); + if (smallScreen) + window.showFullScreen(); + else + window.show(); return app.exec(); } diff --git a/examples/draganddrop/puzzle/mainwindow.cpp b/examples/draganddrop/puzzle/mainwindow.cpp index 359a245..a037df2 100644 --- a/examples/draganddrop/puzzle/mainwindow.cpp +++ b/examples/draganddrop/puzzle/mainwindow.cpp @@ -120,10 +120,10 @@ void MainWindow::setupMenus() QMenu *fileMenu = menuBar()->addMenu(tr("&File")); QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); + openAction->setShortcuts(QKeySequence::Open); QAction *exitAction = fileMenu->addAction(tr("E&xit")); - exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); + exitAction->setShortcuts(QKeySequence::Quit); QMenu *gameMenu = menuBar()->addMenu(tr("&Game")); diff --git a/examples/draganddrop/puzzle/puzzle.pro b/examples/draganddrop/puzzle/puzzle.pro index 26d2350..20080e9 100644 --- a/examples/draganddrop/puzzle/puzzle.pro +++ b/examples/draganddrop/puzzle/puzzle.pro @@ -13,6 +13,13 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg sources.path = $$[QT_INSTALL_EXAMPLES]/draganddrop/puzzle INSTALLS += target sources +symbian:{ + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + addFile.sources = example.jpg + addFile.path = . + DEPLOYMENT += addFile + TARGET.UID3 = 0xA000CF65 +} wince*: { addFile.sources = example.jpg addFile.path = . diff --git a/examples/effects/blurpicker/blureffect.cpp b/examples/effects/blurpicker/blureffect.cpp new file mode 100644 index 0000000..0b806aa --- /dev/null +++ b/examples/effects/blurpicker/blureffect.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blureffect.h" + +#include <QDebug> + +BlurEffect::BlurEffect(QGraphicsItem *item) + : QGraphicsBlurEffect() + , m_baseLine(200), item(item) +{ +} + +void BlurEffect::adjustForItem() +{ + qreal y = m_baseLine - item->pos().y(); + qreal radius = qBound(qreal(0.0), y / 32, qreal(16.0)); + setBlurRadius(radius); +} + +QRectF BlurEffect::boundingRect() const +{ + const_cast<BlurEffect *>(this)->adjustForItem(); + return QGraphicsBlurEffect::boundingRect(); +} + +void BlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +{ + adjustForItem(); + QGraphicsBlurEffect::draw(painter, source); +} diff --git a/examples/effects/blurpicker/blureffect.h b/examples/effects/blurpicker/blureffect.h new file mode 100644 index 0000000..25e84fe --- /dev/null +++ b/examples/effects/blurpicker/blureffect.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BLUREFFECT_H +#define BLUREFFECT_H + +#include <QGraphicsEffect> +#include <QGraphicsItem> + +class BlurEffect: public QGraphicsBlurEffect +{ +public: + BlurEffect(QGraphicsItem *item); + + void setBaseLine(qreal y) { m_baseLine = y; } + + QRectF boundingRect() const; + + void draw(QPainter *painter, QGraphicsEffectSource *source); + +private: + void adjustForItem(); + +private: + qreal m_baseLine; + QGraphicsItem *item; +}; + +#endif // BLUREFFECT_H diff --git a/examples/effects/blurpicker/blurpicker.cpp b/examples/effects/blurpicker/blurpicker.cpp new file mode 100644 index 0000000..791949a --- /dev/null +++ b/examples/effects/blurpicker/blurpicker.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blurpicker.h" + +#include <QtGui> + +#include "blureffect.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0) +{ + setBackgroundBrush(QPixmap(":/images/background.jpg")); + setScene(&m_scene); + + setupScene(); + updateIconPositions(); + + connect(&m_timeLine, SIGNAL(valueChanged(qreal)), SLOT(updateIconPositions())); + m_timeLine.setDuration(400); + + setRenderHint(QPainter::Antialiasing, true); + setFrameStyle(QFrame::NoFrame); +} + +void BlurPicker::updateIconPositions() +{ + m_index = m_timeLine.currentFrame() / 1000.0; + + qreal baseline = 0; + for (int i = 0; i < m_icons.count(); ++i) { + QGraphicsItem *icon = m_icons[i]; + qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count(); + qreal xs = 170 * sin(a); + qreal ys = 100 * cos(a); + QPointF pos(xs, ys); + pos = QTransform().rotate(-20).map(pos); + pos -= QPointF(40, 40); + icon->setPos(pos); + baseline = qMax(baseline, ys); + static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline); + } + + m_scene.update(); +} + +void BlurPicker::setupScene() +{ + m_scene.setSceneRect(-200, -120, 400, 240); + + QStringList names; + names << ":/images/accessories-calculator.png"; + names << ":/images/accessories-text-editor.png"; + names << ":/images/help-browser.png"; + names << ":/images/internet-group-chat.png"; + names << ":/images/internet-mail.png"; + names << ":/images/internet-web-browser.png"; + names << ":/images/office-calendar.png"; + names << ":/images/system-users.png"; + + for (int i = 0; i < names.count(); i++) { + QPixmap pixmap(names[i]); + QGraphicsPixmapItem *icon = m_scene.addPixmap(pixmap); + icon->setZValue(1); + icon->setGraphicsEffect(new BlurEffect(icon)); + m_icons << icon; + } + + QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/images/background.jpg")); + bg->setZValue(0); + bg->setPos(-200, -150); +} + +void BlurPicker::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Left) { + if (m_timeLine.state() == QTimeLine::NotRunning) { + m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 - 1000); + m_timeLine.start(); + event->accept(); + } + } + + if (event->key() == Qt::Key_Right) { + if (m_timeLine.state() == QTimeLine::NotRunning) { + m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 + 1000); + m_timeLine.start(); + event->accept(); + } + } +} diff --git a/examples/effects/blurpicker/blurpicker.h b/examples/effects/blurpicker/blurpicker.h new file mode 100644 index 0000000..cef4637 --- /dev/null +++ b/examples/effects/blurpicker/blurpicker.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BLURPICKER_H +#define BLURPICKER_H + +#include <QGraphicsEffect> +#include <QGraphicsView> +#include <QTimeLine> + +#include "blureffect.h" + +class BlurPicker: public QGraphicsView +{ + Q_OBJECT + +public: + BlurPicker(QWidget *parent = 0); + +protected: + void keyPressEvent(QKeyEvent *event); + +private slots: + void updateIconPositions(); + +private: + void setupScene(); + +private: + qreal m_index; + QGraphicsScene m_scene; + QList<QGraphicsItem*> m_icons; + QTimeLine m_timeLine; +}; + +#endif // BLURPICKER_H diff --git a/examples/effects/blurpicker/blurpicker.pro b/examples/effects/blurpicker/blurpicker.pro new file mode 100644 index 0000000..76537a9 --- /dev/null +++ b/examples/effects/blurpicker/blurpicker.pro @@ -0,0 +1,9 @@ +SOURCES += main.cpp blurpicker.cpp blureffect.cpp +HEADERS += blurpicker.h blureffect.h +RESOURCES += blurpicker.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/effects/blurpicker +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS blurpicker.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/effects/blurpicker +INSTALLS += target sources diff --git a/examples/effects/blurpicker/blurpicker.qrc b/examples/effects/blurpicker/blurpicker.qrc new file mode 100644 index 0000000..e88eaca --- /dev/null +++ b/examples/effects/blurpicker/blurpicker.qrc @@ -0,0 +1,14 @@ +<RCC> + <qresource prefix="/" > + <file>images/background.jpg</file> + <file>images/accessories-calculator.png</file> + <file>images/accessories-text-editor.png</file> + <file>images/help-browser.png</file> + <file>images/internet-group-chat.png</file> + <file>images/internet-mail.png</file> + <file>images/internet-web-browser.png</file> + <file>images/office-calendar.png</file> + <file>images/system-users.png</file> + </qresource> +</RCC> + diff --git a/examples/effects/blurpicker/images/README.txt b/examples/effects/blurpicker/images/README.txt new file mode 100644 index 0000000..0927e17 --- /dev/null +++ b/examples/effects/blurpicker/images/README.txt @@ -0,0 +1,5 @@ +The background is taken from a public domain photo at: +http://www.photos8.com/view/computer_board2-800x600.html + +All other icons are from the Tango Desktop project: +http://tango.freedesktop.org/Tango_Desktop_Project diff --git a/examples/effects/blurpicker/images/accessories-calculator.png b/examples/effects/blurpicker/images/accessories-calculator.png Binary files differnew file mode 100644 index 0000000..4e7661f --- /dev/null +++ b/examples/effects/blurpicker/images/accessories-calculator.png diff --git a/examples/effects/blurpicker/images/accessories-text-editor.png b/examples/effects/blurpicker/images/accessories-text-editor.png Binary files differnew file mode 100644 index 0000000..33bef0b --- /dev/null +++ b/examples/effects/blurpicker/images/accessories-text-editor.png diff --git a/examples/effects/blurpicker/images/background.jpg b/examples/effects/blurpicker/images/background.jpg Binary files differnew file mode 100644 index 0000000..e75b388 --- /dev/null +++ b/examples/effects/blurpicker/images/background.jpg diff --git a/examples/effects/blurpicker/images/help-browser.png b/examples/effects/blurpicker/images/help-browser.png Binary files differnew file mode 100644 index 0000000..8ef4fae --- /dev/null +++ b/examples/effects/blurpicker/images/help-browser.png diff --git a/examples/effects/blurpicker/images/internet-group-chat.png b/examples/effects/blurpicker/images/internet-group-chat.png Binary files differnew file mode 100644 index 0000000..dd92d93 --- /dev/null +++ b/examples/effects/blurpicker/images/internet-group-chat.png diff --git a/examples/effects/blurpicker/images/internet-mail.png b/examples/effects/blurpicker/images/internet-mail.png Binary files differnew file mode 100644 index 0000000..7e6b93b --- /dev/null +++ b/examples/effects/blurpicker/images/internet-mail.png diff --git a/examples/effects/blurpicker/images/internet-web-browser.png b/examples/effects/blurpicker/images/internet-web-browser.png Binary files differnew file mode 100644 index 0000000..a979a92 --- /dev/null +++ b/examples/effects/blurpicker/images/internet-web-browser.png diff --git a/examples/effects/blurpicker/images/office-calendar.png b/examples/effects/blurpicker/images/office-calendar.png Binary files differnew file mode 100644 index 0000000..e095906 --- /dev/null +++ b/examples/effects/blurpicker/images/office-calendar.png diff --git a/examples/effects/blurpicker/images/system-users.png b/examples/effects/blurpicker/images/system-users.png Binary files differnew file mode 100644 index 0000000..a7f630a --- /dev/null +++ b/examples/effects/blurpicker/images/system-users.png diff --git a/examples/effects/blurpicker/main.cpp b/examples/effects/blurpicker/main.cpp new file mode 100644 index 0000000..b557db6 --- /dev/null +++ b/examples/effects/blurpicker/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blurpicker.h" +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + BlurPicker blurPicker; + blurPicker.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Application Picker")); + blurPicker.setFixedSize(400, 300); + blurPicker.show(); + + return app.exec(); +} diff --git a/examples/effects/customshader/blureffect.cpp b/examples/effects/customshader/blureffect.cpp new file mode 100644 index 0000000..9923324 --- /dev/null +++ b/examples/effects/customshader/blureffect.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blureffect.h" + +#include <QDebug> + +BlurEffect::BlurEffect(QGraphicsItem *item) + : QGraphicsBlurEffect() + , m_baseLine(200), item(item) +{ +} + +void BlurEffect::adjustForItem() +{ + qreal y = m_baseLine - item->pos().y(); + qreal radius = qBound(qreal(0.0), y / 32, qreal(16.0)); + setBlurRadius(radius); +} + +QRectF BlurEffect::boundingRectFor(const QRectF &rect) const +{ + const_cast<BlurEffect *>(this)->adjustForItem(); + return QGraphicsBlurEffect::boundingRectFor(rect); +} + +void BlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +{ + adjustForItem(); + QGraphicsBlurEffect::draw(painter, source); +} diff --git a/examples/effects/customshader/blureffect.h b/examples/effects/customshader/blureffect.h new file mode 100644 index 0000000..b7efde3 --- /dev/null +++ b/examples/effects/customshader/blureffect.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BLUREFFECT_H +#define BLUREFFECT_H + +#include <QGraphicsEffect> +#include <QGraphicsItem> + +class BlurEffect: public QGraphicsBlurEffect +{ +public: + BlurEffect(QGraphicsItem *item); + + void setBaseLine(qreal y) { m_baseLine = y; } + + QRectF boundingRectFor(const QRectF &) const; + + void draw(QPainter *painter, QGraphicsEffectSource*); + +private: + void adjustForItem(); + +private: + qreal m_baseLine; + QGraphicsItem *item; +}; + +#endif // BLUREFFECT_H diff --git a/examples/effects/customshader/blurpicker.cpp b/examples/effects/customshader/blurpicker.cpp new file mode 100644 index 0000000..4b03f31 --- /dev/null +++ b/examples/effects/customshader/blurpicker.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blurpicker.h" + +#include <QtGui> + +#include "blureffect.h" +#include "customshadereffect.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +BlurPicker::BlurPicker(QWidget *parent): QGraphicsView(parent), m_index(0.0) +{ + setBackgroundBrush(QPixmap(":/images/background.jpg")); + setScene(&m_scene); + + setupScene(); + updateIconPositions(); + + connect(&m_timeLine, SIGNAL(valueChanged(qreal)), SLOT(updateIconPositions())); + m_timeLine.setDuration(400); + + setRenderHint(QPainter::Antialiasing, true); + setFrameStyle(QFrame::NoFrame); +} + +void BlurPicker::updateIconPositions() +{ + m_index = m_timeLine.currentFrame() / 1000.0; + + qreal baseline = 0; + for (int i = 0; i < m_icons.count(); ++i) { + QGraphicsItem *icon = m_icons[i]; + qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count(); + qreal xs = 170 * sin(a); + qreal ys = 100 * cos(a); + QPointF pos(xs, ys); + pos = QTransform().rotate(-20).map(pos); + pos -= QPointF(40, 40); + icon->setPos(pos); + baseline = qMax(baseline, ys); + if (i != 3) + static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline); + } + + m_scene.update(); +} + +void BlurPicker::setupScene() +{ + m_scene.setSceneRect(-200, -120, 400, 240); + + QStringList names; + names << ":/images/accessories-calculator.png"; + names << ":/images/accessories-text-editor.png"; + names << ":/images/help-browser.png"; + names << ":/images/internet-group-chat.png"; + names << ":/images/internet-mail.png"; + names << ":/images/internet-web-browser.png"; + names << ":/images/office-calendar.png"; + names << ":/images/system-users.png"; + + for (int i = 0; i < names.count(); i++) { + QPixmap pixmap(names[i]); + QGraphicsPixmapItem *icon = m_scene.addPixmap(pixmap); + icon->setZValue(1); + if (i == 3) + icon->setGraphicsEffect(new CustomShaderEffect()); + else + icon->setGraphicsEffect(new BlurEffect(icon)); + m_icons << icon; + } + + QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/images/background.jpg")); + bg->setZValue(0); + bg->setPos(-200, -150); +} + +void BlurPicker::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Left) { + if (m_timeLine.state() == QTimeLine::NotRunning) { + m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 - 1000); + m_timeLine.start(); + event->accept(); + } + } + + if (event->key() == Qt::Key_Right) { + if (m_timeLine.state() == QTimeLine::NotRunning) { + m_timeLine.setFrameRange(m_index * 1000, m_index * 1000 + 1000); + m_timeLine.start(); + event->accept(); + } + } +} diff --git a/examples/effects/customshader/blurpicker.h b/examples/effects/customshader/blurpicker.h new file mode 100644 index 0000000..cef4637 --- /dev/null +++ b/examples/effects/customshader/blurpicker.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BLURPICKER_H +#define BLURPICKER_H + +#include <QGraphicsEffect> +#include <QGraphicsView> +#include <QTimeLine> + +#include "blureffect.h" + +class BlurPicker: public QGraphicsView +{ + Q_OBJECT + +public: + BlurPicker(QWidget *parent = 0); + +protected: + void keyPressEvent(QKeyEvent *event); + +private slots: + void updateIconPositions(); + +private: + void setupScene(); + +private: + qreal m_index; + QGraphicsScene m_scene; + QList<QGraphicsItem*> m_icons; + QTimeLine m_timeLine; +}; + +#endif // BLURPICKER_H diff --git a/examples/effects/customshader/blurpicker.qrc b/examples/effects/customshader/blurpicker.qrc new file mode 100644 index 0000000..e88eaca --- /dev/null +++ b/examples/effects/customshader/blurpicker.qrc @@ -0,0 +1,14 @@ +<RCC> + <qresource prefix="/" > + <file>images/background.jpg</file> + <file>images/accessories-calculator.png</file> + <file>images/accessories-text-editor.png</file> + <file>images/help-browser.png</file> + <file>images/internet-group-chat.png</file> + <file>images/internet-mail.png</file> + <file>images/internet-web-browser.png</file> + <file>images/office-calendar.png</file> + <file>images/system-users.png</file> + </qresource> +</RCC> + diff --git a/examples/effects/customshader/customshader.pro b/examples/effects/customshader/customshader.pro new file mode 100644 index 0000000..4ce5d2b --- /dev/null +++ b/examples/effects/customshader/customshader.pro @@ -0,0 +1,10 @@ +SOURCES += main.cpp blurpicker.cpp blureffect.cpp customshadereffect.cpp +HEADERS += blurpicker.h blureffect.h customshadereffect.h +RESOURCES += blurpicker.qrc +QT += opengl + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/effects/customshader +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS customshader.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/effects/customshader +INSTALLS += target sources diff --git a/examples/effects/customshader/customshadereffect.cpp b/examples/effects/customshader/customshadereffect.cpp new file mode 100644 index 0000000..69fdb15 --- /dev/null +++ b/examples/effects/customshader/customshadereffect.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "customshadereffect.h" +#include <QGLShaderProgram> + +static char const colorizeShaderCode[] = + "uniform lowp vec4 effectColor;\n" + "mediump vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) {\n" + " vec4 src = texture2D(imageTexture, textureCoords);\n" + " float gray = dot(src.rgb, vec3(0.212671, 0.715160, 0.072169));\n" + " vec4 colorize = 1.0-((1.0-gray)*(1.0-effectColor));\n" + " return vec4(colorize.rgb, src.a);\n" + "}"; + +CustomShaderEffect::CustomShaderEffect() + : QGraphicsShaderEffect(), + color(Qt::red) +{ + setPixelShaderFragment(colorizeShaderCode); +} + +void CustomShaderEffect::setEffectColor(const QColor& c) +{ + color = c; + setUniformsDirty(); +} + +void CustomShaderEffect::setUniforms(QGLShaderProgram *program) +{ + program->setUniformValue("effectColor", color); +} diff --git a/examples/effects/customshader/customshadereffect.h b/examples/effects/customshader/customshadereffect.h new file mode 100644 index 0000000..610af4b --- /dev/null +++ b/examples/effects/customshader/customshadereffect.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMSHADEREFFECT_H +#define CUSTOMSHADEREFFECT_H + +#include <QGraphicsEffect> +#include <QGraphicsShaderEffect> +#include <QGraphicsItem> + +class CustomShaderEffect: public QGraphicsShaderEffect +{ +public: + CustomShaderEffect(); + + QColor effectColor() const { return color; } + void setEffectColor(const QColor& c); + +protected: + void setUniforms(QGLShaderProgram *program); + +private: + QColor color; +}; + +#endif // CUSTOMSHADEREFFECT_H diff --git a/examples/effects/customshader/images/README.txt b/examples/effects/customshader/images/README.txt new file mode 100644 index 0000000..0927e17 --- /dev/null +++ b/examples/effects/customshader/images/README.txt @@ -0,0 +1,5 @@ +The background is taken from a public domain photo at: +http://www.photos8.com/view/computer_board2-800x600.html + +All other icons are from the Tango Desktop project: +http://tango.freedesktop.org/Tango_Desktop_Project diff --git a/examples/effects/customshader/images/accessories-calculator.png b/examples/effects/customshader/images/accessories-calculator.png Binary files differnew file mode 100644 index 0000000..4e7661f --- /dev/null +++ b/examples/effects/customshader/images/accessories-calculator.png diff --git a/examples/effects/customshader/images/accessories-text-editor.png b/examples/effects/customshader/images/accessories-text-editor.png Binary files differnew file mode 100644 index 0000000..33bef0b --- /dev/null +++ b/examples/effects/customshader/images/accessories-text-editor.png diff --git a/examples/effects/customshader/images/background.jpg b/examples/effects/customshader/images/background.jpg Binary files differnew file mode 100644 index 0000000..e75b388 --- /dev/null +++ b/examples/effects/customshader/images/background.jpg diff --git a/examples/effects/customshader/images/help-browser.png b/examples/effects/customshader/images/help-browser.png Binary files differnew file mode 100644 index 0000000..8ef4fae --- /dev/null +++ b/examples/effects/customshader/images/help-browser.png diff --git a/examples/effects/customshader/images/internet-group-chat.png b/examples/effects/customshader/images/internet-group-chat.png Binary files differnew file mode 100644 index 0000000..dd92d93 --- /dev/null +++ b/examples/effects/customshader/images/internet-group-chat.png diff --git a/examples/effects/customshader/images/internet-mail.png b/examples/effects/customshader/images/internet-mail.png Binary files differnew file mode 100644 index 0000000..7e6b93b --- /dev/null +++ b/examples/effects/customshader/images/internet-mail.png diff --git a/examples/effects/customshader/images/internet-web-browser.png b/examples/effects/customshader/images/internet-web-browser.png Binary files differnew file mode 100644 index 0000000..a979a92 --- /dev/null +++ b/examples/effects/customshader/images/internet-web-browser.png diff --git a/examples/effects/customshader/images/office-calendar.png b/examples/effects/customshader/images/office-calendar.png Binary files differnew file mode 100644 index 0000000..e095906 --- /dev/null +++ b/examples/effects/customshader/images/office-calendar.png diff --git a/examples/effects/customshader/images/system-users.png b/examples/effects/customshader/images/system-users.png Binary files differnew file mode 100644 index 0000000..a7f630a --- /dev/null +++ b/examples/effects/customshader/images/system-users.png diff --git a/examples/effects/customshader/main.cpp b/examples/effects/customshader/main.cpp new file mode 100644 index 0000000..b557db6 --- /dev/null +++ b/examples/effects/customshader/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "blurpicker.h" +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + BlurPicker blurPicker; + blurPicker.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Application Picker")); + blurPicker.setFixedSize(400, 300); + blurPicker.show(); + + return app.exec(); +} diff --git a/examples/effects/effects.pro b/examples/effects/effects.pro new file mode 100644 index 0000000..60b5baf --- /dev/null +++ b/examples/effects/effects.pro @@ -0,0 +1,14 @@ +TEMPLATE = \ + subdirs +SUBDIRS = \ + blurpicker \ + lighting + +contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2):SUBDIRS += customshader + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/effects +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS effects.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/effects +INSTALLS += target sources + diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp new file mode 100644 index 0000000..c9851a5 --- /dev/null +++ b/examples/effects/lighting/lighting.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "lighting.h" + +#include <QtGui> + +#include "shadoweffect.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +Lighting::Lighting(QWidget *parent): QGraphicsView(parent), angle(0.0) +{ + setScene(&m_scene); + + setupScene(); + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), SLOT(animate())); + timer->setInterval(30); + timer->start(); + + setRenderHint(QPainter::Antialiasing, true); + setFrameStyle(QFrame::NoFrame); +} + +void Lighting::setupScene() +{ + m_scene.setSceneRect(-300, -200, 600, 460); + + QLinearGradient linearGrad(QPointF(-100, -100), QPointF(100, 100)); + linearGrad.setColorAt(0, QColor(255, 255, 255)); + linearGrad.setColorAt(1, QColor(192, 192, 255)); + setBackgroundBrush(linearGrad); + + QRadialGradient radialGrad(30, 30, 30); + radialGrad.setColorAt(0, Qt::yellow); + radialGrad.setColorAt(0.2, Qt::yellow); + radialGrad.setColorAt(1, Qt::transparent); + QPixmap pixmap(60, 60); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + painter.setPen(Qt::NoPen); + painter.setBrush(radialGrad); + painter.drawEllipse(0, 0, 60, 60); + painter.end(); + + m_lightSource = m_scene.addPixmap(pixmap); + m_lightSource->setZValue(2); + + for (int i = -2; i < 3; ++i) + for (int j = -2; j < 3; ++j) { + QAbstractGraphicsShapeItem *item; + if ((i + j) & 1) + item = new QGraphicsEllipseItem(0, 0, 50, 50); + else + item = new QGraphicsRectItem(0, 0, 50, 50); + + item->setPen(QPen(Qt::black)); + item->setBrush(QBrush(Qt::white)); + item->setGraphicsEffect(new ShadowEffect(item, m_lightSource)); + item->setZValue(1); + item->setPos(i * 80, j * 80); + m_scene.addItem(item); + m_items << item; + } + + +} + +void Lighting::animate() +{ + angle += (M_PI / 30); + qreal xs = 200 * sin(angle) - 40 + 25; + qreal ys = 200 * cos(angle) - 40 + 25; + m_lightSource->setPos(xs, ys); + m_scene.update(); +} + diff --git a/examples/effects/lighting/lighting.h b/examples/effects/lighting/lighting.h new file mode 100644 index 0000000..1c4553c --- /dev/null +++ b/examples/effects/lighting/lighting.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIGHTING_H +#define LIGHTING_H + +#include <QGraphicsEffect> +#include <QGraphicsView> + +#include "shadoweffect.h" + +class Lighting: public QGraphicsView +{ + Q_OBJECT + +public: + Lighting(QWidget *parent = 0); + +private slots: + void animate(); + +private: + void setupScene(); + +private: + qreal angle; + QGraphicsScene m_scene; + QGraphicsItem *m_lightSource; + QList<QGraphicsItem*> m_items; +}; + +#endif // LIGHTING_H diff --git a/examples/effects/lighting/lighting.pro b/examples/effects/lighting/lighting.pro new file mode 100644 index 0000000..ea9d5f6 --- /dev/null +++ b/examples/effects/lighting/lighting.pro @@ -0,0 +1,8 @@ +SOURCES += main.cpp lighting.cpp shadoweffect.cpp +HEADERS += lighting.h shadoweffect.h + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/effects/lighting +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS lighting.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/effects/lighting +INSTALLS += target sources diff --git a/examples/effects/lighting/main.cpp b/examples/effects/lighting/main.cpp new file mode 100644 index 0000000..52ede4a --- /dev/null +++ b/examples/effects/lighting/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "lighting.h" +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + Lighting lighting; + lighting.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Lighting and Shadows")); + lighting.resize(640, 480); + lighting.show(); + + return app.exec(); +} diff --git a/examples/effects/lighting/shadoweffect.cpp b/examples/effects/lighting/shadoweffect.cpp new file mode 100644 index 0000000..1871b89 --- /dev/null +++ b/examples/effects/lighting/shadoweffect.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "shadoweffect.h" + +#include <math.h> + +ShadowEffect::ShadowEffect(QGraphicsItem *item, QGraphicsItem *source) + : QGraphicsDropShadowEffect() + , item(item), m_lightSource(source) +{ + setBlurRadius(8); + m_color = color(); +} + +void ShadowEffect::adjustForItem() +{ + QPointF delta = item->pos() - m_lightSource->pos(); + setOffset(delta.toPoint() / 30); + + qreal dx = delta.x(); + qreal dy = delta.y(); + qreal dd = sqrt(dx * dx + dy * dy); + m_color.setAlphaF(qBound(0.4, 1 - dd / 200.0, 0.7)); + setColor(m_color); +} + +QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const +{ + const_cast<ShadowEffect *>(this)->adjustForItem(); + return QGraphicsDropShadowEffect::boundingRectFor(rect); +} + +void ShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) +{ + adjustForItem(); + QGraphicsDropShadowEffect::draw(painter, source); +} diff --git a/examples/effects/lighting/shadoweffect.h b/examples/effects/lighting/shadoweffect.h new file mode 100644 index 0000000..3221fd1 --- /dev/null +++ b/examples/effects/lighting/shadoweffect.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SHADOWEFFECT_H +#define SHADOWEFFECT_H + +#include <QGraphicsEffect> +#include <QGraphicsItem> + +class ShadowEffect: public QGraphicsDropShadowEffect +{ +public: + ShadowEffect(QGraphicsItem *item, QGraphicsItem *source); + + QRectF boundingRectFor(const QRectF &rect) const; + + void draw(QPainter *painter, QGraphicsEffectSource *source); + +private: + void adjustForItem(); + +private: + QColor m_color; + QGraphicsItem *item; + QGraphicsItem *m_lightSource; +}; + +#endif // SHADOWEFFECT_H diff --git a/examples/examples.pro b/examples/examples.pro index 41501a0..7acd67b 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,8 +1,10 @@ TEMPLATE = subdirs SUBDIRS = \ + animation \ desktop \ dialogs \ draganddrop \ + effects \ graphicsview \ ipc \ itemviews \ @@ -14,24 +16,46 @@ SUBDIRS = \ qtconcurrent \ richtext \ sql \ + statemachine \ threads \ tools \ tutorials \ widgets \ uitools \ xml \ - script + multitouch \ + gestures + +symbian: SUBDIRS = \ + graphicsview \ + itemviews \ + network \ + painting \ + widgets \ + draganddrop \ + mainwindows \ + sql \ + uitools \ + xml + +contains(QT_CONFIG, multimedia) { + SUBDIRS += video + !static: SUBDIRS += multimedia +} + +contains(QT_CONFIG, script): SUBDIRS += script contains(QT_CONFIG, phonon):!static: SUBDIRS += phonon contains(QT_CONFIG, webkit): SUBDIRS += webkit embedded:SUBDIRS += qws -!wince*: { +!wince*:!symbian: { !contains(QT_EDITION, Console):contains(QT_BUILD_PARTS, tools):SUBDIRS += designer contains(QT_BUILD_PARTS, tools):SUBDIRS += assistant qtestlib help } else { contains(QT_BUILD_PARTS, tools):SUBDIRS += qtestlib } contains(QT_CONFIG, opengl): SUBDIRS += opengl +contains(QT_CONFIG, openvg): SUBDIRS += openvg contains(QT_CONFIG, dbus): SUBDIRS += dbus win32: SUBDIRS += activeqt contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns @@ -41,3 +65,5 @@ contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES] INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/gestures/gestures.pro b/examples/gestures/gestures.pro new file mode 100644 index 0000000..09cd56a --- /dev/null +++ b/examples/gestures/gestures.pro @@ -0,0 +1,10 @@ +TEMPLATE = \ + subdirs +SUBDIRS = \ + imageviewer + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/gestures +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS gestures.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/gestures +INSTALLS += target sources diff --git a/examples/gestures/imageviewer/imageviewer.pro b/examples/gestures/imageviewer/imageviewer.pro new file mode 100644 index 0000000..efbca00 --- /dev/null +++ b/examples/gestures/imageviewer/imageviewer.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += imagewidget.h \ + tapandholdgesture.h +SOURCES += imagewidget.cpp \ + tapandholdgesture.cpp \ + main.cpp diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp new file mode 100644 index 0000000..6803d84 --- /dev/null +++ b/examples/gestures/imageviewer/imagewidget.cpp @@ -0,0 +1,247 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "imagewidget.h" + +#include <QtGui> + +ImageWidget::ImageWidget(QWidget *parent) + : QWidget(parent), + position(0), + horizontalOffset(0), + verticalOffset(0), + rotationAngle(0), + scaleFactor(1) + +{ + setObjectName("ImageWidget"); + setMinimumSize(QSize(100,100)); + + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_NoSystemBackground); + + QGesture *panGesture = new QPanGesture(this); + connect(panGesture, SIGNAL(started()), this, SLOT(panTriggered())); + connect(panGesture, SIGNAL(finished()), this, SLOT(panTriggered())); + connect(panGesture, SIGNAL(cancelled()), this, SLOT(panTriggered())); + connect(panGesture, SIGNAL(triggered()), this, SLOT(panTriggered())); + + QGesture *pinchGesture = new QPinchGesture(this); + connect(pinchGesture, SIGNAL(started()), this, SLOT(pinchTriggered())); + connect(pinchGesture, SIGNAL(finished()), this, SLOT(pinchTriggered())); + connect(pinchGesture, SIGNAL(cancelled()), this, SLOT(pinchTriggered())); + connect(pinchGesture, SIGNAL(triggered()), this, SLOT(pinchTriggered())); + + QGesture *swipeGesture = new QSwipeGesture(this); + connect(swipeGesture, SIGNAL(triggered()), this, SLOT(swipeTriggered())); +} + +void ImageWidget::paintEvent(QPaintEvent*) +{ + QPainter p(this); + p.fillRect(rect(), Qt::white); + + float iw = currentImage.width(); + float ih = currentImage.height(); + float wh = height(); + float ww = width(); + + p.translate(ww/2, wh/2); + p.translate(horizontalOffset, verticalOffset); + p.rotate(rotationAngle); + p.scale(scaleFactor, scaleFactor); + p.translate(-iw/2, -ih/2); + p.drawImage(0, 0, currentImage); +} + +void ImageWidget::mouseDoubleClickEvent(QMouseEvent *) +{ + rotationAngle = 0; + scaleFactor = 1; + verticalOffset = 0; + horizontalOffset = 0; + update(); +} + +void ImageWidget::panTriggered() +{ + QPanGesture *pg = qobject_cast<QPanGesture*>(sender()); +#ifndef QT_NO_CURSOR + switch (pg->state()) { + case Qt::GestureStarted: + case Qt::GestureUpdated: + setCursor(Qt::SizeAllCursor); + break; + default: + setCursor(Qt::ArrowCursor); + } +#endif + horizontalOffset += pg->lastOffset().width(); + verticalOffset += pg->lastOffset().height(); + update(); +} + +void ImageWidget::pinchTriggered() +{ + QPinchGesture *pg = qobject_cast<QPinchGesture*>(sender()); + rotationAngle += pg->rotationAngle(); + scaleFactor += pg->scaleFactor(); + update(); +} + +void ImageWidget::swipeTriggered() +{ + QSwipeGesture *pg = qobject_cast<QSwipeGesture*>(sender()); + qDebug() << (int) pg->horizontalDirection(); + qDebug() << pg->swipeAngle(); + + if (pg->horizontalDirection() == QSwipeGesture::Left + || pg->verticalDirection() == QSwipeGesture::Up) + goPrevImage(); + else + goNextImage(); + update(); +} + +void ImageWidget::resizeEvent(QResizeEvent*) +{ + update(); +} + +void ImageWidget::openDirectory(const QString &path) +{ + this->path = path; + QDir dir(path); + QStringList nameFilters; + nameFilters << "*.jpg" << "*.png"; + files = dir.entryList(nameFilters, QDir::Files|QDir::Readable, QDir::Name); + + position = 0; + goToImage(0); + update(); +} + +QImage ImageWidget::loadImage(const QString &fileName) +{ + QImageReader reader(fileName); + if (!reader.canRead()) { + qDebug() << fileName << ": can't load image"; + return QImage(); + } + + QImage image; + if (!reader.read(&image)) { + qDebug() << fileName << ": corrupted image"; + return QImage(); + } + return image; +} + +void ImageWidget::goNextImage() +{ + if (files.isEmpty()) + return; + + if (position < files.size()-1) { + ++position; + prevImage = currentImage; + currentImage = nextImage; + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + } + update(); +} + +void ImageWidget::goPrevImage() +{ + if (files.isEmpty()) + return; + + if (position > 0) { + --position; + nextImage = currentImage; + currentImage = prevImage; + if (position > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + } + update(); +} + +void ImageWidget::goToImage(int index) +{ + if (files.isEmpty()) + return; + + if (index < 0 || index >= files.size()) { + qDebug() << "goToImage: invalid index: " << index; + return; + } + + if (index == position+1) { + goNextImage(); + return; + } + + if (position > 0 && index == position-1) { + goPrevImage(); + return; + } + + position = index; + + if (index > 0) + prevImage = loadImage(path+QLatin1String("/")+files.at(position-1)); + else + prevImage = QImage(); + currentImage = loadImage(path+QLatin1String("/")+files.at(position)); + if (position+1 < files.size()) + nextImage = loadImage(path+QLatin1String("/")+files.at(position+1)); + else + nextImage = QImage(); + update(); +} + +#include "moc_imagewidget.cpp" diff --git a/examples/gestures/imageviewer/imagewidget.h b/examples/gestures/imageviewer/imagewidget.h new file mode 100644 index 0000000..b20d8ad --- /dev/null +++ b/examples/gestures/imageviewer/imagewidget.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IMAGEWIDGET_H +#define IMAGEWIDGET_H + +#include <QWidget> +#include <QImage> +#include <QtGui> + +class ImageWidget : public QWidget +{ + Q_OBJECT + +public: + ImageWidget(QWidget *parent = 0); + + void openDirectory(const QString &path); + +protected: + void paintEvent(QPaintEvent*); + void resizeEvent(QResizeEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + +private slots: + void panTriggered(); + void pinchTriggered(); + void swipeTriggered(); + +private: + void updateImage(); + QImage loadImage(const QString &fileName); + void loadImage(); + void goNextImage(); + void goPrevImage(); + void goToImage(int index); + + QString path; + QStringList files; + int position; + + QImage prevImage, nextImage; + QImage currentImage; + + float horizontalOffset; + float verticalOffset; + float rotationAngle; + float scaleFactor; +}; + +#endif diff --git a/examples/gestures/imageviewer/main.cpp b/examples/gestures/imageviewer/main.cpp new file mode 100644 index 0000000..2d333b8 --- /dev/null +++ b/examples/gestures/imageviewer/main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "imagewidget.h" + +class MainWidget : public QMainWindow +{ + Q_OBJECT + +public: + MainWidget(QWidget *parent = 0); + +public slots: + void openDirectory(const QString &path); + +private: + bool loadImage(const QString &fileName); + + ImageWidget *imageWidget; +}; + +MainWidget::MainWidget(QWidget *parent) + : QMainWindow(parent) +{ + resize(400, 300); + imageWidget = new ImageWidget(this); + setCentralWidget(imageWidget); +} + +void MainWidget::openDirectory(const QString &path) +{ + imageWidget->openDirectory(path); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + MainWidget w; + w.show(); + + if (QApplication::arguments().size() > 1) + w.openDirectory(QApplication::arguments().at(1)); + else + w.openDirectory(QFileDialog::getExistingDirectory(0, "Select image folder")); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/gestures/imageviewer/tapandholdgesture.cpp b/examples/gestures/imageviewer/tapandholdgesture.cpp new file mode 100644 index 0000000..fffe10f --- /dev/null +++ b/examples/gestures/imageviewer/tapandholdgesture.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tapandholdgesture.h" + +#include <QtGui/qevent.h> + +// #define TAPANDHOLD_USING_MOUSE + +/*! + \class TapAndHoldGesture + \since 4.6 + + \brief The TapAndHoldGesture class represents a Tap-and-Hold gesture, + providing additional information. +*/ + +const int TapAndHoldGesture::iterationCount = 40; +const int TapAndHoldGesture::iterationTimeout = 50; + +/*! + Creates a new Tap and Hold gesture handler object and marks it as a child + of \a parent. + + On some platforms like Windows there is a system-wide tap and hold gesture + that cannot be overriden, hence the gesture might never trigger and default + context menu will be shown instead. +*/ +TapAndHoldGesture::TapAndHoldGesture(QWidget *parent) + : QGesture(parent), iteration(0) +{ +} + +/*! \internal */ +bool TapAndHoldGesture::filterEvent(QEvent *event) +{ + const QTouchEvent *ev = static_cast<const QTouchEvent*>(event); + switch (event->type()) { + case QEvent::TouchBegin: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = ev->touchPoints().at(0).pos().toPoint(); + position = p; + break; + } + case QEvent::TouchUpdate: + if (ev->touchPoints().size() == 1) { + const QPoint startPos = ev->touchPoints().at(0).startPos().toPoint(); + const QPoint pos = ev->touchPoints().at(0).pos().toPoint(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + } else { + reset(); + } + break; + case QEvent::TouchEnd: + reset(); + break; +#ifdef TAPANDHOLD_USING_MOUSE + case QEvent::MouseButtonPress: { + if (timer.isActive()) + timer.stop(); + timer.start(TapAndHoldGesture::iterationTimeout, this); + const QPoint p = static_cast<QMouseEvent*>(event)->pos(); + position = startPosition = p; + break; + } + case QEvent::MouseMove: { + const QPoint startPos = startPosition; + const QPoint pos = static_cast<QMouseEvent*>(event)->pos(); + if ((startPos - pos).manhattanLength() > 15) + reset(); + break; + } + case QEvent::MouseButtonRelease: + reset(); + break; +#endif // TAPANDHOLD_USING_MOUSE + default: + break; + } + return false; +} + +/*! \internal */ +void TapAndHoldGesture::timerEvent(QTimerEvent *event) +{ + if (event->timerId() != timer.timerId()) + return; + if (iteration == TapAndHoldGesture::iterationCount) { + timer.stop(); + updateState(Qt::GestureFinished); + } else { + updateState(Qt::GestureUpdated); + } + ++iteration; +} + +/*! \internal */ +void TapAndHoldGesture::reset() +{ + timer.stop(); + iteration = 0; + position = startPosition = QPoint(); + updateState(Qt::NoGesture); +} + +/*! + \property TapAndHoldGesture::pos + + \brief The position of the gesture. +*/ +QPoint TapAndHoldGesture::pos() const +{ + return position; +} diff --git a/examples/gestures/imageviewer/tapandholdgesture.h b/examples/gestures/imageviewer/tapandholdgesture.h new file mode 100644 index 0000000..bf0f867 --- /dev/null +++ b/examples/gestures/imageviewer/tapandholdgesture.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TAPANDHOLDGESTURE_H +#define TAPANDHOLDGESTURE_H + +#include <QtCore/QBasicTimer> +#include <QtGui/QGesture> +#include <QtGui/QWidget> + +class TapAndHoldGesture : public QGesture +{ + Q_OBJECT + Q_PROPERTY(QPoint pos READ pos) + +public: + TapAndHoldGesture(QWidget *parent); + + bool filterEvent(QEvent *event); + void reset(); + + QPoint pos() const; + +protected: + void timerEvent(QTimerEvent *event); + +private: + QBasicTimer timer; + int iteration; + QPoint position; + QPoint startPosition; + static const int iterationCount; + static const int iterationTimeout; +}; + +#endif // TAPANDHOLDGESTURE_H diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro new file mode 100644 index 0000000..c969c8b --- /dev/null +++ b/examples/graphicsview/anchorlayout/anchorlayout.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue May 12 15:22:25 2009 +###################################################################### + +# Input +SOURCES += main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout +sources.files = $$SOURCES $$HEADERS $$RESOURCES anchorlayout.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout +INSTALLS += target sources + +TARGET = anchorlayout_example diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp new file mode 100644 index 0000000..ce6e937 --- /dev/null +++ b/examples/graphicsview/anchorlayout/main.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGraphicsWidget> +#include <QGraphicsProxyWidget> +#include <QGraphicsAnchorLayout> +#include <QtGui> + +static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0), + const QSizeF &preferred = QSize(150.0, 100.0), + const QSizeF &maximum = QSizeF(200.0, 100.0), + const QString &name = "0") +{ + QGraphicsProxyWidget *w = new QGraphicsProxyWidget; + w->setWidget(new QPushButton(name)); + w->setData(0, name); + w->setMinimumSize(minimum); + w->setPreferredSize(preferred); + w->setMaximumSize(maximum); + + return w; +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + scene.setSceneRect(0, 0, 800, 480); + + QSizeF minSize(30, 100); + QSizeF prefSize(210, 100); + QSizeF maxSize(300, 100); + + QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A"); + QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B"); + QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); + QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); + QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); + QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F"); + QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + + QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); + w->setPos(20, 20); + w->setLayout(l); + + // vertical + l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0); + + l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0); + + l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0); + l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); + l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0); + + // horizontal + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + + l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0); + l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); + l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0); + + scene.addItem(w); + scene.setBackgroundBrush(Qt::darkGreen); + QGraphicsView *view = new QGraphicsView(&scene); + view->show(); + + return app.exec(); +} diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro index a166882..8a6aae1 100644 --- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro +++ b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro @@ -10,3 +10,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/basicgraphicslayouts sources.files = $$SOURCES $$HEADERS $$RESOURCES basicgraphicslayouts.pro sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/basicgraphicslayouts INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A645 +} diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp index ca79cd6..299caa8 100644 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp +++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.cpp @@ -43,19 +43,18 @@ //! [0] LayoutItem::LayoutItem(QGraphicsItem *parent/* = 0*/) - : QGraphicsWidget(parent) + : QGraphicsLayoutItem(), QGraphicsItem(parent) { - pix = new QPixmap(QLatin1String(":/images/block.png")); - // Do not allow a size smaller than the pixmap with two frames around it. - setMinimumSize(pix->size() + QSize(12, 12)); + m_pix = new QPixmap(QLatin1String(":/images/block.png")); + setGraphicsItem(this); } //! [0] LayoutItem::~LayoutItem() { - delete pix; + delete m_pix; } - + //! [1] void LayoutItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget /*= 0*/) @@ -64,8 +63,8 @@ void LayoutItem::paint(QPainter *painter, Q_UNUSED(option); QRectF frame(QPointF(0,0), geometry().size()); - qreal w = pix->width(); - qreal h = pix->height(); + qreal w = m_pix->width(); + qreal h = m_pix->height(); QGradientStops stops; //! [1] @@ -94,6 +93,39 @@ void LayoutItem::paint(QPainter *painter, gradient.setStops(stops); painter->setBrush(QBrush(gradient)); painter->drawRoundedRect(innerFrame, 10.0, 10.0); - painter->drawPixmap(pixpos, *pix); + painter->drawPixmap(pixpos, *m_pix); } //! [2] + +//! [3] +QRectF LayoutItem::boundingRect() const +{ + return QRectF(QPointF(0,0), geometry().size()); +} +//! [3] + +//! [4] +void LayoutItem::setGeometry(const QRectF &geom) +{ + prepareGeometryChange(); + QGraphicsLayoutItem::setGeometry(geom); + setPos(geom.topLeft()); +} +//! [4] + +//! [5] +QSizeF LayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + switch (which) { + case Qt::MinimumSize: + case Qt::PreferredSize: + // Do not allow a size smaller than the pixmap with two frames around it. + return m_pix->size() + QSize(12, 12); + case Qt::MaximumSize: + return QSizeF(1000,1000); + default: + break; + } + return constraint; +} +//! [5] diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/graphicsview/basicgraphicslayouts/layoutitem.h index f37939d..de527f4 100644 --- a/examples/graphicsview/basicgraphicslayouts/layoutitem.h +++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.h @@ -44,18 +44,22 @@ #include <QtGui> //! [0] -class LayoutItem : public QGraphicsWidget +class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem { - Q_OBJECT - public: LayoutItem(QGraphicsItem *parent = 0); ~LayoutItem(); + // Inherited from QGraphicsLayoutItem + void setGeometry(const QRectF &geom); + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + + // Inherited from QGraphicsItem + QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: - QPixmap *pix; + QPixmap *m_pix; }; //! [0] diff --git a/examples/graphicsview/collidingmice/collidingmice.pro b/examples/graphicsview/collidingmice/collidingmice.pro index 77543b5..e4dc117 100644 --- a/examples/graphicsview/collidingmice/collidingmice.pro +++ b/examples/graphicsview/collidingmice/collidingmice.pro @@ -12,3 +12,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/collidingmice sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS collidingmice.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/collidingmice INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A643 +} diff --git a/examples/graphicsview/collidingmice/mouse.cpp b/examples/graphicsview/collidingmice/mouse.cpp index 6a0d91e..db5bc83 100644 --- a/examples/graphicsview/collidingmice/mouse.cpp +++ b/examples/graphicsview/collidingmice/mouse.cpp @@ -64,7 +64,7 @@ Mouse::Mouse() : angle(0), speed(0), mouseEyeDirection(0), color(qrand() % 256, qrand() % 256, qrand() % 256) { - rotate(qrand() % (360 * 16)); + setRotation(qrand() % (360 * 16)); } //! [0] @@ -195,7 +195,7 @@ void Mouse::advance(int step) qreal dx = ::sin(angle) * 10; mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5; - rotate(dx); + setRotation(rotation() + dx); setPos(mapToParent(0, -(3 + sin(speed) * 3))); } //! [11] diff --git a/examples/graphicsview/diagramscene/diagramscene.pro b/examples/graphicsview/diagramscene/diagramscene.pro index fe261bd..2021e24 100644 --- a/examples/graphicsview/diagramscene/diagramscene.pro +++ b/examples/graphicsview/diagramscene/diagramscene.pro @@ -18,3 +18,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS diagramscene.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/diagramscene INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp index 0593f07..8a30650 100644 --- a/examples/graphicsview/diagramscene/mainwindow.cpp +++ b/examples/graphicsview/diagramscene/mainwindow.cpp @@ -76,6 +76,7 @@ MainWindow::MainWindow() setCentralWidget(widget); setWindowTitle(tr("Diagramscene")); + setUnifiedTitleAndToolBarOnMac(true); } //! [0] @@ -401,7 +402,7 @@ void MainWindow::createActions() this, SLOT(deleteItem())); exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcut(tr("Ctrl+X")); + exitAction->setShortcuts(QKeySequence::Quit); exitAction->setStatusTip(tr("Quit Scenediagram example")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.pro b/examples/graphicsview/dragdroprobot/dragdroprobot.pro index 769e54a..3d100c0 100644 --- a/examples/graphicsview/dragdroprobot/dragdroprobot.pro +++ b/examples/graphicsview/dragdroprobot/dragdroprobot.pro @@ -16,3 +16,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/dragdroprobot sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dragdroprobot.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/dragdroprobot INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/graphicsview/elasticnodes/elasticnodes.pro b/examples/graphicsview/elasticnodes/elasticnodes.pro index 77ca706..ba17386 100644 --- a/examples/graphicsview/elasticnodes/elasticnodes.pro +++ b/examples/graphicsview/elasticnodes/elasticnodes.pro @@ -9,8 +9,15 @@ SOURCES += \ node.cpp \ graphwidget.cpp +TARGET.EPOCHEAPSIZE = 0x200000 0xA00000 + # install target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/elasticnodes sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS elasticnodes.pro sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/elasticnodes INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A642 +} diff --git a/examples/graphicsview/elasticnodes/node.cpp b/examples/graphicsview/elasticnodes/node.cpp index af59dbd..2050340 100644 --- a/examples/graphicsview/elasticnodes/node.cpp +++ b/examples/graphicsview/elasticnodes/node.cpp @@ -52,6 +52,7 @@ Node::Node(GraphWidget *graphWidget) : graph(graphWidget) { setFlag(ItemIsMovable); + setFlag(ItemSendsGeometryChanges); setCacheMode(DeviceCoordinateCache); setZValue(1); } diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp new file mode 100644 index 0000000..ae512df --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "flowlayout.h" +#include <QtGui/qwidget.h> +#include <QtCore/qmath.h> + +FlowLayout::FlowLayout() +{ + m_spacing[0] = 6; + m_spacing[1] = 6; + QSizePolicy sp = sizePolicy(); + sp.setHeightForWidth(true); + setSizePolicy(sp); +} + +void FlowLayout::insertItem(int index, QGraphicsLayoutItem *item) +{ + item->setParentLayoutItem(this); + if (uint(index) > uint(m_items.count())) + index = m_items.count(); + m_items.insert(index, item); + invalidate(); +} + +int FlowLayout::count() const +{ + return m_items.count(); +} + +QGraphicsLayoutItem *FlowLayout::itemAt(int index) const +{ + return m_items.value(index); +} + +void FlowLayout::removeAt(int index) +{ + m_items.removeAt(index); + invalidate(); +} + +qreal FlowLayout::spacing(Qt::Orientation o) const +{ + return m_spacing[int(o) - 1]; +} + +void FlowLayout::setSpacing(Qt::Orientations o, qreal spacing) +{ + if (o & Qt::Horizontal) + m_spacing[0] = spacing; + if (o & Qt::Vertical) + m_spacing[1] = spacing; +} + +void FlowLayout::setGeometry(const QRectF &geom) +{ + QGraphicsLayout::setGeometry(geom); + doLayout(geom, true); +} + +qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const +{ + QPointF tl = geom.topLeft(); + qreal maxw = geom.width(); + + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + maxw = maxw - left - right; + qreal x = 0; + qreal y = 0; + qreal maxRowHeight = 0; + QSizeF pref; + for (int i = 0; i < m_items.count(); ++i) { + QGraphicsLayoutItem *item = m_items.at(i); + pref = item->effectiveSizeHint(Qt::PreferredSize); + maxRowHeight = qMax(maxRowHeight, pref.height()); + + qreal next_x; + next_x = x + pref.width(); + if (next_x > maxw) { + if (x == 0) { + pref.setWidth(maxw); + } else { + x = 0; + next_x = pref.width(); + } + y += maxRowHeight + spacing(Qt::Vertical); + maxRowHeight = 0; + } + + if (applyNewGeometry) + item->setGeometry(QRectF(QPointF(left + x, top + y), pref)); + x = next_x + spacing(Qt::Horizontal); + } + maxRowHeight = qMax(maxRowHeight, pref.height()); + return top + y + maxRowHeight + bottom; +} + +QSizeF FlowLayout::minSize(const QSizeF &constraint) const +{ + QSizeF size(0, 0); + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + if (constraint.width() > 0) { // height for width + qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); + size = QSizeF(constraint.width(), height); + } else { + QGraphicsLayoutItem *item; + foreach (item, m_items) + size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize)); + size += QSize(left + right, top + bottom); + } + return size; +} + +QSizeF FlowLayout::prefSize() const +{ + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + + QGraphicsLayoutItem *item; + qreal maxh = 0; + qreal totalWidth = 0; + foreach (item, m_items) { + if (totalWidth > 0) + totalWidth += spacing(Qt::Horizontal); + QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); + totalWidth += pref.width(); + maxh = qMax(maxh, pref.height()); + } + maxh += spacing(Qt::Vertical); + + const qreal goldenAspectRatio = 1.61803399; + qreal w = qSqrt(totalWidth * maxh * goldenAspectRatio) + left + right; + + return minSize(QSizeF(w, -1)); +} + +QSizeF FlowLayout::maxSize() const +{ + QGraphicsLayoutItem *item; + qreal totalWidth = 0; + qreal totalHeight = 0; + foreach (item, m_items) { + if (totalWidth > 0) + totalWidth += spacing(Qt::Horizontal); + if (totalHeight > 0) + totalHeight += spacing(Qt::Vertical); + QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize); + totalWidth += pref.width(); + totalHeight += pref.height(); + } + + qreal left, top, right, bottom; + getContentsMargins(&left, &top, &right, &bottom); + return QSizeF(left + totalWidth + right, top + totalHeight + bottom); +} + +QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + switch (which) { + case Qt::PreferredSize: + return prefSize(); + case Qt::MinimumSize: + return minSize(constraint); + case Qt::MaximumSize: + return maxSize(); + default: + break; + } + return constraint; +} diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h new file mode 100644 index 0000000..b0659a9 --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/qgraphicslayout.h> + +class FlowLayout : public QGraphicsLayout +{ +public: + FlowLayout(); + inline void addItem(QGraphicsLayoutItem *item); + void insertItem(int index, QGraphicsLayoutItem *item); + void setSpacing(Qt::Orientations o, qreal spacing); + qreal spacing(Qt::Orientation o) const; + + // inherited functions + void setGeometry(const QRectF &geom); + + int count() const; + QGraphicsLayoutItem *itemAt(int index) const; + void removeAt(int index); + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + +private: + qreal doLayout(const QRectF &geom, bool applyNewGeometry) const; + QSizeF minSize(const QSizeF &constraint) const; + QSizeF prefSize() const; + QSizeF maxSize() const; + + QList<QGraphicsLayoutItem*> m_items; + qreal m_spacing[2]; +}; + + +inline void FlowLayout::addItem(QGraphicsLayoutItem *item) +{ + insertItem(-1, item); +} diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro new file mode 100644 index 0000000..c029d6c --- /dev/null +++ b/examples/graphicsview/flowlayout/flowlayout.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) ma 30. mar 12:46:15 2009 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += flowlayout.h window.h +SOURCES += flowlayout.cpp main.cpp window.cpp diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp new file mode 100644 index 0000000..776ef55 --- /dev/null +++ b/examples/graphicsview/flowlayout/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include "window.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + QGraphicsView *view = new QGraphicsView(&scene); + Window *w = new Window; + scene.addItem(w); + view->show(); + return app.exec(); +} diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp new file mode 100644 index 0000000..2d98026 --- /dev/null +++ b/examples/graphicsview/flowlayout/window.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/qgraphicsproxywidget.h> +#include <QtGui/qlabel.h> +#include "flowlayout.h" +#include "window.h" + +Window::Window() +: QGraphicsWidget(0, Qt::Window) +{ + FlowLayout *lay = new FlowLayout; + QLatin1String wiseWords("I am not bothered by the fact that I am unknown." + "I am bothered when I do not know others. (Confucius)"); + QString sentence(wiseWords); + QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); + for (int i = 0; i < words.count(); ++i) { + QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); + QLabel *label = new QLabel(words.at(i)); + label->setFrameStyle(QFrame::Box | QFrame::Plain); + proxy->setWidget(label); + lay->addItem(proxy); + } + setLayout(lay); +} diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h new file mode 100644 index 0000000..1ed5bc7 --- /dev/null +++ b/examples/graphicsview/flowlayout/window.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/qgraphicswidget.h> + +class Window : public QGraphicsWidget { + Q_OBJECT +public: + Window(); +}; diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro index 66eb0b4..0408111 100644 --- a/examples/graphicsview/graphicsview.pro +++ b/examples/graphicsview/graphicsview.pro @@ -1,18 +1,22 @@ -TEMPLATE = \ - subdirs +TEMPLATE = subdirs SUBDIRS = \ elasticnodes \ collidingmice \ + padnavigator \ + basicgraphicslayouts + +!symbian: SUBDIRS += \ diagramscene \ dragdroprobot \ - padnavigator \ - basicgraphicslayouts + anchorlayout contains(QT_CONFIG, qt3support):SUBDIRS += portedcanvas portedasteroids -contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= dragdroprobot +contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot # install target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS graphicsview.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp index 30e1dc3..a984eab 100644 --- a/examples/graphicsview/padnavigator/main.cpp +++ b/examples/graphicsview/padnavigator/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) Panel panel(3, 3); panel.setFocus(); - panel.show(); + panel.showFullScreen(); return app.exec(); } diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro index 0d094c6..cb09b90 100644 --- a/examples/graphicsview/padnavigator/padnavigator.pro +++ b/examples/graphicsview/padnavigator/padnavigator.pro @@ -22,3 +22,10 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/padnavigator sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS padnavigator.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/padnavigator INSTALLS += target sources + +CONFIG += console + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A644 +} diff --git a/examples/graphicsview/padnavigator/panel.h b/examples/graphicsview/padnavigator/panel.h index 18e755c..810c8ea 100644 --- a/examples/graphicsview/padnavigator/panel.h +++ b/examples/graphicsview/padnavigator/panel.h @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE class QTimeLine; class Ui_BackSide; -QT_END_NAMESPACE; +QT_END_NAMESPACE class RoundRectItem; diff --git a/examples/graphicsview/padnavigator/roundrectitem.h b/examples/graphicsview/padnavigator/roundrectitem.h index bb71652..b2a251c 100644 --- a/examples/graphicsview/padnavigator/roundrectitem.h +++ b/examples/graphicsview/padnavigator/roundrectitem.h @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE class QGraphicsProxyWidget; -QT_END_NAMESPACE; +QT_END_NAMESPACE class RoundRectItem : public QObject, public QGraphicsRectItem { diff --git a/examples/graphicsview/portedasteroids/portedasteroids.pro b/examples/graphicsview/portedasteroids/portedasteroids.pro index 1452e91..b28ab54 100644 --- a/examples/graphicsview/portedasteroids/portedasteroids.pro +++ b/examples/graphicsview/portedasteroids/portedasteroids.pro @@ -17,3 +17,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedasteroids sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS portedasteroids.pro bg.png sounds sprites sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedasteroids INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/graphicsview/portedcanvas/portedcanvas.pro b/examples/graphicsview/portedcanvas/portedcanvas.pro index 71e3d84..850b440 100644 --- a/examples/graphicsview/portedcanvas/portedcanvas.pro +++ b/examples/graphicsview/portedcanvas/portedcanvas.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedcanvas sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS portedcanvas.pro *.png *.xpm *.doc sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedcanvas INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/help/contextsensitivehelp/contextsensitivehelp.pro b/examples/help/contextsensitivehelp/contextsensitivehelp.pro index 5a8c0b1..03b0a8d 100644 --- a/examples/help/contextsensitivehelp/contextsensitivehelp.pro +++ b/examples/help/contextsensitivehelp/contextsensitivehelp.pro @@ -16,3 +16,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/help/contextsensitivehelp sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png *.doc doc sources.path = $$[QT_INSTALL_EXAMPLES]/help/contextsensitivehelp INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/help/help.pro b/examples/help/help.pro index 1ce6322..79b005e 100644 --- a/examples/help/help.pro +++ b/examples/help/help.pro @@ -9,3 +9,5 @@ SUBDIRS += contextsensitivehelp \ sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/help INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/help/remotecontrol/remotecontrol.pro b/examples/help/remotecontrol/remotecontrol.pro index 05fc14c..5547359 100644 --- a/examples/help/remotecontrol/remotecontrol.pro +++ b/examples/help/remotecontrol/remotecontrol.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/help/remotecontrol sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png *.doc doc sources.path = $$[QT_INSTALL_EXAMPLES]/help/remotecontrol INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/help/simpletextviewer/mainwindow.cpp b/examples/help/simpletextviewer/mainwindow.cpp index b702186..60ceb6d 100644 --- a/examples/help/simpletextviewer/mainwindow.cpp +++ b/examples/help/simpletextviewer/mainwindow.cpp @@ -102,12 +102,12 @@ void MainWindow::open() void MainWindow::createActions() { assistantAct = new QAction(tr("Help Contents"), this); - assistantAct->setShortcut(tr("F1")); + assistantAct->setShortcut(QKeySequence::HelpContents); connect(assistantAct, SIGNAL(triggered()), this, SLOT(showDocumentation())); //! [4] openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcut(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); clearAct = new QAction(tr("&Clear"), this); @@ -115,7 +115,7 @@ void MainWindow::createActions() connect(clearAct, SIGNAL(triggered()), textViewer, SLOT(clear())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/help/simpletextviewer/simpletextviewer.pro b/examples/help/simpletextviewer/simpletextviewer.pro index e9e7ea2..bfbd31b 100644 --- a/examples/help/simpletextviewer/simpletextviewer.pro +++ b/examples/help/simpletextviewer/simpletextviewer.pro @@ -14,3 +14,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES documentation *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/help/simpletextviewer INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/ipc/ipc.pro b/examples/ipc/ipc.pro index 0698f89..d084498 100644 --- a/examples/ipc/ipc.pro +++ b/examples/ipc/ipc.pro @@ -1,8 +1,11 @@ TEMPLATE = subdirs -SUBDIRS = sharedmemory +# no QSharedMemory +!vxworks:!qnx:SUBDIRS = sharedmemory !wince*: SUBDIRS += localfortuneserver localfortuneclient # install sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS ipc.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/ipc INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/ipc/localfortuneclient/localfortuneclient.pro b/examples/ipc/localfortuneclient/localfortuneclient.pro index 906cc8a..a937ea1 100644 --- a/examples/ipc/localfortuneclient/localfortuneclient.pro +++ b/examples/ipc/localfortuneclient/localfortuneclient.pro @@ -9,4 +9,6 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS localfortuneclient.pro sources.path = $$[QT_INSTALL_EXAMPLES]/ipc/localfortuneclient INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/ipc/localfortuneserver/localfortuneserver.pro b/examples/ipc/localfortuneserver/localfortuneserver.pro index fca9a0a..e14ec8e 100644 --- a/examples/ipc/localfortuneserver/localfortuneserver.pro +++ b/examples/ipc/localfortuneserver/localfortuneserver.pro @@ -9,4 +9,6 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS localfortuneserver.pro sources.path = $$[QT_INSTALL_EXAMPLES]/ipc/localfortuneserver INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/ipc/sharedmemory/sharedmemory.pro b/examples/ipc/sharedmemory/sharedmemory.pro index 4833090..37ac2c8 100644 --- a/examples/ipc/sharedmemory/sharedmemory.pro +++ b/examples/ipc/sharedmemory/sharedmemory.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/ipc/sharedmemory sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/ipc/sharedmemory INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/addressbook/addressbook.pro b/examples/itemviews/addressbook/addressbook.pro index 6f6a72d..b53a1cf 100644 --- a/examples/itemviews/addressbook/addressbook.pro +++ b/examples/itemviews/addressbook/addressbook.pro @@ -15,3 +15,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/addressbook sources.files = $$SOURCES $$HEADERS $$RESOURCES addressbook.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/addressbook INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A646 +} diff --git a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro index 7870b39..1daba5d 100644 --- a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro +++ b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/basicsortfiltermodel sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/basicsortfiltermodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/chart/chart.pro b/examples/itemviews/chart/chart.pro index d202451..8568181 100644 --- a/examples/itemviews/chart/chart.pro +++ b/examples/itemviews/chart/chart.pro @@ -4,10 +4,17 @@ RESOURCES = chart.qrc SOURCES = main.cpp \ mainwindow.cpp \ pieview.cpp -unix:!mac:LIBS+= -lm +unix:!mac:!symbian:!vxworks:LIBS+= -lm + +TARGET.EPOCHEAPSIZE = 0x200000 0x800000 # install target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/chart sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.cht sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/chart INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A647 +} diff --git a/examples/itemviews/chart/mainwindow.cpp b/examples/itemviews/chart/mainwindow.cpp index f38d2df..e3bf398 100644 --- a/examples/itemviews/chart/mainwindow.cpp +++ b/examples/itemviews/chart/mainwindow.cpp @@ -48,11 +48,11 @@ MainWindow::MainWindow() { QMenu *fileMenu = new QMenu(tr("&File"), this); QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); + openAction->setShortcuts(QKeySequence::Open); QAction *saveAction = fileMenu->addAction(tr("&Save As...")); - saveAction->setShortcut(QKeySequence(tr("Ctrl+S"))); + saveAction->setShortcuts(QKeySequence::SaveAs); QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); + quitAction->setShortcuts(QKeySequence::Quit); setupModel(); setupViews(); diff --git a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro b/examples/itemviews/coloreditorfactory/coloreditorfactory.pro index ebb3b8e..934d880 100644 --- a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro +++ b/examples/itemviews/coloreditorfactory/coloreditorfactory.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/coloreditorfactory sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/coloreditorfactory INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro index 5a9b9f9..df32a2b 100644 --- a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro +++ b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/customsortfiltermodel sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/customsortfiltermodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/dirview/dirview.pro b/examples/itemviews/dirview/dirview.pro index 5865d3c..3197000 100644 --- a/examples/itemviews/dirview/dirview.pro +++ b/examples/itemviews/dirview/dirview.pro @@ -5,3 +5,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/dirview sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/dirview INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/editabletreemodel/editabletreemodel.pro b/examples/itemviews/editabletreemodel/editabletreemodel.pro index 2b7b7de..d9ce803 100644 --- a/examples/itemviews/editabletreemodel/editabletreemodel.pro +++ b/examples/itemviews/editabletreemodel/editabletreemodel.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/editabletreemodel sources.files = $$FORMS $$HEADERS $$RESOURCES $$SOURCES *.pro *.txt sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/editabletreemodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/itemviews.pro b/examples/itemviews/itemviews.pro index 7dcf0f6..56eeee1 100644 --- a/examples/itemviews/itemviews.pro +++ b/examples/itemviews/itemviews.pro @@ -17,7 +17,13 @@ SUBDIRS = addressbook \ spinboxdelegate \ stardelegate +symbian: SUBDIRS = \ + addressbook \ + chart + # install sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/pixelator/mainwindow.cpp b/examples/itemviews/pixelator/mainwindow.cpp index 3c25860..012da64 100644 --- a/examples/itemviews/pixelator/mainwindow.cpp +++ b/examples/itemviews/pixelator/mainwindow.cpp @@ -79,14 +79,14 @@ MainWindow::MainWindow() QMenu *fileMenu = new QMenu(tr("&File"), this); QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); + openAction->setShortcuts(QKeySequence::Open); printAction = fileMenu->addAction(tr("&Print...")); printAction->setEnabled(false); - printAction->setShortcut(QKeySequence(tr("Ctrl+P"))); + printAction->setShortcut(QKeySequence::Print); QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); + quitAction->setShortcuts(QKeySequence::Quit); QMenu *helpMenu = new QMenu(tr("&Help"), this); QAction *aboutAction = helpMenu->addAction(tr("&About")); diff --git a/examples/itemviews/pixelator/pixelator.pro b/examples/itemviews/pixelator/pixelator.pro index dc05296..a41d906 100644 --- a/examples/itemviews/pixelator/pixelator.pro +++ b/examples/itemviews/pixelator/pixelator.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/pixelator sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/pixelator INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/puzzle/mainwindow.cpp b/examples/itemviews/puzzle/mainwindow.cpp index 76bbdfa..fe7f5a6 100644 --- a/examples/itemviews/puzzle/mainwindow.cpp +++ b/examples/itemviews/puzzle/mainwindow.cpp @@ -107,10 +107,10 @@ void MainWindow::setupMenus() QMenu *fileMenu = menuBar()->addMenu(tr("&File")); QAction *openAction = fileMenu->addAction(tr("&Open...")); - openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); + openAction->setShortcuts(QKeySequence::Open); QAction *exitAction = fileMenu->addAction(tr("E&xit")); - exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); + exitAction->setShortcuts(QKeySequence::Quit); QMenu *gameMenu = menuBar()->addMenu(tr("&Game")); diff --git a/examples/itemviews/puzzle/puzzle.pro b/examples/itemviews/puzzle/puzzle.pro index 4f5aaad..b1c490a 100644 --- a/examples/itemviews/puzzle/puzzle.pro +++ b/examples/itemviews/puzzle/puzzle.pro @@ -13,6 +13,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.jpg sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/puzzle INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince* { DEPLOYMENT_PLUGIN += qjpeg qgif qtiff } diff --git a/examples/itemviews/simpledommodel/mainwindow.cpp b/examples/itemviews/simpledommodel/mainwindow.cpp index ad3e670..6382c8a 100644 --- a/examples/itemviews/simpledommodel/mainwindow.cpp +++ b/examples/itemviews/simpledommodel/mainwindow.cpp @@ -50,9 +50,9 @@ MainWindow::MainWindow() : QMainWindow(), model(0) { fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), - QKeySequence(tr("Ctrl+O"))); + QKeySequence::Open); fileMenu->addAction(tr("E&xit"), this, SLOT(close()), - QKeySequence(tr("Ctrl+Q"))); + QKeySequence::Quit); model = new DomModel(QDomDocument(), this); view = new QTreeView(this); diff --git a/examples/itemviews/simpledommodel/simpledommodel.pro b/examples/itemviews/simpledommodel/simpledommodel.pro index bc9b1ca..c0c4b1d 100644 --- a/examples/itemviews/simpledommodel/simpledommodel.pro +++ b/examples/itemviews/simpledommodel/simpledommodel.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simpledommodel sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simpledommodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/simpletreemodel/simpletreemodel.pro b/examples/itemviews/simpletreemodel/simpletreemodel.pro index 9db74d4..4f0e7c4 100644 --- a/examples/itemviews/simpletreemodel/simpletreemodel.pro +++ b/examples/itemviews/simpletreemodel/simpletreemodel.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simpletreemodel sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.txt sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simpletreemodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro index b2940d7..67eaf11 100644 --- a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro +++ b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simplewidgetmapper sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/simplewidgetmapper INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro b/examples/itemviews/spinboxdelegate/spinboxdelegate.pro index a202748..42e957b 100644 --- a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro +++ b/examples/itemviews/spinboxdelegate/spinboxdelegate.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/itemviews/spinboxdelegate sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/spinboxdelegate INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/itemviews/stardelegate/stardelegate.pro b/examples/itemviews/stardelegate/stardelegate.pro index 4e1ef45..5b5c10b 100644 --- a/examples/itemviews/stardelegate/stardelegate.pro +++ b/examples/itemviews/stardelegate/stardelegate.pro @@ -12,3 +12,5 @@ sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/itemviews/stardelegate INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/layouts/basiclayouts/basiclayouts.pro b/examples/layouts/basiclayouts/basiclayouts.pro index 8fa73ff..95e6ec4 100644 --- a/examples/layouts/basiclayouts/basiclayouts.pro +++ b/examples/layouts/basiclayouts/basiclayouts.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/layouts/basiclayouts sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/layouts/basiclayouts INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/layouts/borderlayout/borderlayout.pro b/examples/layouts/borderlayout/borderlayout.pro index e327574..e7214d9 100644 --- a/examples/layouts/borderlayout/borderlayout.pro +++ b/examples/layouts/borderlayout/borderlayout.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/layouts/borderlayout sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/layouts/borderlayout INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/layouts/dynamiclayouts/dynamiclayouts.pro b/examples/layouts/dynamiclayouts/dynamiclayouts.pro index c169dd0..58e6d79 100644 --- a/examples/layouts/dynamiclayouts/dynamiclayouts.pro +++ b/examples/layouts/dynamiclayouts/dynamiclayouts.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/layouts/dynamiclayouts sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/layouts/dynamiclayouts INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/layouts/flowlayout/flowlayout.pro b/examples/layouts/flowlayout/flowlayout.pro index 0e97824..40ff447 100644 --- a/examples/layouts/flowlayout/flowlayout.pro +++ b/examples/layouts/flowlayout/flowlayout.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/layouts/flowlayout sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/layouts/flowlayout INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/layouts/layouts.pro b/examples/layouts/layouts.pro index 9676f4b..d84e721 100644 --- a/examples/layouts/layouts.pro +++ b/examples/layouts/layouts.pro @@ -8,3 +8,5 @@ SUBDIRS = basiclayouts \ sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/layouts INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/linguist/arrowpad/arrowpad.pro b/examples/linguist/arrowpad/arrowpad.pro index c8a6fb2..0a463d3 100644 --- a/examples/linguist/arrowpad/arrowpad.pro +++ b/examples/linguist/arrowpad/arrowpad.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/linguist/arrowpad sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/linguist/arrowpad INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/linguist/arrowpad/mainwindow.cpp b/examples/linguist/arrowpad/mainwindow.cpp index f62c41e..43a59f4 100644 --- a/examples/linguist/arrowpad/mainwindow.cpp +++ b/examples/linguist/arrowpad/mainwindow.cpp @@ -53,7 +53,7 @@ MainWindow::MainWindow() //! [1] exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); //! [1] diff --git a/examples/linguist/hellotr/hellotr.pro b/examples/linguist/hellotr/hellotr.pro index c0065a4..7a930ff 100644 --- a/examples/linguist/hellotr/hellotr.pro +++ b/examples/linguist/hellotr/hellotr.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/linguist/hellotr sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/linguist/hellotr INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/linguist/linguist.pro b/examples/linguist/linguist.pro index 921667d..2b7515a 100644 --- a/examples/linguist/linguist.pro +++ b/examples/linguist/linguist.pro @@ -7,3 +7,5 @@ SUBDIRS = arrowpad \ sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/linguist INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/linguist/trollprint/trollprint.pro b/examples/linguist/trollprint/trollprint.pro index 9f3aaeb..0ec64b0 100644 --- a/examples/linguist/trollprint/trollprint.pro +++ b/examples/linguist/trollprint/trollprint.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/linguist/trollprint sources.files = $$SOURCES $$HEADERS $$TRANSLATIONS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/linguist/trollprint INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/application/application.pro b/examples/mainwindows/application/application.pro index ad1168a..0851f72 100644 --- a/examples/mainwindows/application/application.pro +++ b/examples/mainwindows/application/application.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/application sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS application.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/application INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/application/main.cpp b/examples/mainwindows/application/main.cpp index bb913cd..ead5ff9 100644 --- a/examples/mainwindows/application/main.cpp +++ b/examples/mainwindows/application/main.cpp @@ -49,6 +49,8 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(application); QApplication app(argc, argv); + app.setOrganizationName("Trolltech"); + app.setApplicationName("Application Example"); MainWindow mainWin; mainWin.show(); return app.exec(); diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp index a4623b5..687a3e0 100644 --- a/examples/mainwindows/application/mainwindow.cpp +++ b/examples/mainwindows/application/mainwindow.cpp @@ -174,7 +174,7 @@ void MainWindow::createActions() //! [20] exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); //! [20] exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); @@ -328,9 +328,13 @@ void MainWindow::loadFile(const QString &fileName) } QTextStream in(&file); +#ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::WaitCursor); +#endif textEdit->setPlainText(in.readAll()); +#ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); +#endif setCurrentFile(fileName); statusBar()->showMessage(tr("File loaded"), 2000); @@ -351,9 +355,13 @@ bool MainWindow::saveFile(const QString &fileName) } QTextStream out(&file); +#ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::WaitCursor); +#endif out << textEdit->toPlainText(); +#ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); +#endif setCurrentFile(fileName); statusBar()->showMessage(tr("File saved"), 2000); @@ -369,13 +377,10 @@ void MainWindow::setCurrentFile(const QString &fileName) textEdit->document()->setModified(false); setWindowModified(false); - QString shownName; + QString shownName = curFile; if (curFile.isEmpty()) shownName = "untitled.txt"; - else - shownName = strippedName(curFile); - - setWindowTitle(tr("%1[*] - %2").arg(shownName).arg(tr("Application"))); + setWindowFilePath(shownName); } //! [47] diff --git a/examples/mainwindows/dockwidgets/dockwidgets.pro b/examples/mainwindows/dockwidgets/dockwidgets.pro index afc8aaa..a196587 100644 --- a/examples/mainwindows/dockwidgets/dockwidgets.pro +++ b/examples/mainwindows/dockwidgets/dockwidgets.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/dockwidgets sources.files = $$SOURCES $$HEADERS $$RESOURCES dockwidgets.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/dockwidgets INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/dockwidgets/mainwindow.cpp b/examples/mainwindows/dockwidgets/mainwindow.cpp index ed6dc4b..0d4da15 100644 --- a/examples/mainwindows/dockwidgets/mainwindow.cpp +++ b/examples/mainwindows/dockwidgets/mainwindow.cpp @@ -242,7 +242,7 @@ void MainWindow::createActions() connect(undoAct, SIGNAL(triggered()), this, SLOT(undo())); quitAct = new QAction(tr("&Quit"), this); - quitAct->setShortcut(tr("Ctrl+Q")); + quitAct->setShortcuts(QKeySequence::Quit); quitAct->setStatusTip(tr("Quit the application")); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); diff --git a/examples/mainwindows/mainwindows.pro b/examples/mainwindows/mainwindows.pro index 90ff3a5..661b741 100644 --- a/examples/mainwindows/mainwindows.pro +++ b/examples/mainwindows/mainwindows.pro @@ -6,8 +6,14 @@ SUBDIRS = application \ recentfiles \ sdi +symbian: SUBDIRS = \ + menus + + # install target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mainwindows.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp index 4c6a3e0..1b01977 100644 --- a/examples/mainwindows/mdi/mainwindow.cpp +++ b/examples/mainwindows/mdi/mainwindow.cpp @@ -235,7 +235,7 @@ void MainWindow::createActions() //! [0] exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); //! [0] @@ -259,7 +259,6 @@ void MainWindow::createActions() connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste())); closeAct = new QAction(tr("Cl&ose"), this); - closeAct->setShortcut(tr("Ctrl+F4")); closeAct->setStatusTip(tr("Close the active window")); connect(closeAct, SIGNAL(triggered()), mdiArea, SLOT(closeActiveSubWindow())); diff --git a/examples/mainwindows/mdi/mdi.pro b/examples/mainwindows/mdi/mdi.pro index 4601f1c..8d859b0 100644 --- a/examples/mainwindows/mdi/mdi.pro +++ b/examples/mainwindows/mdi/mdi.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/mdi sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mdi.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/mdi INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/menus/mainwindow.cpp b/examples/mainwindows/menus/mainwindow.cpp index 66246c9..eb4d758 100644 --- a/examples/mainwindows/menus/mainwindow.cpp +++ b/examples/mainwindows/menus/mainwindow.cpp @@ -219,7 +219,7 @@ void MainWindow::createActions() connect(printAct, SIGNAL(triggered()), this, SLOT(print())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); @@ -240,7 +240,7 @@ void MainWindow::createActions() connect(cutAct, SIGNAL(triggered()), this, SLOT(cut())); copyAct = new QAction(tr("&Copy"), this); - copyAct->setShortcut(tr("Ctrl+C")); + copyAct->setShortcuts(QKeySequence::Copy); copyAct->setStatusTip(tr("Copy the current selection's contents to the " "clipboard")); connect(copyAct, SIGNAL(triggered()), this, SLOT(copy())); @@ -253,7 +253,7 @@ void MainWindow::createActions() boldAct = new QAction(tr("&Bold"), this); boldAct->setCheckable(true); - boldAct->setShortcut(tr("Ctrl+B")); + boldAct->setShortcut(QKeySequence::Bold); boldAct->setStatusTip(tr("Make the text bold")); connect(boldAct, SIGNAL(triggered()), this, SLOT(bold())); @@ -263,7 +263,7 @@ void MainWindow::createActions() italicAct = new QAction(tr("&Italic"), this); italicAct->setCheckable(true); - italicAct->setShortcut(tr("Ctrl+I")); + italicAct->setShortcut(QKeySequence::Italic); italicAct->setStatusTip(tr("Make the text italic")); connect(italicAct, SIGNAL(triggered()), this, SLOT(italic())); diff --git a/examples/mainwindows/menus/menus.pro b/examples/mainwindows/menus/menus.pro index 7b0a2ec..5ac5b34 100644 --- a/examples/mainwindows/menus/menus.pro +++ b/examples/mainwindows/menus/menus.pro @@ -7,3 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/menus sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS menus.pro sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/menus INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF66 +} diff --git a/examples/mainwindows/recentfiles/main.cpp b/examples/mainwindows/recentfiles/main.cpp index 00a5608..5caf734 100644 --- a/examples/mainwindows/recentfiles/main.cpp +++ b/examples/mainwindows/recentfiles/main.cpp @@ -46,6 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + app.setOrganizationName("Trolltech"); + app.setApplicationName("Recent Files Example"); MainWindow *mainWin = new MainWindow; mainWin->show(); return app.exec(); diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp index 527ab31..d5c2a8c 100644 --- a/examples/mainwindows/recentfiles/mainwindow.cpp +++ b/examples/mainwindows/recentfiles/mainwindow.cpp @@ -54,7 +54,7 @@ MainWindow::MainWindow() createMenus(); (void)statusBar(); - setWindowTitle(tr("Recent Files")); + setWindowFilePath(QString()); resize(400, 300); } @@ -132,7 +132,7 @@ void MainWindow::createActions() } exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); @@ -209,13 +209,9 @@ void MainWindow::saveFile(const QString &fileName) void MainWindow::setCurrentFile(const QString &fileName) { curFile = fileName; - if (curFile.isEmpty()) - setWindowTitle(tr("Recent Files")); - else - setWindowTitle(tr("%1 - %2").arg(strippedName(curFile)) - .arg(tr("Recent Files"))); + setWindowFilePath(curFile); - QSettings settings("Trolltech", "Recent Files Example"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); files.removeAll(fileName); files.prepend(fileName); @@ -233,7 +229,7 @@ void MainWindow::setCurrentFile(const QString &fileName) void MainWindow::updateRecentFileActions() { - QSettings settings("Trolltech", "Recent Files Example"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); diff --git a/examples/mainwindows/recentfiles/recentfiles.pro b/examples/mainwindows/recentfiles/recentfiles.pro index 7c62cdf..9724b77 100644 --- a/examples/mainwindows/recentfiles/recentfiles.pro +++ b/examples/mainwindows/recentfiles/recentfiles.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/recentfiles sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS recentfiles.pro sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/recentfiles INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/mainwindows/sdi/main.cpp b/examples/mainwindows/sdi/main.cpp index c73718a..23164c9 100644 --- a/examples/mainwindows/sdi/main.cpp +++ b/examples/mainwindows/sdi/main.cpp @@ -47,6 +47,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(sdi); QApplication app(argc, argv); + app.setApplicationName("SDI Example"); + app.setOrganizationName("Trolltech"); MainWindow *mainWin = new MainWindow; mainWin->show(); return app.exec(); diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp index 284048b..0587170 100644 --- a/examples/mainwindows/sdi/mainwindow.cpp +++ b/examples/mainwindows/sdi/mainwindow.cpp @@ -180,7 +180,7 @@ void MainWindow::createActions() connect(closeAct, SIGNAL(triggered()), this, SLOT(close())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); @@ -266,7 +266,7 @@ void MainWindow::createStatusBar() void MainWindow::readSettings() { - QSettings settings("Trolltech", "SDI Example"); + QSettings settings; QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); QSize size = settings.value("size", QSize(400, 400)).toSize(); move(pos); @@ -275,7 +275,7 @@ void MainWindow::readSettings() void MainWindow::writeSettings() { - QSettings settings("Trolltech", "SDI Example"); + QSettings settings; settings.setValue("pos", pos()); settings.setValue("size", size()); } @@ -352,9 +352,7 @@ void MainWindow::setCurrentFile(const QString &fileName) textEdit->document()->setModified(false); setWindowModified(false); - - setWindowTitle(tr("%1[*] - %2").arg(strippedName(curFile)) - .arg(tr("SDI"))); + setWindowFilePath(curFile); } QString MainWindow::strippedName(const QString &fullFileName) diff --git a/examples/mainwindows/sdi/sdi.pro b/examples/mainwindows/sdi/sdi.pro index 3283334..5707c41 100644 --- a/examples/mainwindows/sdi/sdi.pro +++ b/examples/mainwindows/sdi/sdi.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/sdi sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sdi.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/mainwindows/sdi INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/multimedia/README b/examples/multimedia/README new file mode 100644 index 0000000..aa78e36 --- /dev/null +++ b/examples/multimedia/README @@ -0,0 +1,34 @@ + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/multimedia/audio/audio.pro b/examples/multimedia/audio/audio.pro new file mode 100644 index 0000000..c64bb34 --- /dev/null +++ b/examples/multimedia/audio/audio.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = audioinput \ + audiooutput \ + audiodevices + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS audio.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiodevices/audiodevices.cpp b/examples/multimedia/audio/audiodevices/audiodevices.cpp new file mode 100644 index 0000000..e2243ae --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.cpp @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QDebug> +#include <QAudioDeviceInfo> + +#include "audiodevices.h" + +AudioDevicesBase::AudioDevicesBase( QMainWindow *parent, Qt::WFlags f ) +{ + Q_UNUSED(parent) + Q_UNUSED(f) + setupUi( this ); +} + +AudioDevicesBase::~AudioDevicesBase() {} + + +AudioTest::AudioTest( QMainWindow *parent, Qt::WFlags f ) + : AudioDevicesBase( parent, f ) +{ + mode = QAudio::AudioOutput; + modeBox->addItem("Input"); + modeBox->addItem("Output"); + + connect(testButton,SIGNAL(clicked()),SLOT(test())); + connect(modeBox,SIGNAL(activated(int)),SLOT(modeChanged(int))); + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + connect(frequencyBox,SIGNAL(activated(int)),SLOT(freqChanged(int))); + connect(channelsBox,SIGNAL(activated(int)),SLOT(channelChanged(int))); + connect(codecsBox,SIGNAL(activated(int)),SLOT(codecChanged(int))); + connect(sampleSizesBox,SIGNAL(activated(int)),SLOT(sampleSizeChanged(int))); + connect(sampleTypesBox,SIGNAL(activated(int)),SLOT(sampleTypeChanged(int))); + connect(endianBox,SIGNAL(activated(int)),SLOT(endianChanged(int))); + + device = 0; + + modeBox->setCurrentIndex(0); + modeChanged(0); + deviceBox->setCurrentIndex(0); + deviceChanged(0); +} + +AudioTest::~AudioTest() +{ +} + +void AudioTest::test() +{ + // tries to set all the settings picked. + + if(device) { + if(device->isFormatSupported(settings)) { + logOutput->append("Success"); + nearestFreq->setText(""); + nearestChannel->setText(""); + nearestCodec->setText(""); + nearestSampleSize->setText(""); + nearestSampleType->setText(""); + nearestEndian->setText(""); + } else { + QAudioFormat nearest = device->nearestFormat(settings); + logOutput->append(tr("Failed")); + nearestFreq->setText(QString("%1").arg(nearest.frequency())); + nearestChannel->setText(QString("%1").arg(nearest.channels())); + nearestCodec->setText(nearest.codec()); + nearestSampleSize->setText(QString("%1").arg(nearest.sampleSize())); + + switch(nearest.sampleType()) { + case QAudioFormat::SignedInt: + nearestSampleType->setText("SignedInt"); + break; + case QAudioFormat::UnSignedInt: + nearestSampleType->setText("UnSignedInt"); + break; + case QAudioFormat::Float: + nearestSampleType->setText("Float"); + break; + case QAudioFormat::Unknown: + nearestSampleType->setText("Unknown"); + } + switch(nearest.byteOrder()) { + case QAudioFormat::LittleEndian: + nearestEndian->setText("LittleEndian"); + break; + case QAudioFormat::BigEndian: + nearestEndian->setText("BigEndian"); + } + } + } + else + logOutput->append("No Device"); +} + +void AudioTest::modeChanged(int idx) +{ + // mode has changed + if(idx == 0) + mode=QAudio::AudioInput; + else + mode=QAudio::AudioOutput; + + deviceBox->clear(); + QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(mode); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } +} + +void AudioTest::deviceChanged(int idx) +{ + delete device; + device = 0; + + if (deviceBox->count() == 0) + return; + + // device has changed + deviceHandle = deviceBox->itemData(idx).value<QAudioDeviceId>(); + device = new QAudioDeviceInfo(deviceHandle, this); + + frequencyBox->clear(); + QList<int> freqz = device->supportedFrequencies(); + for(int i = 0; i < freqz.size(); ++i) + frequencyBox->addItem(QString("%1").arg(freqz.at(i))); + if(freqz.size()) + settings.setFrequency(freqz.at(0)); + + channelsBox->clear(); + QList<int> chz = device->supportedChannels(); + for(int i = 0; i < chz.size(); ++i) + channelsBox->addItem(QString("%1").arg(chz.at(i))); + if(chz.size()) + settings.setChannels(chz.at(0)); + + codecsBox->clear(); + QStringList codecz = device->supportedCodecs(); + for(int i = 0; i < codecz.size(); ++i) + codecsBox->addItem(QString("%1").arg(codecz.at(i))); + if(codecz.size()) + settings.setCodec(codecz.at(0)); + // Add false to create failed condition! + codecsBox->addItem("audio/mpeg"); + + sampleSizesBox->clear(); + QList<int> sampleSizez = device->supportedSampleSizes(); + for(int i = 0; i < sampleSizez.size(); ++i) + sampleSizesBox->addItem(QString("%1").arg(sampleSizez.at(i))); + if(sampleSizez.size()) + settings.setSampleSize(sampleSizez.at(0)); + + sampleTypesBox->clear(); + QList<QAudioFormat::SampleType> sampleTypez = device->supportedSampleTypes(); + for(int i = 0; i < sampleTypez.size(); ++i) { + switch(sampleTypez.at(i)) { + case QAudioFormat::SignedInt: + sampleTypesBox->addItem("SignedInt"); + break; + case QAudioFormat::UnSignedInt: + sampleTypesBox->addItem("UnSignedInt"); + break; + case QAudioFormat::Float: + sampleTypesBox->addItem("Float"); + break; + case QAudioFormat::Unknown: + sampleTypesBox->addItem("Unknown"); + } + if(sampleTypez.size()) + settings.setSampleType(sampleTypez.at(0)); + } + + endianBox->clear(); + QList<QAudioFormat::Endian> endianz = device->supportedByteOrders(); + for(int i = 0; i < endianz.size(); ++i) { + switch(endianz.at(i)) { + case QAudioFormat::LittleEndian: + endianBox->addItem("Little Endian"); + break; + case QAudioFormat::BigEndian: + endianBox->addItem("Big Endian"); + break; + } + } + if(endianz.size()) + settings.setByteOrder(endianz.at(0)); +} + +void AudioTest::freqChanged(int idx) +{ + // freq has changed + settings.setFrequency(frequencyBox->itemText(idx).toInt()); +} + +void AudioTest::channelChanged(int idx) +{ + settings.setChannels(channelsBox->itemText(idx).toInt()); +} + +void AudioTest::codecChanged(int idx) +{ + settings.setCodec(codecsBox->itemText(idx)); +} + +void AudioTest::sampleSizeChanged(int idx) +{ + settings.setSampleSize(sampleSizesBox->itemText(idx).toInt()); +} + +void AudioTest::sampleTypeChanged(int idx) +{ + switch(sampleTypesBox->itemText(idx).toInt()) { + case QAudioFormat::SignedInt: + settings.setSampleType(QAudioFormat::SignedInt); + break; + case QAudioFormat::UnSignedInt: + settings.setSampleType(QAudioFormat::UnSignedInt); + break; + case QAudioFormat::Float: + settings.setSampleType(QAudioFormat::Float); + } +} + +void AudioTest::endianChanged(int idx) +{ + switch(endianBox->itemText(idx).toInt()) { + case QAudioFormat::LittleEndian: + settings.setByteOrder(QAudioFormat::LittleEndian); + break; + case QAudioFormat::BigEndian: + settings.setByteOrder(QAudioFormat::BigEndian); + } +} + diff --git a/examples/multimedia/audio/audiodevices/audiodevices.h b/examples/multimedia/audio/audiodevices/audiodevices.h new file mode 100644 index 0000000..cd696c3 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QObject> +#include <QMainWindow> +#include <QAudioDeviceInfo> + +#include "ui_audiodevicesbase.h" + +class AudioDevicesBase : public QMainWindow, public Ui::AudioDevicesBase +{ +public: + AudioDevicesBase( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + virtual ~AudioDevicesBase(); +}; + +class AudioTest : public AudioDevicesBase +{ + Q_OBJECT +public: + AudioTest( QMainWindow *parent = 0, Qt::WFlags f = 0 ); + virtual ~AudioTest(); + + QAudioDeviceId deviceHandle; + QAudioDeviceInfo* device; + QAudioFormat settings; + QAudio::Mode mode; + +private slots: + void modeChanged(int idx); + void deviceChanged(int idx); + void freqChanged(int idx); + void channelChanged(int idx); + void codecChanged(int idx); + void sampleSizeChanged(int idx); + void sampleTypeChanged(int idx); + void endianChanged(int idx); + void test(); +}; + diff --git a/examples/multimedia/audio/audiodevices/audiodevices.pro b/examples/multimedia/audio/audiodevices/audiodevices.pro new file mode 100644 index 0000000..adc4890 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevices.pro @@ -0,0 +1,12 @@ +HEADERS = audiodevices.h +SOURCES = audiodevices.cpp \ + main.cpp +FORMS += audiodevicesbase.ui + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiodevices +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audiodevices.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiodevices +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiodevices/audiodevicesbase.ui b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui new file mode 100644 index 0000000..674f201 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/audiodevicesbase.ui @@ -0,0 +1,255 @@ +<ui version="4.0" > + <class>AudioDevicesBase</class> + <widget class="QMainWindow" name="AudioDevicesBase" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>504</width> + <height>702</height> + </rect> + </property> + <property name="windowTitle" > + <string>AudioDevicesBase</string> + </property> + <widget class="QWidget" name="centralwidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>28</y> + <width>504</width> + <height>653</height> + </rect> + </property> + <widget class="QWidget" name="layoutWidget" > + <property name="geometry" > + <rect> + <x>40</x> + <y>21</y> + <width>321</width> + <height>506</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="deviceLabel" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Device</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QLabel" name="modeLabel" > + <property name="text" > + <string>Mode</string> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QComboBox" name="deviceBox" /> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="modeBox" /> + </item> + <item row="2" column="0" > + <widget class="QLabel" name="actualLabel" > + <property name="frameShape" > + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <property name="text" > + <string>Actual Settings</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="2" column="1" > + <widget class="QLabel" name="nearestLabel" > + <property name="frameShape" > + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <property name="text" > + <string>Nearest Settings</string> + </property> + <property name="alignment" > + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="0" > + <widget class="QLabel" name="actualFreqLabel" > + <property name="text" > + <string>Frequency</string> + </property> + </widget> + </item> + <item row="3" column="1" > + <widget class="QLabel" name="nearestFreqLabel" > + <property name="text" > + <string>Frequency</string> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QComboBox" name="frequencyBox" /> + </item> + <item row="4" column="1" > + <widget class="QLineEdit" name="nearestFreq" /> + </item> + <item row="5" column="0" > + <widget class="QLabel" name="actualChannelsLabel" > + <property name="text" > + <string>Channels</string> + </property> + </widget> + </item> + <item row="5" column="1" > + <widget class="QLabel" name="nearestChannelLabel" > + <property name="text" > + <string>Channel</string> + </property> + </widget> + </item> + <item row="6" column="0" > + <widget class="QComboBox" name="channelsBox" /> + </item> + <item row="6" column="1" > + <widget class="QLineEdit" name="nearestChannel" /> + </item> + <item row="7" column="0" > + <widget class="QLabel" name="actualCodecLabel" > + <property name="text" > + <string>Codecs</string> + </property> + </widget> + </item> + <item row="7" column="1" > + <widget class="QLabel" name="nearestCodecLabel" > + <property name="text" > + <string>Codec</string> + </property> + </widget> + </item> + <item row="8" column="0" > + <widget class="QComboBox" name="codecsBox" /> + </item> + <item row="8" column="1" > + <widget class="QLineEdit" name="nearestCodec" /> + </item> + <item row="9" column="0" > + <widget class="QLabel" name="actualSampleSizeLabel" > + <property name="text" > + <string>SampleSize</string> + </property> + </widget> + </item> + <item row="9" column="1" > + <widget class="QLabel" name="nearestSampleSizeLabel" > + <property name="text" > + <string>SampleSize</string> + </property> + </widget> + </item> + <item row="10" column="0" > + <widget class="QComboBox" name="sampleSizesBox" /> + </item> + <item row="10" column="1" > + <widget class="QLineEdit" name="nearestSampleSize" /> + </item> + <item row="11" column="0" > + <widget class="QLabel" name="actualSampleTypeLabel" > + <property name="text" > + <string>SampleType</string> + </property> + </widget> + </item> + <item row="11" column="1" > + <widget class="QLabel" name="nearestSampleTypeLabel" > + <property name="text" > + <string>SampleType</string> + </property> + </widget> + </item> + <item row="12" column="0" > + <widget class="QComboBox" name="sampleTypesBox" /> + </item> + <item row="12" column="1" > + <widget class="QLineEdit" name="nearestSampleType" /> + </item> + <item row="13" column="0" > + <widget class="QLabel" name="actualEndianLabel" > + <property name="text" > + <string>Endianess</string> + </property> + </widget> + </item> + <item row="13" column="1" > + <widget class="QLabel" name="nearestEndianLabel" > + <property name="text" > + <string>Endianess</string> + </property> + </widget> + </item> + <item row="14" column="0" > + <widget class="QComboBox" name="endianBox" /> + </item> + <item row="14" column="1" > + <widget class="QLineEdit" name="nearestEndian" /> + </item> + <item row="15" column="0" colspan="2" > + <widget class="QTextEdit" name="logOutput" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>40</height> + </size> + </property> + </widget> + </item> + <item row="16" column="0" colspan="2" > + <widget class="QPushButton" name="testButton" > + <property name="text" > + <string>Test</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <widget class="QMenuBar" name="menubar" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>504</width> + <height>28</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar" > + <property name="geometry" > + <rect> + <x>0</x> + <y>681</y> + <width>504</width> + <height>21</height> + </rect> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/examples/multimedia/audio/audiodevices/main.cpp b/examples/multimedia/audio/audiodevices/main.cpp new file mode 100644 index 0000000..01860b7 --- /dev/null +++ b/examples/multimedia/audio/audiodevices/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "audiodevices.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Device Test"); + + AudioTest audio; + audio.show(); + + return app.exec(); +} diff --git a/examples/multimedia/audio/audioinput/audioinput.cpp b/examples/multimedia/audio/audioinput/audioinput.cpp new file mode 100644 index 0000000..b040328 --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.cpp @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <stdlib.h> +#include <math.h> + +#include <QDebug> +#include <QPainter> +#include <QVBoxLayout> + +#include <QAudioDeviceInfo> +#include <QAudioInput> +#include "audioinput.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +Spectrum::Spectrum(QObject* parent, QAudioInput* device, float* out) + :QIODevice( parent ) +{ + input = device; + output = out; + + unsigned int i; + + // Allocate sample buffer and initialize sin and cos lookup tables + fftState = (fft_state *) malloc (sizeof(fft_state)); + + for(i = 0; i < BUFFER_SIZE; i++) { + bitReverse[i] = reverseBits(i); + } + for(i = 0; i < BUFFER_SIZE / 2; i++) { + float j = 2 * M_PI * i / BUFFER_SIZE; + costable[i] = cos(j); + sintable[i] = sin(j); + } +} + +Spectrum::~Spectrum() +{ +} + +void Spectrum::start() +{ + open(QIODevice::WriteOnly); +} + +void Spectrum::stop() +{ + close(); +} + +qint64 Spectrum::readData(char *data, qint64 maxlen) +{ + Q_UNUSED(data) + Q_UNUSED(maxlen) + + return 0; +} + +qint64 Spectrum::writeData(const char *data, qint64 len) +{ + performFFT((sound_sample*)data); + emit update(); + + return len; +} + +int Spectrum::reverseBits(unsigned int initial) { + // BIT-REVERSE-COPY(a,A) + + unsigned int reversed = 0, loop; + for(loop = 0; loop < BUFFER_SIZE_LOG; loop++) { + reversed <<= 1; + reversed += (initial & 1); + initial >>= 1; + } + return reversed; +} + +void Spectrum::performFFT(const sound_sample *input) { + /* Convert to reverse bit order for FFT */ + prepFFT(input, fftState->real, fftState->imag); + + /* Calculate FFT */ + calcFFT(fftState->real, fftState->imag); + + /* Convert FFT to intensities */ + outputFFT(fftState->real, fftState->imag); +} + +void Spectrum::prepFFT(const sound_sample *input, float * re, float * im) { + unsigned int i; + float *realptr = re; + float *imagptr = im; + + /* Get input, in reverse bit order */ + for(i = 0; i < BUFFER_SIZE; i++) { + *realptr++ = input[bitReverse[i]]; + *imagptr++ = 0; + } +} + +void Spectrum::calcFFT(float * re, float * im) { + unsigned int i, j, k; + unsigned int exchanges; + float fact_real, fact_imag; + float tmp_real, tmp_imag; + unsigned int factfact; + + /* Set up some variables to reduce calculation in the loops */ + exchanges = 1; + factfact = BUFFER_SIZE / 2; + + /* divide and conquer method */ + for(i = BUFFER_SIZE_LOG; i != 0; i--) { + for(j = 0; j != exchanges; j++) { + fact_real = costable[j * factfact]; + fact_imag = sintable[j * factfact]; + for(k = j; k < BUFFER_SIZE; k += exchanges << 1) { + int k1 = k + exchanges; + tmp_real = fact_real * re[k1] - fact_imag * im[k1]; + tmp_imag = fact_real * im[k1] + fact_imag * re[k1]; + re[k1] = re[k] - tmp_real; + im[k1] = im[k] - tmp_imag; + re[k] += tmp_real; + im[k] += tmp_imag; + } + } + exchanges <<= 1; + factfact >>= 1; + } +} + +void Spectrum::outputFFT(const float * re, const float * im) { + const float *realptr = re; + const float *imagptr = im; + float *outputptr = output; + + float *endptr = output + BUFFER_SIZE / 2; + + /* Convert FFT to intensities */ + + while(outputptr <= endptr) { + *outputptr = (*realptr * *realptr) + (*imagptr * *imagptr); + outputptr++; realptr++; imagptr++; + } + *output /= 4; + *endptr /= 4; +} + + +RenderArea::RenderArea(QWidget *parent) + : QWidget(parent) +{ + setBackgroundRole(QPalette::Base); + setAutoFillBackground(true); + + samples = 0; + sampleSize = 0; + setMinimumHeight(30); + setMinimumWidth(200); +} + +void RenderArea::paintEvent(QPaintEvent * /* event */) +{ + QPainter painter(this); + + if(sampleSize == 0) + return; + + painter.setPen(Qt::red); + int max = 0; + for(int i=0;i<sampleSize;i++) { + int m = (int)(sqrt(samples[i])/32768); + if(m > max) + max = m; + } + int x1,y1,x2,y2; + + for(int i=0;i<10;i++) { + x1 = painter.viewport().left()+11; + y1 = painter.viewport().top()+10+i; + x2 = painter.viewport().right()-20-max; + y2 = painter.viewport().top()+10+i; + if(x2 < painter.viewport().left()+10) + x2 = painter.viewport().left()+10; + + painter.drawLine(QPoint(x1,y1),QPoint(x2,y2)); + } + + painter.setPen(Qt::black); + painter.drawRect(QRect(painter.viewport().left()+10, painter.viewport().top()+10, + painter.viewport().right()-20, painter.viewport().bottom()-20)); +} + +void RenderArea::spectrum(float* output, int size) +{ + samples = output; + sampleSize = size; + repaint(); +} + + +InputTest::InputTest() +{ + QWidget *window = new QWidget; + QVBoxLayout* layout = new QVBoxLayout; + + canvas = new RenderArea; + layout->addWidget(canvas); + + deviceBox = new QComboBox(this); + QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioInput); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + layout->addWidget(deviceBox); + + button = new QPushButton(this); + button->setText(tr("Click for Push Mode")); + connect(button,SIGNAL(clicked()),SLOT(toggleMode())); + layout->addWidget(button); + + button2 = new QPushButton(this); + button2->setText(tr("Click To Suspend")); + connect(button2,SIGNAL(clicked()),SLOT(toggleSuspend())); + layout->addWidget(button2); + + window->setLayout(layout); + setCentralWidget(window); + window->show(); + + buffer = new char[BUFFER_SIZE*10]; + output = new float[1024]; + + pullMode = true; + + format.setFrequency(8000); + format.setChannels(1); + format.setSampleSize(8); + format.setSampleType(QAudioFormat::UnSignedInt); + format.setByteOrder(QAudioFormat::LittleEndian); + format.setCodec("audio/pcm"); + + audioInput = new QAudioInput(format,this); + connect(audioInput,SIGNAL(notify()),SLOT(status())); + connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + spec = new Spectrum(this,audioInput,output); + connect(spec,SIGNAL(update()),SLOT(refreshDisplay())); + spec->start(); + audioInput->start(spec); +} + +InputTest::~InputTest() {} + +void InputTest::status() +{ + qWarning()<<"bytesReady = "<<audioInput->bytesReady()<<" bytes, clock = "<<audioInput->clock()<<"ms, totalTime = "<<audioInput->totalTime()/1000<<"ms"; +} + +void InputTest::readMore() +{ + if(!audioInput) + return; + qint64 len = audioInput->bytesReady(); + if(len > BUFFER_SIZE*10) + len = BUFFER_SIZE*10; + qint64 l = input->read(buffer,len); + if(l > 0) { + spec->write(buffer,l); + } +} + +void InputTest::toggleMode() +{ + // Change bewteen pull and push modes + audioInput->stop(); + + if(pullMode) { + button->setText(tr("Click for Push Mode")); + input = audioInput->start(0); + connect(input,SIGNAL(readyRead()),SLOT(readMore())); + pullMode = false; + } else { + button->setText(tr("Click for Pull Mode")); + pullMode = true; + audioInput->start(spec); + } +} + +void InputTest::toggleSuspend() +{ + // toggle suspend/resume + if(audioInput->state() == QAudio::SuspendState) { + qWarning()<<"status: Suspended, resume()"; + audioInput->resume(); + button2->setText("Click To Suspend"); + } else if (audioInput->state() == QAudio::ActiveState) { + qWarning()<<"status: Active, suspend()"; + audioInput->suspend(); + button2->setText("Click To Resume"); + } else if (audioInput->state() == QAudio::StopState) { + qWarning()<<"status: Stopped, resume()"; + audioInput->resume(); + button2->setText("Click To Suspend"); + } else if (audioInput->state() == QAudio::IdleState) { + qWarning()<<"status: IdleState"; + } +} + +void InputTest::state(QAudio::State state) +{ + qWarning()<<" state="<<state; +} + +void InputTest::refreshDisplay() +{ + canvas->spectrum(output,256); + canvas->repaint(); +} + +void InputTest::deviceChanged(int idx) +{ + spec->stop(); + audioInput->stop(); + audioInput->disconnect(this); + delete audioInput; + + device = deviceBox->itemData(idx).value<QAudioDeviceId>(); + audioInput = new QAudioInput(device, format, this); + connect(audioInput,SIGNAL(notify()),SLOT(status())); + connect(audioInput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + spec->start(); + audioInput->start(spec); +} diff --git a/examples/multimedia/audio/audioinput/audioinput.h b/examples/multimedia/audio/audioinput/audioinput.h new file mode 100644 index 0000000..c19f453 --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.h @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QPixmap> +#include <QWidget> +#include <QObject> +#include <QMainWindow> +#include <QPushButton> +#include <QComboBox> + +#include <qaudioinput.h> + +#define BUFFER_SIZE_LOG 9 +#define BUFFER_SIZE (1 << BUFFER_SIZE_LOG) + +struct _struct_fft_state { + float real[BUFFER_SIZE]; + float imag[BUFFER_SIZE]; +}; +typedef _struct_fft_state fft_state; +typedef short int sound_sample; + +class Spectrum : public QIODevice +{ + Q_OBJECT +public: + Spectrum(QObject* parent, QAudioInput* device, float* out); + ~Spectrum(); + + void start(); + void stop(); + + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + + QAudioInput* input; + float* output; + fft_state* fftState; + + unsigned int bitReverse[BUFFER_SIZE]; + float sintable[BUFFER_SIZE / 2]; + float costable[BUFFER_SIZE / 2]; + + void prepFFT (const sound_sample *input, float *re, float *im); + void calcFFT (float *re, float *im); + void outputFFT (const float *re, const float *im); + int reverseBits (unsigned int initial); + void performFFT (const sound_sample *input); + +signals: + void update(); +}; + + +class RenderArea : public QWidget +{ + Q_OBJECT + +public: + RenderArea(QWidget *parent = 0); + + void spectrum(float* output, int size); + +protected: + void paintEvent(QPaintEvent *event); + +private: + QPixmap pixmap; + + float* samples; + int sampleSize; +}; + +class InputTest : public QMainWindow +{ + Q_OBJECT +public: + InputTest(); + ~InputTest(); + + QAudioDeviceId device; + QAudioFormat format; + QAudioInput* audioInput; + Spectrum* spec; + QIODevice* input; + RenderArea* canvas; + + bool pullMode; + + QPushButton* button; + QPushButton* button2; + QComboBox* deviceBox; + + char* buffer; + float* output; + +private slots: + void refreshDisplay(); + void status(); + void readMore(); + void toggleMode(); + void toggleSuspend(); + void state(QAudio::State s); + void deviceChanged(int idx); +}; + diff --git a/examples/multimedia/audio/audioinput/audioinput.pro b/examples/multimedia/audio/audioinput/audioinput.pro new file mode 100644 index 0000000..d930750 --- /dev/null +++ b/examples/multimedia/audio/audioinput/audioinput.pro @@ -0,0 +1,12 @@ +HEADERS = audioinput.h +SOURCES = audioinput.cpp \ + main.cpp + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audioinput +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audioinput.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audioinput +INSTALLS += target sources + diff --git a/examples/multimedia/audio/audioinput/main.cpp b/examples/multimedia/audio/audioinput/main.cpp new file mode 100644 index 0000000..8f138d2 --- /dev/null +++ b/examples/multimedia/audio/audioinput/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "audioinput.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Input Test"); + + InputTest input; + input.show(); + + return app.exec(); +} diff --git a/examples/multimedia/audio/audiooutput/audiooutput.cpp b/examples/multimedia/audio/audiooutput/audiooutput.cpp new file mode 100644 index 0000000..e954f8a --- /dev/null +++ b/examples/multimedia/audio/audiooutput/audiooutput.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include <QVBoxLayout> + +#include <QAudioOutput> +#include <QAudioDeviceInfo> +#include "audiooutput.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +Generator::Generator(QObject *parent) + :QIODevice( parent ) +{ + finished = false; + buffer = new char[SECONDS*44100*4+1000]; + t=buffer; + len=fillData(t+4,450,SECONDS); /* left channel, 450Hz sine */ + len+=fillData(t+6,452,SECONDS); /* right channel, 452Hz sine */ + putLong(t,len); + putLong(buffer+4,len+8+16+8); + pos = 0; + total = len+8+16+8; +} + +Generator::~Generator() +{ + delete [] buffer; +} + +void Generator::start() +{ + open(QIODevice::ReadOnly); +} + +void Generator::stop() +{ + close(); +} + +int Generator::putShort(char *t, unsigned int value) +{ + *(unsigned char *)(t++)=value&255; + *(unsigned char *)(t)=(value/256)&255; + return 2; +} + +int Generator::putLong(char *t, unsigned int value) +{ + *(unsigned char *)(t++)=value&255; + *(unsigned char *)(t++)=(value/256)&255; + *(unsigned char *)(t++)=(value/(256*256))&255; + *(unsigned char *)(t)=(value/(256*256*256))&255; + return 4; +} + +int Generator::fillData(char *start, int frequency, int seconds) +{ + int i, len=0; + int value; + for(i=0; i<seconds*44100; i++) { + value=(int)(32767.0*sin(2.0*M_PI*((double)(i))*(double)(frequency)/44100.0)); + putShort(start, value); + start += 4; + len+=2; + } + return len; +} + +qint64 Generator::readData(char *data, qint64 maxlen) +{ + int len = maxlen; + if(len > 16384) + len = 16384; + + if(len < (SECONDS*44100*4+1000)-pos) { + // Normal + memcpy(data,t+pos,len); + pos+=len; + return len; + } else { + // Whats left and reset to start + qint64 left = (SECONDS*44100*4+1000)-pos; + memcpy(data,t+pos,left); + pos=0; + return left; + } +} + +qint64 Generator::writeData(const char *data, qint64 len) +{ + Q_UNUSED(data); + Q_UNUSED(len); + + return 0; +} + +AudioTest::AudioTest() +{ + QWidget *window = new QWidget; + QVBoxLayout* layout = new QVBoxLayout; + + deviceBox = new QComboBox(this); + QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput); + for(int i = 0; i < devices.size(); ++i) { + deviceBox->addItem(QAudioDeviceInfo(devices.at(i)).deviceName(), qVariantFromValue(devices.at(i))); + } + connect(deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); + layout->addWidget(deviceBox); + + button = new QPushButton(this); + button->setText(tr("Click for Push Mode")); + connect(button,SIGNAL(clicked()),SLOT(toggle())); + layout->addWidget(button); + + button2 = new QPushButton(this); + button2->setText(tr("Click To Suspend")); + connect(button2,SIGNAL(clicked()),SLOT(togglePlay())); + layout->addWidget(button2); + + window->setLayout(layout); + setCentralWidget(window); + window->show(); + + buffer = new char[BUFFER_SIZE]; + + gen = new Generator(this); + + pullMode = true; + + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),SLOT(writeMore())); + + gen->start(); + + settings.setFrequency(44100); + settings.setChannels(2); + settings.setSampleSize(16); + settings.setCodec("audio/pcm"); + settings.setByteOrder(QAudioFormat::LittleEndian); + settings.setSampleType(QAudioFormat::SignedInt); + audioOutput = new QAudioOutput(settings,this); + connect(audioOutput,SIGNAL(notify()),SLOT(status())); + connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + + audioOutput->start(gen); +} + +AudioTest::~AudioTest() +{ + delete [] buffer; +} + +void AudioTest::deviceChanged(int idx) +{ + timer->stop(); + gen->stop(); + audioOutput->stop(); + audioOutput->disconnect(this); + delete audioOutput; + + device = deviceBox->itemData(idx).value<QAudioDeviceId>(); + audioOutput = new QAudioOutput(device,settings,this); + connect(audioOutput,SIGNAL(notify()),SLOT(status())); + connect(audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(state(QAudio::State))); + gen->start(); + audioOutput->start(gen); +} + +void AudioTest::status() +{ + qWarning()<<"byteFree = "<<audioOutput->bytesFree()<<" bytes, clock = "<<audioOutput->clock()<<"ms, totalTime = "<<audioOutput->totalTime()/1000<<"ms"; +} + +void AudioTest::writeMore() +{ + if(!audioOutput) + return; + + if(audioOutput->state() == QAudio::StopState) + return; + + int l; + int out; + + int chunks = audioOutput->bytesFree()/audioOutput->periodSize(); + while(chunks) { + l = gen->read(buffer,audioOutput->periodSize()); + if(l > 0) + out = output->write(buffer,l); + if(l != audioOutput->periodSize()) + break; + chunks--; + } +} + +void AudioTest::toggle() +{ + // Change between pull and push modes + + timer->stop(); + audioOutput->stop(); + + if (pullMode) { + button->setText("Click for Pull Mode"); + output = audioOutput->start(0); + pullMode = false; + timer->start(20); + } else { + button->setText("Click for Push Mode"); + pullMode = true; + audioOutput->start(gen); + } +} + +void AudioTest::togglePlay() +{ + // toggle suspend/resume + if(audioOutput->state() == QAudio::SuspendState) { + qWarning()<<"status: Suspended, resume()"; + audioOutput->resume(); + button2->setText("Click To Suspend"); + } else if (audioOutput->state() == QAudio::ActiveState) { + qWarning()<<"status: Active, suspend()"; + audioOutput->suspend(); + button2->setText("Click To Resume"); + } else if (audioOutput->state() == QAudio::StopState) { + qWarning()<<"status: Stopped, resume()"; + audioOutput->resume(); + button2->setText("Click To Suspend"); + } else if (audioOutput->state() == QAudio::IdleState) { + qWarning()<<"status: IdleState"; + } +} + +void AudioTest::state(QAudio::State state) +{ + qWarning()<<" state="<<state; +} diff --git a/examples/multimedia/audio/audiooutput/audiooutput.h b/examples/multimedia/audio/audiooutput/audiooutput.h new file mode 100644 index 0000000..cdb2639 --- /dev/null +++ b/examples/multimedia/audio/audiooutput/audiooutput.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <math.h> + +#define BUFFER_SIZE 32768 +#define SECONDS 3 + +#include <QObject> +#include <QMainWindow> +#include <QIODevice> +#include <QTimer> +#include <QPushButton> +#include <QComboBox> + +#include <QAudioOutput> + +class Generator : public QIODevice +{ + Q_OBJECT +public: + Generator(QObject *parent); + ~Generator(); + + void start(); + void stop(); + + char *t; + int len; + int pos; + int total; + char *buffer; + bool finished; + int chunk_size; + + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + +private: + int putShort(char *t, unsigned int value); + int putLong(char *t, unsigned int value); + int fillData(char *start, int frequency, int seconds); +}; + +class AudioTest : public QMainWindow +{ + Q_OBJECT +public: + AudioTest(); + ~AudioTest(); + + QAudioDeviceId device; + Generator* gen; + QAudioOutput* audioOutput; + QIODevice* output; + QTimer* timer; + QAudioFormat settings; + + bool pullMode; + char* buffer; + + QPushButton* button; + QPushButton* button2; + QComboBox* deviceBox; + +private slots: + void status(); + void writeMore(); + void toggle(); + void togglePlay(); + void state(QAudio::State s); + void deviceChanged(int idx); +}; + diff --git a/examples/multimedia/audio/audiooutput/audiooutput.pro b/examples/multimedia/audio/audiooutput/audiooutput.pro new file mode 100644 index 0000000..08f43ce --- /dev/null +++ b/examples/multimedia/audio/audiooutput/audiooutput.pro @@ -0,0 +1,11 @@ +HEADERS = audiooutput.h +SOURCES = audiooutput.cpp \ + main.cpp + +QT += multimedia + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiooutput +sources.files = $$SOURCES *.h $$RESOURCES $$FORMS audiooutput.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audio/audiooutput +INSTALLS += target sources diff --git a/examples/multimedia/audio/audiooutput/main.cpp b/examples/multimedia/audio/audiooutput/main.cpp new file mode 100644 index 0000000..0b5d569 --- /dev/null +++ b/examples/multimedia/audio/audiooutput/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtGui> + +#include "audiooutput.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + app.setApplicationName("Audio Output Test"); + + AudioTest audio; + audio.show(); + + return app.exec(); +} diff --git a/examples/multimedia/multimedia.pro b/examples/multimedia/multimedia.pro new file mode 100644 index 0000000..ac78b15 --- /dev/null +++ b/examples/multimedia/multimedia.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS = audio + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multimedia +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS multimedia.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/multimedia +INSTALLS += target sources diff --git a/examples/multitouch/dials/dials.pro b/examples/multitouch/dials/dials.pro new file mode 100644 index 0000000..e592232 --- /dev/null +++ b/examples/multitouch/dials/dials.pro @@ -0,0 +1,2 @@ +SOURCES += main.cpp +FORMS += dials.ui diff --git a/examples/multitouch/dials/dials.ui b/examples/multitouch/dials/dials.ui new file mode 100644 index 0000000..8ca7ae9 --- /dev/null +++ b/examples/multitouch/dials/dials.ui @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Dials</class> + <widget class="QWidget" name="Dials"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QDial" name="dial_1"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDial" name="dial_2"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QDial" name="dial_3"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QDial" name="dial_4"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QDial" name="dial_5"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QDial" name="dial_6"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QDial" name="dial_7"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QDial" name="dial_8"> + <property name="notchesVisible"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/examples/multitouch/dials/main.cpp b/examples/multitouch/dials/main.cpp new file mode 100644 index 0000000..4b21abd --- /dev/null +++ b/examples/multitouch/dials/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QWidget> +#include <QDial> + +#include "ui_dials.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QWidget window; + Ui::Dials dialsUi; + dialsUi.setupUi(&window); + QList<QAbstractSlider *> sliders = window.findChildren<QAbstractSlider *>(); + foreach (QAbstractSlider *slider, sliders) + slider->setAttribute(Qt::WA_AcceptTouchEvents); + window.showMaximized(); + return app.exec(); +} diff --git a/examples/multitouch/fingerpaint/fingerpaint.pro b/examples/multitouch/fingerpaint/fingerpaint.pro new file mode 100644 index 0000000..1d45635 --- /dev/null +++ b/examples/multitouch/fingerpaint/fingerpaint.pro @@ -0,0 +1,11 @@ +HEADERS = mainwindow.h \ + scribblearea.h +SOURCES = main.cpp \ + mainwindow.cpp \ + scribblearea.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multitouch/fingerpaint +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fingerpaint.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/multitouch/fingerpaint +INSTALLS += target sources diff --git a/examples/multitouch/fingerpaint/main.cpp b/examples/multitouch/fingerpaint/main.cpp new file mode 100644 index 0000000..524d222 --- /dev/null +++ b/examples/multitouch/fingerpaint/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow window; + window.showMaximized(); + return app.exec(); +} diff --git a/examples/multitouch/fingerpaint/mainwindow.cpp b/examples/multitouch/fingerpaint/mainwindow.cpp new file mode 100644 index 0000000..8147f1f --- /dev/null +++ b/examples/multitouch/fingerpaint/mainwindow.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "mainwindow.h" +#include "scribblearea.h" + +//! [0] +MainWindow::MainWindow() +{ + scribbleArea = new ScribbleArea; + setCentralWidget(scribbleArea); + + createActions(); + createMenus(); + + setWindowTitle(tr("Finger Paint")); + resize(500, 500); +} +//! [0] + +//! [1] +void MainWindow::closeEvent(QCloseEvent *event) +//! [1] //! [2] +{ + if (maybeSave()) { + event->accept(); + } else { + event->ignore(); + } +} +//! [2] + +//! [3] +void MainWindow::open() +//! [3] //! [4] +{ + if (maybeSave()) { + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open File"), QDir::currentPath()); + if (!fileName.isEmpty()) + scribbleArea->openImage(fileName); + } +} +//! [4] + +//! [5] +void MainWindow::save() +//! [5] //! [6] +{ + QAction *action = qobject_cast<QAction *>(sender()); + QByteArray fileFormat = action->data().toByteArray(); + saveFile(fileFormat); +} +//! [6] + +//! [11] +void MainWindow::about() +//! [11] //! [12] +{ + QMessageBox::about(this, tr("About Scribble"), + tr("<p>The <b>Scribble</b> example shows how to use QMainWindow as the " + "base widget for an application, and how to reimplement some of " + "QWidget's event handlers to receive the events generated for " + "the application's widgets:</p><p> We reimplement the mouse event " + "handlers to facilitate drawing, the paint event handler to " + "update the application and the resize event handler to optimize " + "the application's appearance. In addition we reimplement the " + "close event handler to intercept the close events before " + "terminating the application.</p><p> The example also demonstrates " + "how to use QPainter to draw an image in real time, as well as " + "to repaint widgets.</p>")); +} +//! [12] + +//! [13] +void MainWindow::createActions() +//! [13] //! [14] +{ + openAct = new QAction(tr("&Open..."), this); + openAct->setShortcut(tr("Ctrl+O")); + connect(openAct, SIGNAL(triggered()), this, SLOT(open())); + + foreach (QByteArray format, QImageWriter::supportedImageFormats()) { + QString text = tr("%1...").arg(QString(format).toUpper()); + + QAction *action = new QAction(text, this); + action->setData(format); + connect(action, SIGNAL(triggered()), this, SLOT(save())); + saveAsActs.append(action); + } + + printAct = new QAction(tr("&Print..."), this); + connect(printAct, SIGNAL(triggered()), scribbleArea, SLOT(print())); + + exitAct = new QAction(tr("E&xit"), this); + exitAct->setShortcut(tr("Ctrl+Q")); + connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); + + clearScreenAct = new QAction(tr("&Clear Screen"), this); + clearScreenAct->setShortcut(tr("Ctrl+L")); + connect(clearScreenAct, SIGNAL(triggered()), + scribbleArea, SLOT(clearImage())); + + aboutAct = new QAction(tr("&About"), this); + connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); + + aboutQtAct = new QAction(tr("About &Qt"), this); + connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); +} +//! [14] + +//! [15] +void MainWindow::createMenus() +//! [15] //! [16] +{ + saveAsMenu = new QMenu(tr("&Save As"), this); + foreach (QAction *action, saveAsActs) + saveAsMenu->addAction(action); + + fileMenu = new QMenu(tr("&File"), this); + fileMenu->addAction(openAct); + fileMenu->addMenu(saveAsMenu); + fileMenu->addAction(printAct); + fileMenu->addSeparator(); + fileMenu->addAction(exitAct); + + optionMenu = new QMenu(tr("&Options"), this); + optionMenu->addAction(clearScreenAct); + + helpMenu = new QMenu(tr("&Help"), this); + helpMenu->addAction(aboutAct); + helpMenu->addAction(aboutQtAct); + + menuBar()->addMenu(fileMenu); + menuBar()->addMenu(optionMenu); + menuBar()->addMenu(helpMenu); +} +//! [16] + +//! [17] +bool MainWindow::maybeSave() +//! [17] //! [18] +{ + if (scribbleArea->isModified()) { + QMessageBox::StandardButton ret; + ret = QMessageBox::warning(this, tr("Scribble"), + tr("The image has been modified.\n" + "Do you want to save your changes?"), + QMessageBox::Save | QMessageBox::Discard + | QMessageBox::Cancel); + if (ret == QMessageBox::Save) { + return saveFile("png"); + } else if (ret == QMessageBox::Cancel) { + return false; + } + } + return true; +} +//! [18] + +//! [19] +bool MainWindow::saveFile(const QByteArray &fileFormat) +//! [19] //! [20] +{ + QString initialPath = QDir::currentPath() + "/untitled." + fileFormat; + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), + initialPath, + tr("%1 Files (*.%2);;All Files (*)") + .arg(QString(fileFormat.toUpper())) + .arg(QString(fileFormat))); + if (fileName.isEmpty()) { + return false; + } else { + return scribbleArea->saveImage(fileName, fileFormat); + } +} +//! [20] diff --git a/examples/multitouch/fingerpaint/mainwindow.h b/examples/multitouch/fingerpaint/mainwindow.h new file mode 100644 index 0000000..e200812 --- /dev/null +++ b/examples/multitouch/fingerpaint/mainwindow.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QList> +#include <QMainWindow> + +class ScribbleArea; + +//! [0] +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(); + +protected: + void closeEvent(QCloseEvent *event); + +private slots: + void open(); + void save(); + void about(); + +private: + void createActions(); + void createMenus(); + bool maybeSave(); + bool saveFile(const QByteArray &fileFormat); + + ScribbleArea *scribbleArea; + + QMenu *saveAsMenu; + QMenu *fileMenu; + QMenu *optionMenu; + QMenu *helpMenu; + + QAction *openAct; + QList<QAction *> saveAsActs; + QAction *exitAct; + QAction *printAct; + QAction *clearScreenAct; + QAction *aboutAct; + QAction *aboutQtAct; +}; +//! [0] + +#endif diff --git a/examples/multitouch/fingerpaint/scribblearea.cpp b/examples/multitouch/fingerpaint/scribblearea.cpp new file mode 100644 index 0000000..eab6908 --- /dev/null +++ b/examples/multitouch/fingerpaint/scribblearea.cpp @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "scribblearea.h" + +//! [0] +ScribbleArea::ScribbleArea(QWidget *parent) + : QWidget(parent) +{ + setAttribute(Qt::WA_AcceptTouchEvents); + setAttribute(Qt::WA_StaticContents); + modified = false; + + myPenColors + << QColor("green") + << QColor("purple") + << QColor("red") + << QColor("blue") + << QColor("yellow") + + << QColor("pink") + << QColor("orange") + << QColor("brown") + << QColor("grey") + << QColor("black"); +} +//! [0] + +//! [1] +bool ScribbleArea::openImage(const QString &fileName) +//! [1] //! [2] +{ + QImage loadedImage; + if (!loadedImage.load(fileName)) + return false; + + QSize newSize = loadedImage.size().expandedTo(size()); + resizeImage(&loadedImage, newSize); + image = loadedImage; + modified = false; + update(); + return true; +} +//! [2] + +//! [3] +bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat) +//! [3] //! [4] +{ + QImage visibleImage = image; + resizeImage(&visibleImage, size()); + + if (visibleImage.save(fileName, fileFormat)) { + modified = false; + return true; + } else { + return false; + } +} +//! [4] + +//! [9] +void ScribbleArea::clearImage() +//! [9] //! [10] +{ + image.fill(qRgb(255, 255, 255)); + modified = true; + update(); +} +//! [10] + +//! [12] //! [13] +void ScribbleArea::paintEvent(QPaintEvent *event) +//! [13] //! [14] +{ + QPainter painter(this); + const QRect rect = event->rect(); + painter.drawImage(rect.topLeft(), image, rect); +} +//! [14] + +//! [15] +void ScribbleArea::resizeEvent(QResizeEvent *event) +//! [15] //! [16] +{ + if (width() > image.width() || height() > image.height()) { + int newWidth = qMax(width() + 128, image.width()); + int newHeight = qMax(height() + 128, image.height()); + resizeImage(&image, QSize(newWidth, newHeight)); + update(); + } + QWidget::resizeEvent(event); +} +//! [16] + +//! [19] +void ScribbleArea::resizeImage(QImage *image, const QSize &newSize) +//! [19] //! [20] +{ + if (image->size() == newSize) + return; + + QImage newImage(newSize, QImage::Format_RGB32); + newImage.fill(qRgb(255, 255, 255)); + QPainter painter(&newImage); + painter.drawImage(QPoint(0, 0), *image); + *image = newImage; +} +//! [20] + +//! [21] +void ScribbleArea::print() +{ +#ifndef QT_NO_PRINTER + QPrinter printer(QPrinter::HighResolution); + + QPrintDialog *printDialog = new QPrintDialog(&printer, this); +//! [21] //! [22] + if (printDialog->exec() == QDialog::Accepted) { + QPainter painter(&printer); + QRect rect = painter.viewport(); + QSize size = image.size(); + size.scale(rect.size(), Qt::KeepAspectRatio); + painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); + painter.setWindow(image.rect()); + painter.drawImage(0, 0, image); + } +#endif // QT_NO_PRINTER +} +//! [22] + +bool ScribbleArea::event(QEvent *event) +{ + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + { + QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints(); + foreach (const QTouchEvent::TouchPoint &touchPoint, touchPoints) { + switch (touchPoint.state()) { + case Qt::TouchPointStationary: + // don't do anything if this touch point hasn't moved + continue; + default: + { + QRectF rect = touchPoint.rect(); + if (rect.isEmpty()) { + qreal diameter = qreal(50) * touchPoint.pressure(); + rect.setSize(QSizeF(diameter, diameter)); + } + + QPainter painter(&image); + painter.setPen(Qt::NoPen); + painter.setBrush(myPenColors.at(touchPoint.id() % myPenColors.count())); + painter.drawEllipse(rect); + painter.end(); + + modified = true; + int rad = 2; + update(rect.toRect().adjusted(-rad,-rad, +rad, +rad)); + } + break; + } + } + break; + } + default: + return QWidget::event(event); + } + return true; +} diff --git a/examples/multitouch/fingerpaint/scribblearea.h b/examples/multitouch/fingerpaint/scribblearea.h new file mode 100644 index 0000000..81bcf24 --- /dev/null +++ b/examples/multitouch/fingerpaint/scribblearea.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SCRIBBLEAREA_H +#define SCRIBBLEAREA_H + +#include <QColor> +#include <QImage> +#include <QPoint> +#include <QWidget> + +//! [0] +class ScribbleArea : public QWidget +{ + Q_OBJECT + +public: + ScribbleArea(QWidget *parent = 0); + + bool openImage(const QString &fileName); + bool saveImage(const QString &fileName, const char *fileFormat); + + bool isModified() const { return modified; } + +public slots: + void clearImage(); + void print(); + +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + bool event(QEvent *event); + +private: + void resizeImage(QImage *image, const QSize &newSize); + + bool modified; + QList<QColor> myPenColors; + QImage image; +}; +//! [0] + +#endif diff --git a/examples/multitouch/knobs/knob.cpp b/examples/multitouch/knobs/knob.cpp new file mode 100644 index 0000000..20182e8 --- /dev/null +++ b/examples/multitouch/knobs/knob.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "knob.h" + +#include <QBrush> +#include <QTouchEvent> + +Knob::Knob() + : QGraphicsEllipseItem(-50, -50, 100, 100) +{ + setAcceptTouchEvents(true); + setBrush(Qt::lightGray); + + QGraphicsEllipseItem *leftItem = new QGraphicsEllipseItem(0, 0, 20, 20, this); + leftItem->setPos(-40, -10); + leftItem->setBrush(Qt::darkGreen); + + QGraphicsEllipseItem *rightItem = new QGraphicsEllipseItem(0, 0, 20, 20, this); + rightItem->setPos(20, -10); + rightItem->setBrush(Qt::darkRed); +} + +bool Knob::sceneEvent(QEvent *event) +{ + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + { + QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); + + if (touchEvent->touchPoints().count() == 2) { + const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first(); + const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last(); + + QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos()); + QLineF line2(touchPoint1.scenePos(), touchPoint2.scenePos()); + + rotate(line2.angleTo(line1)); + } + + break; + } + + default: + return QGraphicsItem::sceneEvent(event); + } + + return true; +} diff --git a/examples/multitouch/knobs/knob.h b/examples/multitouch/knobs/knob.h new file mode 100644 index 0000000..37b6aa3 --- /dev/null +++ b/examples/multitouch/knobs/knob.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef KNOB_H +#define KNOB_H + +#include <QGraphicsItem> + +class Knob : public QGraphicsEllipseItem +{ +public: + Knob(); + + bool sceneEvent(QEvent *event); +}; + +#endif // KNOB_H diff --git a/examples/multitouch/knobs/knobs.pro b/examples/multitouch/knobs/knobs.pro new file mode 100644 index 0000000..90f0ba5 --- /dev/null +++ b/examples/multitouch/knobs/knobs.pro @@ -0,0 +1,2 @@ +HEADERS = knob.h +SOURCES = main.cpp knob.cpp diff --git a/examples/multitouch/knobs/main.cpp b/examples/multitouch/knobs/main.cpp new file mode 100644 index 0000000..dbdf32d --- /dev/null +++ b/examples/multitouch/knobs/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QGraphicsView> + +#include "knob.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + QGraphicsView view(&scene); + + Knob *knob1 = new Knob; + knob1->setPos(-110, 0); + Knob *knob2 = new Knob; + + scene.addItem(knob1); + scene.addItem(knob2); + + view.showMaximized(); + view.fitInView(scene.sceneRect().adjusted(-20, -20, 20, 20), Qt::KeepAspectRatio); + + return app.exec(); +} diff --git a/examples/multitouch/multitouch.pro b/examples/multitouch/multitouch.pro new file mode 100644 index 0000000..d5983eb --- /dev/null +++ b/examples/multitouch/multitouch.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = pinchzoom fingerpaint knobs dials diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp new file mode 100644 index 0000000..969f604 --- /dev/null +++ b/examples/multitouch/pinchzoom/graphicsview.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "graphicsview.h" + +#include <QScrollBar> +#include <QTouchEvent> + +GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent) + : QGraphicsView(scene, parent) +{ + viewport()->setAttribute(Qt::WA_AcceptTouchEvents); + setDragMode(ScrollHandDrag); +} + +bool GraphicsView::viewportEvent(QEvent *event) +{ + switch (event->type()) { + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: + { + QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints(); + if (touchPoints.count() == 2) { + // determine scale factor + const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first(); + const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last(); + const qreal scaleFactor = QLineF(touchPoint0.pos(), touchPoint1.pos()).length() + / QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length(); + setTransform(QTransform().scale(scaleFactor, scaleFactor)); + } + return true; + } + default: + break; + } + return QGraphicsView::viewportEvent(event); +} diff --git a/examples/multitouch/pinchzoom/graphicsview.h b/examples/multitouch/pinchzoom/graphicsview.h new file mode 100644 index 0000000..e4ca65d --- /dev/null +++ b/examples/multitouch/pinchzoom/graphicsview.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#pragma once +#include <QGraphicsView> + +class GraphicsView : public QGraphicsView +{ + Q_OBJECT + +public: + GraphicsView(QGraphicsScene *scene = 0, QWidget *parent = 0); + + bool viewportEvent(QEvent *event); +}; diff --git a/examples/multitouch/pinchzoom/images/cheese.jpg b/examples/multitouch/pinchzoom/images/cheese.jpg Binary files differnew file mode 100644 index 0000000..dea5795 --- /dev/null +++ b/examples/multitouch/pinchzoom/images/cheese.jpg diff --git a/examples/multitouch/pinchzoom/main.cpp b/examples/multitouch/pinchzoom/main.cpp new file mode 100644 index 0000000..37c8035 --- /dev/null +++ b/examples/multitouch/pinchzoom/main.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "graphicsview.h" +#include "mouse.h" + +#include <QtGui> + +#include <math.h> + +static const int MouseCount = 7; + +//! [0] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); +//! [0] + +//! [1] + QGraphicsScene scene; + scene.setSceneRect(-300, -300, 600, 600); +//! [1] //! [2] + scene.setItemIndexMethod(QGraphicsScene::NoIndex); +//! [2] + +//! [3] + for (int i = 0; i < MouseCount; ++i) { + Mouse *mouse = new Mouse; + mouse->setPos(::sin((i * 6.28) / MouseCount) * 200, + ::cos((i * 6.28) / MouseCount) * 200); + scene.addItem(mouse); + } +//! [3] + +//! [4] + GraphicsView view(&scene); + view.setRenderHint(QPainter::Antialiasing); + view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); +//! [4] //! [5] + view.setCacheMode(QGraphicsView::CacheBackground); + view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); +//! [5] //! [6] + view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice")); + view.showMaximized(); + + return app.exec(); +} +//! [6] diff --git a/examples/multitouch/pinchzoom/mice.qrc b/examples/multitouch/pinchzoom/mice.qrc new file mode 100644 index 0000000..accdb4d --- /dev/null +++ b/examples/multitouch/pinchzoom/mice.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/" > + <file>images/cheese.jpg</file> + </qresource> +</RCC> diff --git a/examples/multitouch/pinchzoom/mouse.cpp b/examples/multitouch/pinchzoom/mouse.cpp new file mode 100644 index 0000000..32ca3eb --- /dev/null +++ b/examples/multitouch/pinchzoom/mouse.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mouse.h" + +#include <QGraphicsScene> +#include <QPainter> +#include <QStyleOption> + +#include <math.h> + +static const double Pi = 3.14159265358979323846264338327950288419717; +static double TwoPi = 2.0 * Pi; + +static qreal normalizeAngle(qreal angle) +{ + while (angle < 0) + angle += TwoPi; + while (angle > TwoPi) + angle -= TwoPi; + return angle; +} + +//! [0] +Mouse::Mouse() + : angle(0), speed(0), mouseEyeDirection(0), + color(qrand() % 256, qrand() % 256, qrand() % 256) +{ + rotate(qrand() % (360 * 16)); + startTimer(1000 / 33); +} +//! [0] + +//! [1] +QRectF Mouse::boundingRect() const +{ + qreal adjust = 0.5; + return QRectF(-18 - adjust, -22 - adjust, + 36 + adjust, 60 + adjust); +} +//! [1] + +//! [2] +QPainterPath Mouse::shape() const +{ + QPainterPath path; + path.addRect(-10, -20, 20, 40); + return path; +} +//! [2] + +//! [3] +void Mouse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + // Body + painter->setBrush(color); + painter->drawEllipse(-10, -20, 20, 40); + + // Eyes + painter->setBrush(Qt::white); + painter->drawEllipse(-10, -17, 8, 8); + painter->drawEllipse(2, -17, 8, 8); + + // Nose + painter->setBrush(Qt::black); + painter->drawEllipse(QRectF(-2, -22, 4, 4)); + + // Pupils + painter->drawEllipse(QRectF(-8.0 + mouseEyeDirection, -17, 4, 4)); + painter->drawEllipse(QRectF(4.0 + mouseEyeDirection, -17, 4, 4)); + + // Ears + painter->setBrush(scene()->collidingItems(this).isEmpty() ? Qt::darkYellow : Qt::red); + painter->drawEllipse(-17, -12, 16, 16); + painter->drawEllipse(1, -12, 16, 16); + + // Tail + QPainterPath path(QPointF(0, 20)); + path.cubicTo(-5, 22, -5, 22, 0, 25); + path.cubicTo(5, 27, 5, 32, 0, 30); + path.cubicTo(-5, 32, -5, 42, 0, 35); + painter->setBrush(Qt::NoBrush); + painter->drawPath(path); +} +//! [3] + +//! [4] +void Mouse::timerEvent(QTimerEvent *) +{ +//! [4] + // Don't move too far away +//! [5] + QLineF lineToCenter(QPointF(0, 0), mapFromScene(0, 0)); + if (lineToCenter.length() > 150) { + qreal angleToCenter = ::acos(lineToCenter.dx() / lineToCenter.length()); + if (lineToCenter.dy() < 0) + angleToCenter = TwoPi - angleToCenter; + angleToCenter = normalizeAngle((Pi - angleToCenter) + Pi / 2); + + if (angleToCenter < Pi && angleToCenter > Pi / 4) { + // Rotate left + angle += (angle < -Pi / 2) ? 0.25 : -0.25; + } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) { + // Rotate right + angle += (angle < Pi / 2) ? 0.25 : -0.25; + } + } else if (::sin(angle) < 0) { + angle += 0.25; + } else if (::sin(angle) > 0) { + angle -= 0.25; +//! [5] //! [6] + } +//! [6] + + // Try not to crash with any other mice +//! [7] + QList<QGraphicsItem *> dangerMice = scene()->items(QPolygonF() + << mapToScene(0, 0) + << mapToScene(-30, -50) + << mapToScene(30, -50)); + foreach (QGraphicsItem *item, dangerMice) { + if (item == this) + continue; + + QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0)); + qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length()); + if (lineToMouse.dy() < 0) + angleToMouse = TwoPi - angleToMouse; + angleToMouse = normalizeAngle((Pi - angleToMouse) + Pi / 2); + + if (angleToMouse >= 0 && angleToMouse < Pi / 2) { + // Rotate right + angle += 0.5; + } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) { + // Rotate left + angle -= 0.5; +//! [7] //! [8] + } +//! [8] //! [9] + } +//! [9] + + // Add some random movement +//! [10] + if (dangerMice.size() > 1 && (qrand() % 10) == 0) { + if (qrand() % 1) + angle += (qrand() % 100) / 500.0; + else + angle -= (qrand() % 100) / 500.0; + } +//! [10] + +//! [11] + speed += (-50 + qrand() % 100) / 100.0; + + qreal dx = ::sin(angle) * 10; + mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5; + + rotate(dx); + setPos(mapToParent(0, -(3 + sin(speed) * 3))); +} +//! [11] diff --git a/examples/multitouch/pinchzoom/mouse.h b/examples/multitouch/pinchzoom/mouse.h new file mode 100644 index 0000000..5e8e145 --- /dev/null +++ b/examples/multitouch/pinchzoom/mouse.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MOUSE_H +#define MOUSE_H + +#include <QGraphicsItem> +#include <QObject> + +//! [0] +class Mouse : public QObject, public QGraphicsItem +{ + Q_OBJECT + +public: + Mouse(); + + QRectF boundingRect() const; + QPainterPath shape() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + +protected: + void timerEvent(QTimerEvent *event); + +private: + qreal angle; + qreal speed; + qreal mouseEyeDirection; + QColor color; +}; +//! [0] + +#endif diff --git a/examples/multitouch/pinchzoom/pinchzoom.pro b/examples/multitouch/pinchzoom/pinchzoom.pro new file mode 100644 index 0000000..bd87cf7 --- /dev/null +++ b/examples/multitouch/pinchzoom/pinchzoom.pro @@ -0,0 +1,16 @@ +HEADERS += \ + mouse.h \ + graphicsview.h +SOURCES += \ + main.cpp \ + mouse.cpp \ + graphicsview.cpp + +RESOURCES += \ + mice.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/multitouch/pinchzoom +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pinchzoom.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/multitouch/pinchzoom +INSTALLS += target sources diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.pro b/examples/network/blockingfortuneclient/blockingfortuneclient.pro index fa146fa..5840d30 100644 --- a/examples/network/blockingfortuneclient/blockingfortuneclient.pro +++ b/examples/network/blockingfortuneclient/blockingfortuneclient.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/blockingfortuneclient sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS blockingfortuneclient.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/blockingfortuneclient INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/broadcastreceiver/broadcastreceiver.pro b/examples/network/broadcastreceiver/broadcastreceiver.pro index ad04e2c..0778f96 100644 --- a/examples/network/broadcastreceiver/broadcastreceiver.pro +++ b/examples/network/broadcastreceiver/broadcastreceiver.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/broadcastreceiver sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS broadcastreceiver.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/broadcastreceiver INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/broadcastsender/broadcastsender.pro b/examples/network/broadcastsender/broadcastsender.pro index b300a50..6415706 100644 --- a/examples/network/broadcastsender/broadcastsender.pro +++ b/examples/network/broadcastsender/broadcastsender.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/broadcastsender sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS broadcastsender.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/broadcastsender INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/download/download.pro b/examples/network/download/download.pro index 254c356..432998d 100644 --- a/examples/network/download/download.pro +++ b/examples/network/download/download.pro @@ -17,3 +17,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/download sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/network/download INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/downloadmanager/downloadmanager.pro b/examples/network/downloadmanager/downloadmanager.pro index 1b979ca..8d91cf0 100644 --- a/examples/network/downloadmanager/downloadmanager.pro +++ b/examples/network/downloadmanager/downloadmanager.pro @@ -18,3 +18,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/downloadmanager sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/network/downloadmanager INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp index 86e31ff..b850a57 100644 --- a/examples/network/fortuneclient/client.cpp +++ b/examples/network/fortuneclient/client.cpp @@ -44,6 +44,10 @@ #include "client.h" +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif + //! [0] Client::Client(QWidget *parent) : QDialog(parent) @@ -102,6 +106,10 @@ Client::Client(QWidget *parent) setWindowTitle(tr("Fortune Client")); portLineEdit->setFocus(); + +#ifdef Q_OS_SYMBIAN + isDefaultIapSet = false; +#endif //! [5] } //! [5] @@ -110,6 +118,12 @@ Client::Client(QWidget *parent) void Client::requestNewFortune() { getFortuneButton->setEnabled(false); +#ifdef Q_OS_SYMBIAN + if(!isDefaultIapSet) { + qt_SetDefaultIap(); + isDefaultIapSet = true; + } +#endif blockSize = 0; tcpSocket->abort(); //! [7] diff --git a/examples/network/fortuneclient/client.h b/examples/network/fortuneclient/client.h index 52d2c26..5375322 100644 --- a/examples/network/fortuneclient/client.h +++ b/examples/network/fortuneclient/client.h @@ -80,6 +80,9 @@ private: QTcpSocket *tcpSocket; QString currentFortune; quint16 blockSize; +#ifdef Q_OS_SYMBIAN + bool isDefaultIapSet; +#endif }; //! [0] diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro index 1c7b0a8..d7ad9d5 100644 --- a/examples/network/fortuneclient/fortuneclient.pro +++ b/examples/network/fortuneclient/fortuneclient.pro @@ -8,3 +8,11 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/fortuneclient sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fortuneclient.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/fortuneclient INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock + TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/examples/network/fortuneclient/main.cpp b/examples/network/fortuneclient/main.cpp index afb5249..08752a4 100644 --- a/examples/network/fortuneclient/main.cpp +++ b/examples/network/fortuneclient/main.cpp @@ -40,13 +40,17 @@ ****************************************************************************/ #include <QApplication> - #include "client.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Client client; +#ifdef Q_OS_SYMBIAN + // Make application better looking and more usable on small screen + client.showMaximized(); +#else client.show(); +#endif return client.exec(); } diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro index e98385a..0a132a5 100644 --- a/examples/network/fortuneserver/fortuneserver.pro +++ b/examples/network/fortuneserver/fortuneserver.pro @@ -8,3 +8,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/fortuneserver sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fortuneserver.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/fortuneserver INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock + TARGET.UID3 = 0xA000CF71 + TARGET.CAPABILITY = "All -TCB" + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/examples/network/fortuneserver/main.cpp b/examples/network/fortuneserver/main.cpp index 32fd640..9097c7d 100644 --- a/examples/network/fortuneserver/main.cpp +++ b/examples/network/fortuneserver/main.cpp @@ -46,11 +46,22 @@ #include "server.h" +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif + int main(int argc, char *argv[]) { +#ifdef Q_OS_SYMBIAN + qt_SetDefaultIap(); +#endif QApplication app(argc, argv); Server server; +#ifdef Q_OS_SYMBIAN + server.showMaximized(); +#else server.show(); +#endif qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); return server.exec(); } diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index cb47dd8..7564199 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -63,10 +63,15 @@ Server::Server(QWidget *parent) return; } //! [0] + QList<QHostAddress> ipAddresseList = QNetworkInterface::allAddresses(); + QString ipAddresses; + for (int i = 0; i < ipAddresseList.size(); ++i) { + ipAddresses.append(ipAddresseList.at(i).toString()).append("\n"); + } - statusLabel->setText(tr("The server is running on port %1.\n" + statusLabel->setText(tr("The server is running on \n IP: \n%1 PORT: \n%2\n" "Run the Fortune Client example now.") - .arg(tcpServer->serverPort())); + .arg(ipAddresses).arg(tcpServer->serverPort())); //! [1] //! [2] diff --git a/examples/network/ftp/ftp.pro b/examples/network/ftp/ftp.pro index cabc003..73eb716 100644 --- a/examples/network/ftp/ftp.pro +++ b/examples/network/ftp/ftp.pro @@ -9,3 +9,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/ftp sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS ftp.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/network/ftp INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + HEADERS += sym_iap_util.h + INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + TARGET.CAPABILITY="NetworkServices ReadUserData WriteUserData" + TARGET.UID3 = 0xA000A648 + LIBS+=-lesock -lcommdb -linsock # For IAP selection +} diff --git a/examples/network/ftp/ftpwindow.cpp b/examples/network/ftp/ftpwindow.cpp index 38c47aa..422d9f0 100644 --- a/examples/network/ftp/ftpwindow.cpp +++ b/examples/network/ftp/ftpwindow.cpp @@ -44,6 +44,10 @@ #include "ftpwindow.h" +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif + FtpWindow::FtpWindow(QWidget *parent) : QDialog(parent), ftp(0) { @@ -52,6 +56,10 @@ FtpWindow::FtpWindow(QWidget *parent) ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); +#ifdef Q_OS_SYMBIAN + // Use word wrapping to fit the text on screen + statusLabel->setWordWrap( true ); +#endif fileList = new QTreeWidget; fileList->setEnabled(false); @@ -61,7 +69,7 @@ FtpWindow::FtpWindow(QWidget *parent) connectButton = new QPushButton(tr("Connect")); connectButton->setDefault(true); - + cdToParentButton = new QPushButton; cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); @@ -90,16 +98,31 @@ FtpWindow::FtpWindow(QWidget *parent) QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); +#ifndef Q_OS_SYMBIAN topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); - +#else + // Make app better lookin on small screen + QHBoxLayout *topLayout2 = new QHBoxLayout; + topLayout2->addWidget(cdToParentButton); + topLayout2->addWidget(connectButton); +#endif + QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); +#ifdef Q_OS_SYMBIAN + // Make app better lookin on small screen + mainLayout->addLayout(topLayout2); +#endif mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); mainLayout->addWidget(buttonBox); setLayout(mainLayout); +#ifdef Q_OS_SYMBIAN + bDefaultIapSet = false; +#endif + setWindowTitle(tr("FTP")); } @@ -111,6 +134,12 @@ QSize FtpWindow::sizeHint() const //![0] void FtpWindow::connectOrDisconnect() { +#ifdef Q_OS_SYMBIAN + if(!bDefaultIapSet) { + qt_SetDefaultIap(); + bDefaultIapSet = true; + } +#endif if (ftp) { ftp->abort(); ftp->deleteLater(); @@ -124,6 +153,7 @@ void FtpWindow::connectOrDisconnect() #ifndef QT_NO_CURSOR setCursor(Qt::ArrowCursor); #endif + statusLabel->setText(tr("Please enter the name of an FTP server.")); return; } @@ -131,7 +161,7 @@ void FtpWindow::connectOrDisconnect() setCursor(Qt::WaitCursor); #endif -//![1] +//![1] ftp = new QFtp(this); connect(ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(ftpCommandFinished(int, bool))); diff --git a/examples/network/ftp/ftpwindow.h b/examples/network/ftp/ftpwindow.h index 6ef3d9a..4fce778 100644 --- a/examples/network/ftp/ftpwindow.h +++ b/examples/network/ftp/ftpwindow.h @@ -98,6 +98,10 @@ private: QString currentPath; QFtp *ftp; QFile *file; + +#ifdef Q_OS_SYMBIAN + bool bDefaultIapSet; +#endif //![1] }; diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index e96a8ab..645492b 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -40,15 +40,28 @@ ****************************************************************************/ #include <QApplication> - #include "ftpwindow.h" +#ifdef Q_OS_SYMBIAN +#include <QDir> +#include <QDesktopWidget> +#endif + int main(int argc, char *argv[]) { Q_INIT_RESOURCE(ftp); - +#ifdef Q_OS_SYMBIAN + // Change current directory from default private to c:\data + // in order that user can access the downloaded content + QDir::setCurrent( "c:\\data" ); +#endif QApplication app(argc, argv); FtpWindow ftpWin; +#ifdef Q_OS_SYMBIAN + // Make application better looking and more usable on small screen + ftpWin.showMaximized(); +#else ftpWin.show(); +#endif return ftpWin.exec(); } diff --git a/examples/network/ftp/sym_iap_util.h b/examples/network/ftp/sym_iap_util.h new file mode 100644 index 0000000..6c43738 --- /dev/null +++ b/examples/network/ftp/sym_iap_util.h @@ -0,0 +1,510 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QSYM_IAP_UTIL_H +#define QSYM_IAP_UTIL_H + +// Symbian +#include <utf.h> +#include <es_sock.h> +#include <in_sock.h> +#include <es_enum.h> +#include <in_iface.h> +#include <commdbconnpref.h> +#include <e32cmn.h> + +// OpenC +#include <sys/socket.h> +#include <net/if.h> + +//Qt +#include <QSettings> +#include <QStringList> +//#include <QTextCodec> + +_LIT(KIapNameSetting, "IAP\\Name"); // text - mandatory +_LIT(KIapDialogPref, "IAP\\DialogPref"); // TUnit32 - optional +_LIT(KIapService, "IAP\\IAPService"); // TUnit32 - mandatory +_LIT(KIapServiceType, "IAP\\IAPServiceType"); // text - mandatory +_LIT(KIapBearer, "IAP\\IAPBearer"); // TUint32 - optional +_LIT(KIapBearerType, "IAP\\IAPBearerType"); // text - optional +_LIT(KIapNetwork, "IAP\\IAPNetwork"); // TUint32 - optional + +const QLatin1String qtOrganizationTag("Trolltech"); +const QLatin1String qtNetworkModuleTag("QtNetwork"); +const QLatin1String iapGroupTag("IAP"); +const QLatin1String iapNamesArrayTag("Names"); +const QLatin1String iapNameItemTag("Name"); + +static QTextCodec *utf16LETextCodec = 0; + +void clearIapNamesSettings(QSettings &settings) { + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + settings.remove(iapNamesArrayTag); + settings.endGroup(); + settings.endGroup(); +} + +void writeIapNamesSettings(QSettings &settings, const QStringList& iapNames) { + clearIapNamesSettings(settings); + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + settings.beginWriteArray(iapNamesArrayTag); + for (int index = 0; index < iapNames.size(); ++index) { + settings.setArrayIndex(index); + settings.setValue(iapNameItemTag, iapNames.at(index)); + } + settings.endArray(); + settings.endGroup(); + settings.endGroup(); +} + +void readIapNamesSettings(QSettings &settings, QStringList& iapNames) { + settings.beginGroup(qtNetworkModuleTag); + settings.beginGroup(iapGroupTag); + int last = settings.beginReadArray(iapNamesArrayTag); + for (int index = 0; index < last; ++index) { + settings.setArrayIndex(index); + iapNames.append(settings.value(iapNameItemTag).toString()); + } + settings.endArray(); + settings.endGroup(); + settings.endGroup(); +} + +static QString qt_TNameToQString(TName data) { + if(utf16LETextCodec == 0) + utf16LETextCodec = QTextCodec::codecForName("UTF-16LE"); + + QByteArray tmpByteArray = QByteArray::fromRawData((char*)(data.PtrZ()), data.Length() * 2); + return utf16LETextCodec->toUnicode(tmpByteArray); +} + +static QString qt_InterfaceInfoL() +{ + QString output; + + TBuf8<512> buffer; + TBuf<128> t; + TAutoClose<RSocketServ> ss; + User::LeaveIfError(ss.iObj.Connect()); + ss.PushL(); + + TAutoClose<RSocket> sock; + User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); + sock.PushL(); + + User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl)); + + TProtocolDesc in; + User::LeaveIfError(sock.iObj.Info(in)); + printf("EPOC32 IP Configuration TCPIP Version %d.%d.%d\n", in.iVersion.iMajor, in.iVersion.iMinor, in.iVersion.iBuild); + + TPckgBuf<TSoInetInterfaceInfo> info, next; + + TInt res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info); + if(res!=KErrNone) + User::Leave(res); + TInt count = 0; + while(res==KErrNone) { + res=sock.iObj.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, next); + + if(info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) { + printf("Interface %d\n", count++); + + printf("Name \"%s\"\n", qt_TNameToQString(info().iName).toLatin1().data()); + printf("NIF tag \"%s\"\n", qt_TNameToQString(info().iTag).toLatin1().data()); + + printf("State "); + switch (info().iState) + { + case EIfPending: + printf("pending\n"); + break; + case EIfUp: + printf("up\n"); + break; + case EIfBusy: + printf("busy\n"); + break; + default: + printf("down\n"); + break; + } + + printf("Mtu %d\n", info().iMtu); + printf("Speed Metric %d\n", info().iSpeedMetric); + + printf("Features:"); + info().iFeatures & KIfIsLoopback ? printf(" loopback") : printf(""); + info().iFeatures & KIfIsDialup ? printf(" dialup") : printf(""); + info().iFeatures & KIfIsPointToPoint ? printf(" pointtopoint") : printf(""); + info().iFeatures & KIfCanBroadcast ? printf(" canbroadcast") : printf(""); + info().iFeatures & KIfCanMulticast ? printf(" canmulticast") : printf(""); + info().iFeatures & KIfCanSetMTU ? printf(" cansetmtu") : printf(""); + info().iFeatures & KIfHasHardwareAddr ? printf(" hardwareaddr") : printf(""); + info().iFeatures & KIfCanSetHardwareAddr ? printf(" cansethardwareaddr") : printf(""); + printf("\n"); + + TName address; + info().iAddress.Output(address); + printf("Addr: %s\n", qt_TNameToQString(address).toLatin1().data()); + + if(info().iAddress.IsLinkLocal()) { + printf(" -link local\n"); + } else if(info().iAddress.IsSiteLocal()) { + printf(" -site local\n"); + } else { + printf(" -global\n"); + } + + info().iNetMask.Output(address); + printf("Netmask %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iBrdAddr.Output(address); + printf("Broadcast address %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iDefGate.Output(address); + printf("Gatew: %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iNameSer1.Output(address); + printf("DNS 1: %s\n", qt_TNameToQString(address).toLatin1().data()); + + info().iNameSer2.Output(address); + printf("DNS 2: %s\n", qt_TNameToQString(address).toLatin1().data()); + + if (info().iHwAddr.Family() != KAFUnspec) { + printf("Hardware address "); + TUint j; + for(j = sizeof(SSockAddr) ; j < sizeof(SSockAddr) + 6 ; ++j) { + if(j < (TUint)info().iHwAddr.Length()) { + printf("%02X", info().iHwAddr[j]); + } else { + printf("??"); + } + if(j < sizeof(SSockAddr) + 5) + printf("-"); + else + printf("\n"); + } + } + } + if(res == KErrNone) { + info = next; + printf("\n"); + } else { + printf("\n"); + } + } + + sock.Pop(); + ss.Pop(); + + return output; +} + +static QString qt_RouteInfoL() { + QString output; + TAutoClose<RSocketServ> ss; + User::LeaveIfError(ss.iObj.Connect()); + ss.PushL(); + + TAutoClose<RSocket> sock; + User::LeaveIfError(sock.iObj.Open(ss.iObj, _L("udp"))); + sock.PushL(); + + TSoInetRouteInfo routeInfo; + TPckg<TSoInetRouteInfo> routeInfoPkg(routeInfo); + + TName destAddr; + TName netMask; + TName gateway; + TName ifAddr; + + // Begins enumeration of routes by setting this option + User::LeaveIfError(sock.iObj.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl)); + + // The TSoInetRouteInfo contains information for a new route each time GetOpt returns KErrNone + for(TInt i = 0; sock.iObj.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone ; i++) + { + // Extract the destination and netmask + routeInfo.iDstAddr.Output(destAddr); + routeInfo.iNetMask.Output(netMask); + routeInfo.iGateway.Output(gateway); + routeInfo.iIfAddr.Output(ifAddr); +/* + if(destAddr.Length() <= 2) + continue; + + if(netMask.Find(_L("255.255.255.255")) != KErrNotFound + || netMask.Find(_L("0.0.0.0")) != KErrNotFound + || netMask.Find(_L("ffff:ffff:ffff:ffff")) != KErrNotFound) + continue; +*/ + printf("Route Info #[%i]\n", i); + printf("DstAddr %s\n", qt_TNameToQString(destAddr).toLatin1().data()); + printf("NetMask %s\n", qt_TNameToQString(netMask).toLatin1().data()); + printf("Gateway %s\n", qt_TNameToQString(gateway).toLatin1().data()); + printf("IfAddr %s\n", qt_TNameToQString(ifAddr).toLatin1().data()); + printf("\n"); + } + + sock.Pop(); + ss.Pop(); + + return output; +} + +QString qt_TDesC2QStringL(const TDesC& aDescriptor) +{ +#ifdef QT_NO_UNICODE + return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); +#else + return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); +#endif +} + +static bool qt_SetDefaultIapName(const QString &iapName, int &error) { + struct ifreq ifReq; + // clear structure + memset(&ifReq, 0, sizeof(struct ifreq)); + // set IAP name value + // make sure it is in UTF8 + strcpy(ifReq.ifr_name, iapName.toUtf8().data()); + + if(setdefaultif(&ifReq) == 0) { + // OK + error = 0; + return true; + } else { + error = errno; + return false; + } + +} +static bool qt_SetDefaultSnapId(const int snapId, int &error) { + struct ifreq ifReq; + // clear structure + memset(&ifReq, 0, sizeof(struct ifreq)); + // set SNAP ID value + ifReq.ifr_ifru.snap_id = snapId; + + if(setdefaultif(&ifReq) == 0) { + // OK + error = 0; + return true; + } else { + error = errno; + return false; + } + +} + +static void qt_SaveIapName(QSettings& settings, QStringList& iapNames, QString& iapNameValue) { + if(iapNames.contains(iapNameValue) && iapNames.first() == iapNameValue) { + // no need to update + } else { + if(iapNameValue != QString("Easy WLAN")) { + // new selection alway on top + iapNames.removeAll(iapNameValue); + iapNames.prepend(iapNameValue); + writeIapNamesSettings(settings, iapNames); + } else { + // Unbeliveable ... if IAP dodn't exist before + // no matter what you choose from IAP selection list + // you will get "Easy WLAN" as IAP name value + + // somehow commsdb is not in sync + } + } +} + +static QString qt_OfferIapDialog() { + TBuf8<256> iapName; + + RSocketServ socketServ; + CleanupClosePushL(socketServ); + + RConnection connection; + CleanupClosePushL(connection); + + socketServ.Connect(); + connection.Open(socketServ); + connection.Start(); + + connection.GetDesSetting(TPtrC(KIapNameSetting), iapName); + + //connection.Stop(); + + iapName.ZeroTerminate(); + QString strIapName((char*)iapName.Ptr()); + + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } + + CleanupStack::PopAndDestroy(&connection); + CleanupStack::PopAndDestroy(&socketServ); + + return strIapName; +} + +static QString qt_CheckForActiveConnection() { + TUint count; + + RSocketServ serv; + CleanupClosePushL(serv); + + RConnection conn; + CleanupClosePushL(conn); + + serv.Connect(); + conn.Open(serv); + + TConnectionInfoBuf connInfo; + + TBuf8<256> iapName; + TBuf8<256> iapServiceType; + + QString strIapName; + + if (conn.EnumerateConnections(count) == KErrNone) { + if(count > 0) { + for (TUint i = 1; i <= count; i++) { + if (conn.GetConnectionInfo(i, connInfo) == KErrNone) { + RConnection tempConn; + CleanupClosePushL(tempConn); + tempConn.Open(serv); + if (tempConn.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { + tempConn.GetDesSetting(TPtrC(KIapNameSetting), iapName); + tempConn.GetDesSetting(TPtrC(KIapServiceType), iapServiceType); + //tempConn.Stop(); + iapName.ZeroTerminate(); + iapServiceType.ZeroTerminate(); + +// if(iapServiceType.Find(_L8("LANService")) != KErrNotFound) { +// activeLanConnectionFound = ETrue; +// break; +// } + strIapName = QString((char*)iapName.Ptr()); + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } + + CleanupStack::PopAndDestroy(&tempConn); + break; + } + } + } + } + } + + //conn.Stop(); + + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); + + return strIapName; +} + +static QString qt_CheckSettingsForConnection(QStringList& iapNames) { + QString strIapName; + for(int index = 0; index < iapNames.size(); ++index) { + strIapName = iapNames.at(index); + int error = 0; + if(!qt_SetDefaultIapName(strIapName, error)) { + //printf("failed setdefaultif @ %i with %s and errno = %d \n", __LINE__, strIapName.toUtf8().data(), error); + strIapName = QString(""); + } else { + return strIapName; + } + } + return strIapName; +} + +static void qt_SetDefaultIapL() +{ + // settings @ /c/data/.config/Trolltech.com + QSettings settings(QSettings::UserScope, qtOrganizationTag); + // populate iap name list + QStringList iapNames; + readIapNamesSettings(settings, iapNames); + + QString iapNameValue; + + iapNameValue = qt_CheckForActiveConnection(); + + if(!iapNameValue.isEmpty()) { + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + } + + iapNameValue = qt_CheckSettingsForConnection(iapNames); + + if(!iapNameValue.isEmpty()) { + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + } + + /* + * no active LAN connections yet + * no IAP in settings + * offer IAP dialog to user + */ + iapNameValue = qt_OfferIapDialog(); + qt_SaveIapName(settings, iapNames, iapNameValue); + return; + +} + +static int qt_SetDefaultIap() +{ + TRAPD(err1, qt_SetDefaultIapL()); +// TRAPD(err2, qt_InterfaceInfoL()); +// TRAPD(err3, qt_RouteInfoL()); + return err1; +} + +#endif // QSYM_IAP_UTIL_H diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp index 74b2444..ba62093 100644 --- a/examples/network/googlesuggest/googlesuggest.cpp +++ b/examples/network/googlesuggest/googlesuggest.cpp @@ -134,7 +134,6 @@ bool GSuggestCompletion::eventFilter(QObject *obj, QEvent *ev) void GSuggestCompletion::showCompletion(const QStringList &choices, const QStringList &hits) { - if (choices.isEmpty() || choices.count() != hits.count()) return; @@ -204,16 +203,16 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) QXmlStreamReader xml(response); while (!xml.atEnd()) { xml.readNext(); - if (xml.tokenType() == QXmlStreamReader::StartElement) + if (xml.isStartElement()) { if (xml.name() == "suggestion") { QStringRef str = xml.attributes().value("data"); choices << str.toString(); } - if (xml.tokenType() == QXmlStreamReader::StartElement) - if (xml.name() == "num_queries") { + else if (xml.name() == "num_queries") { QStringRef str = xml.attributes().value("int"); hits << str.toString(); } + } } showCompletion(choices, hits); diff --git a/examples/network/http/http.pro b/examples/network/http/http.pro index 7f58d9f..2b702ea 100644 --- a/examples/network/http/http.pro +++ b/examples/network/http/http.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/http sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS http.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/http INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp index e2b5905..6a25149 100644 --- a/examples/network/http/main.cpp +++ b/examples/network/http/main.cpp @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager."); HttpWindow httpWin; httpWin.show(); return httpWin.exec(); diff --git a/examples/network/loopback/loopback.pro b/examples/network/loopback/loopback.pro index 88b7a8b..cf6a0f3 100644 --- a/examples/network/loopback/loopback.pro +++ b/examples/network/loopback/loopback.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/loopback sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loopback.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/loopback INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index 600c601..fa8a3b0 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -54,6 +54,10 @@ ChatDialog::ChatDialog(QWidget *parent) listWidget->setFocusPolicy(Qt::NoFocus); connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); +#ifdef Q_OS_SYMBIAN + connect(sendButton, SIGNAL(clicked()), this, SLOT(returnPressed())); +#endif + connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(&client, SIGNAL(newMessage(const QString &, const QString &)), this, SLOT(appendMessage(const QString &, const QString &))); connect(&client, SIGNAL(newParticipant(const QString &)), diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index 1a64af3..e8b4637 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -42,11 +42,22 @@ #include <QApplication> #include "chatdialog.h" +#ifdef Q_OS_SYMBIAN +#include "sym_iap_util.h" +#endif int main(int argc, char *argv[]) { +#ifdef Q_OS_SYMBIAN + qt_SetDefaultIap(); +#endif QApplication app(argc, argv); ChatDialog dialog; +#ifdef Q_OS_SYMBIAN + // Make application better looking and more usable on small screen + dialog.showMaximized(); +#else dialog.show(); +#endif return app.exec(); } diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro index 5d5efea..99e82ae 100644 --- a/examples/network/network-chat/network-chat.pro +++ b/examples/network/network-chat/network-chat.pro @@ -17,3 +17,11 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/network-chat sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS network-chat.pro *.chat sources.path = $$[QT_INSTALL_EXAMPLES]/network/network-chat INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + HEADERS += $$QT_SOURCE_TREE/examples/network/ftp/sym_iap_util.h + LIBS += -lesock -lconnmon -lcharconv -linsock + TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp index 16d9eb1..50224f7 100644 --- a/examples/network/network-chat/peermanager.cpp +++ b/examples/network/network-chat/peermanager.cpp @@ -70,7 +70,11 @@ PeerManager::PeerManager(Client *client) } if (username.isEmpty()) +#ifndef Q_OS_SYMBIAN username = "unknown"; +#else + username = "QtS60"; +#endif updateAddresses(); serverPort = 0; @@ -160,8 +164,7 @@ void PeerManager::updateAddresses() foreach (QNetworkInterface interface, QNetworkInterface::allInterfaces()) { foreach (QNetworkAddressEntry entry, interface.addressEntries()) { QHostAddress broadcastAddress = entry.broadcast(); - if (broadcastAddress != QHostAddress::Null && - entry.ip() != QHostAddress::LocalHost) { + if (broadcastAddress != QHostAddress::Null && entry.ip() != QHostAddress::LocalHost) { broadcastAddresses << broadcastAddress; ipAddresses << entry.ip(); } diff --git a/examples/network/network.pro b/examples/network/network.pro index 8c45745..38cdae8 100644 --- a/examples/network/network.pro +++ b/examples/network/network.pro @@ -1,10 +1,9 @@ TEMPLATE = subdirs SUBDIRS = blockingfortuneclient \ - broadcastreceiver \ + broadcastreceiver \ broadcastsender \ - network-chat \ - download \ - downloadmanager \ + download \ + downloadmanager \ fortuneclient \ fortuneserver \ ftp \ @@ -12,7 +11,12 @@ SUBDIRS = blockingfortuneclient \ loopback \ threadedfortuneserver \ googlesuggest \ - torrent + torrent + +# no QProcess +!vxworks:!qnx:SUBDIRS += network-chat + +symbian: SUBDIRS = ftp contains(QT_CONFIG, openssl):SUBDIRS += securesocketclient @@ -20,3 +24,5 @@ contains(QT_CONFIG, openssl):SUBDIRS += securesocketclient sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS network.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/network INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/securesocketclient/securesocketclient.pro b/examples/network/securesocketclient/securesocketclient.pro index 4d70a71..48c8e0d 100644 --- a/examples/network/securesocketclient/securesocketclient.pro +++ b/examples/network/securesocketclient/securesocketclient.pro @@ -14,3 +14,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/securesocketclient sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png *.jpg images sources.path = $$[QT_INSTALL_EXAMPLES]/network/securesocketclient INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF67 +} diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp index fe38d8f..f83886b 100644 --- a/examples/network/securesocketclient/sslclient.cpp +++ b/examples/network/securesocketclient/sslclient.cpp @@ -145,7 +145,9 @@ void SslClient::socketEncrypted() if (!padLock) { padLock = new QToolButton; padLock->setIcon(QIcon(":/encrypted.png")); +#ifndef QT_NO_CURSOR padLock->setCursor(Qt::ArrowCursor); +#endif padLock->setToolTip(tr("Display encryption details.")); int extent = form->hostNameEdit->height() - 2; diff --git a/examples/network/threadedfortuneserver/threadedfortuneserver.pro b/examples/network/threadedfortuneserver/threadedfortuneserver.pro index 0867dac..7853d57 100644 --- a/examples/network/threadedfortuneserver/threadedfortuneserver.pro +++ b/examples/network/threadedfortuneserver/threadedfortuneserver.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/network/threadedfortuneserver sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS threadedfortuneserver.pro sources.path = $$[QT_INSTALL_EXAMPLES]/network/threadedfortuneserver INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/network/torrent/main.cpp b/examples/network/torrent/main.cpp index d4665a6..49d52d6 100644 --- a/examples/network/torrent/main.cpp +++ b/examples/network/torrent/main.cpp @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager."); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); Q_INIT_RESOURCE(icons); diff --git a/examples/network/torrent/torrent.pro b/examples/network/torrent/torrent.pro index 10b2672..7665455 100644 --- a/examples/network/torrent/torrent.pro +++ b/examples/network/torrent/torrent.pro @@ -35,3 +35,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES torrent.pro *.torrent sources.files += icons forms 3rdparty sources.path = $$[QT_INSTALL_EXAMPLES]/network/torrent INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/2dpainting/2dpainting.pro b/examples/opengl/2dpainting/2dpainting.pro index c45b764..80c865c 100644 --- a/examples/opengl/2dpainting/2dpainting.pro +++ b/examples/opengl/2dpainting/2dpainting.pro @@ -15,3 +15,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/2dpainting sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS 2dpainting.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/2dpainting INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/framebufferobject/bubbles.svg b/examples/opengl/framebufferobject/bubbles.svg index 65867da..5173012 100644 --- a/examples/opengl/framebufferobject/bubbles.svg +++ b/examples/opengl/framebufferobject/bubbles.svg @@ -72,7 +72,7 @@ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="100" fx="-50" fy="50"> <stop offset="0%" stop-color="black" stop-opacity="1.0" /> - <stop offset="100%" stop-color="white" stop-opacity="0.0" /> + <stop offset="100%" stop-color="black" stop-opacity="0.0" /> </radialGradient> <!-- Define a shadow for each sphere. --> @@ -91,56 +91,56 @@ <g transform="translate(200,700)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(315,700)"> <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(80,700)"> <g transform="scale(0.65,0.65)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(255,700)"> <g transform="scale(0.3,0.3)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(565,700)"> <g transform="scale(0.4,0.4)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(715,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(645,700)"> <g transform="scale(0.375,0.375)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(555,700)"> <g transform="scale(0.9,0.9)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -148,28 +148,28 @@ <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(215,700)"> <g transform="scale(0.45,0.45)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(420,700)"> <g transform="scale(0.75,0.75)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(815,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -186,7 +186,7 @@ <circle fill="#a6ce39" cx="0" cy="0" r="33" /> <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10 L -11,22 L -1,12 Z" /> - <animateTransform attributeName="transform" type="rotate" values="0; 360" + <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360" begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(200,375)"> diff --git a/examples/opengl/framebufferobject/framebufferobject.pro b/examples/opengl/framebufferobject/framebufferobject.pro index 4bc667c..f9ee7e7 100644 --- a/examples/opengl/framebufferobject/framebufferobject.pro +++ b/examples/opengl/framebufferobject/framebufferobject.pro @@ -20,3 +20,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.png *.svg sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/framebufferobject INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/opengl/framebufferobject/glwidget.cpp b/examples/opengl/framebufferobject/glwidget.cpp index ea16a28..c1f852f 100644 --- a/examples/opengl/framebufferobject/glwidget.cpp +++ b/examples/opengl/framebufferobject/glwidget.cpp @@ -53,7 +53,19 @@ GLWidget::GLWidget(QWidget *parent) { setWindowTitle(tr("OpenGL framebuffer objects")); makeCurrent(); - fbo = new QGLFramebufferObject(1024, 1024); + + if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) { + QGLFramebufferObjectFormat format; + format.setSamples(4); + format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + + render_fbo = new QGLFramebufferObject(512, 512, format); + texture_fbo = new QGLFramebufferObject(512, 512); + } else { + render_fbo = new QGLFramebufferObject(1024, 1024); + texture_fbo = render_fbo; + } + rot_x = rot_y = rot_z = 0.0f; scale = 0.1f; anim = new QTimeLine(750, this); @@ -113,7 +125,9 @@ GLWidget::~GLWidget() { delete[] wave; glDeleteLists(tile_list, 1); - delete fbo; + delete texture_fbo; + if (render_fbo != texture_fbo) + delete render_fbo; } void GLWidget::paintEvent(QPaintEvent *) @@ -129,10 +143,16 @@ void GLWidget::draw() saveGLState(); // render the 'bubbles.svg' file into our framebuffer object - QPainter fbo_painter(fbo); + QPainter fbo_painter(render_fbo); svg_renderer->render(&fbo_painter); fbo_painter.end(); + if (render_fbo != texture_fbo) { + QRect rect(0, 0, render_fbo->width(), render_fbo->height()); + QGLFramebufferObject::blitFramebuffer(texture_fbo, rect, + render_fbo, rect); + } + // draw into the GL widget glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); @@ -145,8 +165,9 @@ void GLWidget::draw() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, fbo->texture()); + glBindTexture(GL_TEXTURE_2D, texture_fbo->texture()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glEnable(GL_TEXTURE_2D); glEnable(GL_MULTISAMPLE); glEnable(GL_CULL_FACE); diff --git a/examples/opengl/framebufferobject/glwidget.h b/examples/opengl/framebufferobject/glwidget.h index 478ff7f..00a07e1 100644 --- a/examples/opengl/framebufferobject/glwidget.h +++ b/examples/opengl/framebufferobject/glwidget.h @@ -77,6 +77,7 @@ private: QImage logo; QTimeLine *anim; QSvgRenderer *svg_renderer; - QGLFramebufferObject *fbo; + QGLFramebufferObject *render_fbo; + QGLFramebufferObject *texture_fbo; }; diff --git a/examples/opengl/framebufferobject2/framebufferobject2.pro b/examples/opengl/framebufferobject2/framebufferobject2.pro index 9f1644c..094ad80 100644 --- a/examples/opengl/framebufferobject2/framebufferobject2.pro +++ b/examples/opengl/framebufferobject2/framebufferobject2.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/framebufferobject2 sources.files = $$SOURCES $$HEADERS $$RESOURCES framebufferobject2.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/framebufferobject2 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/framebufferobject2/glwidget.cpp b/examples/opengl/framebufferobject2/glwidget.cpp index b98608c..aeaf8f9 100644 --- a/examples/opengl/framebufferobject2/glwidget.cpp +++ b/examples/opengl/framebufferobject2/glwidget.cpp @@ -208,7 +208,7 @@ void GLWidget::paintGL() for (int y = 0; y < 5; ++y) { for (int x = 0; x < 5; ++x) { glTranslatef(2.0f, 0, 0); - glColor4f(0.8, 0.8, 0.8, 1.0); + glColor4f(0.8f, 0.8f, 0.8f, 1.0f); glDrawArrays(GL_QUADS, 0, 4); } glTranslatef(-10.0f, 2.0f, 0); diff --git a/examples/opengl/grabber/grabber.pro b/examples/opengl/grabber/grabber.pro index 15eaf02..daa32b3 100644 --- a/examples/opengl/grabber/grabber.pro +++ b/examples/opengl/grabber/grabber.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/grabber sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grabber.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/grabber INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/grabber/mainwindow.cpp b/examples/opengl/grabber/mainwindow.cpp index e1307bd..eaeb490 100644 --- a/examples/opengl/grabber/mainwindow.cpp +++ b/examples/opengl/grabber/mainwindow.cpp @@ -136,7 +136,7 @@ void MainWindow::createActions() connect(clearPixmapAct, SIGNAL(triggered()), this, SLOT(clearPixmap())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/opengl/hellogl/hellogl.pro b/examples/opengl/hellogl/hellogl.pro index ce9c8e8..6d57c19 100644 --- a/examples/opengl/hellogl/hellogl.pro +++ b/examples/opengl/hellogl/hellogl.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS hellogl.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/hellogl INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index 3cc1dda..849131f 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -41,6 +41,7 @@ #include "glwidget.h" #include <QPainter> +#include <QPaintEngine> #include <math.h> #include "bubble.h" @@ -48,124 +49,10 @@ const int bubbleNum = 8; -inline void CrossProduct(qreal &xOut, qreal &yOut, qreal &zOut, qreal x1, qreal y1, qreal z1, qreal x2, qreal y2, qreal z2) -{ - xOut = y1 * z2 - z1 * y2; - yOut = z1 * x2 - x1 * z2; - zOut = x1 * y2 - y1 * x2; -} - -inline void Normalize(qreal &x, qreal &y, qreal &z) -{ - qreal l = sqrt(x*x + y*y + z*z); - x = x / l; - y = y / l; - z = z / l; -} - -inline void IdentityMatrix(GLfloat *m) -{ - m[0 * 4 + 0] = 1.0f; - m[1 * 4 + 0] = 0.0f; - m[2 * 4 + 0] = 0.0f; - m[3 * 4 + 0] = 0.0f; - m[0 * 4 + 1] = 0.0f; - m[1 * 4 + 1] = 1.0f; - m[2 * 4 + 1] = 0.0f; - m[3 * 4 + 1] = 0.0f; - m[0 * 4 + 2] = 0.0f; - m[1 * 4 + 2] = 0.0f; - m[2 * 4 + 2] = 1.0f; - m[3 * 4 + 2] = 0.0f; - m[0 * 4 + 3] = 0.0f; - m[1 * 4 + 3] = 0.0f; - m[2 * 4 + 3] = 0.0f; - m[3 * 4 + 3] = 1.0f; -} - -// Adjust a 4x4 matrix to apply a scale. -inline void ScaleMatrix(GLfloat *m, GLfloat scalex, GLfloat scaley, GLfloat scalez) -{ - m[0 * 4 + 0] *= scalex; - m[0 * 4 + 1] *= scalex; - m[0 * 4 + 2] *= scalex; - m[0 * 4 + 3] *= scalex; - m[1 * 4 + 0] *= scaley; - m[1 * 4 + 1] *= scaley; - m[1 * 4 + 2] *= scaley; - m[1 * 4 + 3] *= scaley; - m[2 * 4 + 0] *= scalez; - m[2 * 4 + 1] *= scalez; - m[2 * 4 + 2] *= scalez; - m[2 * 4 + 3] *= scalez; -} - -// Adjust a 4x4 matrix to apply a translation. -inline void TranslateMatrix(GLfloat *m, GLfloat translatex, GLfloat translatey, GLfloat translatez) -{ - m[3 * 4 + 0] += m[0 * 4 + 0] * translatex + m[1 * 4 + 0] * translatey + m[2 * 4 + 0] * translatez; - m[3 * 4 + 1] += m[0 * 4 + 1] * translatex + m[1 * 4 + 1] * translatey + m[2 * 4 + 1] * translatez; - m[3 * 4 + 2] += m[0 * 4 + 2] * translatex + m[1 * 4 + 2] * translatey + m[2 * 4 + 2] * translatez; - m[3 * 4 + 3] += m[0 * 4 + 3] * translatex + m[1 * 4 + 3] * translatey + m[2 * 4 + 3] * translatez; -} - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -// Adjust a 4x4 matrix to apply a rotation. -inline void RotateMatrix(GLfloat *m, GLfloat angle, GLfloat vx, GLfloat vy, GLfloat vz) -{ - GLfloat len = sqrt(vx * vx + vy * vy + vz * vz); - if (len != 0) { - vx /= len; - vy /= len; - vz /= len; - } - - GLfloat c, s, ic; - c = cos(angle * M_PI / 180.0); - s = sin(angle * M_PI / 180.0); - ic = 1.0f - c; - - GLfloat rot[16]; - rot[0 * 4 + 0] = vx * vx * ic + c; - rot[1 * 4 + 0] = vx * vy * ic - vz * s; - rot[2 * 4 + 0] = vx * vz * ic + vy * s; - rot[3 * 4 + 0] = 0.0f; - rot[0 * 4 + 1] = vy * vx * ic + vz * s; - rot[1 * 4 + 1] = vy * vy * ic + c; - rot[2 * 4 + 1] = vy * vz * ic - vx * s; - rot[3 * 4 + 1] = 0.0f; - rot[0 * 4 + 2] = vx * vz * ic - vy * s; - rot[1 * 4 + 2] = vy * vz * ic + vx * s; - rot[2 * 4 + 2] = vz * vz * ic + c; - rot[3 * 4 + 2] = 0.0f; - rot[0 * 4 + 3] = 0.0f; - rot[1 * 4 + 3] = 0.0f; - rot[2 * 4 + 3] = 0.0f; - rot[3 * 4 + 3] = 1.0f; - - GLfloat temp[16]; - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - temp[j * 4 + i] = 0.0f; - for (int k = 0; k < 4; ++k) { - temp[j * 4 + i] += m[k * 4 + i] * rot[j * 4 + k]; - } - } - } - - qMemCopy(m, temp, sizeof(temp)); -} - GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent) { qtLogo = true; - createdVertices = 0; - createdNormals = 0; - m_vertexNumber = 0; frames = 0; setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_NoSystemBackground); @@ -178,10 +65,6 @@ GLWidget::GLWidget(QWidget *parent) GLWidget::~GLWidget() { - if (createdVertices) - delete[] createdVertices; - if (createdNormals) - delete[] createdNormals; } void GLWidget::setScaling(int scale) { @@ -210,13 +93,11 @@ void GLWidget::showBubbles(bool bubbles) void GLWidget::paintQtLogo() { glDisable(GL_TEXTURE_2D); - glVertexAttribPointer(vertexAttr1, 3, GL_FLOAT, GL_FALSE, 0, createdVertices); - glEnableVertexAttribArray(vertexAttr1); - glVertexAttribPointer(normalAttr1, 3, GL_FLOAT, GL_FALSE, 0, createdNormals); - glEnableVertexAttribArray(normalAttr1); - glDrawArrays(GL_TRIANGLES, 0, m_vertexNumber / 3); - glDisableVertexAttribArray(normalAttr1); - glDisableVertexAttribArray(vertexAttr1); + program1.setAttributeArray(vertexAttr1, vertices.constData()); + program1.setAttributeArray(normalAttr1, normals.constData()); + glDrawArrays(GL_TRIANGLES, 0, vertices.size()); + program1.disableAttributeArray(normalAttr1); + program1.disableAttributeArray(vertexAttr1); } void GLWidget::paintTexturedCube() @@ -239,8 +120,7 @@ void GLWidget::paintTexturedCube() -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5 }; - glVertexAttribPointer(vertexAttr2, 3, GL_FLOAT, GL_FALSE, 0, afVertices); - glEnableVertexAttribArray(vertexAttr2); + program2.setAttributeArray(vertexAttr2, afVertices, 3); GLfloat afTexCoord[] = { 0.0f,0.0f, 1.0f,1.0f, 1.0f,0.0f, @@ -258,8 +138,7 @@ void GLWidget::paintTexturedCube() 1.0f,0.0f, 1.0f,1.0f, 0.0f,0.0f, 0.0f,1.0f, 0.0f,0.0f, 1.0f,1.0f }; - glVertexAttribPointer(texCoordAttr2, 2, GL_FLOAT, GL_FALSE, 0, afTexCoord); - glEnableVertexAttribArray(texCoordAttr2); + program2.setAttributeArray(texCoordAttr2, afTexCoord, 2); GLfloat afNormals[] = { @@ -278,50 +157,15 @@ void GLWidget::paintTexturedCube() 0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,1,0, 0,1,0 }; - glVertexAttribPointer(normalAttr2, 3, GL_FLOAT, GL_FALSE, 0, afNormals); - glEnableVertexAttribArray(normalAttr2); + program2.setAttributeArray(normalAttr2, afNormals, 3); - glUniform1i(textureUniform2, 0); // use texture unit 0 + program2.setUniformValue(textureUniform2, 0); // use texture unit 0 glDrawArrays(GL_TRIANGLES, 0, 36); - glDisableVertexAttribArray(vertexAttr2); - glDisableVertexAttribArray(normalAttr2); - glDisableVertexAttribArray(texCoordAttr2); -} - -static void reportCompileErrors(GLuint shader, const char *src) -{ - GLint value = 0; - glGetShaderiv(shader, GL_COMPILE_STATUS, &value); - bool compiled = (value != 0); - value = 0; - glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &value); - if (!compiled && value > 1) { - char *log = new char [value]; - GLint len; - glGetShaderInfoLog(shader, value, &len, log); - qWarning("%s\n", log); - qWarning("when compiling:\n%s\n", src); - delete [] log; - } -} - -static void reportLinkErrors(GLuint program, const char *vsrc, const char *fsrc) -{ - GLint value = 0; - glGetProgramiv(program, GL_LINK_STATUS, &value); - bool linked = (value != 0); - value = 0; - glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value); - if (!linked && value > 1) { - char *log = new char [value]; - GLint len; - glGetProgramInfoLog(program, value, &len, log); - qWarning("%s\n", log); - qWarning("when linking:\n%s\nwith:\n%s\n", vsrc, fsrc); - delete [] log; - } + program2.disableAttributeArray(vertexAttr2); + program2.disableAttributeArray(normalAttr2); + program2.disableAttributeArray(texCoordAttr2); } void GLWidget::initializeGL () @@ -332,8 +176,8 @@ void GLWidget::initializeGL () glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); - GLuint vshader1 = glCreateShader(GL_VERTEX_SHADER); - const char *vsrc1[1] = { + QGLShader *vshader1 = new QGLShader(QGLShader::VertexShader, this); + const char *vsrc1 = "attribute highp vec4 vertex;\n" "attribute mediump vec3 normal;\n" "uniform mediump mat4 matrix;\n" @@ -346,36 +190,28 @@ void GLWidget::initializeGL () " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n" " color = clamp(color, 0.0, 1.0);\n" " gl_Position = matrix * vertex;\n" - "}\n" - }; - glShaderSource(vshader1, 1, vsrc1, 0); - glCompileShader(vshader1); - reportCompileErrors(vshader1, vsrc1[0]); + "}\n"; + vshader1->compile(vsrc1); - GLuint fshader1 = glCreateShader(GL_FRAGMENT_SHADER); - const char *fsrc1[1] = { + QGLShader *fshader1 = new QGLShader(QGLShader::FragmentShader, this); + const char *fsrc1 = "varying mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" - "}\n" - }; - glShaderSource(fshader1, 1, fsrc1, 0); - glCompileShader(fshader1); - reportCompileErrors(fshader1, fsrc1[0]); - - program1 = glCreateProgram(); - glAttachShader(program1, vshader1); - glAttachShader(program1, fshader1); - glLinkProgram(program1); - reportLinkErrors(program1, vsrc1[0], fsrc1[0]); - - vertexAttr1 = glGetAttribLocation(program1, "vertex"); - normalAttr1 = glGetAttribLocation(program1, "normal"); - matrixUniform1 = glGetUniformLocation(program1, "matrix"); - - GLuint vshader2 = glCreateShader(GL_VERTEX_SHADER); - const char *vsrc2[1] = { + "}\n"; + fshader1->compile(fsrc1); + + program1.addShader(vshader1); + program1.addShader(fshader1); + program1.link(); + + vertexAttr1 = program1.attributeLocation("vertex"); + normalAttr1 = program1.attributeLocation("normal"); + matrixUniform1 = program1.uniformLocation("matrix"); + + QGLShader *vshader2 = new QGLShader(QGLShader::VertexShader); + const char *vsrc2 = "attribute highp vec4 vertex;\n" "attribute highp vec4 texCoord;\n" "attribute mediump vec3 normal;\n" @@ -388,14 +224,11 @@ void GLWidget::initializeGL () " angle = max(dot(normal, toLight), 0.0);\n" " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" - "}\n" - }; - glShaderSource(vshader2, 1, vsrc2, 0); - glCompileShader(vshader2); - reportCompileErrors(vshader2, vsrc2[0]); + "}\n"; + vshader2->compile(vsrc2); - GLuint fshader2 = glCreateShader(GL_FRAGMENT_SHADER); - const char *fsrc2[1] = { + QGLShader *fshader2 = new QGLShader(QGLShader::FragmentShader); + const char *fsrc2 = "varying highp vec4 texc;\n" "uniform sampler2D tex;\n" "varying mediump float angle;\n" @@ -404,23 +237,18 @@ void GLWidget::initializeGL () " highp vec3 color = texture2D(tex, texc.st).rgb;\n" " color = color * 0.2 + color * 0.8 * angle;\n" " gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n" - "}\n" - }; - glShaderSource(fshader2, 1, fsrc2, 0); - glCompileShader(fshader2); - reportCompileErrors(fshader2, fsrc2[0]); - - program2 = glCreateProgram(); - glAttachShader(program2, vshader2); - glAttachShader(program2, fshader2); - glLinkProgram(program2); - reportLinkErrors(program2, vsrc2[0], fsrc2[0]); - - vertexAttr2 = glGetAttribLocation(program2, "vertex"); - normalAttr2 = glGetAttribLocation(program2, "normal"); - texCoordAttr2 = glGetAttribLocation(program2, "texCoord"); - matrixUniform2 = glGetUniformLocation(program2, "matrix"); - textureUniform2 = glGetUniformLocation(program2, "tex"); + "}\n"; + fshader2->compile(fsrc2); + + program2.addShader(vshader2); + program2.addShader(fshader2); + program2.link(); + + vertexAttr2 = program2.attributeLocation("vertex"); + normalAttr2 = program2.attributeLocation("normal"); + texCoordAttr2 = program2.attributeLocation("texCoord"); + matrixUniform2 = program2.uniformLocation("matrix"); + textureUniform2 = program2.uniformLocation("tex"); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -438,6 +266,8 @@ void GLWidget::paintGL() QPainter painter; painter.begin(this); + painter.beginNativePainting(); + glClearColor(0.1f, 0.1f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); @@ -450,29 +280,30 @@ void GLWidget::paintGL() glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); - GLfloat modelview[16]; - IdentityMatrix(modelview); - RotateMatrix(modelview, m_fAngle, 0.0, 1.0, 0.0); - RotateMatrix(modelview, m_fAngle, 1.0, 0.0, 0.0); - RotateMatrix(modelview, m_fAngle, 0.0, 0.0, 1.0); - ScaleMatrix(modelview, m_fScale, m_fScale, m_fScale); - TranslateMatrix(modelview, 0, -0.2, 0); + QMatrix4x4 modelview; + modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f); + modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f); + modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f); + modelview.scale(m_fScale); + modelview.translate(0.0f, -0.2f, 0.0f); if (qtLogo) { - glUseProgram(program1); - glUniformMatrix4fv(matrixUniform1, 1, GL_FALSE, modelview); + program1.enable(); + program1.setUniformValue(matrixUniform1, modelview); paintQtLogo(); - glUseProgram(0); + program1.disable(); } else { - glUseProgram(program2); - glUniformMatrix4fv(matrixUniform2, 1, GL_FALSE, modelview); + program2.enable(); + program1.setUniformValue(matrixUniform2, modelview); paintTexturedCube(); - glUseProgram(0); + program2.disable(); } glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); + painter.endNativePainting(); + if (m_showBubbles) foreach (Bubble *bubble, bubbles) { bubble->drawBubble(&painter); @@ -563,80 +394,69 @@ void GLWidget::createGeometry() extrude(x8, y8, x5, y5); } - m_vertexNumber = vertices.size(); - createdVertices = new GLfloat[m_vertexNumber]; - createdNormals = new GLfloat[m_vertexNumber]; - for (int i = 0;i < m_vertexNumber;i++) { - createdVertices[i] = vertices.at(i) * 2; - createdNormals[i] = normals.at(i); - } - vertices.clear(); - normals.clear(); + for (int i = 0;i < vertices.size();i++) + vertices[i] *= 2.0f; } void GLWidget::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4) { - qreal nx, ny, nz; - - vertices << x1 << y1 << -0.05f; - vertices << x2 << y2 << -0.05f; - vertices << x4 << y4 << -0.05f; + vertices << QVector3D(x1, y1, -0.05f); + vertices << QVector3D(x2, y2, -0.05f); + vertices << QVector3D(x4, y4, -0.05f); - vertices << x3 << y3 << -0.05f; - vertices << x4 << y4 << -0.05f; - vertices << x2 << y2 << -0.05f; + vertices << QVector3D(x3, y3, -0.05f); + vertices << QVector3D(x4, y4, -0.05f); + vertices << QVector3D(x2, y2, -0.05f); - CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0, x4 - x1, y4 - y1, 0); - Normalize(nx, ny, nz); + QVector3D n = QVector3D::normal + (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f)); - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; - vertices << x4 << y4 << 0.05f; - vertices << x2 << y2 << 0.05f; - vertices << x1 << y1 << 0.05f; + vertices << QVector3D(x4, y4, 0.05f); + vertices << QVector3D(x2, y2, 0.05f); + vertices << QVector3D(x1, y1, 0.05f); - vertices << x2 << y2 << 0.05f; - vertices << x4 << y4 << 0.05f; - vertices << x3 << y3 << 0.05f; + vertices << QVector3D(x2, y2, 0.05f); + vertices << QVector3D(x4, y4, 0.05f); + vertices << QVector3D(x3, y3, 0.05f); - CrossProduct(nx, ny, nz, x2 - x4, y2 - y4, 0, x1 - x4, y1 - y4, 0); - Normalize(nx, ny, nz); + n = QVector3D::normal + (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f)); - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; } void GLWidget::extrude(qreal x1, qreal y1, qreal x2, qreal y2) { - qreal nx, ny, nz; - - vertices << x1 << y1 << +0.05f; - vertices << x2 << y2 << +0.05f; - vertices << x1 << y1 << -0.05f; + vertices << QVector3D(x1, y1, +0.05f); + vertices << QVector3D(x2, y2, +0.05f); + vertices << QVector3D(x1, y1, -0.05f); - vertices << x2 << y2 << -0.05f; - vertices << x1 << y1 << -0.05f; - vertices << x2 << y2 << +0.05f; + vertices << QVector3D(x2, y2, -0.05f); + vertices << QVector3D(x1, y1, -0.05f); + vertices << QVector3D(x2, y2, +0.05f); - CrossProduct(nx, ny, nz, x2 - x1, y2 - y1, 0.0f, 0.0f, 0.0f, -0.1f); - Normalize(nx, ny, nz); + QVector3D n = QVector3D::normal + (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f)); - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; - normals << nx << ny << nz; - normals << nx << ny << nz; - normals << nx << ny << nz; + normals << n; + normals << n; + normals << n; } diff --git a/examples/opengl/hellogl_es2/glwidget.h b/examples/opengl/hellogl_es2/glwidget.h index 13a3f20..f6b7ed1 100644 --- a/examples/opengl/hellogl_es2/glwidget.h +++ b/examples/opengl/hellogl_es2/glwidget.h @@ -43,7 +43,11 @@ #define GLWIDGET_H #include <QGLWidget> +#include <QtGui/qvector3d.h> +#include <QtGui/qmatrix4x4.h> +#include <QtOpenGL/qglshaderprogram.h> #include <QTime> +#include <QVector> class Bubble; class GLWidget : public QGLWidget { @@ -71,24 +75,21 @@ private: void createBubbles(int number); void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4); void extrude(qreal x1, qreal y1, qreal x2, qreal y2); - QList<qreal> vertices; - QList<qreal> normals; - GLfloat *createdVertices; - GLfloat *createdNormals; - int m_vertexNumber; + QVector<QVector3D> vertices; + QVector<QVector3D> normals; bool qtLogo; QList<Bubble*> bubbles; int frames; QTime time; - GLuint program1; - GLuint program2; - GLuint vertexAttr1; - GLuint normalAttr1; - GLuint matrixUniform1; - GLuint vertexAttr2; - GLuint normalAttr2; - GLuint texCoordAttr2; - GLuint matrixUniform2; - GLuint textureUniform2; + QGLShaderProgram program1; + QGLShaderProgram program2; + int vertexAttr1; + int normalAttr1; + int matrixUniform1; + int vertexAttr2; + int normalAttr2; + int texCoordAttr2; + int matrixUniform2; + int textureUniform2; }; #endif diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index a4c2a22..567eb7b 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -27,3 +27,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS opengl.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/opengl INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/overpainting/glwidget.cpp b/examples/opengl/overpainting/glwidget.cpp index c21107f..9aa872e 100644 --- a/examples/opengl/overpainting/glwidget.cpp +++ b/examples/opengl/overpainting/glwidget.cpp @@ -166,6 +166,11 @@ void GLWidget::paintEvent(QPaintEvent *event) //! [7] //! [8] + glShadeModel(GL_FLAT); + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glMatrixMode(GL_MODELVIEW); glPopMatrix(); //! [8] diff --git a/examples/opengl/overpainting/overpainting.pro b/examples/opengl/overpainting/overpainting.pro index b8e79eb..10b6bd3 100644 --- a/examples/opengl/overpainting/overpainting.pro +++ b/examples/opengl/overpainting/overpainting.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/overpainting sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS overpainting.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/overpainting INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index 65e3c08..2ecd4a4 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -154,7 +154,7 @@ void GLWidget::paintGL() for (int y = 0; y < 5; ++y) { for (int x = 0; x < 5; ++x) { glTranslatef(2.0f, 0, 0); - glColor4f(0.8, 0.8, 0.8, 1.0); + glColor4f(0.8f, 0.8f, 0.8f, 1.0f); glDrawArrays(GL_QUADS, 0, 4); } glTranslatef(-10.0f, 2.0f, 0); diff --git a/examples/opengl/pbuffers/pbuffers.pro b/examples/opengl/pbuffers/pbuffers.pro index c1060e2..4f7740e 100644 --- a/examples/opengl/pbuffers/pbuffers.pro +++ b/examples/opengl/pbuffers/pbuffers.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/pbuffers sources.files = $$SOURCES $$HEADERS $$RESOURCES pbuffers.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/pbuffers INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/pbuffers2/bubbles.svg b/examples/opengl/pbuffers2/bubbles.svg index 65867da..5173012 100644 --- a/examples/opengl/pbuffers2/bubbles.svg +++ b/examples/opengl/pbuffers2/bubbles.svg @@ -72,7 +72,7 @@ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="100" fx="-50" fy="50"> <stop offset="0%" stop-color="black" stop-opacity="1.0" /> - <stop offset="100%" stop-color="white" stop-opacity="0.0" /> + <stop offset="100%" stop-color="black" stop-opacity="0.0" /> </radialGradient> <!-- Define a shadow for each sphere. --> @@ -91,56 +91,56 @@ <g transform="translate(200,700)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(315,700)"> <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(80,700)"> <g transform="scale(0.65,0.65)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(255,700)"> <g transform="scale(0.3,0.3)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(565,700)"> <g transform="scale(0.4,0.4)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(715,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(645,700)"> <g transform="scale(0.375,0.375)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(555,700)"> <g transform="scale(0.9,0.9)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -148,28 +148,28 @@ <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(215,700)"> <g transform="scale(0.45,0.45)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(420,700)"> <g transform="scale(0.75,0.75)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(815,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -186,7 +186,7 @@ <circle fill="#a6ce39" cx="0" cy="0" r="33" /> <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10 L -11,22 L -1,12 Z" /> - <animateTransform attributeName="transform" type="rotate" values="0; 360" + <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360" begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(200,375)"> diff --git a/examples/opengl/pbuffers2/pbuffers2.pro b/examples/opengl/pbuffers2/pbuffers2.pro index cbd0cb5..ec718e5 100644 --- a/examples/opengl/pbuffers2/pbuffers2.pro +++ b/examples/opengl/pbuffers2/pbuffers2.pro @@ -19,3 +19,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/pbuffers2 sources.files = $$SOURCES $$HEADERS $$RESOURCES pbuffers2.pro *.png *.svg sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/pbuffers2 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/samplebuffers/samplebuffers.pro b/examples/opengl/samplebuffers/samplebuffers.pro index 9eb5f58..232c1f4 100644 --- a/examples/opengl/samplebuffers/samplebuffers.pro +++ b/examples/opengl/samplebuffers/samplebuffers.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/samplebuffers sources.files = $$SOURCES $$HEADERS samplebuffers.pro sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/samplebuffers INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/opengl/textures/textures.pro b/examples/opengl/textures/textures.pro index cd98a68..8d6cc4e 100644 --- a/examples/opengl/textures/textures.pro +++ b/examples/opengl/textures/textures.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/opengl/textures sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS textures.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/textures INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/openvg/README b/examples/openvg/README new file mode 100644 index 0000000..5e385ea --- /dev/null +++ b/examples/openvg/README @@ -0,0 +1,40 @@ +Qt provides support for integration with OpenVG implementations on +platforms with appropriate hardware acceleration. + +These examples demonstrate the basic techniques used to take advantage of +OpenVG in Qt applications. In particular, the "star" example shows how +to mix QPainter and OpenVG calls in the same paint event. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/openvg/openvg.pro b/examples/openvg/openvg.pro new file mode 100644 index 0000000..d76a389 --- /dev/null +++ b/examples/openvg/openvg.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS = star + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/openvg +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS openvg.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/openvg +INSTALLS += target sources diff --git a/examples/openvg/star/main.cpp b/examples/openvg/star/main.cpp new file mode 100644 index 0000000..276d685 --- /dev/null +++ b/examples/openvg/star/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include "starwidget.h" + +int main(int argc, char *argv[]) +{ +#ifdef Q_OS_SYMBIAN + QApplication::setGraphicsSystem("openvg"); +#endif + QApplication app(argc, argv); + StarWidget mw; + mw.show(); + return app.exec(); +} diff --git a/examples/openvg/star/star.pro b/examples/openvg/star/star.pro new file mode 100644 index 0000000..90c236d --- /dev/null +++ b/examples/openvg/star/star.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = star +CONFIG += qt debug warn_on +QT += openvg +SOURCES = starwidget.cpp main.cpp +HEADERS = starwidget.h diff --git a/examples/openvg/star/starwidget.cpp b/examples/openvg/star/starwidget.cpp new file mode 100644 index 0000000..ab11bdb --- /dev/null +++ b/examples/openvg/star/starwidget.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "starwidget.h" + +StarWidget::StarWidget(QWidget *parent) + : QWidget(parent) + , path(VG_INVALID_HANDLE) + , pen(Qt::red, 4.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin) + , brush(Qt::yellow) +{ + setMinimumSize(220, 250); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); +} + +static VGubyte const starSegments[] = { + VG_MOVE_TO_ABS, + VG_LINE_TO_REL, + VG_LINE_TO_REL, + VG_LINE_TO_REL, + VG_LINE_TO_REL, + VG_CLOSE_PATH +}; +static VGfloat const starCoords[] = { + 110, 35, + 50, 160, + -130, -100, + 160, 0, + -130, 100 +}; + +void StarWidget::paintEvent(QPaintEvent *) +{ + QPainter painter; + painter.begin(this); + + // Make sure that we are using the OpenVG paint engine. + if (painter.paintEngine()->type() != QPaintEngine::OpenVG) { +#ifdef Q_WS_QWS + qWarning("Not using OpenVG: use the '-display' option to specify an OpenVG driver"); +#else + qWarning("Not using OpenVG: specify '-graphicssystem OpenVG'"); +#endif + return; + } + + // Select a pen and a brush for drawing the star. + painter.setPen(pen); + painter.setBrush(brush); + + // We want the star border to be anti-aliased. + painter.setRenderHints(QPainter::Antialiasing); + + // Flush the state changes to the OpenVG implementation + // and prepare to perform raw OpenVG calls. + painter.beginNativePainting(); + + // Cache the path if we haven't already. + if (path == VG_INVALID_HANDLE) { + path = vgCreatePath(VG_PATH_FORMAT_STANDARD, + VG_PATH_DATATYPE_F, + 1.0f, // scale + 0.0f, // bias + 6, // segmentCapacityHint + 10, // coordCapacityHint + VG_PATH_CAPABILITY_ALL); + vgAppendPathData(path, sizeof(starSegments), starSegments, starCoords); + } + + // Draw the star directly using the OpenVG API. + vgDrawPath(path, VG_FILL_PATH | VG_STROKE_PATH); + + // Restore normal QPainter operations. + painter.endNativePainting(); + + painter.end(); +} diff --git a/examples/openvg/star/starwidget.h b/examples/openvg/star/starwidget.h new file mode 100644 index 0000000..fdc6794 --- /dev/null +++ b/examples/openvg/star/starwidget.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STARWIDGET_H +#define STARWIDGET_H + +#include <QWidget> +#include <QPainter> +#include <QPaintEngine> +#include "qvg.h" + +class StarWidget : public QWidget +{ + Q_OBJECT +public: + StarWidget(QWidget *parent = 0); + ~StarWidget() {} + +protected: + void paintEvent(QPaintEvent *); + +private: + VGPath path; + QPen pen; + QBrush brush; +}; + +#endif diff --git a/examples/painting/basicdrawing/basicdrawing.pro b/examples/painting/basicdrawing/basicdrawing.pro index 4011260..ea23706 100644 --- a/examples/painting/basicdrawing/basicdrawing.pro +++ b/examples/painting/basicdrawing/basicdrawing.pro @@ -10,3 +10,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting/basicdrawing sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS basicdrawing.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/painting/basicdrawing INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A649 +} diff --git a/examples/painting/concentriccircles/concentriccircles.pro b/examples/painting/concentriccircles/concentriccircles.pro index 093ea1c..a8d2c36 100644 --- a/examples/painting/concentriccircles/concentriccircles.pro +++ b/examples/painting/concentriccircles/concentriccircles.pro @@ -9,3 +9,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting/concentriccircles sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS concentriccircles.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/concentriccircles INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64A +} diff --git a/examples/painting/fontsampler/fontsampler.pro b/examples/painting/fontsampler/fontsampler.pro index 8b63752..1bb2f1d 100644 --- a/examples/painting/fontsampler/fontsampler.pro +++ b/examples/painting/fontsampler/fontsampler.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting/fontsampler sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fontsampler.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/fontsampler INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/painting/imagecomposition/imagecomposition.pro b/examples/painting/imagecomposition/imagecomposition.pro index 935a1d4..fe29a8a 100644 --- a/examples/painting/imagecomposition/imagecomposition.pro +++ b/examples/painting/imagecomposition/imagecomposition.pro @@ -9,3 +9,7 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES images *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/imagecomposition INSTALLS += target sources +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64B +} diff --git a/examples/painting/painterpaths/painterpaths.pro b/examples/painting/painterpaths/painterpaths.pro index 76c9e82..1d981bb 100644 --- a/examples/painting/painterpaths/painterpaths.pro +++ b/examples/painting/painterpaths/painterpaths.pro @@ -3,10 +3,15 @@ HEADERS = renderarea.h \ SOURCES = main.cpp \ renderarea.cpp \ window.cpp -unix:!mac:LIBS += -lm +unix:!mac:!symbian:!vxworks:LIBS += -lm # install target.path = $$[QT_INSTALL_EXAMPLES]/painting/painterpaths sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS painterpaths.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/painterpaths INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64C +} diff --git a/examples/painting/painting.pro b/examples/painting/painting.pro index 6d00720..229c1be 100644 --- a/examples/painting/painting.pro +++ b/examples/painting/painting.pro @@ -5,7 +5,7 @@ SUBDIRS = basicdrawing \ painterpaths \ transformations -!wince*: SUBDIRS += fontsampler +!wince*:!symbian: SUBDIRS += fontsampler contains(QT_CONFIG, svg): SUBDIRS += svggenerator svgviewer @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS painting.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/painting INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/painting/svggenerator/displaywidget.cpp b/examples/painting/svggenerator/displaywidget.cpp index 4ac60ce..804cc67 100644 --- a/examples/painting/svggenerator/displaywidget.cpp +++ b/examples/painting/svggenerator/displaywidget.cpp @@ -63,7 +63,7 @@ DisplayWidget::DisplayWidget(QWidget *parent) } //! [paint event] -void DisplayWidget::paintEvent(QPaintEvent *event) +void DisplayWidget::paintEvent(QPaintEvent * /* event */) { QPainter painter; painter.begin(this); diff --git a/examples/painting/svggenerator/svggenerator.pro b/examples/painting/svggenerator/svggenerator.pro index 4d08ba4..1134619 100644 --- a/examples/painting/svggenerator/svggenerator.pro +++ b/examples/painting/svggenerator/svggenerator.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting/svggenerator sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS svggenerator.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/svggenerator INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000CF68
\ No newline at end of file diff --git a/examples/painting/svgviewer/files/bubbles.svg b/examples/painting/svgviewer/files/bubbles.svg index 65867da..5173012 100644 --- a/examples/painting/svgviewer/files/bubbles.svg +++ b/examples/painting/svgviewer/files/bubbles.svg @@ -72,7 +72,7 @@ <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="100" fx="-50" fy="50"> <stop offset="0%" stop-color="black" stop-opacity="1.0" /> - <stop offset="100%" stop-color="white" stop-opacity="0.0" /> + <stop offset="100%" stop-color="black" stop-opacity="0.0" /> </radialGradient> <!-- Define a shadow for each sphere. --> @@ -91,56 +91,56 @@ <g transform="translate(200,700)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(315,700)"> <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(80,700)"> <g transform="scale(0.65,0.65)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(255,700)"> <g transform="scale(0.3,0.3)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(565,700)"> <g transform="scale(0.4,0.4)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(715,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(645,700)"> <g transform="scale(0.375,0.375)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(555,700)"> <g transform="scale(0.9,0.9)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -148,28 +148,28 @@ <g transform="scale(0.5,0.5)"> <use xlink:href="#bubble" fill="url(#blueBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(215,700)"> <g transform="scale(0.45,0.45)"> <use xlink:href="#bubble" fill="url(#redBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(420,700)"> <g transform="scale(0.75,0.75)"> <use xlink:href="#bubble" fill="url(#greenBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(815,700)"> <g transform="scale(0.6,0.6)"> <use xlink:href="#bubble" fill="url(#yellowBubble)" /> </g> - <animateTransform attributeName="transform" type="translate" + <animateTransform attributeName="transform" type="translate" additive="sum" values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" /> </g> @@ -186,7 +186,7 @@ <circle fill="#a6ce39" cx="0" cy="0" r="33" /> <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10 L -11,22 L -1,12 Z" /> - <animateTransform attributeName="transform" type="rotate" values="0; 360" + <animateTransform attributeName="transform" type="rotate" additive="sum" values="0; 360" begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" /> </g> <g transform="translate(200,375)"> diff --git a/examples/painting/svgviewer/mainwindow.cpp b/examples/painting/svgviewer/mainwindow.cpp index eee1496..c58dbb4 100644 --- a/examples/painting/svgviewer/mainwindow.cpp +++ b/examples/painting/svgviewer/mainwindow.cpp @@ -53,7 +53,7 @@ MainWindow::MainWindow() QAction *openAction = fileMenu->addAction(tr("&Open...")); openAction->setShortcut(QKeySequence(tr("Ctrl+O"))); QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); + quitAction->setShortcuts(QKeySequence::Quit); menuBar()->addMenu(fileMenu); diff --git a/examples/painting/svgviewer/svgviewer.pro b/examples/painting/svgviewer/svgviewer.pro index b29e218..583d51c 100644 --- a/examples/painting/svgviewer/svgviewer.pro +++ b/examples/painting/svgviewer/svgviewer.pro @@ -21,3 +21,11 @@ wince*: { addFiles.path = \My Documents DEPLOYMENT += addFiles } + +symbian: { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64E + addFiles.sources = files\*.svg + addFiles.path = . + DEPLOYMENT += addFiles +} diff --git a/examples/painting/transformations/transformations.pro b/examples/painting/transformations/transformations.pro index a8ff610..9e225a4 100644 --- a/examples/painting/transformations/transformations.pro +++ b/examples/painting/transformations/transformations.pro @@ -9,3 +9,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/painting/transformations sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS transformations.pro sources.path = $$[QT_INSTALL_EXAMPLES]/painting/transformations INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64D +} diff --git a/examples/phonon/capabilities/capabilities.pro b/examples/phonon/capabilities/capabilities.pro index 52b6b1b..d05e5ec 100644 --- a/examples/phonon/capabilities/capabilities.pro +++ b/examples/phonon/capabilities/capabilities.pro @@ -14,3 +14,4 @@ wince*{ DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout } +symbian:TARGET.UID3 = 0xA000CF69 diff --git a/examples/phonon/musicplayer/mainwindow.cpp b/examples/phonon/musicplayer/mainwindow.cpp index 7515739..8914c19 100644 --- a/examples/phonon/musicplayer/mainwindow.cpp +++ b/examples/phonon/musicplayer/mainwindow.cpp @@ -184,7 +184,7 @@ void MainWindow::metaStateChanged(Phonon::State newState, Phonon::State /* oldSt QMessageBox::warning(this, tr("Error opening files"), metaInformationResolver->errorString()); while (!sources.isEmpty() && - !(sources.takeLast() == metaInformationResolver->currentSource())); + !(sources.takeLast() == metaInformationResolver->currentSource())) {} /* loop */; return; } @@ -264,7 +264,7 @@ void MainWindow::setupActions() addFilesAction = new QAction(tr("Add &Files"), this); addFilesAction->setShortcut(tr("Ctrl+F")); exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcut(tr("Ctrl+X")); + exitAction->setShortcuts(QKeySequence::Quit); aboutAction = new QAction(tr("A&bout"), this); aboutAction->setShortcut(tr("Ctrl+B")); aboutQtAction = new QAction(tr("About &Qt"), this); diff --git a/examples/phonon/musicplayer/musicplayer.pro b/examples/phonon/musicplayer/musicplayer.pro index 0a93dc2..a0c953a 100644 --- a/examples/phonon/musicplayer/musicplayer.pro +++ b/examples/phonon/musicplayer/musicplayer.pro @@ -14,3 +14,4 @@ wince*{ DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout } +symbian:TARGET.UID3 = 0xA000CF6A diff --git a/examples/phonon/phonon.pro b/examples/phonon/phonon.pro index 0dea766..0ddf767 100644 --- a/examples/phonon/phonon.pro +++ b/examples/phonon/phonon.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/phonon sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS phonon.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/phonon INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtconcurrent/imagescaling/imagescaling.pro b/examples/qtconcurrent/imagescaling/imagescaling.pro index 0a25efb..c70013d 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.pro +++ b/examples/qtconcurrent/imagescaling/imagescaling.pro @@ -12,4 +12,6 @@ sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/imagescaling INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: DEPLOYMENT_PLUGIN += qgif qjpeg qtiff diff --git a/examples/qtconcurrent/map/map.pro b/examples/qtconcurrent/map/map.pro index f20267b..e0b87f4 100644 --- a/examples/qtconcurrent/map/map.pro +++ b/examples/qtconcurrent/map/map.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/map sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/map INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtconcurrent/progressdialog/progressdialog.pro b/examples/qtconcurrent/progressdialog/progressdialog.pro index 12ba0bf..ffdb4c7 100644 --- a/examples/qtconcurrent/progressdialog/progressdialog.pro +++ b/examples/qtconcurrent/progressdialog/progressdialog.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/progressdialog sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/progressdialog INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtconcurrent/qtconcurrent.pro b/examples/qtconcurrent/qtconcurrent.pro index 5d73533..1157d25 100644 --- a/examples/qtconcurrent/qtconcurrent.pro +++ b/examples/qtconcurrent/qtconcurrent.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qtconcurrent.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtconcurrent/runfunction/runfunction.pro b/examples/qtconcurrent/runfunction/runfunction.pro index 9034476..d312e2b 100644 --- a/examples/qtconcurrent/runfunction/runfunction.pro +++ b/examples/qtconcurrent/runfunction/runfunction.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/runfunction sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/runfunction INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtconcurrent/wordcount/wordcount.pro b/examples/qtconcurrent/wordcount/wordcount.pro index fba95ee..8cd0392 100644 --- a/examples/qtconcurrent/wordcount/wordcount.pro +++ b/examples/qtconcurrent/wordcount/wordcount.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/wordcount sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/qtconcurrent/wordcount INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtestlib/qtestlib.pro b/examples/qtestlib/qtestlib.pro index 8addbcb..79bed8c 100644 --- a/examples/qtestlib/qtestlib.pro +++ b/examples/qtestlib/qtestlib.pro @@ -6,3 +6,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qtestlib.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qtestlib/tutorial1/tutorial1.pro b/examples/qtestlib/tutorial1/tutorial1.pro index baa15b2..bcce234 100644 --- a/examples/qtestlib/tutorial1/tutorial1.pro +++ b/examples/qtestlib/tutorial1/tutorial1.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial1 sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial1 INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60B +} diff --git a/examples/qtestlib/tutorial2/tutorial2.pro b/examples/qtestlib/tutorial2/tutorial2.pro index 44211d8..bcfe940 100644 --- a/examples/qtestlib/tutorial2/tutorial2.pro +++ b/examples/qtestlib/tutorial2/tutorial2.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial2 sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial2 INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60C +} diff --git a/examples/qtestlib/tutorial3/tutorial3.pro b/examples/qtestlib/tutorial3/tutorial3.pro index b494ba8..fed5064 100644 --- a/examples/qtestlib/tutorial3/tutorial3.pro +++ b/examples/qtestlib/tutorial3/tutorial3.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial3 sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial3 INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60D +} diff --git a/examples/qtestlib/tutorial4/tutorial4.pro b/examples/qtestlib/tutorial4/tutorial4.pro index 0777d48..00c2147 100644 --- a/examples/qtestlib/tutorial4/tutorial4.pro +++ b/examples/qtestlib/tutorial4/tutorial4.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial4 sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial4 INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60E +} diff --git a/examples/qtestlib/tutorial5/tutorial5.pro b/examples/qtestlib/tutorial5/tutorial5.pro index 0310916..4fdcec9 100644 --- a/examples/qtestlib/tutorial5/tutorial5.pro +++ b/examples/qtestlib/tutorial5/tutorial5.pro @@ -6,3 +6,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial5 sources.files = $$SOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtestlib/tutorial5 INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60F +} diff --git a/examples/qws/ahigl/ahigl.pro b/examples/qws/ahigl/ahigl.pro index 1ee8e6e..c831335 100644 --- a/examples/qws/ahigl/ahigl.pro +++ b/examples/qws/ahigl/ahigl.pro @@ -7,6 +7,8 @@ TARGET = qahiglscreen target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target +include($$QT_SOURCE_TREE/examples/examplebase.pri) + HEADERS = qwindowsurface_ahigl_p.h \ qscreenahigl_qws.h diff --git a/examples/qws/dbscreen/dbscreen.cpp b/examples/qws/dbscreen/dbscreen.cpp index 81df21d..aa33a97 100644 --- a/examples/qws/dbscreen/dbscreen.cpp +++ b/examples/qws/dbscreen/dbscreen.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,8 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +****************************************************************************/ #include "dbscreen.h" #include <QApplication> diff --git a/examples/qws/dbscreen/dbscreen.pro b/examples/qws/dbscreen/dbscreen.pro index 172a02a..86152ab 100644 --- a/examples/qws/dbscreen/dbscreen.pro +++ b/examples/qws/dbscreen/dbscreen.pro @@ -5,6 +5,8 @@ TARGET = dbscreen target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target +include($$QT_SOURCE_TREE/examples/examplebase.pri) + HEADERS = dbscreen.h SOURCES = dbscreendriverplugin.cpp \ dbscreen.cpp diff --git a/examples/qws/dbscreen/dbscreendriverplugin.cpp b/examples/qws/dbscreen/dbscreendriverplugin.cpp index c1cc03c..bc2434b 100644 --- a/examples/qws/dbscreen/dbscreendriverplugin.cpp +++ b/examples/qws/dbscreen/dbscreendriverplugin.cpp @@ -1,11 +1,11 @@ - /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) - ** - ** This file is part of the examples of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the examples 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 @@ -36,12 +36,9 @@ ** ** ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ - +** +****************************************************************************/ + #include <QScreenDriverPlugin> #include "dbscreen.h" diff --git a/examples/qws/framebuffer/framebuffer.pro b/examples/qws/framebuffer/framebuffer.pro index f9fe850..3fd0975 100644 --- a/examples/qws/framebuffer/framebuffer.pro +++ b/examples/qws/framebuffer/framebuffer.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qws/framebuffer sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS framebuffer.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qws/framebuffer INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qws/mousecalibration/mousecalibration.pro b/examples/qws/mousecalibration/mousecalibration.pro index bd31853..fc1c469 100644 --- a/examples/qws/mousecalibration/mousecalibration.pro +++ b/examples/qws/mousecalibration/mousecalibration.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qws/mousecalibration sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qws/mousecalibration INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qws/qws.pro b/examples/qws/qws.pro index fb3c3c7..48c59c1 100644 --- a/examples/qws/qws.pro +++ b/examples/qws/qws.pro @@ -1,7 +1,11 @@ TEMPLATE = subdirs -SUBDIRS = framebuffer mousecalibration simpledecoration +# no /dev/fbX +!qnx:!vxworks:SUBDIRS = framebuffer +SUBDIRS += mousecalibration simpledecoration # install sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qws INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/qws/svgalib/svgalib.pro b/examples/qws/svgalib/svgalib.pro index 8a47c1d..3ab5a19 100644 --- a/examples/qws/svgalib/svgalib.pro +++ b/examples/qws/svgalib/svgalib.pro @@ -7,6 +7,8 @@ TARGET = svgalibscreen target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target +include($$QT_SOURCE_TREE/examples/examplebase.pri) + HEADERS = svgalibscreen.h \ svgalibpaintengine.h \ svgalibsurface.h \ diff --git a/examples/richtext/calendar/calendar.pro b/examples/richtext/calendar/calendar.pro index bf032f5..efb99b4 100644 --- a/examples/richtext/calendar/calendar.pro +++ b/examples/richtext/calendar/calendar.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/richtext/calendar sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS calendar.pro sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/calendar INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/richtext/orderform/mainwindow.cpp b/examples/richtext/orderform/mainwindow.cpp index db1a1d5..1888aeb 100644 --- a/examples/richtext/orderform/mainwindow.cpp +++ b/examples/richtext/orderform/mainwindow.cpp @@ -49,12 +49,12 @@ MainWindow::MainWindow() { QMenu *fileMenu = new QMenu(tr("&File"), this); QAction *newAction = fileMenu->addAction(tr("&New...")); - newAction->setShortcut(tr("Ctrl+N")); + newAction->setShortcuts(QKeySequence::New); printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile())); - printAction->setShortcut(tr("Ctrl+P")); + printAction->setShortcuts(QKeySequence::Print); printAction->setEnabled(false); QAction *quitAction = fileMenu->addAction(tr("E&xit")); - quitAction->setShortcut(tr("Ctrl+Q")); + quitAction->setShortcuts(QKeySequence::Quit); menuBar()->addMenu(fileMenu); letters = new QTabWidget; diff --git a/examples/richtext/orderform/orderform.pro b/examples/richtext/orderform/orderform.pro index 63739b0..dee2855 100644 --- a/examples/richtext/orderform/orderform.pro +++ b/examples/richtext/orderform/orderform.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/richtext/orderform sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS orderform.pro sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/orderform INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro index ef8f094..1440de2 100644 --- a/examples/richtext/richtext.pro +++ b/examples/richtext/richtext.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/richtext sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS richtext.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/richtext INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/richtext/syntaxhighlighter/mainwindow.cpp b/examples/richtext/syntaxhighlighter/mainwindow.cpp index d37a6d4..738cfd7 100644 --- a/examples/richtext/syntaxhighlighter/mainwindow.cpp +++ b/examples/richtext/syntaxhighlighter/mainwindow.cpp @@ -110,14 +110,13 @@ void MainWindow::setupFileMenu() menuBar()->addMenu(fileMenu); fileMenu->addAction(tr("&New"), this, SLOT(newFile()), - QKeySequence(tr("Ctrl+N", - "File|New"))); + QKeySequence::New); + fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()), - QKeySequence(tr("Ctrl+O", - "File|Open"))); + QKeySequence::Open); + fileMenu->addAction(tr("E&xit"), qApp, SLOT(quit()), - QKeySequence(tr("Ctrl+Q", - "File|Exit"))); + QKeySequence::Quit); } void MainWindow::setupHelpMenu() diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro index b861970..0574b2d 100644 --- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro +++ b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro @@ -10,6 +10,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS syntaxhighlighter.pro ex sources.path = $$[QT_INSTALL_EXAMPLES]/richtext/syntaxhighlighter INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: { addFiles.sources = main.cpp mainwindow.cpp addFiles.path = . diff --git a/examples/script/calculator/calculator.js b/examples/script/calculator/calculator.js index 62c2cba..ac3c1b6 100644 --- a/examples/script/calculator/calculator.js +++ b/examples/script/calculator/calculator.js @@ -1,10 +1,19 @@ +Function.prototype.bind = function() { + var func = this; + var thisObject = arguments[0]; + var args = Array.prototype.slice.call(arguments, 1); + return function() { + return func.apply(thisObject, args); + } +} + //! [0] function Calculator(ui) { this.ui = ui; - this.pendingAdditiveOperator = ""; - this.pendingMultiplicativeOperator = ""; + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; this.sumInMemory = 0; this.sumSoFar = 0; this.factorSoFar = 0; @@ -13,16 +22,16 @@ function Calculator(ui) with (ui) { display.text = "0"; - zeroButton.clicked.connect(this, this.digitClicked); - oneButton.clicked.connect(this, "digitClicked"); - twoButton.clicked.connect(this, "digitClicked"); - threeButton.clicked.connect(this, "digitClicked"); - fourButton.clicked.connect(this, "digitClicked"); - fiveButton.clicked.connect(this, "digitClicked"); - sixButton.clicked.connect(this, "digitClicked"); - sevenButton.clicked.connect(this, "digitClicked"); - eightButton.clicked.connect(this, "digitClicked"); - nineButton.clicked.connect(this, "digitClicked"); + zeroButton.clicked.connect(this.digitClicked.bind(this, 0)); + oneButton.clicked.connect(this.digitClicked.bind(this, 1)); + twoButton.clicked.connect(this.digitClicked.bind(this, 2)); + threeButton.clicked.connect(this.digitClicked.bind(this, 3)); + fourButton.clicked.connect(this.digitClicked.bind(this, 4)); + fiveButton.clicked.connect(this.digitClicked.bind(this, 5)); + sixButton.clicked.connect(this.digitClicked.bind(this, 6)); + sevenButton.clicked.connect(this.digitClicked.bind(this, 7)); + eightButton.clicked.connect(this.digitClicked.bind(this, 8)); + nineButton.clicked.connect(this.digitClicked.bind(this, 9)); pointButton.clicked.connect(this, "pointClicked"); changeSignButton.clicked.connect(this, "changeSignClicked"); @@ -36,19 +45,28 @@ function Calculator(ui) setMemoryButton.clicked.connect(this, "setMemory"); addToMemoryButton.clicked.connect(this, "addToMemory"); - divisionButton.clicked.connect(this, "multiplicativeOperatorClicked"); - timesButton.clicked.connect(this, "multiplicativeOperatorClicked"); - minusButton.clicked.connect(this, "additiveOperatorClicked"); - plusButton.clicked.connect(this, "additiveOperatorClicked"); - - squareRootButton.clicked.connect(this, "unaryOperatorClicked"); - powerButton.clicked.connect(this, "unaryOperatorClicked"); - reciprocalButton.clicked.connect(this, "unaryOperatorClicked"); + divisionButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.DIVISION_OPERATOR)); + timesButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.TIMES_OPERATOR)); + minusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.MINUS_OPERATOR)); + plusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.PLUS_OPERATOR)); + + squareRootButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.SQUARE_OPERATOR)); + powerButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.POWER_OPERATOR)); + reciprocalButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.RECIPROCAL_OPERATOR)); equalButton.clicked.connect(this, "equalClicked"); } } //! [0] +Calculator.NO_OPERATOR = 0; +Calculator.SQUARE_OPERATOR = 1; +Calculator.POWER_OPERATOR = 2; +Calculator.RECIPROCAL_OPERATOR = 3; +Calculator.DIVISION_OPERATOR = 4; +Calculator.TIMES_OPERATOR = 5; +Calculator.MINUS_OPERATOR = 6; +Calculator.PLUS_OPERATOR = 7; + Calculator.prototype.abortOperation = function() { this.clearAll(); @@ -57,24 +75,23 @@ Calculator.prototype.abortOperation = function() Calculator.prototype.calculate = function(rightOperand, pendingOperator) { - if (pendingOperator == "+") { + if (pendingOperator == Calculator.PLUS_OPERATOR) { this.sumSoFar += rightOperand; - } else if (pendingOperator == "-") { + } else if (pendingOperator == Calculator.MINUS_OPERATOR) { this.sumSoFar -= rightOperand; - } else if (pendingOperator == "*") { + } else if (pendingOperator == Calculator.TIMES_OPERATOR) { this.factorSoFar *= rightOperand; - } else if (pendingOperator == "/") { + } else if (pendingOperator == Calculator.DIVISION_OPERATOR) { if (rightOperand == 0) - return false; + return false; this.factorSoFar /= rightOperand; } return true; } //! [1] -Calculator.prototype.digitClicked = function() +Calculator.prototype.digitClicked = function(digitValue) { - var digitValue = __qt_sender__.text - 0; if ((digitValue == 0) && (this.ui.display.text == "0")) return; if (this.waitingForOperand) { @@ -85,19 +102,19 @@ Calculator.prototype.digitClicked = function() } //! [1] -Calculator.prototype.unaryOperatorClicked = function() +Calculator.prototype.unaryOperatorClicked = function(op) { var operand = this.ui.display.text - 0; var result = 0; - if (__qt_sender__.text == "Sqrt") { + if (op == Calculator.SQUARE_OPERATOR) { if (operand < 0) { this.abortOperation(); return; } result = Math.sqrt(operand); - } else if (__qt_sender__.text == "x^2") { + } else if (op == Calculator.POWER_OPERATOR) { result = Math.pow(operand, 2); - } else if (__qt_sender__.text == "1/x") { + } else if (op == Calculator.RECIPROCAL_OPERATOR) { if (operand == 0.0) { this.abortOperation(); return; @@ -108,11 +125,11 @@ Calculator.prototype.unaryOperatorClicked = function() this.waitingForOperand = true; } -Calculator.prototype.additiveOperatorClicked = function() +Calculator.prototype.additiveOperatorClicked = function(op) { var operand = this.ui.display.text - 0; - if (this.pendingMultiplicativeOperator.length != 0) { + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { this.abortOperation(); return; @@ -120,10 +137,10 @@ Calculator.prototype.additiveOperatorClicked = function() this.ui.display.text = this.factorSoFar + ""; operand = this.factorSoFar; this.factorSoFar = 0; - this.pendingMultiplicativeOperator = ""; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; } - if (this.pendingAdditiveOperator.length != 0) { + if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) { if (!this.calculate(operand, this.pendingAdditiveOperator)) { this.abortOperation(); return; @@ -133,15 +150,15 @@ Calculator.prototype.additiveOperatorClicked = function() this.sumSoFar = operand; } - this.pendingAdditiveOperator = __qt_sender__.text; + this.pendingAdditiveOperator = op; this.waitingForOperand = true; } -Calculator.prototype.multiplicativeOperatorClicked = function() +Calculator.prototype.multiplicativeOperatorClicked = function(op) { var operand = this.ui.display.text - 0; - if (this.pendingMultiplicativeOperator.length != 0) { + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { this.abortOperation(); return; @@ -151,7 +168,7 @@ Calculator.prototype.multiplicativeOperatorClicked = function() this.factorSoFar = operand; } - this.pendingMultiplicativeOperator = __qt_sender__.text; + this.pendingMultiplicativeOperator = op; this.waitingForOperand = true; } @@ -159,21 +176,21 @@ Calculator.prototype.equalClicked = function() { var operand = this.ui.display.text - 0; - if (this.pendingMultiplicativeOperator.length != 0) { + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { this.abortOperation(); return; } operand = this.factorSoFar; this.factorSoFar = 0.0; - this.pendingMultiplicativeOperator = ""; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; } - if (this.pendingAdditiveOperator.length != 0) { + if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) { if (!this.calculate(operand, this.pendingAdditiveOperator)) { this.abortOperation(); return; } - this.pendingAdditiveOperator = ""; + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; } else { this.sumSoFar = operand; } @@ -234,8 +251,8 @@ Calculator.prototype.clearAll = function() { this.sumSoFar = 0.0; this.factorSoFar = 0.0; - this.pendingAdditiveOperator = ""; - this.pendingMultiplicativeOperator = ""; + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; this.ui.display.text = "0"; this.waitingForOperand = true; } diff --git a/examples/script/calculator/calculator.pro b/examples/script/calculator/calculator.pro index 226d5f4..6385d7e 100644 --- a/examples/script/calculator/calculator.pro +++ b/examples/script/calculator/calculator.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/calculator sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.js *.ui sources.path = $$[QT_INSTALL_EXAMPLES]/script/calculator INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/calculator/main.cpp b/examples/script/calculator/main.cpp index 2f952bc..97e195e 100644 --- a/examples/script/calculator/main.cpp +++ b/examples/script/calculator/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char **argv) QScriptEngine engine; //! [0a] -#ifndef QT_NO_SCRIPTTOOLS +#if !defined(QT_NO_SCRIPTTOOLS) QScriptEngineDebugger debugger; debugger.attachTo(&engine); QMainWindow *debugWindow = debugger.standardWindow(); @@ -89,7 +89,7 @@ int main(int argc, char **argv) QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi); //! [2] -#ifndef QT_NO_SCRIPTTOOLS +#if !defined(QT_NO_SCRIPTTOOLS) QLineEdit *display = qFindChild<QLineEdit*>(ui, "display"); QObject::connect(display, SIGNAL(returnPressed()), debugWindow, SLOT(show())); diff --git a/examples/script/context2d/context2d.pro b/examples/script/context2d/context2d.pro index 30ec9a7..301c227 100644 --- a/examples/script/context2d/context2d.pro +++ b/examples/script/context2d/context2d.pro @@ -21,3 +21,12 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/context2d sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS context2d.pro scripts sources.path = $$[QT_INSTALL_EXAMPLES]/script/context2d INSTALLS += target sources + +symbian:{ + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C608 + TARGET.EPOCHEAPSIZE = 0x200000 0xA00000 + contextScripts.path = . + contextScripts.sources = scripts + DEPLOYMENT += contextScripts +} diff --git a/examples/script/context2d/main.cpp b/examples/script/context2d/main.cpp index c9a8898..a61452a 100644 --- a/examples/script/context2d/main.cpp +++ b/examples/script/context2d/main.cpp @@ -48,6 +48,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); Window win; - win.show(); + //win.show(); + win.showFullScreen(); return app.exec(); } diff --git a/examples/script/context2d/qcontext2dcanvas.cpp b/examples/script/context2d/qcontext2dcanvas.cpp index f4f74c4..e1e6a30 100644 --- a/examples/script/context2d/qcontext2dcanvas.cpp +++ b/examples/script/context2d/qcontext2dcanvas.cpp @@ -85,6 +85,11 @@ void QContext2DCanvas::contentsChanged(const QImage &image) void QContext2DCanvas::paintEvent(QPaintEvent *e) { QPainter p(this); +#ifdef Q_WS_S60 +// Draw white rect first since in with some themes the js-file content will produce black-on-black. + QBrush whiteBgBrush(Qt::white); + p.fillRect(e->rect(), whiteBgBrush); +#endif p.setClipRect(e->rect()); p.drawImage(0, 0, m_image); } diff --git a/examples/script/context2d/window.cpp b/examples/script/context2d/window.cpp index f370da9..a6c2203 100644 --- a/examples/script/context2d/window.cpp +++ b/examples/script/context2d/window.cpp @@ -67,6 +67,9 @@ static QString scriptsDir() //! [0] Window::Window(QWidget *parent) : QWidget(parent) +#ifndef QT_NO_SCRIPTTOOLS + , m_debugger(0), m_debugWindow(0) +#endif { m_env = new Environment(this); QObject::connect(m_env, SIGNAL(scriptError(QScriptValue)), @@ -107,14 +110,6 @@ Window::Window(QWidget *parent) this, SLOT(selectScript(QListWidgetItem*))); //! [1] -#ifndef QT_NO_SCRIPTTOOLS - m_debugger = new QScriptEngineDebugger(this); - m_debugger->attachTo(m_env->engine()); - m_debugWindow = m_debugger->standardWindow(); - m_debugWindow->setWindowModality(Qt::ApplicationModal); - m_debugWindow->resize(1280, 704); -#endif - setWindowTitle(tr("Context 2D")); } @@ -156,8 +151,19 @@ void Window::runScript(const QString &fileName, bool debug) m_env->reset(); #ifndef QT_NO_SCRIPTTOOLS - if (debug) + if (debug) { + if (!m_debugger) { + m_debugger = new QScriptEngineDebugger(this); + m_debugWindow = m_debugger->standardWindow(); + m_debugWindow->setWindowModality(Qt::ApplicationModal); + m_debugWindow->resize(1280, 704); + } + m_debugger->attachTo(m_env->engine()); m_debugger->action(QScriptEngineDebugger::InterruptAction)->trigger(); + } else { + if (m_debugger) + m_debugger->detach(); + } #else Q_UNUSED(debug); #endif @@ -165,7 +171,8 @@ void Window::runScript(const QString &fileName, bool debug) QScriptValue ret = m_env->evaluate(contents, fileName); #ifndef QT_NO_SCRIPTTOOLS - m_debugWindow->hide(); + if (m_debugWindow) + m_debugWindow->hide(); #endif if (ret.isError()) diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 7400a7c..8dc2033 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -100,7 +100,7 @@ ByteArrayClass::ByteArrayClass(QScriptEngine *engine) QScriptValue global = engine->globalObject(); proto.setPrototype(global.property("Object").property("prototype")); - ctor = engine->newFunction(construct); + ctor = engine->newFunction(construct, proto); ctor.setData(qScriptValueFromValue(engine, this)); } //! [0] @@ -224,7 +224,10 @@ QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *) ByteArrayClass *cls = qscriptvalue_cast<ByteArrayClass*>(ctx->callee().data()); if (!cls) return QScriptValue(); - int size = ctx->argument(0).toInt32(); + QScriptValue arg = ctx->argument(0); + if (arg.instanceOf(ctx->callee())) + return cls->newInstance(qscriptvalue_cast<QByteArray>(arg)); + int size = arg.toInt32(); return cls->newInstance(size); } //! [2] @@ -240,7 +243,7 @@ QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba) { - ba = qscriptvalue_cast<QByteArray>(obj.data()); + ba = qvariant_cast<QByteArray>(obj.data().toVariant()); } @@ -294,7 +297,7 @@ void ByteArrayClassPropertyIterator::toBack() QScriptString ByteArrayClassPropertyIterator::name() const { - return QScriptString(); + return object().engine()->toStringHandle(QString::number(m_last)); } uint ByteArrayClassPropertyIterator::id() const diff --git a/examples/script/customclass/customclass.pro b/examples/script/customclass/customclass.pro index ba7f69d..3302d54 100644 --- a/examples/script/customclass/customclass.pro +++ b/examples/script/customclass/customclass.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/customclass sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.pri sources.path = $$[QT_INSTALL_EXAMPLES]/script/customclass INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/customclass/main.cpp b/examples/script/customclass/main.cpp index 2ddcfaa..8ccb09a 100644 --- a/examples/script/customclass/main.cpp +++ b/examples/script/customclass/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char **argv) eng.globalObject().setProperty("ByteArray", baClass->constructor()); qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString(); + qDebug() << "ba instanceof ByteArray:" << eng.evaluate("ba instanceof ByteArray").toBool(); qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber(); qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber(); qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber(); @@ -65,6 +66,9 @@ int main(int argc, char **argv) qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString(); qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString(); qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber(); + qDebug() << "ba2 = new ByteArray(ba):" << eng.evaluate("ba2 = new ByteArray(ba)").toString(); + qDebug() << "ba2.equals(ba):" << eng.evaluate("ba2.equals(ba)").toBool(); + qDebug() << "ba2.equals(new ByteArray()):" << eng.evaluate("ba2.equals(new ByteArray())").toBool(); return 0; } diff --git a/examples/script/defaultprototypes/defaultprototypes.pro b/examples/script/defaultprototypes/defaultprototypes.pro index b9a6765..7cf44d2 100644 --- a/examples/script/defaultprototypes/defaultprototypes.pro +++ b/examples/script/defaultprototypes/defaultprototypes.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/defaultprototypes sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.js defaultprototypes.pro sources.path = $$[QT_INSTALL_EXAMPLES]/script/defaultprototypes INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/helloscript/helloscript.pro b/examples/script/helloscript/helloscript.pro index d94a318..850629e 100644 --- a/examples/script/helloscript/helloscript.pro +++ b/examples/script/helloscript/helloscript.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/helloscript sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS helloscript.pro sources.path = $$[QT_INSTALL_EXAMPLES]/script/helloscript INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/marshal/marshal.pro b/examples/script/marshal/marshal.pro index 46b33b9..4a1fc27 100644 --- a/examples/script/marshal/marshal.pro +++ b/examples/script/marshal/marshal.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/marshal sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS marshal.pro sources.path = $$[QT_INSTALL_EXAMPLES]/script/marshal INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/qscript/qscript.pro b/examples/script/qscript/qscript.pro index 759eedf..4f33459 100644 --- a/examples/script/qscript/qscript.pro +++ b/examples/script/qscript/qscript.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/script/qscript sources.files = $$RESOURCES $$FORMS main.cpp qscript.pro sources.path = $$[QT_INSTALL_EXAMPLES]/script/qscript INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/script/qsdbg/qsdbg.pro b/examples/script/qsdbg/qsdbg.pro index c199123..77b55a2 100644 --- a/examples/script/qsdbg/qsdbg.pro +++ b/examples/script/qsdbg/qsdbg.pro @@ -16,4 +16,6 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qsdbg.pro sources.path = $$[QT_INSTALL_EXAMPLES]/script/qsdbg INSTALLS += target sources +include($$QT_SOURCE_TREE/examples/examplebase.pri) + diff --git a/examples/script/qstetrix/main.cpp b/examples/script/qstetrix/main.cpp index c7a9587..87aaae2 100644 --- a/examples/script/qstetrix/main.cpp +++ b/examples/script/qstetrix/main.cpp @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) engine.globalObject().setProperty("Qt", Qt); //! [1] -#ifndef QT_NO_SCRIPTTOOLS +#if !defined(QT_NO_SCRIPTTOOLS) QScriptEngineDebugger debugger; debugger.attachTo(&engine); QMainWindow *debugWindow = debugger.standardWindow(); @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) //! [3] QPushButton *debugButton = qFindChild<QPushButton*>(ui, "debugButton"); -#ifndef QT_NO_SCRIPTTOOLS +#if !defined(QT_NO_SCRIPTTOOLS) QObject::connect(debugButton, SIGNAL(clicked()), debugger.action(QScriptEngineDebugger::InterruptAction), SIGNAL(triggered())); diff --git a/examples/script/script.pro b/examples/script/script.pro index ae3542e..5f3d04a 100644 --- a/examples/script/script.pro +++ b/examples/script/script.pro @@ -4,8 +4,12 @@ SUBDIRS = helloscript context2d defaultprototypes customclass !wince*:SUBDIRS += qscript marshal !wince*:!cross_compile:SUBDIRS += calculator qstetrix +symbian: SUBDIRS = context2d + # install target.path = $$[QT_INSTALL_EXAMPLES]/script sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS script.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/script INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/cachedtable/cachedtable.pro b/examples/sql/cachedtable/cachedtable.pro index a14aa42..288ec28 100644 --- a/examples/sql/cachedtable/cachedtable.pro +++ b/examples/sql/cachedtable/cachedtable.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/cachedtable sources.files = $$SOURCES *.h $$RESOURCES $$FORMS cachedtable.pro sources.path = $$[QT_INSTALL_EXAMPLES]/sql/cachedtable INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/drilldown/drilldown.pro b/examples/sql/drilldown/drilldown.pro index e15a4ad..b6de511 100644 --- a/examples/sql/drilldown/drilldown.pro +++ b/examples/sql/drilldown/drilldown.pro @@ -1,7 +1,7 @@ HEADERS = ../connection.h \ imageitem.h \ informationwindow.h \ - view.h + view.h RESOURCES = drilldown.qrc SOURCES = imageitem.cpp \ informationwindow.cpp \ @@ -14,3 +14,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/drilldown sources.files = $$SOURCES *.h $$RESOURCES $$FORMS drilldown.pro *.png *.jpg images sources.path = $$[QT_INSTALL_EXAMPLES]/sql/drilldown INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C612 +} diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp index 13f10b5..82737fc 100644 --- a/examples/sql/drilldown/informationwindow.cpp +++ b/examples/sql/drilldown/informationwindow.cpp @@ -101,7 +101,9 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *offices, setWindowFlags(Qt::Window); enableButtons(false); setWindowTitle(tr("Office: %1").arg(locationText->text())); +#ifndef Q_OS_SYMBIAN resize(320, sizeHint().height()); +#endif } //! [4] diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp index 249fce3..433ef34 100644 --- a/examples/sql/drilldown/main.cpp +++ b/examples/sql/drilldown/main.cpp @@ -54,6 +54,10 @@ int main(int argc, char *argv[]) return 1; View view("offices", "images"); +#ifndef Q_OS_SYMBIAN view.show(); +#else + view.showFullScreen(); +#endif return app.exec(); } diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp index 8fc40c6..dfb45c7 100644 --- a/examples/sql/drilldown/view.cpp +++ b/examples/sql/drilldown/view.cpp @@ -63,9 +63,14 @@ View::View(const QString &offices, const QString &images, QWidget *parent) QGraphicsPixmapItem *logo = scene->addPixmap(QPixmap(":/logo.png")); logo->setPos(30, 515); +#ifndef Q_OS_SYMBIAN setMinimumSize(470, 620); setMaximumSize(470, 620); - setWindowTitle(tr("Offices World Wide")); +#else + setDragMode(QGraphicsView::ScrollHandDrag); +#endif + + setWindowTitle(tr("Offices World Wide")); } //! [1] @@ -126,7 +131,11 @@ void View::showInformation(ImageItem *image) window->raise(); window->activateWindow(); } else if (window && !window->isVisible()) { +#ifndef Q_OS_SYMBIAN window->show(); +#else + window->showFullScreen(); +#endif } else { InformationWindow *window; window = new InformationWindow(id, officeTable, this); @@ -134,8 +143,12 @@ void View::showInformation(ImageItem *image) connect(window, SIGNAL(imageChanged(int, QString)), this, SLOT(updateImage(int, QString))); +#ifndef Q_OS_SYMBIAN window->move(pos() + QPoint(20, 40)); window->show(); +#else + window->showFullScreen(); +#endif informationWindows.append(window); } } diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp index 227297d..e9c770c 100644 --- a/examples/sql/masterdetail/mainwindow.cpp +++ b/examples/sql/masterdetail/mainwindow.cpp @@ -362,7 +362,7 @@ void MainWindow::createMenuBar() addAction->setShortcut(tr("Ctrl+A")); deleteAction->setShortcut(tr("Ctrl+D")); - quitAction->setShortcut(tr("Ctrl+Q")); + quitAction->setShortcuts(QKeySequence::Quit); QMenu *fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(addAction); diff --git a/examples/sql/masterdetail/masterdetail.pro b/examples/sql/masterdetail/masterdetail.pro index 205c544..89e7e73 100644 --- a/examples/sql/masterdetail/masterdetail.pro +++ b/examples/sql/masterdetail/masterdetail.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/masterdetail sources.files = $$SOURCES *.h $$RESOURCES $$FORMS masterdetail.pro *.xml images sources.path = $$[QT_INSTALL_EXAMPLES]/sql/masterdetail INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/querymodel/querymodel.pro b/examples/sql/querymodel/querymodel.pro index e0e0813..32c217d 100644 --- a/examples/sql/querymodel/querymodel.pro +++ b/examples/sql/querymodel/querymodel.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/querymodel sources.files = $$SOURCES *.h $$RESOURCES $$FORMS querymodel.pro sources.path = $$[QT_INSTALL_EXAMPLES]/sql/querymodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.pro b/examples/sql/relationaltablemodel/relationaltablemodel.pro index 38f1e21..32c04b6 100644 --- a/examples/sql/relationaltablemodel/relationaltablemodel.pro +++ b/examples/sql/relationaltablemodel/relationaltablemodel.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/relationaltablemodel sources.files = $$SOURCES *.h $$RESOURCES $$FORMS relationaltablemodel.pro sources.path = $$[QT_INSTALL_EXAMPLES]/sql/relationaltablemodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/sql.pro b/examples/sql/sql.pro index 6d0d402..644e2c7 100644 --- a/examples/sql/sql.pro +++ b/examples/sql/sql.pro @@ -1,12 +1,18 @@ TEMPLATE = subdirs -SUBDIRS = cachedtable \ - drilldown \ - relationaltablemodel \ - sqlwidgetmapper -!wince*: SUBDIRS += querymodel tablemodel masterdetail +SUBDIRS = drilldown +!symbian: SUBDIRS += cachedtable \ + relationaltablemodel \ + sqlwidgetmapper + +!wince*:!symbian: SUBDIRS += \ + querymodel \ + tablemodel \ + masterdetail # install sources.files = connection.h sql.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/sql INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/sql/tablemodel/tablemodel.pro b/examples/sql/tablemodel/tablemodel.pro index 4d099d0..700029c 100644 --- a/examples/sql/tablemodel/tablemodel.pro +++ b/examples/sql/tablemodel/tablemodel.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/sql/tablemodel sources.files = $$SOURCES *.h $$RESOURCES $$FORMS tablemodel.pro sources.path = $$[QT_INSTALL_EXAMPLES]/sql/tablemodel INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/statemachine/README b/examples/statemachine/README new file mode 100644 index 0000000..2879e67 --- /dev/null +++ b/examples/statemachine/README @@ -0,0 +1,36 @@ +Qt is provided with a powerful hierchical finite state machine through +the Qt State Machine classes. + +The example launcher provided with Qt can be used to explore each of the +examples in this directory. + +Documentation for these examples can be found via the Tutorial and Examples +link in the main Qt documentation. + + +Finding the Qt Examples and Demos launcher +========================================== + +On Windows: + +The launcher can be accessed via the Windows Start menu. Select the menu +entry entitled "Qt Examples and Demos" entry in the submenu containing +the Qt tools. + +On Mac OS X: + +For the binary distribution, the qtdemo executable is installed in the +/Developer/Applications/Qt directory. For the source distribution, it is +installed alongside the other Qt tools on the path specified when Qt is +configured. + +On Unix/Linux: + +The qtdemo executable is installed alongside the other Qt tools on the path +specified when Qt is configured. + +On all platforms: + +The source code for the launcher can be found in the demos/qtdemo directory +in the Qt package. This example is built at the same time as the Qt libraries, +tools, examples, and demonstrations. diff --git a/examples/statemachine/eventtransitions/eventtransitions.pro b/examples/statemachine/eventtransitions/eventtransitions.pro new file mode 100644 index 0000000..7e92cf2 --- /dev/null +++ b/examples/statemachine/eventtransitions/eventtransitions.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/eventtransitions +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS eventtransitions.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/eventtransitions +INSTALLS += target sources diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp new file mode 100644 index 0000000..a06186f --- /dev/null +++ b/examples/statemachine/eventtransitions/main.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +//! [0] +class Window : public QWidget +{ +public: + Window(QWidget *parent = 0) + : QWidget(parent) + { + QPushButton *button = new QPushButton(this); + button->setGeometry(QRect(100, 100, 100, 100)); +//! [0] + +//! [1] + QStateMachine *machine = new QStateMachine(this); + + QState *s1 = new QState(); + s1->assignProperty(button, "text", "Outside"); + + QState *s2 = new QState(); + s2->assignProperty(button, "text", "Inside"); +//! [1] + +//! [2] + QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter); + enterTransition->setTargetState(s2); + s1->addTransition(enterTransition); +//! [2] + +//! [3] + QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave); + leaveTransition->setTargetState(s1); + s2->addTransition(leaveTransition); +//! [3] + +//! [4] + QState *s3 = new QState(); + s3->assignProperty(button, "text", "Pressing..."); + + QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress); + pressTransition->setTargetState(s3); + s2->addTransition(pressTransition); + + QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease); + releaseTransition->setTargetState(s2); + s3->addTransition(releaseTransition); +//! [4] + +//! [5] + machine->addState(s1); + machine->addState(s2); + machine->addState(s3); + + machine->setInitialState(s1); + machine->start(); + } +}; +//! [5] + +//! [6] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Window window; + window.resize(300, 300); + window.show(); + + return app.exec(); +} +//! [6] diff --git a/examples/statemachine/factorial/factorial.pro b/examples/statemachine/factorial/factorial.pro new file mode 100644 index 0000000..14a6833 --- /dev/null +++ b/examples/statemachine/factorial/factorial.pro @@ -0,0 +1,11 @@ +QT = core +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/factorial +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS factorial.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/factorial +INSTALLS += target sources diff --git a/examples/statemachine/factorial/main.cpp b/examples/statemachine/factorial/main.cpp new file mode 100644 index 0000000..32916f8 --- /dev/null +++ b/examples/statemachine/factorial/main.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <stdio.h> + +//! [0] +class Factorial : public QObject +{ + Q_OBJECT + Q_PROPERTY(int x READ x WRITE setX) + Q_PROPERTY(int fac READ fac WRITE setFac) +public: + Factorial(QObject *parent = 0) + : QObject(parent), m_x(-1), m_fac(1) + { + } + + int x() const + { + return m_x; + } + + void setX(int x) + { + if (x == m_x) + return; + m_x = x; + emit xChanged(x); + } + + int fac() const + { + return m_fac; + } + + void setFac(int fac) + { + m_fac = fac; + } + +Q_SIGNALS: + void xChanged(int value); + +private: + int m_x; + int m_fac; +}; +//! [0] + +//! [1] +class FactorialLoopTransition : public QSignalTransition +{ +public: + FactorialLoopTransition(Factorial *fact) + : QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact) + {} + + virtual bool eventTest(QEvent *e) + { + if (!QSignalTransition::eventTest(e)) + return false; + QSignalEvent *se = static_cast<QSignalEvent*>(e); + return se->arguments().at(0).toInt() > 1; + } + + virtual void onTransition(QEvent *e) + { + QSignalEvent *se = static_cast<QSignalEvent*>(e); + int x = se->arguments().at(0).toInt(); + int fac = m_fact->property("fac").toInt(); + m_fact->setProperty("fac", x * fac); + m_fact->setProperty("x", x - 1); + } + +private: + Factorial *m_fact; +}; +//! [1] + +//! [2] +class FactorialDoneTransition : public QSignalTransition +{ +public: + FactorialDoneTransition(Factorial *fact) + : QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact) + {} + + virtual bool eventTest(QEvent *e) + { + if (!QSignalTransition::eventTest(e)) + return false; + QSignalEvent *se = static_cast<QSignalEvent*>(e); + return se->arguments().at(0).toInt() <= 1; + } + + virtual void onTransition(QEvent *) + { + fprintf(stdout, "%d\n", m_fact->property("fac").toInt()); + } + +private: + Factorial *m_fact; +}; +//! [2] + +//! [3] +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + Factorial factorial; + QStateMachine machine; +//! [3] + +//! [4] + QState *compute = new QState(&machine); + compute->assignProperty(&factorial, "fac", 1); + compute->assignProperty(&factorial, "x", 6); + compute->addTransition(new FactorialLoopTransition(&factorial)); +//! [4] + +//! [5] + QFinalState *done = new QFinalState(&machine); + FactorialDoneTransition *doneTransition = new FactorialDoneTransition(&factorial); + doneTransition->setTargetState(done); + compute->addTransition(doneTransition); +//! [5] + +//! [6] + machine.setInitialState(compute); + QObject::connect(&machine, SIGNAL(finished()), &app, SLOT(quit())); + machine.start(); + + return app.exec(); +} +//! [6] + +#include "main.moc" diff --git a/examples/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp new file mode 100644 index 0000000..7961923 --- /dev/null +++ b/examples/statemachine/pingpong/main.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> +#include <stdio.h> + +//! [0] +class PingEvent : public QEvent +{ +public: + PingEvent() : QEvent(QEvent::Type(QEvent::User+2)) + {} +}; + +class PongEvent : public QEvent +{ +public: + PongEvent() : QEvent(QEvent::Type(QEvent::User+3)) + {} +}; +//! [0] + +//! [1] +class Pinger : public QState +{ +public: + Pinger(QState *parent) + : QState(parent) {} + +protected: + virtual void onEntry(QEvent *) + { + machine()->postEvent(new PingEvent()); + fprintf(stdout, "ping?\n"); + } +}; +//! [1] + +//! [3] +class PongTransition : public QAbstractTransition +{ +public: + PongTransition() {} + +protected: + virtual bool eventTest(QEvent *e) { + return (e->type() == QEvent::User+3); + } + virtual void onTransition(QEvent *) + { + machine()->postEvent(new PingEvent(), 500); + fprintf(stdout, "ping?\n"); + } +}; +//! [3] + +//! [2] +class PingTransition : public QAbstractTransition +{ +public: + PingTransition() {} + +protected: + virtual bool eventTest(QEvent *e) { + return (e->type() == QEvent::User+2); + } + virtual void onTransition(QEvent *) + { + machine()->postEvent(new PongEvent(), 500); + fprintf(stdout, "pong!\n"); + } +}; +//! [2] + +//! [4] +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QStateMachine machine; + QState *group = new QState(QState::ParallelStates); + group->setObjectName("group"); +//! [4] + +//! [5] + Pinger *pinger = new Pinger(group); + pinger->setObjectName("pinger"); + pinger->addTransition(new PongTransition()); + + QState *ponger = new QState(group); + ponger->setObjectName("ponger"); + ponger->addTransition(new PingTransition()); +//! [5] + +//! [6] + machine.addState(group); + machine.setInitialState(group); + machine.start(); + + return app.exec(); +} +//! [6] diff --git a/examples/statemachine/pingpong/pingpong.pro b/examples/statemachine/pingpong/pingpong.pro new file mode 100644 index 0000000..42eab6c --- /dev/null +++ b/examples/statemachine/pingpong/pingpong.pro @@ -0,0 +1,11 @@ +QT = core +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/pingpong +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pingpong.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/pingpong +INSTALLS += target sources diff --git a/examples/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp new file mode 100644 index 0000000..b55331c --- /dev/null +++ b/examples/statemachine/rogue/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "window.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + Window window; + window.show(); + + return app.exec(); +} + diff --git a/examples/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h new file mode 100644 index 0000000..1da8bc7 --- /dev/null +++ b/examples/statemachine/rogue/movementtransition.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MOVEMENTTRANSITION_H +#define MOVEMENTTRANSITION_H + +#include <QtGui> + +#include "window.h" + +//![0] +class MovementTransition : public QEventTransition +{ + Q_OBJECT + +public: + MovementTransition(Window *window) : + QEventTransition(window, QEvent::KeyPress) { + this->window = window; + } +//![0] + +//![1] +protected: + bool eventTest(QEvent *event) { + if (event->type() == QEvent::Wrapped && + static_cast<QWrappedEvent *>(event)->event()->type() == QEvent::KeyPress) { + QEvent *wrappedEvent = static_cast<QWrappedEvent *>(event)->event(); + + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(wrappedEvent); + int key = keyEvent->key(); + + return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 || + key == Qt::Key_4; + } + return false; + } +//![1] + +//![2] + void onTransition(QEvent *event) { + QKeyEvent *keyEvent = static_cast<QKeyEvent *>( + static_cast<QWrappedEvent *>(event)->event()); + + int key = keyEvent->key(); + switch (key) { + case Qt::Key_4: + window->movePlayer(Window::Left); + break; + case Qt::Key_8: + window->movePlayer(Window::Up); + break; + case Qt::Key_6: + window->movePlayer(Window::Right); + break; + case Qt::Key_2: + window->movePlayer(Window::Down); + break; + default: + ; + } + } +//![2] + +private: + Window *window; +}; + +#endif + diff --git a/examples/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro new file mode 100644 index 0000000..1571854 --- /dev/null +++ b/examples/statemachine/rogue/rogue.pro @@ -0,0 +1,11 @@ +HEADERS = window.h \ + movementtransition.h +SOURCES = main.cpp \ + window.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/rogue +sources.files = $$SOURCES $$HEADERS *.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/rogue +INSTALLS += target sources + diff --git a/examples/statemachine/rogue/window.cpp b/examples/statemachine/rogue/window.cpp new file mode 100644 index 0000000..f6991f1 --- /dev/null +++ b/examples/statemachine/rogue/window.cpp @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +#include "window.h" +#include "movementtransition.h" + +//![0] +Window::Window() +{ + pX = 5; + pY = 5; +//![0] + + QFontDatabase database; + QFont font; + if (database.families().contains("Monospace")) + font = QFont("Monospace", 12); + else { + foreach (QString family, database.families()) { + if (database.isFixedPitch(family)) { + font = QFont(family, 12); + break; + } + } + } + setFont(font); + +//![1] + setupMap(); + buildMachine(); +} +//![1] + +void Window::setStatus(const QString &status) +{ + myStatus = status; + repaint(); +} + +QString Window::status() const +{ + return myStatus; +} + +void Window::paintEvent(QPaintEvent * /* event */) +{ + QFontMetrics metrics(font()); + QPainter painter(this); + int fontHeight = metrics.height(); + int fontWidth = metrics.width('X'); + int yPos = fontHeight; + int xPos; + + painter.fillRect(rect(), Qt::black); + painter.setPen(Qt::white); + + painter.drawText(QPoint(0, yPos), status()); + + for (int y = 0; y < HEIGHT; ++y) { + yPos += fontHeight; + xPos = 0; + + for (int x = 0; x < WIDTH; ++x) { + if (y == pY && x == pX) { + xPos += fontWidth; + continue; + } + + painter.drawText(QPoint(xPos, yPos), map[x][y]); + xPos += fontWidth; + } + } + painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@')); +} + +QSize Window::sizeHint() const +{ + QFontMetrics metrics(font()); + + return QSize(metrics.width('X') * WIDTH, metrics.height() * (HEIGHT + 1)); +} + +//![2] +void Window::buildMachine() +{ + machine = new QStateMachine; + + QState *inputState = new QState(machine); + inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8"); + + MovementTransition *transition = new MovementTransition(this); + inputState->addTransition(transition); +//![2] + +//![3] + QState *quitState = new QState(machine); + quitState->assignProperty(this, "status", "Really quit(y/n)?"); + + QKeyEventTransition *yesTransition = new + QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y); + yesTransition->setTargetState(new QFinalState(machine)); + quitState->addTransition(yesTransition); + + QKeyEventTransition *noTransition = + new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N); + noTransition->setTargetState(inputState); + quitState->addTransition(noTransition); +//![3] + +//![4] + QKeyEventTransition *quitTransition = + new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q); + quitTransition->setTargetState(quitState); + inputState->addTransition(quitTransition); +//![4] + +//![5] + machine->setInitialState(inputState); + + connect(machine, SIGNAL(finished()), qApp, SLOT(quit())); + + machine->start(); +} +//![5] + +void Window::movePlayer(Direction direction) +{ + switch (direction) { + case Left: + if (map[pX - 1][pY] != '#') + --pX; + break; + case Right: + if (map[pX + 1][pY] != '#') + ++pX; + break; + case Up: + if (map[pX][pY - 1] != '#') + --pY; + break; + case Down: + if (map[pX][pY + 1] != '#') + ++pY; + break; + } + repaint(); +} + +void Window::setupMap() +{ + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + for (int x = 0; x < WIDTH; ++x) + for (int y = 0; y < HEIGHT; ++y) { + if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || qrand() % 40 == 0) + map[x][y] = '#'; + else + map[x][y] = '.'; + } +} + diff --git a/examples/statemachine/rogue/window.h b/examples/statemachine/rogue/window.h new file mode 100644 index 0000000..50b40d1 --- /dev/null +++ b/examples/statemachine/rogue/window.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +class QState; +class QStateMachine; +class QTransition; +QT_END_NAMESPACE + +#define WIDTH 35 +#define HEIGHT 20 + +//![0] +class Window : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QString status READ status WRITE setStatus) + +public: + enum Direction { Up, Down, Left, Right }; + + Window(); + + void movePlayer(Direction direction); + void setStatus(const QString &status); + QString status() const; + + QSize sizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); +//![0] + +//![1] +private: + void buildMachine(); + void setupMap(); + + QChar map[WIDTH][HEIGHT]; + int pX, pY; + + QStateMachine *machine; + QString myStatus; +}; +//![1] + +#endif + diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro new file mode 100644 index 0000000..298c0ae --- /dev/null +++ b/examples/statemachine/statemachine.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs +SUBDIRS = \ + eventtransitions \ + factorial \ + pingpong \ + rogue \ + trafficlight \ + twowaybutton + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS statemachine.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine +INSTALLS += target sources diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp new file mode 100644 index 0000000..2b64a98 --- /dev/null +++ b/examples/statemachine/trafficlight/main.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +//! [0] +class LightWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(bool on READ isOn WRITE setOn) +public: + LightWidget(const QColor &color, QWidget *parent = 0) + : QWidget(parent), m_color(color), m_on(false) {} + + bool isOn() const + { return m_on; } + void setOn(bool on) + { + if (on == m_on) + return; + m_on = on; + update(); + } + +public slots: + void turnOff() { setOn(false); } + void turnOn() { setOn(true); } + +protected: + virtual void paintEvent(QPaintEvent *) + { + if (!m_on) + return; + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(m_color); + painter.drawEllipse(0, 0, width(), height()); + } + +private: + QColor m_color; + bool m_on; +}; +//! [0] + +//! [1] +class TrafficLightWidget : public QWidget +{ +public: + TrafficLightWidget(QWidget *parent = 0) + : QWidget(parent) + { + QVBoxLayout *vbox = new QVBoxLayout(this); + m_red = new LightWidget(Qt::red); + vbox->addWidget(m_red); + m_yellow = new LightWidget(Qt::yellow); + vbox->addWidget(m_yellow); + m_green = new LightWidget(Qt::green); + vbox->addWidget(m_green); + QPalette pal = palette(); + pal.setColor(QPalette::Background, Qt::black); + setPalette(pal); + setAutoFillBackground(true); + } + + LightWidget *redLight() const + { return m_red; } + LightWidget *yellowLight() const + { return m_yellow; } + LightWidget *greenLight() const + { return m_green; } + +private: + LightWidget *m_red; + LightWidget *m_yellow; + LightWidget *m_green; +}; +//! [1] + +//! [2] +QState *createLightState(LightWidget *light, int duration, QState *parent = 0) +{ + QState *lightState = new QState(parent); + QTimer *timer = new QTimer(lightState); + timer->setInterval(duration); + timer->setSingleShot(true); + QState *timing = new QState(lightState); + QObject::connect(timing, SIGNAL(entered()), light, SLOT(turnOn())); + QObject::connect(timing, SIGNAL(entered()), timer, SLOT(start())); + QObject::connect(timing, SIGNAL(exited()), light, SLOT(turnOff())); + QFinalState *done = new QFinalState(lightState); + timing->addTransition(timer, SIGNAL(timeout()), done); + lightState->setInitialState(timing); + return lightState; +} +//! [2] + +//! [3] +class TrafficLight : public QWidget +{ +public: + TrafficLight(QWidget *parent = 0) + : QWidget(parent) + { + QVBoxLayout *vbox = new QVBoxLayout(this); + TrafficLightWidget *widget = new TrafficLightWidget(); + vbox->addWidget(widget); + vbox->setMargin(0); + + QStateMachine *machine = new QStateMachine(this); + QState *redGoingYellow = createLightState(widget->redLight(), 3000); + redGoingYellow->setObjectName("redGoingYellow"); + QState *yellowGoingGreen = createLightState(widget->yellowLight(), 1000); + yellowGoingGreen->setObjectName("yellowGoingGreen"); + redGoingYellow->addTransition(redGoingYellow, SIGNAL(finished()), yellowGoingGreen); + QState *greenGoingYellow = createLightState(widget->greenLight(), 3000); + greenGoingYellow->setObjectName("greenGoingYellow"); + yellowGoingGreen->addTransition(yellowGoingGreen, SIGNAL(finished()), greenGoingYellow); + QState *yellowGoingRed = createLightState(widget->yellowLight(), 1000); + yellowGoingRed->setObjectName("yellowGoingRed"); + greenGoingYellow->addTransition(greenGoingYellow, SIGNAL(finished()), yellowGoingRed); + yellowGoingRed->addTransition(yellowGoingRed, SIGNAL(finished()), redGoingYellow); + + machine->addState(redGoingYellow); + machine->addState(yellowGoingGreen); + machine->addState(greenGoingYellow); + machine->addState(yellowGoingRed); + machine->setInitialState(redGoingYellow); + machine->start(); + } +}; +//! [3] + +//! [4] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + TrafficLight widget; + widget.resize(110, 300); + widget.show(); + + return app.exec(); +} +//! [4] + +#include "main.moc" diff --git a/examples/statemachine/trafficlight/trafficlight.pro b/examples/statemachine/trafficlight/trafficlight.pro new file mode 100644 index 0000000..684575a --- /dev/null +++ b/examples/statemachine/trafficlight/trafficlight.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/trafficlight +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS trafficlight.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/trafficlight +INSTALLS += target sources diff --git a/examples/statemachine/twowaybutton/main.cpp b/examples/statemachine/twowaybutton/main.cpp new file mode 100644 index 0000000..b6cef44 --- /dev/null +++ b/examples/statemachine/twowaybutton/main.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> + +//! [0] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QPushButton button; + QStateMachine machine; +//! [0] + +//! [1] + QState *off = new QState(); + off->assignProperty(&button, "text", "Off"); + off->setObjectName("off"); + + QState *on = new QState(); + on->setObjectName("on"); + on->assignProperty(&button, "text", "On"); +//! [1] + +//! [2] + off->addTransition(&button, SIGNAL(clicked()), on); + on->addTransition(&button, SIGNAL(clicked()), off); +//! [2] + +//! [3] + machine.addState(off); + machine.addState(on); +//! [3] + +//! [4] + machine.setInitialState(off); + machine.start(); +//! [4] + +//! [5] + button.resize(100, 50); + button.show(); + return app.exec(); +} +//! [5] diff --git a/examples/statemachine/twowaybutton/twowaybutton.pro b/examples/statemachine/twowaybutton/twowaybutton.pro new file mode 100644 index 0000000..f6cbc57 --- /dev/null +++ b/examples/statemachine/twowaybutton/twowaybutton.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/twowaybutton +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS twowaybutton.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/twowaybutton +INSTALLS += target sources diff --git a/examples/symbianpkgrules.pri b/examples/symbianpkgrules.pri new file mode 100644 index 0000000..59c5480 --- /dev/null +++ b/examples/symbianpkgrules.pri @@ -0,0 +1,13 @@ +!symbian: error(Only include this file for Symbian platforms) + +RSS_RULES ="group_name=\"QtExamples\";" + +vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt\"}" \ + " " \ + "; Unique Vendor name" \ + ":\"Nokia, Qt\"" \ + " " + +default_deployment.pkg_prerules += vendorinfo diff --git a/examples/threads/mandelbrot/mandelbrot.pro b/examples/threads/mandelbrot/mandelbrot.pro index 437f449..ecbec56 100644 --- a/examples/threads/mandelbrot/mandelbrot.pro +++ b/examples/threads/mandelbrot/mandelbrot.pro @@ -4,10 +4,12 @@ SOURCES = main.cpp \ mandelbrotwidget.cpp \ renderthread.cpp -unix:!mac:LIBS += -lm +unix:!mac:!symbian:!vxworks:LIBS += -lm # install target.path = $$[QT_INSTALL_EXAMPLES]/threads/mandelbrot sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS mandelbrot.pro sources.path = $$[QT_INSTALL_EXAMPLES]/threads/mandelbrot INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/threads/semaphores/semaphores.pro b/examples/threads/semaphores/semaphores.pro index 2e468b7..85f7311 100644 --- a/examples/threads/semaphores/semaphores.pro +++ b/examples/threads/semaphores/semaphores.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/threads/semaphores sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS semaphores.pro sources.path = $$[QT_INSTALL_EXAMPLES]/threads/semaphores INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/threads/threads.pro b/examples/threads/threads.pro index a2ccfa7..93d8cc8 100644 --- a/examples/threads/threads.pro +++ b/examples/threads/threads.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/threads sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS threads.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/threads INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/threads/waitconditions/waitconditions.pro b/examples/threads/waitconditions/waitconditions.pro index 8c34cec..b07b413 100644 --- a/examples/threads/waitconditions/waitconditions.pro +++ b/examples/threads/waitconditions/waitconditions.pro @@ -10,11 +10,13 @@ INCLUDEPATH += . # Input SOURCES += waitconditions.cpp CONFIG += qt warn_on create_prl link_prl console -OBJECTS_DIR=.obj/debug-shared -MOC_DIR=.moc/debug-shared +OBJECTS_DIR=obj/debug-shared +MOC_DIR=moc/debug-shared # install target.path = $$[QT_INSTALL_EXAMPLES]/threads/waitconditions sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS waitconditions.pro sources.path = $$[QT_INSTALL_EXAMPLES]/threads/waitconditions INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/codecs/codecs.pro b/examples/tools/codecs/codecs.pro index 6ae225a..0c06997 100644 --- a/examples/tools/codecs/codecs.pro +++ b/examples/tools/codecs/codecs.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/codecs sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS encodedfiles codecs.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/codecs INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/codecs/encodedfiles/.gitattributes b/examples/tools/codecs/encodedfiles/.gitattributes deleted file mode 100644 index 996aab2..0000000 --- a/examples/tools/codecs/encodedfiles/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -iso-8859-15.txt -crlf -iso-8859-1.txt -crlf diff --git a/examples/tools/codecs/encodedfiles/iso-8859-1.txt b/examples/tools/codecs/encodedfiles/iso-8859-1.txt index 4a7ebe3..d7fcaca 100644 --- a/examples/tools/codecs/encodedfiles/iso-8859-1.txt +++ b/examples/tools/codecs/encodedfiles/iso-8859-1.txt @@ -1,6 +1,6 @@ -Paulo Coelho: O Gênio e as Rosas
-Anna Hallström, Urban Östberg: Svår svenska
-Darrell Huff: How to Lie with Statistics
-Franz Kafka: Das Schloß
-Walter Moers: Die 13½ Leben des Käpt'n Blaubär
-Dag Solstad: Forsøk på å beskrive det ugjennomtrengelige
+Paulo Coelho: O Gênio e as Rosas +Anna Hallström, Urban Östberg: Svår svenska +Darrell Huff: How to Lie with Statistics +Franz Kafka: Das Schloß +Walter Moers: Die 13½ Leben des Käpt'n Blaubär +Dag Solstad: Forsøk på å beskrive det ugjennomtrengelige diff --git a/examples/tools/codecs/encodedfiles/iso-8859-15.txt b/examples/tools/codecs/encodedfiles/iso-8859-15.txt index cd43ea3..be2d83c 100644 --- a/examples/tools/codecs/encodedfiles/iso-8859-15.txt +++ b/examples/tools/codecs/encodedfiles/iso-8859-15.txt @@ -1,8 +1,8 @@ -Paulo Coelho: O Gênio e as Rosas
-Jean-Pierre Coffe: À table en famille avec 15 ¤ par jour
-Anna Hallström, Urban Östberg: Svår svenska
-Darrell Huff: How to Lie with Statistics
-Franz Kafka: Das Schloß
-Helena Lehecková: T¨ekkiä suomalaisille
-Arthur Rimbaud: ¼uvres complètes
-Dag Solstad: Forsøk på å beskrive det ugjennomtrengelige
+Paulo Coelho: O Gênio e as Rosas +Jean-Pierre Coffe: À table en famille avec 15 ¤ par jour +Anna Hallström, Urban Östberg: Svår svenska +Darrell Huff: How to Lie with Statistics +Franz Kafka: Das Schloß +Helena Lehecková: T¨ekkiä suomalaisille +Arthur Rimbaud: ¼uvres complètes +Dag Solstad: Forsøk på å beskrive det ugjennomtrengelige diff --git a/examples/tools/codecs/mainwindow.cpp b/examples/tools/codecs/mainwindow.cpp index f6614d4..47d073b 100644 --- a/examples/tools/codecs/mainwindow.cpp +++ b/examples/tools/codecs/mainwindow.cpp @@ -156,7 +156,7 @@ void MainWindow::findCodecs() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); foreach (QTextCodec *codec, codecs) { @@ -169,7 +169,7 @@ void MainWindow::createActions() } exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro index 4ac5084..96d3734 100644 --- a/examples/tools/completer/completer.pro +++ b/examples/tools/completer/completer.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/completer sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS completer.pro resources sources.path = $$[QT_INSTALL_EXAMPLES]/tools/completer INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp index ff7e1a1..923e806 100644 --- a/examples/tools/completer/mainwindow.cpp +++ b/examples/tools/completer/mainwindow.cpp @@ -78,6 +78,12 @@ MainWindow::MainWindow(QWidget *parent) //! [0] //! [1] + QLabel *maxVisibleLabel = new QLabel; + maxVisibleLabel->setText(tr("Max Visible Items")); + maxVisibleSpinBox = new QSpinBox; + maxVisibleSpinBox->setRange(3,25); + maxVisibleSpinBox->setValue(10); + wrapCheckBox = new QCheckBox; wrapCheckBox->setText(tr("Wrap around completions")); wrapCheckBox->setChecked(true); @@ -90,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) connect(modelCombo, SIGNAL(activated(int)), this, SLOT(changeModel())); connect(modeCombo, SIGNAL(activated(int)), this, SLOT(changeMode(int))); connect(caseCombo, SIGNAL(activated(int)), this, SLOT(changeCase(int))); + connect(maxVisibleSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changeMaxVisible(int))); //! [2] //! [3] @@ -99,9 +106,10 @@ MainWindow::MainWindow(QWidget *parent) layout->addWidget(modelLabel, 0, 0); layout->addWidget(modelCombo, 0, 1); layout->addWidget(modeLabel, 1, 0); layout->addWidget(modeCombo, 1, 1); layout->addWidget(caseLabel, 2, 0); layout->addWidget(caseCombo, 2, 1); - layout->addWidget(wrapCheckBox, 3, 0); - layout->addWidget(contentsLabel, 4, 0, 1, 2); - layout->addWidget(lineEdit, 5, 0, 1, 2); + layout->addWidget(maxVisibleLabel, 3, 0); layout->addWidget(maxVisibleSpinBox, 3, 1); + layout->addWidget(wrapCheckBox, 4, 0); + layout->addWidget(contentsLabel, 5, 0, 1, 2); + layout->addWidget(lineEdit, 6, 0, 1, 2); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -205,6 +213,7 @@ void MainWindow::changeModel() { delete completer; completer = new QCompleter(this); + completer->setMaxVisibleItems(maxVisibleSpinBox->value()); switch (modelCombo->currentIndex()) { default: @@ -256,9 +265,16 @@ void MainWindow::changeModel() //! [14] //! [15] +void MainWindow::changeMaxVisible(int max) +{ + completer->setMaxVisibleItems(max); +} +//! [15] + +//! [16] void MainWindow::about() { QMessageBox::about(this, tr("About"), tr("This example demonstrates the " "different features of the QCompleter class.")); } -//! [15] +//! [16] diff --git a/examples/tools/completer/mainwindow.h b/examples/tools/completer/mainwindow.h index 1d22a09..fb306b4 100644 --- a/examples/tools/completer/mainwindow.h +++ b/examples/tools/completer/mainwindow.h @@ -52,6 +52,7 @@ class QLabel; class QLineEdit; class QProgressBar; class QCheckBox; +class QSpinBox; QT_END_NAMESPACE //! [0] @@ -67,6 +68,7 @@ private slots: void changeCase(int); void changeMode(int); void changeModel(); + void changeMaxVisible(int); //! [0] //! [1] @@ -77,6 +79,7 @@ private: QComboBox *caseCombo; QComboBox *modeCombo; QComboBox *modelCombo; + QSpinBox *maxVisibleSpinBox; QCheckBox *wrapCheckBox; QCompleter *completer; QLabel *contentsLabel; diff --git a/examples/tools/completer/resources/wordlist.txt b/examples/tools/completer/resources/wordlist.txt index e598a19..1f56e36 100644 --- a/examples/tools/completer/resources/wordlist.txt +++ b/examples/tools/completer/resources/wordlist.txt @@ -1366,7 +1366,6 @@ transparency transparent travel traveled -Trolltech true try turn diff --git a/examples/tools/contiguouscache/contiguouscache.pro b/examples/tools/contiguouscache/contiguouscache.pro new file mode 100644 index 0000000..f840514 --- /dev/null +++ b/examples/tools/contiguouscache/contiguouscache.pro @@ -0,0 +1,9 @@ +HEADERS = randomlistmodel.h +SOURCES = randomlistmodel.cpp \ + main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS contiguouscache.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tools/contiguouscache +INSTALLS += target sources diff --git a/examples/tools/contiguouscache/main.cpp b/examples/tools/contiguouscache/main.cpp new file mode 100644 index 0000000..42aca07 --- /dev/null +++ b/examples/tools/contiguouscache/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "randomlistmodel.h" +#include <QListView> +#include <QApplication> + +int main(int c, char **v) +{ + QApplication a(c, v); + + QListView view; + view.setUniformItemSizes(true); + view.setModel(new RandomListModel(&view)); + view.show(); + + return a.exec(); +} diff --git a/examples/tools/contiguouscache/randomlistmodel.cpp b/examples/tools/contiguouscache/randomlistmodel.cpp new file mode 100644 index 0000000..fa53e51 --- /dev/null +++ b/examples/tools/contiguouscache/randomlistmodel.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "randomlistmodel.h" +#include <stdlib.h> + +static const int bufferSize(500); +static const int lookAhead(100); +static const int halfLookAhead(lookAhead/2); + +RandomListModel::RandomListModel(QObject *parent) +: QAbstractListModel(parent), m_rows(bufferSize), m_count(10000) +{ +} + +RandomListModel::~RandomListModel() +{ +} + +int RandomListModel::rowCount(const QModelIndex &) const +{ + return m_count; +} + +//! [0] +QVariant RandomListModel::data(const QModelIndex &index, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + int row = index.row(); + + if (row > m_rows.lastIndex()) { + if (row - m_rows.lastIndex() > lookAhead) + cacheRows(row-halfLookAhead, qMin(m_count, row+halfLookAhead)); + else while (row > m_rows.lastIndex()) + m_rows.append(fetchRow(m_rows.lastIndex()+1)); + } else if (row < m_rows.firstIndex()) { + if (m_rows.firstIndex() - row > lookAhead) + cacheRows(qMax(0, row-halfLookAhead), row+halfLookAhead); + else while (row < m_rows.firstIndex()) + m_rows.prepend(fetchRow(m_rows.firstIndex()-1)); + } + + return m_rows.at(row); +} + +void RandomListModel::cacheRows(int from, int to) const +{ + for (int i = from; i <= to; ++i) + m_rows.insert(i, fetchRow(i)); +} +//![0] + +//![1] +QString RandomListModel::fetchRow(int position) const +{ + return QString::number(rand() % ++position); +} +//![1] diff --git a/examples/tools/contiguouscache/randomlistmodel.h b/examples/tools/contiguouscache/randomlistmodel.h new file mode 100644 index 0000000..e4a0d69 --- /dev/null +++ b/examples/tools/contiguouscache/randomlistmodel.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef RANDOMLISTMODEL_H +#define RANDOMLISTMODEL_H + +#include <QContiguousCache> +#include <QAbstractListModel> + +class QTimer; +class RandomListModel : public QAbstractListModel +{ + Q_OBJECT +public: + RandomListModel(QObject *parent = 0); + ~RandomListModel(); + + int rowCount(const QModelIndex & = QModelIndex()) const; + QVariant data(const QModelIndex &, int) const; + +private: + void cacheRows(int, int) const; + QString fetchRow(int) const; + + mutable QContiguousCache<QString> m_rows; + const int m_count; +}; + +#endif diff --git a/examples/tools/customcompleter/customcompleter.pro b/examples/tools/customcompleter/customcompleter.pro index ebaa831..5ab7849 100644 --- a/examples/tools/customcompleter/customcompleter.pro +++ b/examples/tools/customcompleter/customcompleter.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS customcompleter.pro resources sources.path = $$[QT_INSTALL_EXAMPLES]/tools/customcompleter INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/echoplugin/echoplugin.pro b/examples/tools/echoplugin/echoplugin.pro index 998f25c..700e9e0 100644 --- a/examples/tools/echoplugin/echoplugin.pro +++ b/examples/tools/echoplugin/echoplugin.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS echoplugin.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/echoplugin/echowindow/echowindow.pro b/examples/tools/echoplugin/echowindow/echowindow.pro index fb1cea9..bdf8c41 100644 --- a/examples/tools/echoplugin/echowindow/echowindow.pro +++ b/examples/tools/echoplugin/echowindow/echowindow.pro @@ -16,3 +16,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS echowindow.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin/echowindow INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/echoplugin/plugin/plugin.pro b/examples/tools/echoplugin/plugin/plugin.pro index 5c0c5af..cfc8a5f 100644 --- a/examples/tools/echoplugin/plugin/plugin.pro +++ b/examples/tools/echoplugin/plugin/plugin.pro @@ -13,3 +13,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin/plugin sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plugin.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/echoplugin/plugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + +symbian:TARGET.EPOCALLOWDLLDATA = 1 diff --git a/examples/tools/i18n/i18n.pro b/examples/tools/i18n/i18n.pro index 0ef9a0b..69d7f04 100644 --- a/examples/tools/i18n/i18n.pro +++ b/examples/tools/i18n/i18n.pro @@ -24,3 +24,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/i18n sources.files = $$SOURCES $$HEADERS $$RESOURCES translations i18n.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/i18n INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/inputpanel/inputpanel.pro b/examples/tools/inputpanel/inputpanel.pro new file mode 100644 index 0000000..3b3767f --- /dev/null +++ b/examples/tools/inputpanel/inputpanel.pro @@ -0,0 +1,17 @@ +SOURCES += main.cpp \ + myinputpanel.cpp \ + myinputpanelcontext.cpp + +HEADERS += myinputpanel.h \ + myinputpanelcontext.h + +FORMS += mainform.ui \ + myinputpanelform.ui + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tools/inputpanel +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS inputpanel.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tools/inputpanel +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/inputpanel/main.cpp b/examples/tools/inputpanel/main.cpp new file mode 100644 index 0000000..2e39883 --- /dev/null +++ b/examples/tools/inputpanel/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtGui/QWidget> + +//! [main] +#include "myinputpanelcontext.h" +#include "ui_mainform.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + MyInputPanelContext *ic = new MyInputPanelContext; + app.setInputContext(ic); + + QWidget widget; + Ui::MainForm form; + form.setupUi(&widget); + widget.show(); + return app.exec(); +} +//! [main] diff --git a/examples/tools/inputpanel/mainform.ui b/examples/tools/inputpanel/mainform.ui new file mode 100644 index 0000000..c16ae31 --- /dev/null +++ b/examples/tools/inputpanel/mainform.ui @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainForm</class> + <widget class="QWidget" name="MainForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>140</width> + <height>200</height> + </rect> + </property> + <property name="windowTitle"> + <string>Input Panel Example</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>My age:</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> + </property> + <property name="buddy"> + <cstring>lineEdit</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>My phone number:</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> + </property> + <property name="buddy"> + <cstring>lineEdit_2</cstring> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_2"/> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>My gender:</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="radioButton"> + <property name="text"> + <string>Male</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="radioButton_2"> + <property name="text"> + <string>Female</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/examples/tools/inputpanel/myinputpanel.cpp b/examples/tools/inputpanel/myinputpanel.cpp new file mode 100644 index 0000000..c44ead8 --- /dev/null +++ b/examples/tools/inputpanel/myinputpanel.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "myinputpanel.h" + +//! [0] + +MyInputPanel::MyInputPanel() + : QWidget(0, Qt::Tool | Qt::WindowStaysOnTopHint), + lastFocusedWidget(0) +{ + form.setupUi(this); + + connect(qApp, SIGNAL(focusChanged(QWidget *, QWidget *)), + this, SLOT(saveFocusWidget(QWidget *, QWidget *))); + + signalMapper.setMapping(form.panelButton_1, form.panelButton_1); + signalMapper.setMapping(form.panelButton_2, form.panelButton_2); + signalMapper.setMapping(form.panelButton_3, form.panelButton_3); + signalMapper.setMapping(form.panelButton_4, form.panelButton_4); + signalMapper.setMapping(form.panelButton_5, form.panelButton_5); + signalMapper.setMapping(form.panelButton_6, form.panelButton_6); + signalMapper.setMapping(form.panelButton_7, form.panelButton_7); + signalMapper.setMapping(form.panelButton_8, form.panelButton_8); + signalMapper.setMapping(form.panelButton_9, form.panelButton_9); + signalMapper.setMapping(form.panelButton_star, form.panelButton_star); + signalMapper.setMapping(form.panelButton_0, form.panelButton_0); + signalMapper.setMapping(form.panelButton_hash, form.panelButton_hash); + + connect(form.panelButton_1, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_2, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_3, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_4, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_5, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_6, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_7, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_8, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_9, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_star, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_0, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + connect(form.panelButton_hash, SIGNAL(clicked()), + &signalMapper, SLOT(map())); + + connect(&signalMapper, SIGNAL(mapped(QWidget *)), + this, SLOT(buttonClicked(QWidget *))); +} + +//! [0] + +bool MyInputPanel::event(QEvent *e) +{ + switch (e->type()) { +//! [1] + case QEvent::WindowActivate: + if (lastFocusedWidget) + lastFocusedWidget->activateWindow(); + break; +//! [1] + default: + break; + } + + return QWidget::event(e); +} + +//! [2] + +void MyInputPanel::saveFocusWidget(QWidget * /*oldFocus*/, QWidget *newFocus) +{ + if (newFocus != 0 && !this->isAncestorOf(newFocus)) { + lastFocusedWidget = newFocus; + } +} + +//! [2] + +//! [3] + +void MyInputPanel::buttonClicked(QWidget *w) +{ + QChar chr = qvariant_cast<QChar>(w->property("buttonValue")); + emit characterGenerated(chr); +} + +//! [3] diff --git a/examples/tools/inputpanel/myinputpanel.h b/examples/tools/inputpanel/myinputpanel.h new file mode 100644 index 0000000..5f91c05 --- /dev/null +++ b/examples/tools/inputpanel/myinputpanel.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYINPUTPANEL_H +#define MYINPUTPANEL_H + +#include <QtGui> +#include <QtCore> + +#include "ui_myinputpanelform.h" + +//! [0] + +class MyInputPanel : public QWidget +{ + Q_OBJECT + +public: + MyInputPanel(); + +signals: + void characterGenerated(QChar character); + +protected: + bool event(QEvent *e); + +private slots: + void saveFocusWidget(QWidget *oldFocus, QWidget *newFocus); + void buttonClicked(QWidget *w); + +private: + Ui::MyInputPanelForm form; + QWidget *lastFocusedWidget; + QSignalMapper signalMapper; +}; + +//! [0] + +#endif // MYINPUTPANEL_H diff --git a/examples/tools/inputpanel/myinputpanelcontext.cpp b/examples/tools/inputpanel/myinputpanelcontext.cpp new file mode 100644 index 0000000..dc31028 --- /dev/null +++ b/examples/tools/inputpanel/myinputpanelcontext.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> + +#include "myinputpanelcontext.h" + +//! [0] + +MyInputPanelContext::MyInputPanelContext() +{ + inputPanel = new MyInputPanel; + connect(inputPanel, SIGNAL(characterGenerated(QChar)), SLOT(sendCharacter(QChar))); +} + +//! [0] + +MyInputPanelContext::~MyInputPanelContext() +{ + delete inputPanel; +} + +//! [1] + +bool MyInputPanelContext::filterEvent(const QEvent* event) +{ + if (event->type() == QEvent::RequestSoftwareInputPanel) { + updatePosition(); + inputPanel->show(); + return true; + } else if (event->type() == QEvent::CloseSoftwareInputPanel) { + inputPanel->hide(); + return true; + } + return false; +} + +//! [1] + +QString MyInputPanelContext::identifierName() +{ + return "MyInputPanelContext"; +} + +void MyInputPanelContext::reset() +{ +} + +bool MyInputPanelContext::isComposing() const +{ + return false; +} + +QString MyInputPanelContext::language() +{ + return "en_US"; +} + +//! [2] + +void MyInputPanelContext::sendCharacter(QChar character) +{ + QPointer<QWidget> w = focusWidget(); + + if (!w) + return; + + QKeyEvent keyPress(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString(character)); + QApplication::sendEvent(w, &keyPress); + + if (!w) + return; + + QKeyEvent keyRelease(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString()); + QApplication::sendEvent(w, &keyRelease); +} + +//! [2] + +//! [3] + +void MyInputPanelContext::updatePosition() +{ + QWidget *widget = focusWidget(); + if (!widget) + return; + + QRect widgetRect = widget->rect(); + QPoint panelPos = QPoint(widgetRect.left(), widgetRect.bottom() + 2); + panelPos = widget->mapToGlobal(panelPos); + inputPanel->move(panelPos); +} + +//! [3] diff --git a/examples/tools/inputpanel/myinputpanelcontext.h b/examples/tools/inputpanel/myinputpanelcontext.h new file mode 100644 index 0000000..d711800 --- /dev/null +++ b/examples/tools/inputpanel/myinputpanelcontext.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYINPUTPANELCONTEXT_H +#define MYINPUTPANELCONTEXT_H + +#include <QtGui/QInputContext> + +#include "myinputpanel.h" + +class MyInputPanel; + +//! [0] + +class MyInputPanelContext : public QInputContext +{ + Q_OBJECT + +public: + MyInputPanelContext(); + ~MyInputPanelContext(); + + bool filterEvent(const QEvent* event); + + QString identifierName(); + QString language(); + + bool isComposing() const; + + void reset(); + +private slots: + void sendCharacter(QChar character); + +private: + void updatePosition(); + +private: + MyInputPanel *inputPanel; +}; + +//! [0] + +#endif // MYINPUTPANELCONTEXT_H diff --git a/examples/tools/inputpanel/myinputpanelform.ui b/examples/tools/inputpanel/myinputpanelform.ui new file mode 100644 index 0000000..fe78442 --- /dev/null +++ b/examples/tools/inputpanel/myinputpanelform.ui @@ -0,0 +1,398 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MyInputPanelForm</class> + <widget class="QWidget" name="MyInputPanelForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>167</width> + <height>233</height> + </rect> + </property> + <property name="windowTitle"> + <string>Input Panel</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QPushButton" name="panelButton_1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>1</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>49</unicode> + </char> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="panelButton_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>2</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>50</unicode> + </char> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="panelButton_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>3</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>51</unicode> + </char> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QPushButton" name="panelButton_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>4</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>52</unicode> + </char> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QPushButton" name="panelButton_5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>5</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>53</unicode> + </char> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QPushButton" name="panelButton_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>6</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>54</unicode> + </char> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QPushButton" name="panelButton_7"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>7</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>55</unicode> + </char> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QPushButton" name="panelButton_8"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>8</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>56</unicode> + </char> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="panelButton_9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>9</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>57</unicode> + </char> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QPushButton" name="panelButton_star"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>*</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>42</unicode> + </char> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="panelButton_0"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>48</unicode> + </char> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="panelButton_hash"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>45</width> + <height>40</height> + </size> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>#</string> + </property> + <property name="buttonValue" stdset="0"> + <char> + <unicode>35</unicode> + </char> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="font"> + <font> + <pointsize>8</pointsize> + </font> + </property> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>closeButton</sender> + <signal>clicked()</signal> + <receiver>MyInputPanelForm</receiver> + <slot>hide()</slot> + <hints> + <hint type="sourcelabel"> + <x>114</x> + <y>209</y> + </hint> + <hint type="destinationlabel"> + <x>83</x> + <y>116</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/examples/tools/plugandpaint/mainwindow.cpp b/examples/tools/plugandpaint/mainwindow.cpp index 4eb8086..b6ac95f 100644 --- a/examples/tools/plugandpaint/mainwindow.cpp +++ b/examples/tools/plugandpaint/mainwindow.cpp @@ -179,15 +179,15 @@ void MainWindow::aboutPlugins() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAsAct = new QAction(tr("&Save As..."), this); - saveAsAct->setShortcut(tr("Ctrl+S")); + saveAsAct->setShortcuts(QKeySequence::SaveAs); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); brushColorAct = new QAction(tr("&Brush Color..."), this); diff --git a/examples/tools/plugandpaint/plugandpaint.pro b/examples/tools/plugandpaint/plugandpaint.pro index 15bc21e..9616eb8 100644 --- a/examples/tools/plugandpaint/plugandpaint.pro +++ b/examples/tools/plugandpaint/plugandpaint.pro @@ -7,7 +7,11 @@ SOURCES = main.cpp \ mainwindow.cpp \ paintarea.cpp \ plugindialog.cpp -LIBS = -L$${QT_BUILD_TREE}/examples/tools/plugandpaint/plugins -lpnp_basictools +symbian { + LIBS = -lpnp_basictools.lib +} else { + LIBS = -L$${QT_BUILD_TREE}/examples/tools/plugandpaint/plugins -lpnp_basictools +} if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug @@ -20,3 +24,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaint sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plugandpaint.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaint INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/plugandpaintplugins/basictools/basictools.pro b/examples/tools/plugandpaintplugins/basictools/basictools.pro index f015fdc..0ab9d90 100644 --- a/examples/tools/plugandpaintplugins/basictools/basictools.pro +++ b/examples/tools/plugandpaintplugins/basictools/basictools.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaint/plugins sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS basictools.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins/basictools INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro index 3cf2b66..e480dc1 100644 --- a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro +++ b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro @@ -13,3 +13,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaint/plugins sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extrafilters.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins/extrafilters INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + +symbian:TARGET.EPOCALLOWDLLDATA = 1 diff --git a/examples/tools/plugandpaintplugins/plugandpaintplugins.pro b/examples/tools/plugandpaintplugins/plugandpaintplugins.pro index 89e8b7e..e157b66 100644 --- a/examples/tools/plugandpaintplugins/plugandpaintplugins.pro +++ b/examples/tools/plugandpaintplugins/plugandpaintplugins.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plugandpaintplugins.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/plugandpaintplugins INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/regexp/regexp.pro b/examples/tools/regexp/regexp.pro index 15ca9a4..35756da 100644 --- a/examples/tools/regexp/regexp.pro +++ b/examples/tools/regexp/regexp.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/regexp sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS regexp.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/regexp INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/regexp/regexpdialog.cpp b/examples/tools/regexp/regexpdialog.cpp index ddf3cc9..153748b 100644 --- a/examples/tools/regexp/regexpdialog.cpp +++ b/examples/tools/regexp/regexpdialog.cpp @@ -69,6 +69,7 @@ RegExpDialog::RegExpDialog(QWidget *parent) syntaxComboBox->addItem(tr("Regular expression v2"), QRegExp::RegExp2); syntaxComboBox->addItem(tr("Wildcard"), QRegExp::Wildcard); syntaxComboBox->addItem(tr("Fixed string"), QRegExp::FixedString); + syntaxComboBox->addItem(tr("W3C Xml Schema 1.1"), QRegExp::W3CXmlSchema11); syntaxLabel = new QLabel(tr("&Pattern Syntax:")); syntaxLabel->setBuddy(syntaxComboBox); diff --git a/examples/tools/settingseditor/mainwindow.cpp b/examples/tools/settingseditor/mainwindow.cpp index aa3d07c..926d4a6 100644 --- a/examples/tools/settingseditor/mainwindow.cpp +++ b/examples/tools/settingseditor/mainwindow.cpp @@ -122,7 +122,7 @@ void MainWindow::about() void MainWindow::createActions() { openSettingsAct = new QAction(tr("&Open Application Settings..."), this); - openSettingsAct->setShortcut(tr("Ctrl+O")); + openSettingsAct->setShortcuts(QKeySequence::Open); connect(openSettingsAct, SIGNAL(triggered()), this, SLOT(openSettings())); openIniFileAct = new QAction(tr("Open I&NI File..."), this); @@ -146,7 +146,7 @@ void MainWindow::createActions() connect(refreshAct, SIGNAL(triggered()), settingsTree, SLOT(refresh())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); autoRefreshAct = new QAction(tr("&Auto-Refresh"), this); diff --git a/examples/tools/settingseditor/settingseditor.pro b/examples/tools/settingseditor/settingseditor.pro index 321c2bb..2ebdfe6 100644 --- a/examples/tools/settingseditor/settingseditor.pro +++ b/examples/tools/settingseditor/settingseditor.pro @@ -13,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/settingseditor sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS settingseditor.pro inifiles sources.path = $$[QT_INSTALL_EXAMPLES]/tools/settingseditor INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/styleplugin/plugin/plugin.pro b/examples/tools/styleplugin/plugin/plugin.pro index 1e84e3c..7cb0c97 100644 --- a/examples/tools/styleplugin/plugin/plugin.pro +++ b/examples/tools/styleplugin/plugin/plugin.pro @@ -19,3 +19,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin/styles sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plugin.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin/plugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + +symbian:TARGET.EPOCALLOWDLLDATA = 1 diff --git a/examples/tools/styleplugin/styleplugin.pro b/examples/tools/styleplugin/styleplugin.pro index bf4fa5c..1b9831e 100644 --- a/examples/tools/styleplugin/styleplugin.pro +++ b/examples/tools/styleplugin/styleplugin.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS styleplugin.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/styleplugin/stylewindow/stylewindow.pro b/examples/tools/styleplugin/stylewindow/stylewindow.pro index 7c5266d..8ed1541 100644 --- a/examples/tools/styleplugin/stylewindow/stylewindow.pro +++ b/examples/tools/styleplugin/stylewindow/stylewindow.pro @@ -15,3 +15,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS stylewindow.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tools/styleplugin/stylewindow INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/tools.pro b/examples/tools/tools.pro index 79f0faa..08d44e3 100644 --- a/examples/tools/tools.pro +++ b/examples/tools/tools.pro @@ -5,6 +5,8 @@ SUBDIRS = codecs \ customcompleter \ echoplugin \ i18n \ + inputpanel \ + contiguouscache \ plugandpaintplugins \ plugandpaint \ regexp \ @@ -20,3 +22,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tools.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/tools INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/treemodelcompleter/treemodelcompleter.pro b/examples/tools/treemodelcompleter/treemodelcompleter.pro index 8631e2b..39c83f3 100644 --- a/examples/tools/treemodelcompleter/treemodelcompleter.pro +++ b/examples/tools/treemodelcompleter/treemodelcompleter.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/treemodelcompleter sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS treemodelcompleter.pro resources sources.path = $$[QT_INSTALL_EXAMPLES]/tools/treemodelcompleter INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tools/undoframework/mainwindow.cpp b/examples/tools/undoframework/mainwindow.cpp index a42ab31..45f109e 100644 --- a/examples/tools/undoframework/mainwindow.cpp +++ b/examples/tools/undoframework/mainwindow.cpp @@ -101,16 +101,14 @@ void MainWindow::createActions() //! [5] undoAction = undoStack->createUndoAction(this, tr("&Undo")); - undoAction->setShortcut(tr("Ctrl+Z")); + undoAction->setShortcuts(QKeySequence::Undo); redoAction = undoStack->createRedoAction(this, tr("&Redo")); - QList<QKeySequence> redoShortcuts; - redoShortcuts << tr("Ctrl+Y") << tr("Shift+Ctrl+Z"); - redoAction->setShortcuts(redoShortcuts); + redoAction->setShortcuts(QKeySequence::Redo); //! [5] exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcut(tr("Ctrl+Q")); + exitAction->setShortcuts(QKeySequence::Quit); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); aboutAction = new QAction(tr("&About"), this); diff --git a/examples/tools/undoframework/undoframework.pro b/examples/tools/undoframework/undoframework.pro index 42010f5..5b7b666 100644 --- a/examples/tools/undoframework/undoframework.pro +++ b/examples/tools/undoframework/undoframework.pro @@ -14,3 +14,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tools/undoframework sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS undoframework.pro README images sources.path = $$[QT_INSTALL_EXAMPLES]/tools/undoframework INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook-fr/part1/main.cpp b/examples/tutorials/addressbook-fr/part1/main.cpp index 40aa8cb..7650a9b 100644 --- a/examples/tutorials/addressbook-fr/part1/main.cpp +++ b/examples/tutorials/addressbook-fr/part1/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part2/main.cpp b/examples/tutorials/addressbook-fr/part2/main.cpp index 40aa8cb..7650a9b 100644 --- a/examples/tutorials/addressbook-fr/part2/main.cpp +++ b/examples/tutorials/addressbook-fr/part2/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part3/addressbook.cpp b/examples/tutorials/addressbook-fr/part3/addressbook.cpp index 2b4a4e0..aa264d3 100644 --- a/examples/tutorials/addressbook-fr/part3/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part3/addressbook.cpp @@ -125,8 +125,7 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), - tr("Please enter a name and adderss.")); - return; + tr("Please enter a name and address.")); } if (!contacts.contains(name)) { @@ -136,7 +135,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } if (contacts.isEmpty()) { diff --git a/examples/tutorials/addressbook-fr/part3/main.cpp b/examples/tutorials/addressbook-fr/part3/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook-fr/part3/main.cpp +++ b/examples/tutorials/addressbook-fr/part3/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part4/addressbook.cpp b/examples/tutorials/addressbook-fr/part4/addressbook.cpp index 558f6b1..f288268 100644 --- a/examples/tutorials/addressbook-fr/part4/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part4/addressbook.cpp @@ -135,7 +135,6 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); - return; } //! [submitContact() function part1] if (currentMode == AddingMode) { @@ -147,7 +146,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } //! [submitContact() function part1] //! [submitContact() function part2] @@ -162,7 +160,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Edit Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (oldAddress != address) { QMessageBox::information(this, tr("Edit Successful"), diff --git a/examples/tutorials/addressbook-fr/part4/main.cpp b/examples/tutorials/addressbook-fr/part4/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook-fr/part4/main.cpp +++ b/examples/tutorials/addressbook-fr/part4/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part5/addressbook.cpp b/examples/tutorials/addressbook-fr/part5/addressbook.cpp index f1ad772..b690bb4 100644 --- a/examples/tutorials/addressbook-fr/part5/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part5/addressbook.cpp @@ -142,7 +142,6 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); - return; } if (currentMode == AddingMode) { @@ -154,7 +153,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (currentMode == EditingMode) { @@ -167,7 +165,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Edit Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (oldAddress != address) { QMessageBox::information(this, tr("Edit Successful"), diff --git a/examples/tutorials/addressbook-fr/part5/main.cpp b/examples/tutorials/addressbook-fr/part5/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook-fr/part5/main.cpp +++ b/examples/tutorials/addressbook-fr/part5/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part6/addressbook.cpp b/examples/tutorials/addressbook-fr/part6/addressbook.cpp index a89fe83..a0ca5ed 100644 --- a/examples/tutorials/addressbook-fr/part6/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part6/addressbook.cpp @@ -148,7 +148,6 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); - return; } if (currentMode == AddingMode) { @@ -160,7 +159,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (currentMode == EditingMode) { @@ -173,7 +171,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Edit Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (oldAddress != address) { QMessageBox::information(this, tr("Edit Successful"), diff --git a/examples/tutorials/addressbook-fr/part6/main.cpp b/examples/tutorials/addressbook-fr/part6/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook-fr/part6/main.cpp +++ b/examples/tutorials/addressbook-fr/part6/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook-fr/part7/addressbook.cpp b/examples/tutorials/addressbook-fr/part7/addressbook.cpp index 3629c48..65e7eba 100644 --- a/examples/tutorials/addressbook-fr/part7/addressbook.cpp +++ b/examples/tutorials/addressbook-fr/part7/addressbook.cpp @@ -150,7 +150,6 @@ void AddressBook::submitContact() if (name == "" || address == "") { QMessageBox::information(this, tr("Empty Field"), tr("Please enter a name and address.")); - return; } if (currentMode == AddingMode) { @@ -162,7 +161,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Add Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (currentMode == EditingMode) { @@ -175,7 +173,6 @@ void AddressBook::submitContact() } else { QMessageBox::information(this, tr("Edit Unsuccessful"), tr("Sorry, \"%1\" is already in your address book.").arg(name)); - return; } } else if (oldAddress != address) { QMessageBox::information(this, tr("Edit Successful"), diff --git a/examples/tutorials/addressbook-fr/part7/main.cpp b/examples/tutorials/addressbook-fr/part7/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook-fr/part7/main.cpp +++ b/examples/tutorials/addressbook-fr/part7/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/addressbook.pro b/examples/tutorials/addressbook/addressbook.pro index 4607c25..70abcbb 100644 --- a/examples/tutorials/addressbook/addressbook.pro +++ b/examples/tutorials/addressbook/addressbook.pro @@ -6,3 +6,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS addressbook.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part1/main.cpp b/examples/tutorials/addressbook/part1/main.cpp index 40aa8cb..7650a9b 100644 --- a/examples/tutorials/addressbook/part1/main.cpp +++ b/examples/tutorials/addressbook/part1/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part1/part1.pro b/examples/tutorials/addressbook/part1/part1.pro index bb181dd..03d7f14 100644 --- a/examples/tutorials/addressbook/part1/part1.pro +++ b/examples/tutorials/addressbook/part1/part1.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part1 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part1.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part1 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part2/main.cpp b/examples/tutorials/addressbook/part2/main.cpp index 40aa8cb..7650a9b 100644 --- a/examples/tutorials/addressbook/part2/main.cpp +++ b/examples/tutorials/addressbook/part2/main.cpp @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part2/part2.pro b/examples/tutorials/addressbook/part2/part2.pro index 01ce344..e540b0b 100644 --- a/examples/tutorials/addressbook/part2/part2.pro +++ b/examples/tutorials/addressbook/part2/part2.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part2 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part2.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part2 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part3/main.cpp b/examples/tutorials/addressbook/part3/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook/part3/main.cpp +++ b/examples/tutorials/addressbook/part3/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part3/part3.pro b/examples/tutorials/addressbook/part3/part3.pro index 128c038..35bfac9 100644 --- a/examples/tutorials/addressbook/part3/part3.pro +++ b/examples/tutorials/addressbook/part3/part3.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part3 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part3.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part3 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part4/main.cpp b/examples/tutorials/addressbook/part4/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook/part4/main.cpp +++ b/examples/tutorials/addressbook/part4/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part4/part4.pro b/examples/tutorials/addressbook/part4/part4.pro index 23ce3e6..7187d0d 100644 --- a/examples/tutorials/addressbook/part4/part4.pro +++ b/examples/tutorials/addressbook/part4/part4.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part4 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part4.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part4 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part5/main.cpp b/examples/tutorials/addressbook/part5/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook/part5/main.cpp +++ b/examples/tutorials/addressbook/part5/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part5/part5.pro b/examples/tutorials/addressbook/part5/part5.pro index 95123d0..e7b7199 100644 --- a/examples/tutorials/addressbook/part5/part5.pro +++ b/examples/tutorials/addressbook/part5/part5.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part5 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part5.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part5 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part6/main.cpp b/examples/tutorials/addressbook/part6/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook/part6/main.cpp +++ b/examples/tutorials/addressbook/part6/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part6/part6.pro b/examples/tutorials/addressbook/part6/part6.pro index dc895613..f6ba411 100644 --- a/examples/tutorials/addressbook/part6/part6.pro +++ b/examples/tutorials/addressbook/part6/part6.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part6 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part6.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part6 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/addressbook/part7/main.cpp b/examples/tutorials/addressbook/part7/main.cpp index 33edf29..5b57aad 100644 --- a/examples/tutorials/addressbook/part7/main.cpp +++ b/examples/tutorials/addressbook/part7/main.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - AddressBook *addressBook = new AddressBook; - addressBook->show(); + AddressBook addressBook; + addressBook.show(); return app.exec(); } diff --git a/examples/tutorials/addressbook/part7/part7.pro b/examples/tutorials/addressbook/part7/part7.pro index a726d91..d2b089e 100644 --- a/examples/tutorials/addressbook/part7/part7.pro +++ b/examples/tutorials/addressbook/part7/part7.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part7 sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part7.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/addressbook/part7 INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/tutorials.pro b/examples/tutorials/tutorials.pro index 8b3f41f..949fdf6 100644 --- a/examples/tutorials/tutorials.pro +++ b/examples/tutorials/tutorials.pro @@ -6,3 +6,5 @@ SUBDIRS = \ sources.files = README *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials INSTALLS += sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/tutorials/widgets/childwidget/childwidget.pro b/examples/tutorials/widgets/childwidget/childwidget.pro new file mode 100644 index 0000000..37ae98e --- /dev/null +++ b/examples/tutorials/widgets/childwidget/childwidget.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS childwidget.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/childwidget +INSTALLS += target sources diff --git a/examples/tutorials/widgets/childwidget/main.cpp b/examples/tutorials/widgets/childwidget/main.cpp new file mode 100644 index 0000000..f6f5630 --- /dev/null +++ b/examples/tutorials/widgets/childwidget/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; + window.resize(320, 240); + window.setWindowTitle(QApplication::translate("childwidget", "Child widget")); + window.show(); + +//! [create, position and show] + QPushButton *button = new QPushButton( + QApplication::translate("childwidget", "Press me"), &window); + button->move(100, 100); + button->show(); +//! [create, position and show] + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/nestedlayouts/main.cpp b/examples/tutorials/widgets/nestedlayouts/main.cpp new file mode 100644 index 0000000..dbd0057 --- /dev/null +++ b/examples/tutorials/widgets/nestedlayouts/main.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +//! [first part] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; + + QLabel *queryLabel = new QLabel( + QApplication::translate("nestedlayouts", "Query:")); + QLineEdit *queryEdit = new QLineEdit(); + QTableView *resultView = new QTableView(); + + QHBoxLayout *queryLayout = new QHBoxLayout(); + queryLayout->addWidget(queryLabel); + queryLayout->addWidget(queryEdit); + + QVBoxLayout *mainLayout = new QVBoxLayout(); + mainLayout->addLayout(queryLayout); + mainLayout->addWidget(resultView); + window.setLayout(mainLayout); + + // Set up the model and configure the view... +//! [first part] + +//! [set up the model] + QStandardItemModel model; + model.setHorizontalHeaderLabels( + QStringList() << QApplication::translate("nestedlayouts", "Name") + << QApplication::translate("nestedlayouts", "Office")); + + QList<QStringList> rows = QList<QStringList>() + << (QStringList() << "Verne Nilsen" << "123") + << (QStringList() << "Carlos Tang" << "77") + << (QStringList() << "Bronwyn Hawcroft" << "119") + << (QStringList() << "Alessandro Hanssen" << "32") + << (QStringList() << "Andrew John Bakken" << "54") + << (QStringList() << "Vanessa Weatherley" << "85") + << (QStringList() << "Rebecca Dickens" << "17") + << (QStringList() << "David Bradley" << "42") + << (QStringList() << "Knut Walters" << "25") + << (QStringList() << "Andrea Jones" << "34"); + + foreach (QStringList row, rows) { + QList<QStandardItem *> items; + foreach (QString text, row) + items.append(new QStandardItem(text)); + model.appendRow(items); + } + + resultView->setModel(&model); + resultView->verticalHeader()->hide(); + resultView->horizontalHeader()->setStretchLastSection(true); +//! [set up the model] +//! [last part] + window.setWindowTitle( + QApplication::translate("nestedlayouts", "Nested layouts")); + window.show(); + return app.exec(); +} +//! [last part] +//! [main program] diff --git a/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro new file mode 100644 index 0000000..a7f141c --- /dev/null +++ b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS nestedlayouts.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/nestedlayouts +INSTALLS += target sources diff --git a/examples/tutorials/widgets/toplevel/main.cpp b/examples/tutorials/widgets/toplevel/main.cpp new file mode 100644 index 0000000..06eaa22 --- /dev/null +++ b/examples/tutorials/widgets/toplevel/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); +//! [create, resize and show] + QWidget window; + window.resize(320, 240); + window.show(); +//! [create, resize and show] + window.setWindowTitle( + QApplication::translate("toplevel", "Top-level widget")); + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/toplevel/toplevel.pro b/examples/tutorials/widgets/toplevel/toplevel.pro new file mode 100644 index 0000000..58d59c5 --- /dev/null +++ b/examples/tutorials/widgets/toplevel/toplevel.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS toplevel.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/toplevel +INSTALLS += target sources diff --git a/examples/tutorials/widgets/widgets.pro b/examples/tutorials/widgets/widgets.pro new file mode 100644 index 0000000..7a870e7 --- /dev/null +++ b/examples/tutorials/widgets/widgets.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS = toplevel childwidget windowlayout nestedlayouts + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS widgets.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets +INSTALLS += target sources diff --git a/examples/tutorials/widgets/windowlayout/main.cpp b/examples/tutorials/widgets/windowlayout/main.cpp new file mode 100644 index 0000000..664a709 --- /dev/null +++ b/examples/tutorials/widgets/windowlayout/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [main program] +#include <QtGui> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; +//! [create, lay out widgets and show] + QLabel *label = new QLabel(QApplication::translate("windowlayout", "Name:")); + QLineEdit *lineEdit = new QLineEdit(); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->addWidget(label); + layout->addWidget(lineEdit); + window.setLayout(layout); +//! [create, lay out widgets and show] + window.setWindowTitle( + QApplication::translate("windowlayout", "Window layout")); + window.show(); + return app.exec(); +} +//! [main program] diff --git a/examples/tutorials/widgets/windowlayout/windowlayout.pro b/examples/tutorials/widgets/windowlayout/windowlayout.pro new file mode 100644 index 0000000..408f6ef --- /dev/null +++ b/examples/tutorials/widgets/windowlayout/windowlayout.pro @@ -0,0 +1,7 @@ +SOURCES = main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS windowlayout.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tutorials/widgets/windowlayout +INSTALLS += target sources diff --git a/examples/uitools/multipleinheritance/multipleinheritance.pro b/examples/uitools/multipleinheritance/multipleinheritance.pro index 92dda2e..e8f59fb 100644 --- a/examples/uitools/multipleinheritance/multipleinheritance.pro +++ b/examples/uitools/multipleinheritance/multipleinheritance.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/uitools/multipleinheritance sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/uitools/multipleinheritance INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/uitools/textfinder/forms/input.txt b/examples/uitools/textfinder/forms/input.txt index fae542f..29dfe5d 100644 --- a/examples/uitools/textfinder/forms/input.txt +++ b/examples/uitools/textfinder/forms/input.txt @@ -1,5 +1,5 @@ These forms are processed at run-time to produce dynamically-generated user interfaces. -In order to generate a form at run-time, a resource file containing a .ui file is needed. +In order to generate a form at run-time, a resource file containing a UI file is needed. Applications that use the form handling classes need to be configured to be built against the QtUiTools module. This is done by including the following declaration in a qmake project file to ensure that the application is compiled and linked appropriately. A form loader object, diff --git a/examples/uitools/textfinder/textfinder.pro b/examples/uitools/textfinder/textfinder.pro index 9d2a96d..91df91d 100644 --- a/examples/uitools/textfinder/textfinder.pro +++ b/examples/uitools/textfinder/textfinder.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/uitools/textfinder sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro forms sources.path = $$[QT_INSTALL_EXAMPLES]/uitools/textfinder INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/uitools/uitools.pro b/examples/uitools/uitools.pro index ddec822..4a643e6 100644 --- a/examples/uitools/uitools.pro +++ b/examples/uitools/uitools.pro @@ -1,10 +1,12 @@ TEMPLATE = subdirs SUBDIRS = multipleinheritance -!wince*:contains(QT_BUILD_PARTS, tools): SUBDIRS += textfinder +!wince*:!symbian:contains(QT_BUILD_PARTS, tools): SUBDIRS += textfinder # install target.path = $$[QT_INSTALL_EXAMPLES]/uitools sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS uitools.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/uitools INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/video/video.pro b/examples/video/video.pro new file mode 100644 index 0000000..f0b63b6 --- /dev/null +++ b/examples/video/video.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + videographicsitem \ + videowidget + diff --git a/examples/video/videographicsitem/main.cpp b/examples/video/videographicsitem/main.cpp new file mode 100644 index 0000000..b80ac47 --- /dev/null +++ b/examples/video/videographicsitem/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videoplayer.h" + +#include <QtGui/QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + VideoPlayer player; + player.show(); + + return app.exec(); +} + diff --git a/examples/video/videographicsitem/videographicsitem.pro b/examples/video/videographicsitem/videographicsitem.pro new file mode 100644 index 0000000..7e0b4c5 --- /dev/null +++ b/examples/video/videographicsitem/videographicsitem.pro @@ -0,0 +1,16 @@ +QT += multimedia + +contains(QT_CONFIG, opengl): QT += opengl + +HEADERS += videoplayer.h \ + videoitem.h + +SOURCES += main.cpp \ + videoplayer.cpp \ + videoitem.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/video/videographicsitem +sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.png images +sources.path = $$[QT_INSTALL_EXAMPLES]/video/videographicsitem +INSTALLS += target sources diff --git a/examples/video/videographicsitem/videoitem.cpp b/examples/video/videographicsitem/videoitem.cpp new file mode 100644 index 0000000..6c17d6a --- /dev/null +++ b/examples/video/videographicsitem/videoitem.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videoitem.h" + +#include <QtMultimedia> + +VideoItem::VideoItem(QGraphicsItem *parent) + : QGraphicsItem(parent) + , imageFormat(QImage::Format_Invalid) + , framePainted(false) +{ +} + +VideoItem::~VideoItem() +{ +} + +QRectF VideoItem::boundingRect() const +{ + return QRectF(QPointF(0,0), surfaceFormat().sizeHint()); +} + +void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + + if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { + const QTransform oldTransform = painter->transform(); + + if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { + painter->scale(1, -1); + painter->translate(0, -boundingRect().height()); + } + + painter->drawImage(boundingRect(), QImage( + currentFrame.bits(), + imageSize.width(), + imageSize.height(), + imageFormat)); + + painter->setTransform(oldTransform); + + framePainted = true; + + currentFrame.unmap(); + } +} + +QList<QVideoFrame::PixelFormat> VideoItem::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + if (handleType == QAbstractVideoBuffer::NoHandle) { + return QList<QVideoFrame::PixelFormat>() + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_ARGB32_Premultiplied + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_RGB555; + } else { + return QList<QVideoFrame::PixelFormat>(); + } +} + +bool VideoItem::start(const QVideoSurfaceFormat &format) +{ + if (isFormatSupported(format)) { + imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + imageSize = format.frameSize(); + framePainted = true; + + QAbstractVideoSurface::start(format); + + prepareGeometryChange(); + + return true; + } else { + return false; + } +} + +void VideoItem::stop() +{ + currentFrame = QVideoFrame(); + framePainted = false; + + QAbstractVideoSurface::stop(); +} + +bool VideoItem::present(const QVideoFrame &frame) +{ + if (!framePainted) { + if (!isStarted()) + setError(StoppedError); + + return false; + } else { + currentFrame = frame; + framePainted = false; + + update(); + + return true; + } +} diff --git a/examples/video/videographicsitem/videoitem.h b/examples/video/videographicsitem/videoitem.h new file mode 100644 index 0000000..868cd54 --- /dev/null +++ b/examples/video/videographicsitem/videoitem.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIDEOITEM_H +#define VIDEOITEM_H + +#include <QtMultimedia/QAbstractVideoSurface> +#include <QtGui/QGraphicsItem> + +class VideoItem + : public QAbstractVideoSurface, + public QGraphicsItem +{ + Q_OBJECT +public: + explicit VideoItem(QGraphicsItem *parentItem = 0); + ~VideoItem(); + + QRectF boundingRect() const; + void paint( + QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + + //video surface + QList<QVideoFrame::PixelFormat> supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + + bool start(const QVideoSurfaceFormat &format); + void stop(); + bool present(const QVideoFrame &frame); + +private: + QImage::Format imageFormat; + QSize imageSize; + + QVideoFrame currentFrame; + bool framePainted; +}; + +#endif + diff --git a/examples/video/videographicsitem/videoplayer.cpp b/examples/video/videographicsitem/videoplayer.cpp new file mode 100644 index 0000000..85a5527 --- /dev/null +++ b/examples/video/videographicsitem/videoplayer.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videoplayer.h" +#include "videoitem.h" + +#include <QtMultimedia> + +#ifndef QT_NO_OPENGL +# include <QtOpenGL/QGLWidget> +#endif + +VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags) + : QWidget(parent, flags) + , videoItem(0) + , playButton(0) + , positionSlider(0) +{ + connect(&movie, SIGNAL(stateChanged(QMovie::MovieState)), + this, SLOT(movieStateChanged(QMovie::MovieState))); + connect(&movie, SIGNAL(frameChanged(int)), + this, SLOT(frameChanged(int))); + + videoItem = new VideoItem; + + QGraphicsScene *scene = new QGraphicsScene(this); + QGraphicsView *graphicsView = new QGraphicsView(scene); + +#ifndef QT_NO_OPENGL + graphicsView->setViewport(new QGLWidget); +#endif + + scene->addItem(videoItem); + + QSlider *rotateSlider = new QSlider(Qt::Horizontal); + rotateSlider->setRange(-180, 180); + rotateSlider->setValue(0); + + connect(rotateSlider, SIGNAL(valueChanged(int)), + this, SLOT(rotateVideo(int))); + + QAbstractButton *openButton = new QPushButton(tr("Open...")); + connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + + playButton = new QPushButton; + playButton->setEnabled(false); + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); + + connect(playButton, SIGNAL(clicked()), + this, SLOT(play())); + + positionSlider = new QSlider(Qt::Horizontal); + positionSlider->setRange(0, 0); + + connect(positionSlider, SIGNAL(sliderMoved(int)), + this, SLOT(setPosition(int))); + + connect(&movie, SIGNAL(frameChanged(int)), + positionSlider, SLOT(setValue(int))); + + QBoxLayout *controlLayout = new QHBoxLayout; + controlLayout->setMargin(0); + controlLayout->addWidget(openButton); + controlLayout->addWidget(playButton); + controlLayout->addWidget(positionSlider); + + QBoxLayout *layout = new QVBoxLayout; + layout->addWidget(graphicsView); + layout->addWidget(rotateSlider); + layout->addLayout(controlLayout); + + setLayout(layout); +} + +VideoPlayer::~VideoPlayer() +{ +} + +void VideoPlayer::openFile() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); + + if (!fileName.isEmpty()) { + if (videoItem->isStarted()) + videoItem->stop(); + + movie.setFileName(fileName); + + playButton->setEnabled(true); + positionSlider->setMaximum(movie.frameCount()); + + movie.jumpToFrame(0); + } +} + +void VideoPlayer::play() +{ + switch(movie.state()) { + case QMovie::NotRunning: + movie.start(); + break; + case QMovie::Paused: + movie.setPaused(false); + break; + case QMovie::Running: + movie.setPaused(true); + break; + } +} + +void VideoPlayer::movieStateChanged(QMovie::MovieState state) +{ + switch(state) { + case QMovie::NotRunning: + case QMovie::Paused: + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); + break; + case QMovie::Running: + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); + break; + } +} + +void VideoPlayer::frameChanged(int frame) +{ + if (!presentImage(movie.currentImage())) { + movie.stop(); + playButton->setEnabled(false); + positionSlider->setMaximum(0); + } else { + positionSlider->setValue(frame); + } +} + +void VideoPlayer::setPosition(int frame) +{ + movie.jumpToFrame(frame); +} + +void VideoPlayer::rotateVideo(int angle) +{ + //rotate around the center of video element + qreal x = videoItem->boundingRect().width() / 2.0; + qreal y = videoItem->boundingRect().height() / 2.0; + videoItem->setTransform(QTransform().translate(x, y).rotate(angle).translate(-x, -y)); +} + +bool VideoPlayer::presentImage(const QImage &image) +{ + QVideoFrame frame(image); + + if (!frame.isValid()) + return false; + + QVideoSurfaceFormat currentFormat = videoItem->surfaceFormat(); + + if (frame.pixelFormat() != currentFormat.pixelFormat() + || frame.size() != currentFormat.frameSize()) { + QVideoSurfaceFormat format(frame.size(), frame.pixelFormat()); + + if (!videoItem->start(format)) + return false; + } + + if (!videoItem->present(frame)) { + videoItem->stop(); + + return false; + } else { + return true; + } +} diff --git a/examples/video/videographicsitem/videoplayer.h b/examples/video/videographicsitem/videoplayer.h new file mode 100644 index 0000000..246f727 --- /dev/null +++ b/examples/video/videographicsitem/videoplayer.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIDEOPLAYER_H +#define VIDEOPLAYER_H + +#include <QtGui/QMovie> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE +class QAbstractButton; +class QAbstractVideoSurface; +class QSlider; +QT_END_NAMESPACE + + +class VideoItem; + +class VideoPlayer : public QWidget +{ + Q_OBJECT +public: + VideoPlayer(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ~VideoPlayer(); + + QSize sizeHint() const { return QSize(800, 600); } + +public slots: + void openFile(); + void play(); + +private slots: + void movieStateChanged(QMovie::MovieState state); + void frameChanged(int frame); + void setPosition(int frame); + void rotateVideo(int angle); + +private: + bool presentImage(const QImage &image); + + QMovie movie; + VideoItem *videoItem; + QAbstractButton *playButton; + QSlider *positionSlider; +}; + +#endif + diff --git a/examples/video/videowidget/main.cpp b/examples/video/videowidget/main.cpp new file mode 100644 index 0000000..4fba301 --- /dev/null +++ b/examples/video/videowidget/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videoplayer.h" + +#include <QtGui/QApplication> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + VideoPlayer player; + player.show(); + + return app.exec(); +} diff --git a/examples/video/videowidget/videoplayer.cpp b/examples/video/videowidget/videoplayer.cpp new file mode 100644 index 0000000..2e4c758 --- /dev/null +++ b/examples/video/videowidget/videoplayer.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videoplayer.h" + +#include "videowidget.h" + +#include <QtMultimedia> + +VideoPlayer::VideoPlayer(QWidget *parent) + : QWidget(parent) + , surface(0) + , playButton(0) + , positionSlider(0) +{ + connect(&movie, SIGNAL(stateChanged(QMovie::MovieState)), + this, SLOT(movieStateChanged(QMovie::MovieState))); + connect(&movie, SIGNAL(frameChanged(int)), + this, SLOT(frameChanged(int))); + + VideoWidget *videoWidget = new VideoWidget; + surface = videoWidget->videoSurface(); + + QAbstractButton *openButton = new QPushButton(tr("Open...")); + connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); + + playButton = new QPushButton; + playButton->setEnabled(false); + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); + + connect(playButton, SIGNAL(clicked()), + this, SLOT(play())); + + positionSlider = new QSlider(Qt::Horizontal); + positionSlider->setRange(0, 0); + + connect(positionSlider, SIGNAL(sliderMoved(int)), + this, SLOT(setPosition(int))); + + connect(&movie, SIGNAL(frameChanged(int)), + positionSlider, SLOT(setValue(int))); + + QBoxLayout *controlLayout = new QHBoxLayout; + controlLayout->setMargin(0); + controlLayout->addWidget(openButton); + controlLayout->addWidget(playButton); + controlLayout->addWidget(positionSlider); + + QBoxLayout *layout = new QVBoxLayout; + layout->addWidget(videoWidget); + layout->addLayout(controlLayout); + + setLayout(layout); +} + +VideoPlayer::~VideoPlayer() +{ +} + +void VideoPlayer::openFile() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie")); + + if (!fileName.isEmpty()) { + if (surface->isStarted()) + surface->stop(); + + movie.setFileName(fileName); + + playButton->setEnabled(true); + positionSlider->setMaximum(movie.frameCount()); + + movie.jumpToFrame(0); + } +} + +void VideoPlayer::play() +{ + switch(movie.state()) { + case QMovie::NotRunning: + movie.start(); + break; + case QMovie::Paused: + movie.setPaused(false); + break; + case QMovie::Running: + movie.setPaused(true); + break; + } +} + +void VideoPlayer::movieStateChanged(QMovie::MovieState state) +{ + switch(state) { + case QMovie::NotRunning: + case QMovie::Paused: + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); + break; + case QMovie::Running: + playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); + break; + } +} + +void VideoPlayer::frameChanged(int frame) +{ + if (!presentImage(movie.currentImage())) { + movie.stop(); + playButton->setEnabled(false); + positionSlider->setMaximum(0); + } else { + positionSlider->setValue(frame); + } +} + +void VideoPlayer::setPosition(int frame) +{ + movie.jumpToFrame(frame); +} + +bool VideoPlayer::presentImage(const QImage &image) +{ + QVideoFrame frame(image); + + if (!frame.isValid()) + return false; + + QVideoSurfaceFormat currentFormat = surface->surfaceFormat(); + + if (frame.pixelFormat() != currentFormat.pixelFormat() + || frame.size() != currentFormat.frameSize()) { + QVideoSurfaceFormat format(frame.size(), frame.pixelFormat()); + + if (!surface->start(format)) + return false; + } + + if (!surface->present(frame)) { + surface->stop(); + + return false; + } else { + return true; + } +} diff --git a/examples/video/videowidget/videoplayer.h b/examples/video/videowidget/videoplayer.h new file mode 100644 index 0000000..76f3e9e --- /dev/null +++ b/examples/video/videowidget/videoplayer.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIDEOPLAYER_H +#define VIDEOPLAYER_H + +#include <QtGui/QMovie> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE +class QAbstractButton; +class QAbstractVideoSurface; +class QSlider; +QT_END_NAMESPACE + +class VideoPlayer : public QWidget +{ + Q_OBJECT +public: + VideoPlayer(QWidget *parent = 0); + ~VideoPlayer(); + +public slots: + void openFile(); + void play(); + +private slots: + void movieStateChanged(QMovie::MovieState state); + void frameChanged(int frame); + void setPosition(int frame); + +private: + bool presentImage(const QImage &image); + + QMovie movie; + QAbstractVideoSurface *surface; + QAbstractButton *playButton; + QSlider *positionSlider; +}; + +#endif diff --git a/examples/video/videowidget/videowidget.cpp b/examples/video/videowidget/videowidget.cpp new file mode 100644 index 0000000..b29d2ae --- /dev/null +++ b/examples/video/videowidget/videowidget.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videowidget.h" + +#include "videowidgetsurface.h" + +#include <QtMultimedia> + +//! [0] +VideoWidget::VideoWidget(QWidget *parent) + : QWidget(parent) + , surface(0) +{ + setAutoFillBackground(false); + setAttribute(Qt::WA_NoSystemBackground, true); + setAttribute(Qt::WA_PaintOnScreen, true); + + QPalette palette = this->palette(); + palette.setColor(QPalette::Background, Qt::black); + setPalette(palette); + + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + + surface = new VideoWidgetSurface(this); +} +//! [0] + +//! [1] +VideoWidget::~VideoWidget() +{ + delete surface; +} +//! [1] + +//! [2] +QSize VideoWidget::sizeHint() const +{ + return surface->surfaceFormat().sizeHint(); +} +//! [2] + + +//! [3] +void VideoWidget::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + + if (surface->isStarted()) { + const QRect videoRect = surface->videoRect(); + + if (!videoRect.contains(event->rect())) { + QRegion region = event->region(); + region.subtract(videoRect); + + QBrush brush = palette().background(); + + foreach (const QRect &rect, region.rects()) + painter.fillRect(rect, brush); + } + + surface->paint(&painter); + } else { + painter.fillRect(event->rect(), palette().background()); + } +} +//! [3] + +//! [4] +void VideoWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + surface->updateVideoRect(); +} +//! [4] diff --git a/examples/video/videowidget/videowidget.h b/examples/video/videowidget/videowidget.h new file mode 100644 index 0000000..737d32d --- /dev/null +++ b/examples/video/videowidget/videowidget.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include "videowidgetsurface.h" + +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE +class QAbstractVideoSurface; +QT_END_NAMESPACE + +class VideoWidgetSurface; + +//! [0] +class VideoWidget : public QWidget +{ + Q_OBJECT +public: + VideoWidget(QWidget *parent = 0); + ~VideoWidget(); + + QAbstractVideoSurface *videoSurface() const { return surface; } + + QSize sizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + +private: + VideoWidgetSurface *surface; +}; +//! [0] + +#endif diff --git a/examples/video/videowidget/videowidget.pro b/examples/video/videowidget/videowidget.pro new file mode 100644 index 0000000..a006f2f --- /dev/null +++ b/examples/video/videowidget/videowidget.pro @@ -0,0 +1,14 @@ +TEMPLATE = app + +QT += multimedia + +HEADERS = \ + videoplayer.h \ + videowidget.h \ + videowidgetsurface.h + +SOURCES = \ + main.cpp \ + videoplayer.cpp \ + videowidget.cpp \ + videowidgetsurface.cpp diff --git a/examples/video/videowidget/videowidgetsurface.cpp b/examples/video/videowidget/videowidgetsurface.cpp new file mode 100644 index 0000000..6089b6f --- /dev/null +++ b/examples/video/videowidget/videowidgetsurface.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "videowidgetsurface.h" + +#include <QtMultimedia> + +VideoWidgetSurface::VideoWidgetSurface(QWidget *widget, QObject *parent) + : QAbstractVideoSurface(parent) + , widget(widget) + , imageFormat(QImage::Format_Invalid) +{ +} + +//! [0] +QList<QVideoFrame::PixelFormat> VideoWidgetSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + if (handleType == QAbstractVideoBuffer::NoHandle) { + return QList<QVideoFrame::PixelFormat>() + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_ARGB32_Premultiplied + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_RGB555; + } else { + return QList<QVideoFrame::PixelFormat>(); + } +} +//! [0] + +//! [1] +bool VideoWidgetSurface::isFormatSupported( + const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const +{ + Q_UNUSED(similar); + + const QImage::Format imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + return imageFormat != QImage::Format_Invalid + && !size.isEmpty() + && format.handleType() == QAbstractVideoBuffer::NoHandle; +} +//! [1] + +//! [2] +bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format) +{ + const QImage::Format imageFormat = QVideoFrame::equivalentImageFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { + this->imageFormat = imageFormat; + imageSize = size; + sourceRect = format.viewport(); + + QAbstractVideoSurface::start(format); + + widget->updateGeometry(); + updateVideoRect(); + + return true; + } else { + return false; + } +} +//! [2] + +//! [3] +void VideoWidgetSurface::stop() +{ + currentFrame = QVideoFrame(); + targetRect = QRect(); + + QAbstractVideoSurface::stop(); + + widget->update(); +} +//! [3] + +//! [4] +bool VideoWidgetSurface::present(const QVideoFrame &frame) +{ + if (surfaceFormat().pixelFormat() != frame.pixelFormat() + || surfaceFormat().frameSize() != frame.size()) { + setError(IncorrectFormatError); + stop(); + + return false; + } else { + currentFrame = frame; + + widget->repaint(targetRect); + + return true; + } +} +//! [4] + +//! [5] +void VideoWidgetSurface::updateVideoRect() +{ + QSize size = surfaceFormat().sizeHint(); + size.scale(widget->size().boundedTo(size), Qt::KeepAspectRatio); + + targetRect = QRect(QPoint(0, 0), size); + targetRect.moveCenter(widget->rect().center()); +} +//! [5] + +//! [6] +void VideoWidgetSurface::paint(QPainter *painter) +{ + if (currentFrame.map(QAbstractVideoBuffer::ReadOnly)) { + const QTransform oldTransform = painter->transform(); + + if (surfaceFormat().scanLineDirection() == QVideoSurfaceFormat::BottomToTop) { + painter->scale(1, -1); + painter->translate(0, -widget->height()); + } + + QImage image( + currentFrame.bits(), + currentFrame.width(), + currentFrame.height(), + currentFrame.bytesPerLine(), + imageFormat); + + painter->drawImage(targetRect, image, sourceRect); + + painter->setTransform(oldTransform); + + currentFrame.unmap(); + } +} +//! [6] diff --git a/examples/video/videowidget/videowidgetsurface.h b/examples/video/videowidget/videowidgetsurface.h new file mode 100644 index 0000000..74cda82 --- /dev/null +++ b/examples/video/videowidget/videowidgetsurface.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef VIDEOWIDGETSURFACE_H +#define VIDEOWIDGETSURFACE_H + +#include <QtCore/QRect> +#include <QtGui/QImage> +#include <QtMultimedia/QAbstractVideoSurface> +#include <QtMultimedia/QVideoFrame> + +//! [0] +class VideoWidgetSurface : public QAbstractVideoSurface +{ + Q_OBJECT +public: + VideoWidgetSurface(QWidget *widget, QObject *parent = 0); + + QList<QVideoFrame::PixelFormat> supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + bool isFormatSupported(const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const; + + bool start(const QVideoSurfaceFormat &format); + void stop(); + + bool present(const QVideoFrame &frame); + + QRect videoRect() const { return targetRect; } + void updateVideoRect(); + + void paint(QPainter *painter); + +private: + QWidget *widget; + QImage::Format imageFormat; + QRect targetRect; + QSize imageSize; + QRect sourceRect; + QVideoFrame currentFrame; +}; +//! [0] + +#endif diff --git a/examples/webkit/fancybrowser/fancybrowser.pro b/examples/webkit/fancybrowser/fancybrowser.pro index 3de3036..e496241 100644 --- a/examples/webkit/fancybrowser/fancybrowser.pro +++ b/examples/webkit/fancybrowser/fancybrowser.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = mainwindow.h SOURCES = main.cpp \ mainwindow.cpp @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/fancybrowser sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/fancybrowser INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000CF6C diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp index a5d989c..ecca36b 100644 --- a/examples/webkit/fancybrowser/mainwindow.cpp +++ b/examples/webkit/fancybrowser/mainwindow.cpp @@ -94,6 +94,7 @@ MainWindow::MainWindow() toolsMenu->addAction(tr("Remove all embedded elements"), this, SLOT(removeEmbeddedElements())); setCentralWidget(view); + setUnifiedTitleAndToolBarOnMac(true); } //! [3] diff --git a/examples/webkit/fancybrowser/mainwindow.h b/examples/webkit/fancybrowser/mainwindow.h index c2d0368..6b0c72d 100644 --- a/examples/webkit/fancybrowser/mainwindow.h +++ b/examples/webkit/fancybrowser/mainwindow.h @@ -41,8 +41,8 @@ #include <QtGui> -QT_BEGIN_NAMESPACE class QWebView; +QT_BEGIN_NAMESPACE class QLineEdit; QT_END_NAMESPACE diff --git a/examples/webkit/formextractor/form.html b/examples/webkit/formextractor/form.html index 18ddff1..6b0bbde 100755 --- a/examples/webkit/formextractor/form.html +++ b/examples/webkit/formextractor/form.html @@ -1,22 +1,4 @@ -<html><script> -function extractFormValues() -{ - var firstName = document.getElementById("firstname").value; - var lastName = document.getElementById("lastname").value; - var maleGender = document.getElementById("genderMale"); - var femaleGender = document.getElementById("genderFemale"); - - var gender = ""; - if (maleGender.checked) - gender = maleGender.value; - else if (femaleGender.checked) - gender = femaleGender.value; - - var updates = document.getElementById("updates").checked; - - formExtractor.setValues(firstName, lastName, gender, updates); -} -</script><body> +<html><body> <h1> The Green People Book Club </h1> @@ -24,7 +6,7 @@ The Green People Book Club <p> Welcome to The Green People Book Club. Please register to obtain a membership with us. </p> - <form onsubmit="extractFormValues()"> + <form onsubmit="formExtractor.submit()"> <table> <tbody><tr> <td> @@ -61,4 +43,4 @@ Welcome to The Green People Book Club. Please register to obtain a membership wi <input type="submit" value="Submit"> </form> -</body></html>
\ No newline at end of file +</body></html> diff --git a/examples/webkit/formextractor/formextractor.cpp b/examples/webkit/formextractor/formextractor.cpp index e1d31e8..c0d4063 100644 --- a/examples/webkit/formextractor/formextractor.cpp +++ b/examples/webkit/formextractor/formextractor.cpp @@ -41,6 +41,8 @@ #include "formextractor.h" +#include <QWebElement> + FormExtractor::FormExtractor(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags) { @@ -55,17 +57,28 @@ FormExtractor::~FormExtractor() { } -void FormExtractor::setValues(const QString &firstName, const QString &lastName, - const QString &gender, bool updates) +void FormExtractor::submit() { - ui.firstNameEdit->setText(firstName); - ui.lastNameEdit->setText(lastName); - ui.genderEdit->setText(gender); + QWebFrame *frame = ui.webView->page()->mainFrame(); - if (updates == false) - ui.updatesEdit->setText("No"); - else + QWebElement firstName = frame->findFirstElement("#firstname"); + QWebElement lastName = frame->findFirstElement("#lastname"); + QWebElement maleGender = frame->findFirstElement("#genderMale"); + QWebElement femaleGender = frame->findFirstElement("#genderFemale"); + QWebElement updates = frame->findFirstElement("#updates"); + + ui.firstNameEdit->setText(firstName.scriptableProperty("value").toString()); + ui.lastNameEdit->setText(lastName.scriptableProperty("value").toString()); + + if (maleGender.scriptableProperty("checked").toBool()) + ui.genderEdit->setText(maleGender.scriptableProperty("value").toString()); + else if (femaleGender.scriptableProperty("checked").toBool()) + ui.genderEdit->setText(femaleGender.scriptableProperty("value").toString()); + + if (updates.scriptableProperty("checked").toBool()) ui.updatesEdit->setText("Yes"); + else + ui.updatesEdit->setText("No"); } void FormExtractor::populateJavaScriptWindowObject() diff --git a/examples/webkit/formextractor/formextractor.h b/examples/webkit/formextractor/formextractor.h index 9aba404..a3d67ac 100644 --- a/examples/webkit/formextractor/formextractor.h +++ b/examples/webkit/formextractor/formextractor.h @@ -55,9 +55,7 @@ public: ~FormExtractor(); public slots: - void setValues(const QString &firstName, const QString &lastName, - const QString &gender, bool updates); - + void submit(); void populateJavaScriptWindowObject(); private: diff --git a/examples/webkit/formextractor/formextractor.pro b/examples/webkit/formextractor/formextractor.pro index d2cb240..ba9c72f 100644 --- a/examples/webkit/formextractor/formextractor.pro +++ b/examples/webkit/formextractor/formextractor.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network TARGET = formExtractor TEMPLATE = app SOURCES += main.cpp \ @@ -14,3 +14,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/formextractor sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro form.html images sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/formextractor INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF6D +} diff --git a/examples/webkit/formextractor/mainwindow.cpp b/examples/webkit/formextractor/mainwindow.cpp index dde9e39..7bf8b6b 100644 --- a/examples/webkit/formextractor/mainwindow.cpp +++ b/examples/webkit/formextractor/mainwindow.cpp @@ -48,13 +48,14 @@ MainWindow::MainWindow() createMenus(); centralWidget = new FormExtractor(this); setCentralWidget(centralWidget); + setUnifiedTitleAndToolBarOnMac(true); } void MainWindow::createActions() { exitAct = new QAction(tr("E&xit"), this); exitAct->setStatusTip(tr("Exit the application")); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp new file mode 100644 index 0000000..a241142 --- /dev/null +++ b/examples/webkit/framecapture/framecapture.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "framecapture.h" + +#include <iostream> +#include <QtWebKit> + +FrameCapture::FrameCapture(): QObject(), m_percent(0) +{ + connect(&m_page, SIGNAL(loadProgress(int)), this, SLOT(printProgress(int))); + connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); +} + +void FrameCapture::load(const QUrl &url, const QString &outputFileName) +{ + std::cout << "Loading " << qPrintable(url.toString()) << std::endl; + m_percent = 0; + int index = outputFileName.lastIndexOf('.'); + m_fileName = (index == -1) ? outputFileName + ".png" : outputFileName; + m_page.mainFrame()->load(url); + m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); + m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); +} + +void FrameCapture::printProgress(int percent) +{ + if (m_percent >= percent) + return; + + while (m_percent++ < percent) + std::cout << "#" << std::flush; +} + +void FrameCapture::saveResult(bool ok) +{ + std::cout << std::endl; + + // crude error-checking + if (!ok) { + std::cerr << "Failed loading " << qPrintable(m_page.mainFrame()->url().toString()) << std::endl; + emit finished(); + return; + } + + // save each internal frame in different image files + int frameCounter = 0; + foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) { + QString fileName(m_fileName); + int index = m_fileName.lastIndexOf('.'); + fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter)); + + frame->setClipRenderToViewport(false); + + QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::transparent); + + saveFrame(frame, image, fileName); + } + + // save the main frame + m_page.setViewportSize(m_page.mainFrame()->contentsSize()); + QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::transparent); + saveFrame(m_page.mainFrame(), image, m_fileName); + + emit finished(); +} + +void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName) +{ + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setRenderHint(QPainter::TextAntialiasing, true); + painter.setRenderHint(QPainter::SmoothPixmapTransform, true); + + frame->render(&painter); + + painter.end(); + + image.save(fileName); +} + diff --git a/examples/webkit/framecapture/framecapture.h b/examples/webkit/framecapture/framecapture.h new file mode 100644 index 0000000..5b887de --- /dev/null +++ b/examples/webkit/framecapture/framecapture.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FRAMECAPTURE_H +#define FRAMECAPTURE_H + +#include <QtWebKit> + +class FrameCapture : public QObject +{ + Q_OBJECT + +public: + FrameCapture(); + void load(const QUrl &url, const QString &outputFileName); + +signals: + void finished(); + +private slots: + void printProgress(int percent); + void saveResult(bool ok); + +private: + QWebPage m_page; + QString m_fileName; + int m_percent; + + void saveFrame(QWebFrame *frame, QImage image, QString fileName); +}; + +#endif diff --git a/examples/webkit/framecapture/framecapture.pro b/examples/webkit/framecapture/framecapture.pro new file mode 100644 index 0000000..6f2f093 --- /dev/null +++ b/examples/webkit/framecapture/framecapture.pro @@ -0,0 +1,11 @@ +QT += webkit + +HEADERS = framecapture.h +SOURCES = main.cpp \ + framecapture.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/webkit/framecapture +sources.files = $$SOURCES $$HEADERS +sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/framecapture +INSTALLS += target sources diff --git a/examples/webkit/framecapture/main.cpp b/examples/webkit/framecapture/main.cpp new file mode 100644 index 0000000..0de5e14 --- /dev/null +++ b/examples/webkit/framecapture/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "framecapture.h" + +#include <iostream> +#include <QtGui> + +int main(int argc, char * argv[]) +{ + if (argc != 3) { + std::cout << "Capture a web page and save its internal frames in different images" << std::endl << std::endl; + std::cout << " framecapture <url> <outputfile>" << std::endl; + std::cout << std::endl; + std::cout << "Notes:" << std::endl; + std::cout << " 'url' is the URL of the web page to be captured" << std::endl; + std::cout << " 'outputfile' is the prefix of the image files to be generated" << std::endl; + std::cout << std::endl; + std::cout << "Example: " << std::endl; + std::cout << " framecapture qt.nokia.com trolltech.png" << std::endl; + std::cout << std::endl; + std::cout << "Result:" << std::endl; + std::cout << " trolltech.png (full page)" << std::endl; + std::cout << " trolltech_frame1.png (...) trolltech_frameN.png ('N' number of internal frames)" << std::endl; + return 0; + } + + QUrl url = QWebView::guessUrlFromString(QString::fromLatin1(argv[1])); + QString fileName = QString::fromLatin1(argv[2]); + + QApplication a(argc, argv); + FrameCapture capture; + QObject::connect(&capture, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); + capture.load(url, fileName); + + return a.exec(); +} + diff --git a/examples/webkit/googlechat/googlechat.pro b/examples/webkit/googlechat/googlechat.pro index 14b7085..8e4f9a6 100644 --- a/examples/webkit/googlechat/googlechat.pro +++ b/examples/webkit/googlechat/googlechat.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = googlechat.h SOURCES = main.cpp \ googlechat.cpp @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/googlechat sources.files = $$SOURCES $$HEADERS $$FORMS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/googlechat INSTALLS += target sources + +symbian:TARGET.UID3 = 0xA000CF6E diff --git a/examples/webkit/previewer/mainwindow.cpp b/examples/webkit/previewer/mainwindow.cpp index 150d7de..88fe167 100644 --- a/examples/webkit/previewer/mainwindow.cpp +++ b/examples/webkit/previewer/mainwindow.cpp @@ -61,7 +61,7 @@ MainWindow::MainWindow() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing HTML file")); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); @@ -72,13 +72,13 @@ void MainWindow::createActions() //! [1] saveAct = new QAction(tr("&Save"), this); - saveAct->setShortcut(tr("Ctrl+S")); + saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the HTML file to disk")); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); exitAct = new QAction(tr("E&xit"), this); exitAct->setStatusTip(tr("Exit the application")); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/webkit/previewer/previewer.pro b/examples/webkit/previewer/previewer.pro index 75ab6fb..c3088a2 100644 --- a/examples/webkit/previewer/previewer.pro +++ b/examples/webkit/previewer/previewer.pro @@ -1,4 +1,4 @@ -QT += webkit +QT += webkit network HEADERS = previewer.h \ mainwindow.h SOURCES = main.cpp \ @@ -11,3 +11,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit/previewer sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/webkit/previewer INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF6F +} diff --git a/examples/webkit/webkit.pro b/examples/webkit/webkit.pro index 225816a..9ad6789 100644 --- a/examples/webkit/webkit.pro +++ b/examples/webkit/webkit.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/webkit sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS webkit.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/webkit INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/analogclock/analogclock.pro b/examples/widgets/analogclock/analogclock.pro index 62a1806..50c0a06 100644 --- a/examples/widgets/analogclock/analogclock.pro +++ b/examples/widgets/analogclock/analogclock.pro @@ -7,3 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/analogclock sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS analogclock.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/analogclock INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000A64F +} diff --git a/examples/widgets/calculator/calculator.pro b/examples/widgets/calculator/calculator.pro index a9a50d6..585ff43 100644 --- a/examples/widgets/calculator/calculator.pro +++ b/examples/widgets/calculator/calculator.pro @@ -9,3 +9,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/calculator sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS calculator.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/calculator INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C602 +} diff --git a/examples/widgets/calendarwidget/calendarwidget.pro b/examples/widgets/calendarwidget/calendarwidget.pro index 9326989..f6cf21f 100644 --- a/examples/widgets/calendarwidget/calendarwidget.pro +++ b/examples/widgets/calendarwidget/calendarwidget.pro @@ -7,3 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/calendarwidget sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS calendarwidget.pro resources sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/calendarwidget INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C603 +} diff --git a/examples/widgets/calendarwidget/window.cpp b/examples/widgets/calendarwidget/window.cpp index 2c719eb..6ba0e4f 100644 --- a/examples/widgets/calendarwidget/window.cpp +++ b/examples/widgets/calendarwidget/window.cpp @@ -167,22 +167,22 @@ void Window::reformatHeaders() //! [8] void Window::reformatCalendarPage() { - QTextCharFormat mayFirstFormat; - if (mayFirstCheckBox->isChecked()) - mayFirstFormat.setForeground(Qt::red); - - QTextCharFormat firstFridayFormat; - if (firstFridayCheckBox->isChecked()) + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } - QDate date(calendar->yearShown(), calendar->monthShown(), 1); - - calendar->setDateTextFormat(QDate(date.year(), 5, 1), mayFirstFormat); - - date.setDate(date.year(), date.month(), 1); - while (date.dayOfWeek() != Qt::Friday) - date = date.addDays(1); - calendar->setDateTextFormat(date, firstFridayFormat); + //May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } } //! [8] diff --git a/examples/widgets/charactermap/charactermap.pro b/examples/widgets/charactermap/charactermap.pro index fe0733d..eea2cb4 100644 --- a/examples/widgets/charactermap/charactermap.pro +++ b/examples/widgets/charactermap/charactermap.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/charactermap sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS charactermap.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/charactermap INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/digitalclock/digitalclock.pro b/examples/widgets/digitalclock/digitalclock.pro index b87b4a0..78e9eae 100644 --- a/examples/widgets/digitalclock/digitalclock.pro +++ b/examples/widgets/digitalclock/digitalclock.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/digitalclock sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS digitalclock.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/digitalclock INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/groupbox/groupbox.pro b/examples/widgets/groupbox/groupbox.pro index 7175f66..2757ce1 100644 --- a/examples/widgets/groupbox/groupbox.pro +++ b/examples/widgets/groupbox/groupbox.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/groupbox sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS groupbox.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/groupbox INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/icons/icons.pro b/examples/widgets/icons/icons.pro index 3b432d9..39c7ab2 100644 --- a/examples/widgets/icons/icons.pro +++ b/examples/widgets/icons/icons.pro @@ -14,6 +14,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS icons.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/icons INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: { imageFiles.sources = images/* wincewm*: { diff --git a/examples/widgets/icons/mainwindow.cpp b/examples/widgets/icons/mainwindow.cpp index 982ae47..20fa275 100644 --- a/examples/widgets/icons/mainwindow.cpp +++ b/examples/widgets/icons/mainwindow.cpp @@ -369,7 +369,7 @@ void MainWindow::createActions() this, SLOT(removeAllImages())); exitAct = new QAction(tr("&Quit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); styleActionGroup = new QActionGroup(this); diff --git a/examples/widgets/imageviewer/imageviewer.pro b/examples/widgets/imageviewer/imageviewer.pro index 31c9d47..c865618 100644 --- a/examples/widgets/imageviewer/imageviewer.pro +++ b/examples/widgets/imageviewer/imageviewer.pro @@ -8,6 +8,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS imageviewer.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/imageviewer INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: { DEPLOYMENT_PLUGIN += qjpeg qmng qgif } diff --git a/examples/widgets/lineedits/lineedits.pro b/examples/widgets/lineedits/lineedits.pro index e963024..409215c 100644 --- a/examples/widgets/lineedits/lineedits.pro +++ b/examples/widgets/lineedits/lineedits.pro @@ -7,3 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/lineedits sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS lineedits.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/lineedits INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C604 +} diff --git a/examples/widgets/movie/movie.pro b/examples/widgets/movie/movie.pro index 6aa5780..517fec7 100644 --- a/examples/widgets/movie/movie.pro +++ b/examples/widgets/movie/movie.pro @@ -8,6 +8,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES movie.pro animation.mng sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/movie INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: { addFiles.sources += *.mng addFiles.path = . diff --git a/examples/widgets/scribble/mainwindow.cpp b/examples/widgets/scribble/mainwindow.cpp index 05b2c17..99c4d45 100644 --- a/examples/widgets/scribble/mainwindow.cpp +++ b/examples/widgets/scribble/mainwindow.cpp @@ -141,7 +141,7 @@ void MainWindow::createActions() //! [13] //! [14] { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); foreach (QByteArray format, QImageWriter::supportedImageFormats()) { @@ -157,7 +157,7 @@ void MainWindow::createActions() connect(printAct, SIGNAL(triggered()), scribbleArea, SLOT(print())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); penColorAct = new QAction(tr("&Pen Color..."), this); diff --git a/examples/widgets/scribble/scribble.pro b/examples/widgets/scribble/scribble.pro index 21f24cc..cf92a25 100644 --- a/examples/widgets/scribble/scribble.pro +++ b/examples/widgets/scribble/scribble.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS scribble.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/scribble INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/shapedclock/shapedclock.pro b/examples/widgets/shapedclock/shapedclock.pro index 6ef5dd0..bf4ee70 100644 --- a/examples/widgets/shapedclock/shapedclock.pro +++ b/examples/widgets/shapedclock/shapedclock.pro @@ -7,3 +7,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/shapedclock sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS shapedclock.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/shapedclock INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C605 +} diff --git a/examples/widgets/sliders/sliders.pro b/examples/widgets/sliders/sliders.pro index b845554..fd39a22 100644 --- a/examples/widgets/sliders/sliders.pro +++ b/examples/widgets/sliders/sliders.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/sliders sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS sliders.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/sliders INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/softkeys/main.cpp b/examples/widgets/softkeys/main.cpp new file mode 100644 index 0000000..a0f6052 --- /dev/null +++ b/examples/widgets/softkeys/main.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include "softkeys.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow mw; + mw.showMaximized(); + return app.exec(); +} diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp new file mode 100644 index 0000000..98ffd69 --- /dev/null +++ b/examples/widgets/softkeys/softkeys.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "softkeys.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + central = new QWidget(this); + central->setContextMenuPolicy(Qt::NoContextMenu); // explicitly forbid usage of context menu so actions item is not shown menu + setCentralWidget(central); + + // Create text editor and set softkeys to it + textEditor= new QTextEdit(tr("Navigate in UI to see context sensitive softkeys in action"), this); + QAction* menu = new QAction(tr("Menu"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); + QAction* clear = new QAction(tr("Clear"), this); + clear->setSoftKeyRole(QAction::CancelSoftKey); + + QList<QAction*> textEditorSoftKeys; + textEditorSoftKeys.append(menu); + textEditorSoftKeys.append(clear); + textEditor->setSoftKeys(textEditorSoftKeys); + + infoLabel = new QLabel(tr(""), this); + infoLabel->setContextMenuPolicy(Qt::NoContextMenu); + + toggleButton = new QPushButton(tr("Custom softkeys"), this); + toggleButton->setContextMenuPolicy(Qt::NoContextMenu); + toggleButton->setCheckable(true); + + pushButton = new QPushButton(tr("Open File Dialog"), this); + pushButton->setContextMenuPolicy(Qt::NoContextMenu); + + QComboBox* comboBox = new QComboBox(this); + comboBox->setContextMenuPolicy(Qt::NoContextMenu); + comboBox->insertItems(0, QStringList() + << QApplication::translate("MainWindow", "Selection1", 0, QApplication::UnicodeUTF8) + << QApplication::translate("MainWindow", "Selection2", 0, QApplication::UnicodeUTF8) + << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8) + ); + + layout = new QVBoxLayout; + layout->addWidget(textEditor); + layout->addWidget(infoLabel); + layout->addWidget(toggleButton); + layout->addWidget(pushButton); + layout->addWidget(comboBox); + central->setLayout(layout); + + fileMenu = menuBar()->addMenu(tr("&File")); + exit = new QAction(tr("&Exit"), this); + fileMenu->addAction(exit); + + connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor())); + connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog())); + connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication())); + connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys())); + pushButton->setFocus(); +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::clearTextEditor() +{ + textEditor->setText(tr("")); +} + +void MainWindow::openDialog() +{ + QFileDialog::getOpenFileName(this); +} + +void MainWindow::addSoftKeys() +{ + ok = new QAction(tr("Ok"), this); + ok->setSoftKeyRole(QAction::OkSoftKey); + connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); + + cancel = new QAction(tr("Cancel"), this); + cancel->setSoftKeyRole(QAction::CancelSoftKey); + connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); + + QList<QAction*> softkeys; + softkeys.append(ok); + softkeys.append(cancel); + QWidget* focusWidget = QApplication::focusWidget(); + if (focusWidget) + focusWidget->setSoftKeys(softkeys); +} + +void MainWindow::setCustomSoftKeys() +{ + if (toggleButton->isChecked()) { + infoLabel->setText(tr("Custom softkeys set")); + addSoftKeys(); + } + else { + infoLabel->setText(tr("Custom softkeys removed")); + QWidget* focusWidget = QApplication::focusWidget(); + if (focusWidget) + focusWidget->setSoftKey(0); + } +} + +void MainWindow::exitApplication() +{ + qApp->exit(); +} + +void MainWindow::okPressed() +{ + infoLabel->setText(tr("OK pressed")); +} + +void MainWindow::cancelPressed() +{ + infoLabel->setText(tr("Cancel pressed")); +} + + diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h new file mode 100644 index 0000000..e0ee89a --- /dev/null +++ b/examples/widgets/softkeys/softkeys.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SOFTKEYS_H +#define SOFTKEYS_H + +#include <QtGui> + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + +private slots: + void clearTextEditor(); + void openDialog(); + void addSoftKeys(); + void exitApplication(); + void okPressed(); + void cancelPressed(); + void setCustomSoftKeys(); +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +private: + QVBoxLayout *layout; + QWidget *central; + QTextEdit* textEditor; + QLabel *infoLabel; + QPushButton* toggleButton; + QPushButton* pushButton; + QMenu* fileMenu; + QAction* addSoftKeysAct; + QAction* exit; + QAction* ok; + QAction* cancel; +}; + +//! [0] +class SoftKey : public QWidget +{ + Q_OBJECT +public: + SoftKey(QWidget *parent = 0); +}; +//! [0] + +#endif diff --git a/examples/widgets/softkeys/softkeys.pro b/examples/widgets/softkeys/softkeys.pro new file mode 100644 index 0000000..6c3271e --- /dev/null +++ b/examples/widgets/softkeys/softkeys.pro @@ -0,0 +1,15 @@ +HEADERS = softkeys.h +SOURCES += \ + main.cpp \ + softkeys.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/widgets/softkeys +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS softkeys.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/softkeys +INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000CF6B +} diff --git a/examples/widgets/spinboxes/spinboxes.pro b/examples/widgets/spinboxes/spinboxes.pro index 4edb79a..129ec81 100644 --- a/examples/widgets/spinboxes/spinboxes.pro +++ b/examples/widgets/spinboxes/spinboxes.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/spinboxes sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spinboxes.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/spinboxes INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/styles/styles.pro b/examples/widgets/styles/styles.pro index 4c6c682..1228803 100644 --- a/examples/widgets/styles/styles.pro +++ b/examples/widgets/styles/styles.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/styles sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS styles.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/styles INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/stylesheet/stylesheet.pro b/examples/widgets/stylesheet/stylesheet.pro index 9a64c00..c67eba3 100644 --- a/examples/widgets/stylesheet/stylesheet.pro +++ b/examples/widgets/stylesheet/stylesheet.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/stylesheet sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro images layouts qss sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/stylesheet INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/tablet/mainwindow.cpp b/examples/widgets/tablet/mainwindow.cpp index 854720a..3471624 100644 --- a/examples/widgets/tablet/mainwindow.cpp +++ b/examples/widgets/tablet/mainwindow.cpp @@ -212,17 +212,17 @@ void MainWindow::createActions() this, SLOT(lineWidthActionTriggered(QAction *))); exitAction = new QAction(tr("E&xit"), this); - exitAction->setShortcut(tr("Ctrl+X")); + exitAction->setShortcuts(QKeySequence::Quit); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); loadAction = new QAction(tr("&Open..."), this); - loadAction->setShortcut(tr("Ctrl+O")); + loadAction->setShortcuts(QKeySequence::Open); connect(loadAction, SIGNAL(triggered()), this, SLOT(loadAct())); saveAction = new QAction(tr("&Save As..."), this); - saveAction->setShortcut(tr("Ctrl+S")); + saveAction->setShortcuts(QKeySequence::SaveAs); connect(saveAction, SIGNAL(triggered()), this, SLOT(saveAct())); diff --git a/examples/widgets/tablet/tablet.pro b/examples/widgets/tablet/tablet.pro index 27d8d2c..e135203 100644 --- a/examples/widgets/tablet/tablet.pro +++ b/examples/widgets/tablet/tablet.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tablet sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tablet.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/tablet INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/tablet/tabletcanvas.cpp b/examples/widgets/tablet/tabletcanvas.cpp index 33a9e3b..abb667c 100644 --- a/examples/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/tablet/tabletcanvas.cpp @@ -137,11 +137,6 @@ void TabletCanvas::paintImage(QPainter &painter, QTabletEvent *event) QPoint brushAdjust(10, 10); switch (myTabletDevice) { - case QTabletEvent::Stylus: - painter.setBrush(myBrush); - painter.setPen(myPen); - painter.drawLine(polyLine[1], event->pos()); - break; case QTabletEvent::Airbrush: myBrush.setColor(myColor); myBrush.setStyle(brushPattern(event->pressure())); @@ -156,10 +151,32 @@ void TabletCanvas::paintImage(QPainter &painter, QTabletEvent *event) case QTabletEvent::Puck: case QTabletEvent::FourDMouse: case QTabletEvent::RotationStylus: - qWarning("This input device is not supported by the example."); + { + const QString error(tr("This input device is not supported by the example.")); +#ifndef QT_NO_STATUSTIP + QStatusTipEvent status(error); + QApplication::sendEvent(this, &status); +#else + qWarning() << error; +#endif + } break; default: - qWarning("Unknown tablet device."); + { + const QString error(tr("Unknown tablet device - treating as stylus")); +#ifndef QT_NO_STATUSTIP + QStatusTipEvent status(error); + QApplication::sendEvent(this, &status); +#else + qWarning() << error; +#endif + } + // FALL-THROUGH + case QTabletEvent::Stylus: + painter.setBrush(myBrush); + painter.setPen(myPen); + painter.drawLine(polyLine[1], event->pos()); + break; } } //! [5] @@ -250,7 +267,7 @@ void TabletCanvas::updateBrush(QTabletEvent *event) } //! [11] -void TabletCanvas::resizeEvent(QResizeEvent *event) +void TabletCanvas::resizeEvent(QResizeEvent *) { initImage(); polyLine[0] = polyLine[1] = polyLine[2] = QPoint(); diff --git a/examples/widgets/tetrix/tetrix.pro b/examples/widgets/tetrix/tetrix.pro index 59392fa..d683f61 100644 --- a/examples/widgets/tetrix/tetrix.pro +++ b/examples/widgets/tetrix/tetrix.pro @@ -11,3 +11,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tetrix sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tetrix.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/tetrix INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C606 +} diff --git a/examples/widgets/tooltips/tooltips.pro b/examples/widgets/tooltips/tooltips.pro index 9f0bf41..f91abea 100644 --- a/examples/widgets/tooltips/tooltips.pro +++ b/examples/widgets/tooltips/tooltips.pro @@ -10,3 +10,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tooltips sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tooltips.pro images sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/tooltips INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/validators/validators.pro b/examples/widgets/validators/validators.pro index 8e7884d..c50b63b 100644 --- a/examples/widgets/validators/validators.pro +++ b/examples/widgets/validators/validators.pro @@ -19,3 +19,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/validators sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.png sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/validators INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro index 0af83c7..d838be0 100644 --- a/examples/widgets/widgets.pro +++ b/examples/widgets/widgets.pro @@ -22,6 +22,16 @@ SUBDIRS = analogclock \ wiggly \ windowflags +symbian: SUBDIRS = \ + analogclock \ + calculator \ + calendarwidget \ + lineedits \ + shapedclock \ + tetrix \ + wiggly \ + softkeys + contains(styles, motif): SUBDIRS += styles # install @@ -29,3 +39,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS widgets.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/widgets INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/widgets/wiggly/dialog.cpp b/examples/widgets/wiggly/dialog.cpp index 2f798a0..da8e1aa 100644 --- a/examples/widgets/wiggly/dialog.cpp +++ b/examples/widgets/wiggly/dialog.cpp @@ -45,7 +45,7 @@ #include "wigglywidget.h" //! [0] -Dialog::Dialog(QWidget *parent) +Dialog::Dialog(QWidget *parent, bool smallScreen) : QDialog(parent) { WigglyWidget *wigglyWidget = new WigglyWidget; @@ -58,9 +58,12 @@ Dialog::Dialog(QWidget *parent) connect(lineEdit, SIGNAL(textChanged(QString)), wigglyWidget, SLOT(setText(QString))); - - lineEdit->setText(tr("Hello world!")); - + if (!smallScreen){ + lineEdit->setText(tr("Hello world!")); + } + else{ + lineEdit->setText(tr("Hello!")); + } setWindowTitle(tr("Wiggly")); resize(360, 145); } diff --git a/examples/widgets/wiggly/dialog.h b/examples/widgets/wiggly/dialog.h index 7aa2bcf..8e902d5 100644 --- a/examples/widgets/wiggly/dialog.h +++ b/examples/widgets/wiggly/dialog.h @@ -50,7 +50,7 @@ class Dialog : public QDialog Q_OBJECT public: - Dialog(QWidget *parent = 0); + Dialog(QWidget *parent = 0, bool smallScreen = false); }; //! [0] diff --git a/examples/widgets/wiggly/main.cpp b/examples/widgets/wiggly/main.cpp index 9706505..5628aac 100644 --- a/examples/widgets/wiggly/main.cpp +++ b/examples/widgets/wiggly/main.cpp @@ -46,8 +46,16 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - - Dialog dialog; - dialog.show(); + bool smallScreen = false; + for (int i=0; i<argc; i++) + if (QString(argv[i]) == "-small-screen") + smallScreen = true; + Dialog dialog(0,smallScreen); + if (!smallScreen){ + dialog.show(); + } + else{ + dialog.showFullScreen(); + } return app.exec(); } diff --git a/examples/widgets/wiggly/wiggly.pro b/examples/widgets/wiggly/wiggly.pro index 5288dd3..857122f 100644 --- a/examples/widgets/wiggly/wiggly.pro +++ b/examples/widgets/wiggly/wiggly.pro @@ -9,3 +9,8 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/wiggly sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS wiggly.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/wiggly INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C607 +} diff --git a/examples/widgets/windowflags/windowflags.pro b/examples/widgets/windowflags/windowflags.pro index fa8a567..27ce025 100644 --- a/examples/widgets/windowflags/windowflags.pro +++ b/examples/widgets/windowflags/windowflags.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowflags sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS windowflags.pro sources.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowflags INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xml/dombookmarks/dombookmarks.pro b/examples/xml/dombookmarks/dombookmarks.pro index e55754f..25e21cd 100644 --- a/examples/xml/dombookmarks/dombookmarks.pro +++ b/examples/xml/dombookmarks/dombookmarks.pro @@ -11,6 +11,8 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dombookmarks.pro *.xbel sources.path = $$[QT_INSTALL_EXAMPLES]/xml/dombookmarks INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + wince*: { addFiles.sources = frank.xbel jennifer.xbel addFiles.path = \My Documents diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp index f961e41..2aa5043 100644 --- a/examples/xml/dombookmarks/mainwindow.cpp +++ b/examples/xml/dombookmarks/mainwindow.cpp @@ -113,15 +113,15 @@ void MainWindow::about() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAsAct = new QAction(tr("&Save As..."), this); - saveAsAct->setShortcut(tr("Ctrl+S")); + saveAsAct->setShortcuts(QKeySequence::SaveAs); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/xml/htmlinfo/apache_org.html b/examples/xml/htmlinfo/apache_org.html new file mode 100644 index 0000000..9e5e4d3 --- /dev/null +++ b/examples/xml/htmlinfo/apache_org.html @@ -0,0 +1,281 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <!-- + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + This file is generated from XML source: DO NOT EDIT! + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + --> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="stylesheet" href="./style/compressed.css" type="text/css" media="screen, projection"/> + <link rel="stylesheet" href="./style/style.css" type="text/css" media="screen, projection"/> + <!--[if IE]><link rel="stylesheet" href="./style/ie.css" type="text/css" media="screen, projection"/><![endif]--> +<link rel="alternate" title="announce@apache.org Archives" type="application/atom+xml" href="http://mail-archives.apache.org/mod_mbox/www-announce/?format=atom" /> + <meta name="author" content="The Apache Software Foundation" /><meta name="email" content="apache.AT.apache.DOT.org" /> + <title>Welcome! - The Apache Software Foundation</title> + </head> + <body> + <div class="navigation"> + <ul> + <li><a href="./foundation" title="About the Foundation">Foundation</a></li> + <li><a href="http://projects.apache.org" title="Apache Projects">Projects</a></li> + <li><a href="http://people.apache.org" title="Apache People">People</a></li> + <li><a href="./foundation/getinvolved.html" title="Get involved in Apache">Get Involved</a></li> + <li><a href="./foundation/sponsorship.html" title="Support the mission of Apache">Support Apache</a></li> + <li class="dlink"><a href="./dyn/closer.cgi" title="Download Apache projects">Download</a></li> + </ul> + </div> + <div class="container"> + <hr class="space col"/> + <div class="block"> + <div class="column span-24"> + <div id="header"> + <h1>The Apache Software Foundation<br /> + <span class="alt"><small>Meritocracy in Action.</small></span></h1><p class="blurb">The Apache Software Foundation provides support for the Apache community of open-source software projects. The <a href="http://projects.apache.org/">Apache projects</a> are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field.</p><p class="highlight">We consider ourselves not simply a group of projects sharing a server, but rather a <em>community of developers and users</em>.</p> + </div> + </div> + </div> + <hr/> + <div class="block"> + <div class="column span-15 first append-1"> + <h3> + Latest News + </h3> + </div> + <div class="column span-8 las search"> + <form action="http://www.google.com/search" method="get"> + <input value="*.apache.org" name="sitesearch" type="hidden"/> + <input size="10" name="q" id="query" type="text"/> + <input name="Search" value="Go" type="submit"/> + </form> + </div> + </div> + <div class="block content"> + <div class="column span-15 colborder"> + +<div class="section-content"> +<p><em>If you would like to keep up with news and announcements from the +foundation and all its projects, you can subscribe to the +<a href="foundation/mailinglists.html#foundation-announce">Apache +Announcements List</a></em>.</p> + +<h4 id="apachecon-eu"> + Free Video Streams from ApacheCon Europe 2008 +</h4> +<div class="section-content"> +<a href="http://www.eu.apachecon.com/"><img src="images/eu_2008_logo.jpg" alt="ApacheCon Europe 2008" title="ApacheCon Europe 2008" border="0" align="right" /></a> +<p> +ApacheCon Europe 2008 held in Amsterdam was a great success, and attracted higher +than ever attendance figures, with about 500 registered attendees. This +figure represents an increase of more than 40% over the previous year, +demonstrating the rapidly growing interest in Apache and Open Source software +amongst European businesses. + +If you have not been able to attend ApacheCon Europe, you can still watch +<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm">videos of all keynotes and select talks online</a>. Keynote sessions +and the opening plenary are available <b>free of charge</b>:</p> +<ul> +<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/jjagielski/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">State of the Feather</a> + by Jim Jagielski, Chairman of the Apache Software Foundation</li> +<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/cschmidt/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Using Audio Technology and Open Content to Reduce Global Illiteracy, Poverty and Disease</a> + by Cliff Schmidt, Executive Director of Literacy Bridge</li> +<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/rghosh/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Apache and Steam Engines: the Magic of Collaborative Innovation</a> + by Rishab Aiyer Ghosh, Open Source Initiative Board Member</li> +<li><a href="http://streaming.linux-magazin.de/events/apacheconfree/archive/rfielding/frames-java.htm" onclick="window.open(this.href, '_blank', 'width=1024, height=768'); return false;">Apache 3.0 (a Tall Tale)</a> + by Roy Fielding, Co-founder of The Apache Software Foundation, + and Vice President, Apache HTTP Server</li> +</ul> +<p>The talks of the following select ApacheCon Europe tracks are +available for just 49 Euro: +<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#wednesday">System Administration</a>, +<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#thursday">Web Security</a>, +<a href="http://streaming.linux-magazin.de/en/archive_apachecon08eu.htm#friday">Web Services and Web 2.0</a>. +</p> +<hr /> +</div> + +<h4 id="apachecon-us"> + ApacheCon US 2008 in New Orleans! +</h4> +<div class="section-content"> +<p> + ApacheCon US 2008 will be held 3 November through 7 November in + New Orleans, Louisiana. + The Call for Papers has already closed and the program and further + information will be made available soon on the ApacheCon US 2008 + Web site <a href="http://www.us.apachecon.com/us2008/"><strong>www.us.apachecon.com</strong></a>. + If you would like to receive information about ApacheCon US 2008, please + <a href="mailto:announce-subscribe@apachecon.com">subscribe to + the ApacheCon announcement mailing list</a>. + </p> +<hr /> +</div> + +<h4 id="sun_jck_letter"> + Notice regarding open letter to Sun Microsystems +</h4> +<div class="section-content"> +<p> + The Apache Software Foundation has written an <a href="jcp/sunopenletter.html">open letter</a> + to Sun Microsystems regarding our inabillity to acquire an acceptable license for the test kit + for Java SE needed by <a href="http://harmony.apache.org">Apache Harmony</a>. For futher information + please see the <a href="jcp/sunopenletterfaq.html">FAQ</a> and direct all questions to Apache's VP + for JCP issues, geirm at apache dot org, or our regular press inquiry address, press at apache dot org. + </p> +</div> +</div> + </div> + <div class="column span-8 last"> + <div class="block"> + <div class="nav column span-11"> + <div> + <div class="menuheader"><a +href="http://projects.apache.org/">Apache Projects</a></div> + <ul> + <li><a href="http://httpd.apache.org/" title="Apache Web Server (httpd)">HTTP Server</a></li> + <li><a href="http://activemq.apache.org/" title="Distributed Messaging System">ActiveMQ</a></li> + <li><a href="http://ant.apache.org/" title="Java-based build tool">Ant</a></li> + <li><a href="http://apr.apache.org/" title="Apache Portable Runtime libraries">APR</a></li> + <li><a href="http://archiva.apache.org/" title="Build Artifact Repository Manager">Archiva</a></li> + <li><a href="http://beehive.apache.org/" title="Metadata frameworks for enterprise applications">Beehive</a></li> + <li><a href="http://cayenne.apache.org/" title="User-friendly Java ORM with Tools">Cayenne</a></li> + <li><a href="http://cocoon.apache.org/" title="Web development framework: separation of concerns, component-based">Cocoon</a></li> + <li><a href="http://commons.apache.org/" title="Reusable Java components">Commons</a></li> + <li><a href="http://continuum.apache.org/" title="Continuous Integration and Build Server">Continuum</a></li> + <li><a href="http://cxf.apache.org/" title="Service Framework">CXF</a></li> + <li><a href="http://db.apache.org/" title="Database access">DB</a></li> + <li><a href="http://directory.apache.org/" title="Apache Directory Server">Directory</a></li> + <li><a href="http://excalibur.apache.org/" title="Embeddable software libraries related to component and service management access">Excalibur</a></li> + <li><a href="http://felix.apache.org/" title="OSGi Framework and components.">Felix</a></li> + <li><a href="http://forrest.apache.org/" title="Aggregated multi-channel documentation, separation of concerns">Forrest</a></li> + <li><a href="http://geronimo.apache.org/" title="Java2, Enterprise Edition (J2EE) container">Geronimo</a></li> + <li><a href="http://gump.apache.org/" title="Continuous integration of open source projects">Gump</a></li> + <li><a href="http://hadoop.apache.org/" title="Distributed computing platform">Hadoop</a></li> + <li><a href="http://harmony.apache.org/" title="Open source implementation of Java SE">Harmony</a></li> + <li><a href="http://hivemind.apache.org/" title="A services and configuration microkernel">HiveMind</a></li> + <li><a href="http://hc.apache.org/" title="Java toolset of low level HTTP components">HttpComponents</a></li> + <li><a href="http://ibatis.apache.org/" title="SQL Data Mapper for Java and .NET">iBATIS</a></li> + <li><a href="http://incubator.apache.org/" title="Shepherd for new projects">Incubator</a></li> + <li><a href="http://jackrabbit.apache.org/" title="Content Repository for Java">Jackrabbit</a></li> + <li><a href="http://jakarta.apache.org/" title="Server-side Java">Jakarta</a></li> + <li><a href="http://james.apache.org/" title="Java Apache Mail Enterprise Server">James</a></li> + <li><a href="http://labs.apache.org/" title="The Innovation Laboratories of the Apache Software Foundation">Labs</a></li> + <li><a href="http://lenya.apache.org/" title="Content Management System">Lenya</a></li> + <li><a href="http://logging.apache.org/" title="Cross-language logging services">Logging</a></li> + <li><a href="http://lucene.apache.org/" title="Search engine library">Lucene</a></li> + <li><a href="http://maven.apache.org/" title="Java project management and comprehension tools">Maven</a></li> + <li><a href="http://mina.apache.org/" title="Multipurpose Infrastructure for Network Application">Mina</a></li> + <li><a href="http://myfaces.apache.org/" title="JavaServer(tm) Faces implementation and components">MyFaces</a></li> + <li><a href="http://ode.apache.org/" title="Orchestration Director Engine: Business Process Management (BPM), Process Orchestration and Workflow through service compositioni.">ODE</a></li> + <li><a href="http://ofbiz.apache.org/" title="Open for Business: enterprise automation software">OFBiz</a></li> + <li><a href="http://openejb.apache.org/" title="OpenEJB: a modular, configurable, and extendable EJB Container System and Server">OpenEJB</a></li> + <li><a href="http://openjpa.apache.org/" title="OpenJPA: Object Relational Mapping for Java">OpenJPA</a></li> + <li><a href="http://perl.apache.org/" title="Dynamic websites using Perl">Perl</a></li> + <li><a href="http://poi.apache.org/" title="Java API for OLE 2 Compound Documents">POI</a></li> + <li><a href="http://portals.apache.org/" title="Portal technology">Portals</a></li> + <li><a href="http://roller.apache.org/" title="Java blog server">Roller</a></li> + <li><a href="http://santuario.apache.org/" title="XML Security in Java and C++">Santuario</a></li> + <li><a href="http://servicemix.apache.org/" title="Enterprise Service Bus">ServiceMix</a></li> + <li><a href="http://shale.apache.org/" title="Web application framework based on JavaServer(tm) Faces">Shale</a></li> + <li><a href="http://spamassassin.apache.org/" title="Mail filter to identify spam">SpamAssassin</a></li> + <li><a href="http://stdcxx.apache.org/" title="Apache C++ Standard Library">STDCXX</a></li> + <li><a href="http://struts.apache.org/" title="Model 2 framework for building Java web applications">Struts</a></li> + <li><a href="http://synapse.apache.org/" title="Enterprise Service Bus and Mediation Framework">Synapse</a></li> + <li><a href="http://tapestry.apache.org/" title="Component-based Java Web Application Framework">Tapestry</a></li> + <li><a href="http://tcl.apache.org/" title="Dynamic websites using TCL">TCL</a></li> + <li><a href="http://tiles.apache.org/" title="A templating framework for web application user interfaces">Tiles</a></li> + <li><a href="http://tomcat.apache.org/" title="A Java Servlet and JSP Container">Tomcat</a></li> + <li><a href="http://turbine.apache.org/" title="A Java Servlet Web Application Framework and associated component library"> + Turbine</a></li> + <li><a href="http://velocity.apache.org/" title="A Java Templating Engine">Velocity</a></li> + <li><a href="http://wicket.apache.org/" title="Component-based Java Web Application Framework.">Wicket</a></li> + <li><a href="http://ws.apache.org/">Web Services</a></li> + <li><a href="http://xalan.apache.org/" title="XSLT processors in Java and C++">Xalan</a></li> + <li><a href="http://xerces.apache.org/" title="XML parsers in Java, C++ and Perl">Xerces</a></li> + <li><a href="http://xml.apache.org/" title="XML solutions focused on the web">XML</a></li> + <li><a href="http://xmlbeans.apache.org/" title="XML-Java binding tool">XMLBeans</a></li> + <li><a href="http://xmlgraphics.apache.org/" title="Conversion from XML to graphical output">XML Graphics</a></li> + </ul> + </div> + </div> + <div class="nav column prepend-1 span-12 last"> + <h6><a +href="/foundation/">Foundation</a></h6> + <ul> + <li><a href="/foundation/faq.html">FAQ</a></li> + <li><a href="/licenses/">Licenses</a></li> + <li><a href="/foundation/news.html">News</a></li> + <li><a href="/foundation/records/">Public Records</a></li> + <li><a href="/foundation/sponsorship.html">Sponsorship</a></li> + <li><a href="/foundation/contributing.html">Donations</a></li> + <li><a href="/foundation/thanks.html">Thanks</a></li> + <li><a href="/foundation/contact.html">Contact</a></li> + </ul> + <h6>Foundation Projects</h6> + <ul> + <li><a href="/foundation/conferences.html" title="Meetings of developers and users">Conferences</a></li> + <li><a href="/dev/" title="ASF Infrastructure: Operations and howto documents for PMCs and contributors">Infrastructure</a></li> + <li><a href="/jcp/" title="Apache and the Java Community Process">JCP</a></li> + </ul> + <h6>How it works</h6> + <ul> + <li><a href="/foundation/how-it-works.html">Introduction</a></li> + <li><a href="/foundation/how-it-works.html#meritocracy">Meritocracy</a></li> + <li><a href="/foundation/how-it-works.html#structure">Structure</a></li> + <li><a href="/foundation/how-it-works.html#roles">Roles</a></li> + <li><a href="/foundation/how-it-works.html#management">Collaboration</a></li> + <li><a href="/foundation/how-it-works.html#infrastructure">Infrastructure</a></li> + <li><a href="/foundation/how-it-works.html#incubator">Incubator</a></li> + <li><a href="/foundation/how-it-works.html#other">Other entities</a></li> + <li><a href="/foundation/glossary.html">Glossary</a></li> + <li><a href="/foundation/voting.html">Voting</a></li> + </ul> + <h6><a +href="/foundation/getinvolved.html">Get Involved</a></h6> + <ul> + <li><a href="/foundation/mailinglists.html">Mailing Lists</a></li> + <li><a href="/dev/version-control.html">Version Control</a></li> + <li><a href="/dev/">Developer Info</a></li> + </ul> + <h6>Download</h6> + <ul> + <li><a href="/dyn/closer.cgi">from a mirror</a></li> + </ul> + <h6>Related Sites</h6> + <ul> + <li><a href="http://apachecon.com/" title="Official Apache Conference">ApacheCon</a></li> + <li><a href="http://apachebookstore.com/" title="Apache Books">Bookstore</a></li> + <li><a href="http://feathercast.org/" title="Apache Podcasts">Feathercast</a></li> + <li><a href="http://planetapache.org/" title="Apache Community Blogs">PlanetApache</a></li> + </ul> + </div> + </div> + </div> + <div class="column span-24 footer"> + <hr/> + <p>Copyright © 2008 The Apache Software Foundation, Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> + </div> + </div> + </div> +</body> +</html> + diff --git a/examples/xml/htmlinfo/htmlinfo.pro b/examples/xml/htmlinfo/htmlinfo.pro new file mode 100644 index 0000000..f70fb7d --- /dev/null +++ b/examples/xml/htmlinfo/htmlinfo.pro @@ -0,0 +1,19 @@ +SOURCES += main.cpp +QT -= gui + +wince*|symbian:{ + htmlfiles.sources = *.html + htmlfiles.path = . + DEPLOYMENT += htmlfiles +} + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/xml/htmlinfo +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.html htmlinfo.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/xml/htmlinfo +INSTALLS += target sources + +symbian { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C609 +} diff --git a/examples/xml/htmlinfo/main.cpp b/examples/xml/htmlinfo/main.cpp new file mode 100644 index 0000000..9831d36 --- /dev/null +++ b/examples/xml/htmlinfo/main.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore> + +void parseHtmlFile(QTextStream &out, const QString &fileName) { + QFile file(fileName); + + out << "Analysis of HTML file: " << fileName << endl; + + if (!file.open(QIODevice::ReadOnly)) { + out << " Couldn't open the file." << endl << endl << endl; + return; + } + +//! [0] + QXmlStreamReader reader(&file); +//! [0] + +//! [1] + int paragraphCount = 0; + QStringList links; + QString title; + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement()) { + if (reader.name() == "title") + title = reader.readElementText(); + else if(reader.name() == "a") + links.append(reader.attributes().value("href").toString()); + else if(reader.name() == "p") + ++paragraphCount; + } + } +//! [1] + +//! [2] + if (reader.hasError()) { + out << " The HTML file isn't well-formed: " << reader.errorString() + << endl << endl << endl; + return; + } +//! [2] + + out << " Title: \"" << title << "\"" << endl + << " Number of paragraphs: " << paragraphCount << endl + << " Number of links: " << links.size() << endl + << " Showing first few links:" << endl; + + while(links.size() > 5) + links.removeLast(); + + foreach(QString link, links) + out << " " << link << endl; + out << endl << endl; +} + +int main(int argc, char **argv) +{ + // intialize QtCore application + QCoreApplication app(argc, argv); + + // get a list of all html files in the current directory + QStringList filter; + filter << "*.htm"; + filter << "*.html"; + QStringList htmlFiles = QDir::current().entryList(filter, QDir::Files); + + QTextStream out(stdout); + + if (htmlFiles.isEmpty()) { + out << "No html files available."; + return 1; + } + + // parse each html file and write the result to file/stream + foreach(QString file, htmlFiles) + parseHtmlFile(out, file); + + return 0; +} diff --git a/examples/xml/htmlinfo/nokia_com.html b/examples/xml/htmlinfo/nokia_com.html new file mode 100644 index 0000000..46d4c95 --- /dev/null +++ b/examples/xml/htmlinfo/nokia_com.html @@ -0,0 +1,215 @@ + + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> + +<html> +<head> + + + <!--startindex--> + <title>Nokia - Nokia on the Web</title> + + + <meta name="description" content="Nokia is the world's leading mobile phone supplier and a leading supplier of mobile and fixed telecom networks including related customer services."/> + <meta name="keywords" content="Nokia,mobile phones,cellular,telecommunications,wireless networks,datacom,GSM,multimedia terminals,handsets,customer services,press releases,financial information,student exchange,open positions,employment opportunities,career opportunities"/> + <meta name="modified" content=""/> + <meta name="category" content="Landing Page Global Flash"/> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <meta name="siteid" content="101"/> + + <!--stopindex--> + <link href="/css/style_46.css" rel="stylesheet" type="text/css"> + + <link href="/NOKIA_COM_1/Home/Landing_page_2007/wayfinder.css" rel="stylesheet" type="text/css"/> + +<script type="text/javascript"> + var useHbx = true; +</script> + + +<!--WEBSIDESTORY CODE HBX1.0 (Universal)--> +<!--COPYRIGHT 1997-2005 WEBSIDESTORY,INC. ALL RIGHTS RESERVED. U.S.PATENT No. 6,393,479B1. MORE INFO:http://websidestory.com/privacy--> +<script language="javascript"> +var _hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;} +var hbx=_hbEvent("pv");hbx.vpc="HBX0100u";hbx.gn="ehg-nokiafin.hitbox.com"; + +//BEGIN EDITABLE SECTION +//CONFIGURATION VARIABLES +hbx.acct="DM550514HPNZ";//ACCOUNT NUMBER(S) +hbx.pn="Home";//PAGE NAME(S) +hbx.mlc="/Home";//MULTI-LEVEL CONTENT CATEGORY +hbx.pndef="title";//DEFAULT PAGE NAME +hbx.ctdef="full";//DEFAULT CONTENT CATEGORY + +//OPTIONAL PAGE VARIABLES +//ACTION SETTINGS +hbx.fv="";//FORM VALIDATION MINIMUM ELEMENTS OR SUBMIT FUNCTION NAME +hbx.lt="none";//LINK TRACKING +hbx.dlf="n";//DOWNLOAD FILTER +hbx.dft="n";//DOWNLOAD FILE NAMING +hbx.elf="n";//EXIT LINK FILTER + +//SEGMENTS AND FUNNELS +hbx.seg="";//VISITOR SEGMENTATION +hbx.fnl="";//FUNNELS + +//CAMPAIGNS +hbx.cmp="";//CAMPAIGN ID +hbx.cmpn="";//CAMPAIGN ID IN QUERY +hbx.dcmp="";//DYNAMIC CAMPAIGN ID +hbx.dcmpn="";//DYNAMIC CAMPAIGN ID IN QUERY +hbx.dcmpe="";//DYNAMIC CAMPAIGN EXPIRATION +hbx.dcmpre="";//DYNAMIC CAMPAIGN RESPONSE EXPIRATION +hbx.hra="";//RESPONSE ATTRIBUTE +hbx.hqsr="";//RESPONSE ATTRIBUTE IN REFERRAL QUERY +hbx.hqsp="";//RESPONSE ATTRIBUTE IN QUERY +hbx.hlt="";//LEAD TRACKING +hbx.hla="";//LEAD ATTRIBUTE +hbx.gp="";//CAMPAIGN GOAL +hbx.gpn="";//CAMPAIGN GOAL IN QUERY +hbx.hcn="";//CONVERSION ATTRIBUTE +hbx.hcv="";//CONVERSION VALUE +hbx.cp="null";//LEGACY CAMPAIGN +hbx.cpd="";//CAMPAIGN DOMAIN + +//CUSTOM VARIABLES +hbx.ci="";//CUSTOMER ID +hbx.hc1="";//CUSTOM 1 +hbx.hc2="";//CUSTOM 2 +hbx.hc3="";//CUSTOM 3 +hbx.hc4="";//CUSTOM 4 +hbx.hrf="";//CUSTOM REFERRER +hbx.pec="";//ERROR CODES + + +var cookieName = 'MyNokia'; +var nameEQ = cookieName + "="; +var ca = document.cookie.split(';'); +for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) { + hbx.ci = c.substring(nameEQ.length,c.length); + } +} + +//INSERT CUSTOM EVENTS +hbx.acct="DM550514HPNZ"; +hbx.mlc="/Home"; +hbx.pn="Home"; +hbx.lt="auto"; + + +//END EDITABLE SECTION + +//REQUIRED SECTION. CHANGE "YOURSERVER" TO VALID LOCATION ON YOUR WEB SERVER (HTTPS IF FROM SECURE SERVER) +</script><script language="javascript1.1" defer src="/Hitbox/hbx_5.js"></script> +<script language="javascript">if(navigator.appName!='Netscape'&&parseInt(navigator.appVersion)==4)document.write("<\!"+"--")</script><noscript> +<img src="http://ehg-nokiafin.hitbox.com/HG?hc=we88&cd=1&hv=6&ce=u&hb=DM550514HPNZ&n=Home&vcon=/Home&seg=&cmp=&gp=&fnl=&pec=&dcmp=&ra=&gn=&cv=&ld=&la=&c1=&c2=&c3=&c4=&vpc=090101rn" border="0" width="1" height="1"> +</noscript><!--//--> + +<!--END WEBSIDESTORY CODE--> + + + + + +</head> +<body lang='en' + style="margin: 0 0 0 0;" bgcolor="#FFFFFF" link="#0033cc" text="#000000" alink="#0033cc" vlink="#800080"> + <div class="pagecontainer"> + + +<!-- start page template [Generated JSP Servlet: class=jsp_servlet._templates._page.__template6layout] --> + + + + + + + + + + + <!--startindex--> + + + +<!-- Begin template '/templates/content/plain.jsp' --> + +<div id="wayfinderContainer"> + <div id="branding"> + <img src="/NOKIA_COM_1/Home/Landing_page_2007/noflash_img/nokia_connecting_people.png" alt="Nokia - Connecting people" /> + + </div> + + <div id="flashcontent"> + + <!-- main page noflash content --> + <div id="mainContentGlobal"> + <div id="mainHdr"><h1>Welcome to Nokia</h1></div> + <div id="selectContainer"> + <h2>Where would you like to go?</h2> + <div id="selectLinks"> + <ul class="mainpage"> + <li><a href="/A4176248">Africa</a></li> + <li><a href="/A4138125">Asia Pacific</a></li> + <li><a href="/A4138121">Europe</a></li> + <li><a href="/A4138127">Latin America</a></li> + <li><a href="/A4176245">Middle East</a></li> + <li><a href="/A4138126">North America</a></li> + </ul> + </div> + </div> + <!-- <a id="banner" href="http://www.nokia.com/seasonsgreetings/">Seasons Greetings</a> --> + </div> + <div id="navi"> + <ul> + <li><a href="http://www.nokiaforbusiness.com/">Nokia for Business</a></li> + <li><a href="http://www.nokia.com/aboutnokia">About Nokia</a></li> + <li><a href="http://www.nokia.com/developers">Developers</a></li> + <li><a href="http://www.nokia.com/press">Press</a></li> + <li class="lastitem"><a href="http://www.nokia.com/investors">Investors</a></li> + <!-- <li class="lastitem"><a href="http://www.nokia.com/environment">Environment</a></li> --> + </ul> + </div> + <!-- noflash content ends --> + + </div> + + <div id="footer"> + <ul> + <li><a href="http://www.nokia.com/siteterms">Site Terms</a></li> + <li class="lastitem"><a href="http://www.nokia.com/privacypolicy">Privacy Policy</a></li> + <span>Copyright © 2008 Nokia. All rights reserved</span> + </ul> + <br /><br /> + </div> +</div> + +<script type="text/javascript" src="/NOKIA_COM_1/javascript/flash_detection_main.js"></script> <!-- for redirection to mobile site --> +<script type="text/javascript" src="/EUROPE_NOKIA_COM_3/flash/swfobject.js"></script> +<script type="text/javascript" src="/NOKIA_COM_1/javascript/cookies.js"></script> +<script type="text/javascript" > + // <![CDATA[ + var so = new SWFObject("/NOKIA_COM_1/Home/Landing_page_2007/wayfinder_assets.swf", "wayfinder", "736", "560", "7"); + so.addParam("allowscriptaccess", "always"); + so.addParam("base", "/NOKIA_COM_1/Home/Landing_page_2007/"); + so.write("flashcontent"); + // ]]> +</script> + +<!-- End template '/templates/content/plain.jsp' --> + <!--stopindex--> + + + + + + </div> +</body> + + + </html> + diff --git a/examples/xml/htmlinfo/simpleexample.html b/examples/xml/htmlinfo/simpleexample.html new file mode 100644 index 0000000..83a55cf --- /dev/null +++ b/examples/xml/htmlinfo/simpleexample.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<html> + <head> + <title>Qt is cute! Frans is too!</title> + </head> + <body> + <p>A paragraph.</p> + <p>A second paragraph. Check out our <a href="http://labs.qt.nokia.com/">developer blogs</a></p> + <p>And the last paragraph. Or our <a href="http://qt.nokia.com/doc/">online documentation</a>.</p> + </body> +</html> diff --git a/examples/xml/htmlinfo/trolltech_com.html b/examples/xml/htmlinfo/trolltech_com.html new file mode 100644 index 0000000..180eb74 --- /dev/null +++ b/examples/xml/htmlinfo/trolltech_com.html @@ -0,0 +1,955 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + + + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" + lang="en"> + + <head> + <meta http-equiv="Content-Type" + content="text/html;charset=utf-8" /> + + <title> + Code Less. Create More. Deploy Everywhere. + — + Trolltech + </title> + + + <!-- ADD ON UPDATE --> + + <meta name="author" content="Trolltech" /> + <meta name="description" + content="Trolltech creates application development platforms for desktop and mobile device innovation." /> + <meta name="keywords" content="" /> + +<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"><!-- --></script> +<script type="text/javascript"> + <!-- Urchin script + _uacct = "UA-4457116-1"; + urchinTracker(); + --> + </script> + + <base href="http://trolltech.com/homepage" /> + + + + <meta name="generator" content="Plone - http://plone.org" /> + + + <!-- Plone ECMAScripts --> + + + + + <script type="text/javascript" + src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts2804.js"> + </script> + + + + <script type="text/javascript" + src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts0445.js"> + </script> + + + + <script type="text/javascript" + src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts5940.js"> + </script> + + + + <script type="text/javascript" + src="http://trolltech.com/portal_javascripts/TTSkin/linkpopper.js"> + </script> + + + + <script type="text/javascript" + src="http://trolltech.com/portal_javascripts/TTSkin/ploneScripts7743.js"> + </script> + + + + + + + + + + + + + + + <style type="text/css"><!-- @import url(http://trolltech.com/portal_css/TTSkin/ploneStyles1145.css); --></style> + + + + + + + + + <style type="text/css" + media="screen"><!-- @import url(http://trolltech.com/portal_css/TTSkin/ploneStyles8707.css); --></style> + + + + + + + + + + + <!-- Internet Explorer CSS Fixes --> + <!--[if IE]> + <style type="text/css" media="all">@import url(http://trolltech.com/IEFixes.css);</style> + <![endif]--> + + <link rel="shortcut icon" type="image/x-icon" + href="http://trolltech.com/favicon.ico" /> + + <link rel="home" href="http://trolltech.com" + title="Front page" /> + <link rel="search" + href="http://trolltech.com/search_form" + title="Search this site" /> + <link rel="author" + href="http://trolltech.com/author/admin" + title="Author information" /> + <link rel="contents" href="http://trolltech.com/sitemap" + title="Site Map" /> + + + + + + + + + + <!-- Disable IE6 image toolbar --> + <meta http-equiv="imagetoolbar" content="no" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + </head> + + <body class="section-homepage" dir="ltr"> + <div id="visual-portal-wrapper"> + <div id="portal-top"> + + <div id="portal-header"> + <a class="hiddenStructure" accesskey="2" + href="http://trolltech.com/#documentContent">Skip to content.</a> + + <a class="hiddenStructure" accesskey="6" + href="http://trolltech.com/#portlet-navigation-tree">Skip to navigation</a> + + <div class="middlesex"> + <ul id="portal-siteactions"> + + <li id="siteaction-sitemap"><a + href="http://trolltech.com/sitemap" accesskey="3" + title="Site Map">Site Map</a></li> + <li id="siteaction-accessibility"><a + href="http://trolltech.com/accessibility-info" + accesskey="0" title="Accessibility">Accessibility</a></li> + <li id="siteaction-contact"><a + href="http://trolltech.com/contact" accesskey="9" + title="Contact">Contact</a></li> + +</ul> + + <div id="portal-searchbox"> + <form name="searchform" + action="http://trolltech.com/search" + style="white-space:nowrap" + onsubmit="return liveSearchSubmit()"> + + <label for="searchGadget" class="hiddenStructure">Search Site</label> + + <div class="LSBox"> + <input id="searchGadget" name="SearchableText" + type="text" size="15" title="Search Site" + accesskey="4" class="visibility:visible" /> + + <input class="searchButton" type="submit" + value="Search" /> + + <div class="LSResult" id="LSResult" style=""><div class="LSShadow" id="LSShadow"></div></div> + </div> + </form> + + <div id="portal-advanced-search" class="hiddenStructure"> + <a href="http://trolltech.com/search_form" + accesskey="5"> + Advanced Search… + </a> + </div> + +</div> + + <div id="country-flags"> + <a href="/lang/cn/"><img class="flag" + border="0" width="30" height="20" src="chineseflag.png" /></a> + <a href="/lang/japanese/"><img + class="flag" border="0" width="30" height="20" + src="japaneseflag.png" /></a> + </div> + <h1 id="portal-logo"> + <a href="http://trolltech.com" accesskey="1">Trolltech</a> +</h1> + + <div id="portal-skinswitcher"> + +</div> + </div> + + + <h5 class="hiddenStructure">Sections</h5> + <div id="portal-globalnav"> + <div class="middlesex"> + <ul> + <li id="portaltab-index_html" + class="selected indextab"><a + href="http://trolltech.com">Home</a></li> + + <li id="portaltab-products" + class="plain"><a + href="http://trolltech.com/products" title="">Products and Services</a></li> + + + <li id="portaltab-solutions" + class="plain"><a + href="http://trolltech.com/solutions" title="">Solutions</a></li> + + + <li id="portaltab-developer" + class="plain"><a + href="http://trolltech.com/developer" title="">Developer Resources</a></li> + + + <li id="portaltab-company" class="plain"><a + href="http://trolltech.com/company" title="">Company</a></li> + + + <li id="portaltab-downloads" + class="plain"><a + href="http://trolltech.com/downloads" title="">Downloads</a></li> + + + + + </ul> + </div> + </div> + + </div> + <div id="portal-personaltools-wrapper"> + +<h5 class="hiddenStructure">Personal tools</h5> + + +</div> + + <div class="middlesex"> + <div id="portal-breadcrumbs"> + + <span id="breadcrumbs-you-are-here">You +are here:</span> + <a href="http://trolltech.com">Home</a> + + +</div> + </div> + </div> + + <div class="visualClear"><!-- --></div> + + + <table id="portal-columns"> + <tbody> + <tr> + + + + + + <td id="portal-column-content"> + + + <div id="content" class=""> + + + + <div class="documentContent" id="region-content"> + + <a name="documentContent"></a> + + + + + + + + + + + + <!-- <table id="frontpagetable" cellpadding="0" cellspacing="0" tal:attributes="width pagew"> --> <!-- tal:on-error="string:replace with error template" Fetch image width here --> + <table id="frontpagetable" cellpadding="0" + cellspacing="0" width="712"> + <tr> + <td colspan="2"> + + <h2>Trolltech provides cross-platform software solutions for:</h2> + <table id="fpSolutions" class="solutions" cellpadding="0" cellspacing="6" width="100%"> + <tbody> + <tr> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/managing-development"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Software Development Managers</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/industrial-embedded-development"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Embedded Developers</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + + </tr> + <tr> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/ce-mobile-vendors"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Consumer Electronics Vendors</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/mobile-application-development"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Mobile Application Developers</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + + </tr> + <tr> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/application-development"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Cross-Platform Developers</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + <td> + <!-- GRANTHAM STYLE --> + <a class="roundedButton" + title="" + href="http://trolltech.com/solutions/solutions-opensource"> + <span class="buttonTop"><span class="roundedButtonTL"><span class="roundedButtonTR"></span></span></span> + <span class="buttonLeft"> + <span class="buttonRight"><span + class="buttonArrow">Open Source Developers</span></span> + </span> + <span class="buttonBottom"><span class="roundedButtonBL"><span class="roundedButtonBR"></span></span></span> + </a> + <!-- OLD STYLE + <div class="roundedBlock" + tal:attributes="title python:solution.Description(); + class python:test(repeat['solution'].odd(), 'roundedBlock odd', 'roundedBlock')"> + <span class="portletTopLeft"></span> + <span class="portletTopRight"></span> + <div class="innerRoundedBlock"> + <a href="#" + tal:attributes="href python:solution.absolute_url()"> + <span class="arrow"></span> + <strong tal:content="python:solution.Title()"> + Title + </strong> + </a> + </div> + <span class="portletBottomLeft"></span> + <span class="portletBottomRight"></span> + </div> + --> + </td> + + </tr> + </tbody> + </table> + + </td> + </tr> + + <!-- BANNER --> + + <tr class="minspacerow"> + <td colspan="2"> + + <div id="flashcontent"> + + + <!-- In case of no imagemap --> + <a + href="http://trolltech.com/products/qt/learnmore/whitepapers"> + <img border="0" + src="http://trolltech.com/include/features/frontpage/whitepaper-feature/mainsplash" + alt="Code Less. Create More. Deploy Everywhere." + height="100" width="700" /> + </a> + + + </div> + + + + </td> + </tr> + + <!-- Product Feature rows --> + <tr id="productfeatures" class="minspacerow"> + <td style="width:350px;"> + <div class="viewlet productviewlet"> +<p class="discreet"><a title="Downloads" href="downloads/index"><img class="image-right" src="images/frontpage/qt_download_90.png" alt="Download Qt Button: Grey BG" /></a></p> +<h2>Qt</h2> +<p>Qt is a cross-platform application framework. It includes:</p> +<ul><li>An <a title="C++ Class Library" href="products/qt/features/library/index">intuitive class library</a></li><li>Integrated <a title="Development Tools" href="products/qt/features/tools/index">development tools</a></li><li>Support for <a title="C++ and Java Support" href="products/qt/features/language-support/index">C++ and Java development</a></li><li><a title="Cross-Platform Development" href="products/qt/features/platforms/index">Desktop and embedded</a> development support</li></ul> +<p> </p> +<p><strong><a title="Qt Cross-Platform Application Framework" href="products/qt/index"><span class="button">Learn More</span></a></strong> <strong><a title="How to order" href="products/qt/orderform"><span class="button">Buy Now</span></a></strong></p> +<p> </p> +<p> </p> +<p> </p> +</div> + </td> + <td style="width:350px;"> + <div class="viewlet productviewlet"> +<p><a title="Qtopia" href="products/qtopia"><img class="image-right" src="images/frontpage/qtopia_learn_more_90.png" alt="Qtopia Learn More button 90px" /></a></p> +<h2>Qtopia</h2> +<p><a title="The Qtopia application platform for embedded Linux" href="products/qtopia/index">Qtopia</a> is an application platform and UI for Linux-based <a title="Qtopia Phone Edition" href="products/qtopia/qtopia-product-family/qtopia-phone-edition">mobile</a>, <a title="Qtopia Platform" href="products/qtopia/qtopia-product-family/qtopia-platform">consumer electronics</a> and <a title="Qtopia Platform" href="products/qtopia/qtopia-product-family/qtopia-platform">embedded devices</a>. Qtopia offers:</p> +<ul><li>Rich <a href="products/qt/features/tools/index">toolkit</a> and intuitive API</li><li>Fully customizable user interface</li><li>Highly efficient development framework</li></ul> +<p> </p> +<p><strong><a title="Customer Devices" href="company/customers/customer-devices"><span class="button">Customer Devices</span></a></strong> <strong><a title="Purchasing Qtopia" href="products/qtopia/orderinfo"><span class="button">Buy Now</span></a></strong></p> +</div> + </td> + </tr> + </table> + + + + + + + + + + + + + </div> + + </div> + + + </td> + + + + + <!-- News/events --> + <td id="frontpage-column-two"> + + <div class="viewlet"> + <h3>Quick Links</h3> + + + <!-- Smart folders --> + + <!-- Links --> + + <p class="smallerExtendedLink"> + <a href="http://trolltech.com/company/careers" + title="Quick Links">Careers at Trolltech</a> + </p> + + + <p class="smallerExtendedLink"> + <a href="http://trolltech.com/products/qt/learnmore/whitepapers" + title="Quick Links">Whitepapers</a> + </p> + + + <p class="smallerExtendedLink"> + <a href="http://trolltech.com/products/qt/learnmore/webinars-videos" + title="Quick Links">Webinars and Videos</a> + </p> + + </div> + + + <div class="viewlet"> + <h3>Nokia Acquisition</h3> + + <div class="viewletBody"> +<p class="smallerExtendedLink"><a title="Nokia Acquires Trolltech" href="../../../28012008/28012008">Learn more about Nokia's acquisition of Trolltech<br /></a></p> +</div> + <!-- Smart folders --> + + <!-- Links --> + + + + </div> + + + <div class="viewlet"> + <h3>News</h3> + + + <!-- Smart folders --> + + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/announcements/press.2008-06-03.1419977468">Trolltech Releases Qt Jambi 4.3.5</a> + <!-- Dates for press release --> + + + (Jun 03) + <!--(<tal:date tal:content="item_pressmonth"/> <tal:date tal:content="item_pressday"/>)--> + + + <!-- Dates for events --> + + <!-- Dates for training --> + + </span> + </p> + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-28.9662742780">Trolltech releases Qt 4.3.5</a> + <!-- Dates for press release --> + + + (May 28) + <!--(<tal:date tal:content="item_pressmonth"/> <tal:date tal:content="item_pressday"/>)--> + + + <!-- Dates for events --> + + <!-- Dates for training --> + + </span> + </p> + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-14.1108908046">Award From Qt Developers Recognizes Best Open Source Development Tools</a> + <!-- Dates for press release --> + + + (May 14) + <!--(<tal:date tal:content="item_pressmonth"/> <tal:date tal:content="item_pressday"/>)--> + + + <!-- Dates for events --> + + <!-- Dates for training --> + + </span> + </p> + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/announcements/press.2008-05-08.1819339587">Trolltech Delivered Revenues of NOK 55.6 Million</a> + <!-- Dates for press release --> + + + (May 08) + <!--(<tal:date tal:content="item_pressmonth"/> <tal:date tal:content="item_pressday"/>)--> + + + <!-- Dates for events --> + + <!-- Dates for training --> + + </span> + </p> + + <!-- Links --> + + + + </div> + + + <div class="viewlet"> + <h3>Events</h3> + + <div class="viewletBody"> +<p> </p> +</div> + <!-- Smart folders --> + + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-05-15.0963129132">Qt Open Enrollment Training Class</a> + <!-- Dates for press release --> + + <!-- Dates for events --> + + + (Jun 09 - Jun 13) + + + <!-- Dates for training --> + + </span> + </p> + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-02-22.1032431617">Israel Qt User Group</a> + <!-- Dates for press release --> + + <!-- Dates for events --> + + + (Jun 16) + + + <!-- Dates for training --> + + </span> + </p> + <p class="smallerFont"> + <span> + <a href="http://trolltech.com/company/newsroom/events/allevents/event.2008-05-19.5707721007">Webinar: Building Tomorrow’s Virtual Driver Control Center</a> + <!-- Dates for press release --> + + <!-- Dates for events --> + + + (Jun 24) + + + <!-- Dates for training --> + + </span> + </p> + + <!-- Links --> + + <p class="smallerExtendedLink"> + <a href="http://trolltech.com/company/newsroom/events" + title="Events">More events</a> + </p> + + + + </div> + + </td> + + + </tr> + </tbody> + </table> + + + <div class="visualClear"><!-- --></div> + + + <hr class="netscape4" /> + + + + <div id="portal-footer"> + + +<p id="bottom-navigation"> + Trolltech® - Code Less. Create More. Deploy Everywhere. + + <br /> + + <a href="http://trolltech.com/company/contact-us/locations" + title="Trolltech ASA"> + Trolltech ASA + </a> + <a href="http://trolltech.com/company/contact-us/locations" + title="Address: Sandakerveien 116, Oslo"> + Sandakerveien 116, Oslo + </a> + <a href="http://trolltech.com/company/contact-us/locations" + class="lastNavItem" title="Phone: +47 21 60 48 00"> + +47 21 60 48 00 + </a> + + <br /> + + <a href="http://trolltech.com/company/contact-us/locations" + title="International locations"> + International locations + </a> + <a href="/trolltech/privacypolicy" title="Privacy policy"> + Privacy Policy + </a> + <a href="/trolltech/copyright" title="Trolltech" class="lastNavItem"><span>2008</span> © Trolltech ASA</a> +</p> + + +</div> + + <div id="portal-colophon"> + + + <a href="http://plone.org" + class="colophonIcon colophonIconPlone" + title="This Plone site was built using Plone CMS, the Open Source Content Management System. Click for more information."> + Powered by Plone CMS, the Open Source Content Management System + </a> + + + + <p class="discreet"> + This site conforms to the following standards: + </p> + + <div class="colophonWrapper"> + <ul> + <li> + <a href="http://www.section508.gov" + class="colophonIcon colophonIcon508" + title="This Plone site conforms to the US Government Section 508 Accessibility Guidelines."> + Section 508 + </a> + </li> + <li> + <a href="http://www.w3.org/WAI/WCAG1AA-Conformance" + class="colophonIcon colophonIconWAI" + title="This Plone site conforms to the W3C-WAI Web Content Accessibility Guidelines."> + WCAG + </a> + </li> + <li> + <a href="http://validator.w3.org/check/referer" + class="colophonIcon colophonIconXHTML" + title="This Plone site is valid XHTML."> + Valid XHTML + </a> + </li> + <li> + <a href="http://jigsaw.w3.org/css-validator/check/referer&warning=no&profile=css3&usermedium=all" + class="colophonIcon colophonIconCSS" + title="This Plone site was built with valid CSS."> + Valid CSS + </a> + </li> + <li> + <a href="http://plone.org/browsersupport" + class="colophonIcon colophonIconAnyBrowser" + title="This Plone site is usable in any web browser."> + Usable in any browser + </a> + </li> + </ul> + </div> + + </div> + + </div> +<!-- ProspectXtractor tracker script --> +<script type="text/javascript"><!-- +function _pxPar() +{ +var p=""; +p+="&ref="+escape(top.document.referrer); +p+="&dt="+escape(document.title); +p+="&sr="+screen.width+"x"+screen.height; +p+="&sd="+screen.colorDepth; +p+="&fv="+_pxFV(); +return p; +} +function _pxFV() +{ +var f=0,n=navigator; +if (n.plugins && n.mimeTypes.length) { +var x=n.plugins["Shockwave Flash"]; +if(x && x.description) { +var y=x.description; +f=y.charAt(y.indexOf('.')-1); +} +} else { +r=false; +for(var i=15;i>=3&&r!=true;i-=1){ +execScript('on error resume next: r=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript'); +f=i; +} +} +return f; +} +document.write('<img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999'+_pxPar()+'" width="1" heigth="1" />'); +//--> +</script> +<noscript> +<div><img src="http://pxreg.onlineservicesas.com/pxreg/?id=50C9FD2F-61D5-4824-B726-50D6B1F89999" width="1" height="1" alt="" /></div> +</noscript> +<!-- END ProspectXtractor tracker script --> +</body> +</html> + diff --git a/examples/xml/htmlinfo/w3c_org.html b/examples/xml/htmlinfo/w3c_org.html new file mode 100644 index 0000000..0fcce48 --- /dev/null +++ b/examples/xml/htmlinfo/w3c_org.html @@ -0,0 +1,507 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> +<head profile="http://www.w3.org/2000/08/w3c-synd/#"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="HTML Tidy for Mac OS X (vers 1st March 2004), see www.w3.org" /> + +<meta name="keywords" content="W3C, World Wide Web, Web, WWW, Consortium, computer, access, accessibility, semantic, worldwide, W3, HTML, XML, standard, language, technology, link, CSS, RDF, XSL, Berners-Lee, Berners, Lee, style sheet, cascading, schema, XHTML, mobile, SVG, PNG, PICS, DOM, SMIL, MathML, markup, Amaya, Jigsaw, free, open source, software" /> +<meta name="description" content="The World Wide Web Consortium (W3C) is an international consortium where Member organizations, a full-time staff, and the public work together to develop Web standards. W3C primarily pursues its mission through the creation of Web standards and guidelines designed to ensure long-term growth for the Web. Over 400 organizations are Members of the Consortium. W3C is jointly run by the MIT Computer Science and Artificial Intelligence Laboratory (MIT CSAIL) in the USA, the European Research Consortium for Informatics and Mathematics (ERCIM) headquartered in France, Keio University in Japan, and has additional Offices worldwide." /> + +<title>World Wide Web Consortium - Web Standards</title> +<link rel="meta" href="/Overview-about.rdf" /> +<link rel="stylesheet" type="text/css" href="/StyleSheets/home.css" /> +<link rel="bookmark" href="#technologies" title="Technologies |" /> +<link rel="bookmark" href="#news" title="News |" /> +<link rel="bookmark" href="#search" title="Search |" /> +<link rel="contents" href="#contents" title="Contents |" /> +<link rel="bookmark" href="#Offices" title="Offices |" /> +<link rel="bookmark" href="#systems" title="Systems |" /> +<link rel="bookmark" href="#donors" title="Supporters |" /> +<link rel="bookmark" href="#footnotes" title="Footnotes |" /> +<link rel="alternate" type="application/rss+xml" title="W3C Home Page News RSS Channel" href="http://www.w3.org/2000/08/w3c-synd/home.rss" /> + +<style type="text/css"> +/**/ + div.spot-image img { + margin-bottom: 20px; + } +/**/ +</style> +</head> + +<body> +<h1 id="logo"><img alt="The World Wide Web Consortium (W3C)" height="48" width="315" src="/Icons/w3c_main" /></h1> + +<h2 id="slogan">Leading the Web to Its Full Potential...</h2> + +<div> +<map name="introLinks" id="introLinks" title="Introductory Links"> +<div class="banner"> +<span class="invisible"><a class="bannerLink" title="Skip introductory links and the mission statement" href="#technologies">Skip to Technologies</a> |</span> <a class="bannerLink" title="W3C Activities" accesskey="A" href="/Consortium/activities">Activities</a> | <a class="bannerLink" title="Technical Reports and Recommendations" accesskey="T" href="/TR/">Technical Reports</a> | <a class="bannerLink" title="Alphabetical Site Index" accesskey="S" href="/Consortium/siteindex">Site Index</a> | <a class="bannerLink" title="Help for new visitors" accesskey="N" href="/Consortium/new-to-w3c">New +Visitors</a> | <a class="bannerLink" title="About W3C" accesskey="B" href="/Consortium/">About W3C</a> | <a class="bannerLink" title="Join W3C" accesskey="J" href="/Consortium/join">Join W3C</a> | +<a class="bannerLink" title="Contact W3C" accesskey="C" href="/Consortium/contact">Contact W3C</a> +</div> +</map> +</div> + +<p class="small">The World Wide Web Consortium (<acronym title="World Wide Web Consortium">W3C</acronym>) develops interoperable +technologies (specifications, guidelines, software, and tools) to lead +the Web to its full potential. W3C is a forum for information, +commerce, communication, and collective understanding. On this page, +you'll find <a href="#news">W3C news</a>, links to <a href="#technologies">W3C technologies</a> and ways to <a href="#contents">get involved</a>. New visitors can find help in +<cite><a href="/Consortium/new-to-w3c">Finding Your Way at +W3C</a></cite>. We encourage organizations to learn more <a href="/Consortium/">about W3C</a> and <a href="/Consortium/membership">about +W3C Membership</a>.</p> + +<div class="navBlock"> +<h2 class="spot-head">XML10</h2> + +<div class="spot"> +<div class="spot-image"> +<a href="/2008/xml10/"> +<img src="/2008/xml10/xml-10.png" width="106" height="48" alt="XML 10" /> +</a> +</div> +<p class="spot-block"> +To celebrate +<a href="/2008/xml10/">ten years of XML</a>, +W3C invites you to +<a href="/2008/xml10/card/greeting-form">send a greeting</a> +and tell us about an XML-related blog or article. +Many thanks to the FLWOR Foundation for their +generous sponsorship of XML10. +</p> +</div> + +<h2 class="spot-head">W3C Supporters</h2> +<div class="spot"> +<p class="spot-block">Help W3C by making a donation through the +<a href="/Consortium/sup">W3C Supporters Program</a>.</p> +</div> + + + +<h2 class="spot-head">Employment</h2> + +<div class="spot"> +<p class="spot-block">Current <a href="/Consortium/Recruitment/">job +opportunities</a> at W3C: <a href="http://www.ercim.org/jobs/wai_consultant.html">Web Accessibility and Ageing Consultant</a>. Current <a href="/Consortium/Recruitment/Fellows#openings">W3C Fellows Program +openings</a> are <a href="/2007/01/comm-fellow1">Business and +Technology Communications Specialist</a>, <a href="/2007/01/comm-fellow2">Web / Graphic Designer</a>, and <a href="/2007/01/SysteamFellowsPosition">Software Engineer</a>.</p> +</div> + +<h2 class="navhead"><a name="technologies" id="technologies">W3C A to +Z</a></h2> + +<ul> +<li class="invisible"><a class="navlink" title="Skip W3C A-Z" href="#news">Skip to News</a></li> + +<li><a href="/WAI/" class="navlink">Accessibility</a></li> + +<li><a href="/Amaya/" class="navlink">Amaya</a></li> + +<li><a href="/Mobile/CCPP/" class="navlink"><abbr title="Composite Capability/Preference Profiles">CC/PP</abbr></a></li> + +<li><a href="/2004/CDF/" class="navlink">Compound Document Formats +(CDF)</a></li> + +<li><a href="/Style/CSS/" class="navlink"><abbr title="Cascading Style Sheets">CSS</abbr></a></li> + +<li><a href="http://jigsaw.w3.org/css-validator/" class="navlink"><abbr title="Cascading Style Sheets">CSS</abbr> +Validator</a></li> + +<li><a href="/2002/ws/databinding/" class="navlink">Databinding</a></li> + +<li><a href="/DOM/" class="navlink"><acronym title="Document Object Model">DOM</acronym></a></li> + +<li><a href="/XML/EXI" class="navlink">Efficient XML +Interchange</a></li> + +<li><a href="/2007/eGov/" class="navlink">eGovernment</a></li> + +<li><a href="/2001/sw/grddl-wg/" class="navlink"><acronym title="Gleaning Resource Descriptions from Dialects of Languages">GRDDL</acronym></a></li> + +<li><a href="/2001/sw/hcls/" class="navlink">Health Care and Life +Sciences</a></li> + +<li><a href="/html/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr></a></li> + +<li><a href="/People/Raggett/tidy/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr> Tidy</a></li> + +<li><a href="http://validator.w3.org/" class="navlink"><abbr title="HyperText Markup Language">HTML</abbr> Validator</a></li> + +<li><a href="/Protocols/" class="navlink"><abbr title="Hypertext Transfer Protocol">HTTP</abbr></a></li> + +<li><a href="/2005/Incubator/" class="navlink">Incubator</a></li> + +<li><a href="/2002/mmi/ink" class="navlink">InkML</a></li> + +<li><a href="/International/" class="navlink">Internationalization</a></li> + +<li><a href="/Jigsaw/" class="navlink">Jigsaw</a></li> + +<li><a href="/Library/" class="navlink">Libwww</a></li> + +<li><a href="/Math/" class="navlink">MathML</a></li> + +<li><a href="/Mobile/" class="navlink">Mobile Web Initiative +(W3C-MWI)</a></li> + +<li><a href="/2002/mmi/" class="navlink">Multimodal +Interaction</a></li> + +<li><a href="/2004/OWL/" class="navlink"><acronym title="OWL Web Ontology Language">OWL</acronym></a></li> + +<li><a href="/2004/pp/" class="navlink">Patent Policy</a></li> + +<li><a href="/PICS/" class="navlink"><acronym title="Platform for Internet Content Selection">PICS</acronym></a></li> + +<li><a href="/Graphics/PNG/" class="navlink"><acronym title="Portable Network Graphics">PNG</acronym></a></li> + +<li><a href="/2007/powder/" class="navlink"><acronym title="Protocol for Web Description Resources">POWDER</acronym></a></li> + +<li><a href="/P3P/" class="navlink">Privacy and <abbr title="Platform for Privacy Preferences">P3P</abbr></a></li> + +<li><a href="/RDF/" class="navlink"><abbr title="Resource Description Framework">RDF</abbr></a></li> + +<li><a href="/2006/rwc/" class="navlink">Rich Web Clients</a></li> + +<li><a href="/2005/rules/" class="navlink">Rules</a></li> + +<li><a href="/Security/" class="navlink">Security</a></li> + +<li><a href="/2001/sw/" class="navlink">Semantic Web</a></li> + +<li><a href="/XML/SML" class="navlink">Service Modeling Language +(<abbr title="Service Modeling Language">SML</abbr>)</a></li> + +<li><a href="/AudioVideo/" class="navlink"><acronym title="Synchronized Multimedia Integration Language">SMIL</acronym></a></li> + +<li><a href="/2000/xp/Group/" class="navlink"><acronym title="Soap">SOAP</acronym>/<abbr title="XML Protocol">XMLP</abbr></a></li> + +<li><a href="/2002/ws/soapjms/" class="navlink"><acronym title="Soap">SOAP-JMS</acronym></a></li> + +<li><a href="/2001/sw/DataAccess/" class="navlink"><acronym title="Simple Protocol and RDF Query Language">SPARQL</acronym></a></li> + +<li><a href="/Style/" class="navlink">Style</a></li> + +<li><a href="/Graphics/SVG/" class="navlink"><abbr title="Scalable Vector Graphics">SVG</abbr></a></li> + +<li><a href="/2001/tag/" class="navlink"><abbr title="Technical Architecture Group">TAG</abbr></a></li> + +<li><a href="/AudioVideo/TT/" class="navlink">Timed Text</a></li> + +<li><a href="/Addressing/" class="navlink"><abbr title="Uniform Resource Identifiers">URI/URL</abbr></a></li> + +<li><a href="/QA/Tools/#validators" class="navlink">Validators</a></li> + +<li><a href="/Voice/" class="navlink">Voice</a></li> + +<li><a href="/2007/uwa/" class="navlink">Ubiquitous Web +Applications</a></li> + +<li><a href="/WAI/" class="navlink"><acronym title="Web Accessibility Initiative">WAI</acronym></a></li> + +<li><a href="/2006/webapi/" class="navlink">Web API</a></li> + +<li><a href="/2006/appformats/" class="navlink">Web Application +Formats</a></li> + +<li><a href="/2001/tag/" class="navlink">Web Architecture +(<acronym title="Technical Architecture Group">TAG</acronym>)</a></li> + +<li><a href="/Graphics/WebCGM/WG/" class="navlink"><abbr title="Web Computer Graphics Metafile">WebCGM</abbr></a></li> + +<li><a href="/2002/ws/" class="navlink">Web Services</a></li> + +<li><a href="/2002/ws/addr/" class="navlink"><abbr title="Web Services">WS</abbr>-Addressing</a></li> + +<li><a href="/2002/ws/chor/" class="navlink"><abbr title="Web Services Choreography Description Language">WS-CDL</abbr></a></li> + +<li><a href="/2002/ws/desc/" class="navlink"><acronym title="Web Services Description Language">WSDL</acronym></a></li> + +<li><a href="/2002/ws/policy/" class="navlink"><abbr title="Web Services">WS</abbr>-Policy</a></li> + +<li><a href="/MarkUp/Forms/" class="navlink"><acronym title="Next Generation Web Forms">XForms</acronym></a></li> + +<li><a href="/MarkUp/" class="navlink"><abbr title="Extensible HyperText Markup Language">XHTML</abbr></a></li> + +<li><a href="/MarkUp/" class="navlink"><abbr title="Extensible HyperText Markup Language">XHTML2</abbr></a></li> + +<li><a href="/XML/Linking" class="navlink"><acronym title="XML Link">XLink</acronym></a></li> + +<li><a href="/XML/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr></a></li> + +<li><a href="/TR/xmlbase/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Base</a></li> + +<li><a href="/2001/XKMS/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Key Management</a></li> + +<li><a href="/XML/Processing/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Processing</a></li> + +<li><a href="/XML/Query" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Query</a></li> + +<li><a href="/XML/Schema" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Schema</a></li> + +<li><a href="/2008/xmlsec/" class="navlink"><abbr title="Extensible Markup Language">XML</abbr> Signature +and Encryption</a></li> + +<li><a href="/Style/XSL/" class="navlink">XPath</a></li> + +<li><a href="/XML/Linking" class="navlink">XPointer</a></li> + +<li><a href="/Style/XSL/" class="navlink"><acronym title="Extensible Stylesheet Language">XSL</acronym> and <acronym title="XSL Transformations">XSLT</acronym></a></li> +</ul> + +<p><a href="/Consortium/siteindex" class="navlink">More +topics...</a></p> +</div> + +<div class="newsBlock"> +<h2 class="newsHeading"><a name="news" id="news">News</a></h2> + +<p class="invisible"><a title="Skip News" href="#search">Skip to +Search</a></p> + +<div id="item103" class="item"><h3 class="headline">New eGovernment Activity to Help Improve Government through Better Use of the Web</h3> +<p><a href="/2007/eGov/"><img class="newsImage" width="300" height="75" src="/2008/06/03-egov" alt="Crowd scene" /></a></p> +<p><span class="date">2008-06-03:</span> W3C launches today a <a href="/2007/eGov/">new forum</a> for governments, citizens, researchers, and other stakeholders to investigate how best to use Web technology for good governance and citizen participation. "Open Standards, and in particular Semantic Web Standards, can help lower the cost of government, make it easier for independent agencies to work together, and increase flexibility in the face of change," said Tim Berners-Lee, W3C Director. W3C invites participation in the new <a href="/2007/eGov/IG/">eGovernment Interest Group</a>, which is open to the public. The group will identify best practices and guidelines in this area, document where current technology does not adequately address stakeholder needs, and suggest improvements via the standards process. Read the <a href="/2007/eGov/IG/faq">W3C eGovernment FAQ</a> and <a href="/2008/06/egov-pressrelease">press release</a>, and learn more about the <a href="/2007/eGov/">W3C eGovernment Activity</a>.<span class="archive"> (<a title="New eGovernment Activity to Help Improve Government through Better Use of the Web" href="/News/2008#item103" rel="details">Permalink</a>) </span></p></div> + +<div id="item105" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Two Group Notes Published About Semantic Web and Life Sciences</h3><p><span class="date">2008-06-05:</span> The <a href="/2001/sw/hcls/">Semantic Web Health Care and Life Sciences Interest Group</a> has published two Group Notes: <a href="/TR/2008/NOTE-hcls-kb-20080604/">A Prototype Knowledge Base for the Life Sciences</a> and <a href="/TR/2008/NOTE-hcls-senselab-20080604/">Experiences with the conversion of SenseLab databases to RDF/OWL</a>. The former describes a prototype of a biomedical knowledge base that integrates 15 distinct data sources using currently available Semantic Web technologies including RDF and OWL. The Note outlines which resources were integrated, how the knowledge base was constructed using free and open source triple store technology, how it can be queried using SPARQL, and what resources and inferences are involved in answering complex queries. While the utility of the knowledge base is illustrated by identifying a set of genes involved in Alzheimer's Disease, the approach described here can be applied to any use case that integrates data from multiple domains. The second document describe the experience of converting SenseLab databases into OWL, an important step towards realizing the benefits of Semantic Web in integrative neuroscience research. Learn more about the <a href="/2001/sw/">Semantic Web Activity</a>.<span class="archive"> (<a title="Two Group Notes Published About Semantic Web and Life Sciences" href="/News/2008#item105" rel="details">Permalink</a>) </span></p></div> + +<div id="item104" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Offline Web Applications Published as W3C Note</h3><p><span class="date">2008-06-03:</span> The <a href="/html/wg/">HTML Working Group</a> has published the <a href="/TR/2008/NOTE-offline-webapps-20080530/">Offline Web Applications</a> Group Note. <a href="/TR/html5/">HTML 5</a> contains several features that address the challenge of building Web applications that work while offline. This document highlights these features (SQL, offline application caching APIs as well as online/offline events, status, and the localStorage API) from HTML 5 and provides brief tutorials on how these features might be used to create Web applications that work offline. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>.<span class="archive"> (<a title="Offline Web Applications Published as W3C Note" href="/News/2008#item104" rel="details">Permalink</a>) </span></p></div> + +<div id="item102" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Advisory Committee Elects Advisory Board</h3><p><span class="date">2008-06-02:</span> The W3C Advisory Committee has filled six open seats on the <a href="/2002/ab/">W3C Advisory Board</a>. Created in 1998, the Advisory Board provides guidance to the Team on issues of strategy, management, legal matters, process, and conflict resolution. Beginning 1 July, the nine Advisory Board participants are Jean-François Abramatic (ILOG), Ann Bassetti (The Boeing Company), Jim Bell (HP), Don Deutsch (Oracle), Eduardo Gutentag (Sun Microsystems), Steve Holbrook (IBM), Ken Laskey (MITRE), Ora Lassila (Nokia), and Arun Ranganathan (Mozilla Foundation). Steve Zilles continues as interim Advisory Board Chair. Read more about the <a href="/2002/ab/">Advisory Board</a>.<span class="archive"> (<a title="W3C Advisory Committee Elects Advisory Board" href="/News/2008#item102" rel="details">Permalink</a>) </span></p></div> + +<div id="item101" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Talks in June</h3><p><span class="date">2008-06-02:</span> Browse <a href="/Talks/">W3C presentations and events</a> also available as an <abbr title="RDF Site Summary"><a href="/2004/08/TalkFiles/Talks.rss">RSS channel</a></abbr>. <span class="archive"> (<a title="W3C Talks in June" href="/News/2008#item101" rel="details">Permalink</a>) </span></p><ul><li><span class="talkstart">2 June, VästerÃ¥s, Sweden: </span><span class="talktitle" lang="sv" xml:lang="sv">Framtidssäkra eFörvaltningen<span class="hide noprint">.</span></span><span class="talkdesc">Olle Olsson participates in a panel at <a href="http://www.offentligarummet.se/" lang="sv" xml:lang="sv">Offentliga Rummet 2008</a>. </span></li><li><span class="talkstart">4 June, Sao Paulo, Brazil: </span><span class="talktitle">Towards eGovernment 2.0 through better use of the Web<span class="hide noprint">.</span></span><span class="talkdesc">José Manuel Alonso presents at <a href="http://www.w3c.br/2008/launch/">W3C Brazil Office Public Launch</a>. </span></li><li><span class="talkstart">4 June, Sao Paolo, Brazil: </span><span class="talktitle">W3C - Web Open Standards<span class="hide noprint">.</span></span><span class="talkdesc">Daniel Dardailler presents at <a href="http://www.w3c.br/2008/lancamento/">W3C Brazil Office Launch event </a>. </span></li><li><span class="talkstart">10 June, Buenos Aires, Argentina: </span><span class="talktitle">Web Accessibility: People with Disabilities and Elderly Citizens<span class="hide noprint">.</span></span><span class="talkdesc">Shadi Abou-Zahra presents at <a href="http://www.isoc.org.ar/accesibilidad.html" lang="es" xml:lang="es">Web Sin Barreras</a>. </span></li><li><span class="talkstart">11 June, Nashville, TN, USA: </span><span class="talktitle">Color for the Global Web<span class="hide noprint">.</span></span><span class="talkdesc">Molly E Holzschlag presents at <a href="http://www.voicesthatmatter.com/webdesign2008/index.aspx">Voices That Matter</a>. </span></li><li><span class="talkstart">12 June, Nashville, TN, USA: </span><span class="talktitle">Designing for Today's Browsers<span class="hide noprint">.</span></span><span class="talkdesc">Molly E Holzschlag presents at <a href="http://www.voicesthatmatter.com/webdesign2008/index.aspx">Voices That Matter</a>. </span></li><li><span class="talkstart">17 June, New York, NY, USA: </span><span class="talktitle">Web of Data<span class="hide noprint">.</span></span><span class="talkdesc">Tim Berners-Lee presents at <a href="http://www.linkeddataplanet.com/index.php">LinkedData Planet Conference: exploring the new web of linked data</a>. </span></li><li><span class="talkstart">19 June, Tokyo, Japan: </span><span class="talktitle">Update on W3C/WAI Guidelines including WCAG 2.0<span class="hide noprint">.</span></span><span class="talkdesc">Judy Brewer presents at <a>Open Seminar of Information Accessibility</a>. </span></li><li><span class="talkstart">19 June, Nancy, France: </span><span class="talktitle" lang="fr" xml:lang="fr">États des lieux du Web sémantique<span class="hide noprint">.</span></span><span class="talkdesc">Ivan Herman gives a keynote at <a href="http://ic2008.loria.fr/" lang="fr" xml:lang="fr">19èmes Journées Francophones d'Ingénierie des Connaissances (IC2008)</a>. </span></li><li><span class="talkstart">19 June, Baltimore, Maryland, USA: </span><span class="talktitle">How New Web Accessibility Standards Impact User Experience Design<span class="hide noprint">.</span></span><span class="talkdesc">Shawn Henry presents at <a href="http://www.usabilityprofessionals.org/conference/2008/">Usability Professionals' Association International Conference 2008</a>. </span></li><li><span class="talkstart">26 June, Frankfurt, Germany: </span><span class="talktitle">Mobile Internet - the Way Forward<span class="hide noprint">.</span></span><span class="talkdesc">Steve Bratt participates in a panel at <a href="http://www.amiando.com/ngmn-2008">2nd NGMN Industry Conference 2008</a>. </span></li><li class="noprint showuris">View <a href="http://www.w3.org/2004/08/W3CTalks?date=Recent+and+upcoming&countryListing=yes&submit=Submit">upcoming talks by country</a></li><li class="noprint showuris"><a href="/Talks/">More talks...</a></li></ul></div> + +<div id="item100" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Launches Group to Help Bridge the Digital Divide</h3><p><a href="/2008/MW4D/"><img class="newsImage" alt="Phone bikes" src="/2008/05/voiturette-sb.png" /></a><span class="date">2008-05-27:</span> As part of the growing set of W3C initiatives related to social development, W3C invites participation in the new <a href="/2008/MW4D/">Mobile Web for Development (MW4D) interest Group</a>, chartered to explore the potential of mobile technology to help bridge the digital divide. "We need to solve important challenges, such as lack of standards in end-user devices, network constraints, service cost, issues of literacy, and an understanding of the real information needs of rural communities," said Ken Banks, kiwanja.net, who Chairs the group. "To do so requires an multidisciplinary approach, a step we take through the creation of this new group." Read more in the <a href="/2008/05/mw4dig-pressrelease">press release</a>. This launch is part of <a href="/Mobile">W3C's Mobile Web Initiative (MWI)</a>, which aims to identify and resolve challenges and issues of accessing the Web when on the move. This work takes place under the auspices of the <a href="http://cordis.europa.eu/fp7/ict/">European Union's 7th Research Framework Programme (FP7)</a>, part of the <a href="http://digitalworld.ercim.org/">Digital World Forum</a> project.<span class="archive"> (Photo credit: Stéphane Boyera. <a title="W3C Launches Group to Help Bridge the Digital Divide" href="/News/2008#item100" rel="details">Permalink</a>) </span></p></div> + +<div id="item99" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: XHTML Access Module</h3><p><span class="date">2008-05-26:</span> The <a href="/MarkUp/">XHTML 2 Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-xhtml-access-20080526/">XHTML Access Module</a>. This document is intended to help make XHTML-family markup languages more effective at supporting the needs of the accessibility community. It does so by providing a generic mechanism for defining the relationship between document components and well-known accessibility taxonomies. Comments are welcome through 16 June. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>. <span class="archive"> (<a title="Last Call: XHTML Access Module" href="/News/2008#item99" rel="details">Permalink</a>) </span></p></div> + +<div id="item98" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Invites Implementations of CSS Namespaces Module (Candidate Recommendation)</h3><p><span class="date">2008-05-23:</span> The <a href="/Style/CSS/members">Cascading Style Sheets (CSS) Working Group</a> has published the Candidate Recommendation of <a href="/TR/2008/CR-css3-namespace-20080523/">CSS Namespaces Module</a>. This CSS Namespaces module defines the syntax for using namespaces in CSS. It defines the @namespace rule for declaring the default namespace and binding namespaces to namespace prefixes, and it also defines a syntax that other specifications can adopt for using those prefixes in namespace-qualified names. Learn more about the <a href="/Style/">Style Activity</a>.<span class="archive"> (<a title="W3C Invites Implementations of CSS Namespaces Module (Candidate Recommendation)" href="/News/2008#item98" rel="details">Permalink</a>) </span></p></div> + +<div id="item97" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Progress Events 1.0</h3><p><span class="date">2008-05-22:</span> The <a href="/2006/webapi/">Web API Working Group</a> has published a Working Draft of <a href="/TR/2008/WD-progress-events-20080521/">Progress Events 1.0</a>.This document describes event types that can be used for monitoring the progress of an operation. It is primarily intended for contexts such as data transfer operations specified by <a href="/TR/XMLHttpRequest">XMLHTTPRequest</a>, or <a href="/TR/MediaAccessEvents/">Media Access Events</a>. Learn more about the <a href="/2006/rwc/">Rich Web Client Activity</a>.<span class="archive"> (<a title="Progress Events 1.0" href="/News/2008#item97" rel="details">Permalink</a>) </span></p></div> + +<div id="item96" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />XML Security Working Group to Take Next Steps on XML Signature, Encryption</h3><p><span class="date">2008-05-21:</span> W3C is pleased to announce the creation of the <a href="/2008/xmlsec/">XML Security Working Group</a>, whose mission is to evaluate and act on <a href="/2007/xmlsec/ws/report">recommendations</a> from the <a href="/2007/xmlsec/ws/agenda.html">September 2007 Workshop on XML Signature and XML Encryption</a> regarding next steps for XML Security specifications. The group's <a href="/2008/02/xmlsec-charter.html#deliverables">deliverables</a> include new work on XML Signature Syntax and Processing and XML Encryption Syntax and Processing, as well as maintenance of related specifications. Frederick Hirsch (Nokia) will Chair the group, with Thomas Roessler (W3C) as Team Contact. Learn more about the <a href="/Security/">W3C Security Activity</a>. <span class="archive"> (<a title="XML Security Working Group to Take Next Steps on XML Signature, Encryption" href="/News/2008#item96" rel="details">Permalink</a>) </span></p></div> + +<div id="item94" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: Cascading Style Sheets (CSS) Snapshot 2007</h3><p><span class="date">2008-05-16:</span> The <a href="/Style/CSS/members">Cascading Style Sheets (CSS) Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-css-beijing-20080516/">Cascading Style Sheets (CSS) Snapshot 2007</a>. This document collects together into one definition all the specifications that together form the current state of Cascading Style Sheets (CSS). The primary audience is CSS implementors, not CSS authors, as this definition includes modules by specification stability, not Web browser adoption rate. Comments are welcome through 09 June. Learn more about the <a href="/Style/">Style Activity</a>.<span class="archive"> (<a title="Last Call: Cascading Style Sheets (CSS) Snapshot 2007" href="/News/2008#item94" rel="details">Permalink</a>) </span></p></div> + +<div id="item93" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />W3C Invites Implementations of XQuery and XPath Full Text 1.0 (Candidate Recommendation); Requirements and Use Cases Drafts Available</h3><p><span class="date">2008-05-16:</span> The W3C <a href="http://www.w3.org/XML/Query/">XML Query Working Group</a> and the W3C <a href="http://www.w3.org/Style/XSL/">XSL Working Group</a> jointly published today a Candidate Recommendation of <a href="/TR/2008/CR-xpath-full-text-10-20080516/">XQuery and XPath Full Text 1.0</a>. This document defines the syntax and formal semantics of XQuery and XPath Full Text 1.0 which is a language that extends XQuery 1.0 [XQuery 1.0: An XML Query Language] and XPath 2.0 [XML Path Language (XPath) 2.0] with full-text search capabilities. Implementors are encouraged to run the groups' <a href="http://dev.w3.org:/cvsweb/2007/xpath-full-text-10-test-suite/">test suite</a> and report their results. The Groups also published Working Drafts of <a href="/TR/2008/WD-xpath-full-text-10-requirements-20080516/">XQuery and XPath Full Text 1.0 Requirements</a> and <a href="/TR/2008/WD-xpath-full-text-10-use-cases-20080516/">Use Cases</a>. Learn more about the <a href="/XML/">XML Activity</a>.<span class="archive"> (<a title="W3C Invites Implementations of XQuery and XPath Full Text 1.0 (Candidate Recommendation); Requirements and Use Cases Drafts Available" href="/News/2008#item93" rel="details">Permalink</a>) </span></p></div> + +<div id="item95" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />State Chart XML (SCXML) Working Draft Published</h3><p><span class="date">2008-05-16:</span> The <a href="/Voice/">Voice Browser Working Group</a> has published an updated Working Draft of <a href="/TR/2008/WD-scxml-20080516/">State Chart XML (SCXML): State Machine Notation for Control Abstraction</a>. <abbr title="State Chart eXtensible Markup Language">SCXML</abbr> is an execution environment based on <a href="http://www.uml.org/#UML1.5"><abbr title="Unified Modeling Language">UML</abbr></a> Harel State Tables and <a href="/TR/ccxml/"><abbr title="Call Control eXtensible Markup Language">CCXML</abbr></a>. The main differences from the previous draft are (1) the modularization of the language, (2) the introduction of profiles and (3) a revision of the algorithm for document interpretation; the document as a whole has changed significantly and the group welcomes review. Learn more about the <a href="/Voice/">Voice Browser Activity</a>.<span class="archive"> (<a title="State Chart XML (SCXML) Working Draft Published" href="/News/2008#item95" rel="details">Permalink</a>) </span></p></div> + +<div id="item92" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />"Web Accessibility for Older Users: A Literature Review"; Comments Welcome on First Public Draft</h3><p><span class="date">2008-05-14:</span> The Web Accessibility Initiative (WAI) <a href="/WAI/EO/">Education and Outreach Working Group Working Group (EOWG)</a> has published <a href="/TR/2008/WD-wai-age-literature-20080514/">Web Accessibility for Older Users: A Literature Review</a> as a First Public Working Draft. The document includes reviews and analysis of guidelines and articles covering the requirements of people with Web accessibility needs related to ageing. This literature review will inform WAI efforts to promote accessibility solutions for older Web users and potentially to develop profiles or extensions to WAI guidelines. The literature review is a deliverable of the <a href="/WAI/WAI-AGE/">WAI-AGE Project</a> (Ageing Education and Harmonisation). See the <a href="http://lists.w3.org/Archives/Public/w3c-wai-ig/2008AprJun/0083.html">call for review and participation</a> for an introduction to the project and an invitation to contribute to the literature review and other WAI-AGE work; and about the <a href="/WAI/">Web Accessibility Initiative</a>.<span class="archive"> (<a title="Web Accessibility for Older Users: A Literature Review; Comments Welcome on First Public Draft" href="/News/2008#item92" rel="details">Permalink</a>) </span></p></div> + +<div id="item91" class="item"><h3><img alt="" width="17" height="11" src="/Icons/right" />Last Call: CURIE Syntax 1.0</h3><p><span class="date">2008-05-08:</span> The <a href="/MarkUp/">XHTML2 Working Group</a> has published the Last Call Working Draft of <a href="/TR/2008/WD-curie-20080506">CURIE Syntax 1.0</a>, which outlines a syntax for expressing URIs in a generic, abbreviated syntax ("Compact URI"). The specification targets language designers who need a mechanism to permit the use of extensible value collections. Any language designer considering the use of QNames in attribute values should consider instead using CURIEs, since CURIEs are designed for this purpose, while QNames are not. Comments are welcome through 10 June. Learn more about the <a href="/MarkUp/Activity">HTML Activity</a>.<span class="archive"> (<a title="Last Call: CURIE Syntax 1.0" href="/News/2008#item91" rel="details">Permalink</a>) </span></p></div> + + + +<h3 class="pastNews"><a href="/News/2008">Past News</a></h3> +</div> + +<div class="navBlock"> +<h2 class="navhead"><a name="search" id="search">Search</a></h2> + +<p class="invisible"><a class="navlink" title="Skip search" href="#contents">Skip to Contents</a></p> + +<form method="get" action="http://www.google.com/custom" enctype="application/x-www-form-urlencoded"> +<div> +<a class="navlink" href="http://www.google.com"><img src="/Icons/Logo_25wht.gif" width="75" height="32" alt="Google" /></a><br /> +<label for="inputField">Search W3C<br /> +<input type="text" size="15" id="inputField" name="q" accesskey="E" maxlength="255" /></label> <input type="submit" value="Go" id="goButton" name="sa" accesskey="G" /><br /> +<input type="hidden" name="cof" value="T:black;LW:72;ALC:#ff3300;L:http://www.w3.org/Icons/w3c_home;LC:#000099;LH:48;BGC:white;AH:left;VLC:#660066;GL:0;AWFID:0b9847e42caf283e;" /> + <input type="hidden" id="searchW3C" name="sitesearch" checked="checked" value="www.w3.org" /><input type="hidden" name="domains" value="www.w3.org" /> +</div> +</form> + +<p><a class="navlink" href="/Search/Mail/Public/">Search W3C Mailing +Lists</a></p> + +<h2 class="navhead"><a name="contents" id="contents">Testimonials</a></h2> + +<div class="hpmt"><div class="hpmt-name">Fraunhofer Gesellschaft</div><div class="hpmt-logo"><a rel="nofollow" href="http://www.fraunhofer.de/"><img alt="Fraunhofer Gesellschaft" src="http://www.w3.org/Consortium/Member/Testimonial/Logo/119" /></a></div><p class="hpmt-testimonial">The Fraunhofer-Gesellschaft undertakes applied contract research in all fields of engineering sciences. Fraunhofer works with W3C to contribute to the development of Web technologies which are the base of many of our research activities. Fraunhofer hosts the W3C Office in Germany and Austria. <a class="hpmt-more" href="http://www.w3.org/Consortium/Member/Testimonial/List">(Member testimonials)</a></p></div> + +<h2 class="navhead">Members</h2> + +<ul> +<li><a href="/Member/" class="navlink">Member Home Page</a></li> + +<li><a href="/Submission/" class="navlink">Member Submissions</a></li> + +<li><a href="/Consortium/Member/List" class="navlink">Current +Members</a></li> + +<li><a href="/Consortium/meetings" class="navlink">Meetings</a></li> + +<li><a href="/Consortium/Recruitment/Fellows" class="navlink">Fellows</a> (<a href="/Consortium/Recruitment/Fellows#openings">New Openings</a>)</li> +</ul> + +<h2 class="navhead">Get Involved</h2> + +<ul> +<li><a href="/Consortium/membership-benefits" class="navlink">W3C +Membership Benefits</a></li> + +<li><a href="/Consortium/membership#bizcase" class="navlink">Reasons to +Join W3C</a></li> + +<li><a href="/Mail/" class="navlink">Mailing Lists</a></li> + +<li><a href="http://lists.w3.org/Archives/Public/public-new-work/latest">Potential +New Work</a></li> + +<li><a href="/Consortium/Translation/" class="navlink">Translations</a></li> + +<li><a href="/2003/08/Workshops/" class="navlink">Workshops</a></li> + +<li><a href="/2001/11/StdLiaison" class="navlink">Liaisons</a></li> + +<li><a href="/Status" class="navlink">Open Source Software</a></li> + +<li><a href="/QA/" class="navlink">Q&A Blog</a></li> + +<li><a href="/Consortium/Recruitment/" class="navlink">Employment</a></li> + +<li><span class="navText">More ways to</span> <a href="/Consortium/org#public" class="navlink">participate</a></li> +</ul> + +<h2 class="navhead">Introduction</h2> + +<ul> +<li><a href="/Consortium/" class="navlink">About W3C</a></li> + +<li><a href="/Consortium/faq" class="navlink">Frequently Asked +Questions (FAQ)</a></li> + +<li><a href="/2003/glossary/" class="navlink">Glossary</a></li> + +<li><a href="/Consortium/Process/" class="navlink">Process +Document</a></li> + +<li><a href="/2002/03/tutorials" class="navlink">Tutorials</a></li> + +<li><a href="/2002/03/new-to-w3c" class="navlink">More...</a></li> +</ul> + +<h2 class="navhead">W3C Team</h2> + +<ul> +<li><a href="/People/" class="navlink">People</a></li> + +<li><a href="/TeamSubmission/" class="navlink">Team +Submissions</a></li> +</ul> + +<h2 class="navhead">Presentations</h2> + +<ul> +<li><a href="/Talks/" class="navlink">Public Presentations</a></li> +</ul> + +<h2 class="navhead">News Room</h2> + +<ul> +<li><a href="/News/" class="navlink">W3C News Archive</a> <span class="navText">(</span><a href="/2000/08/w3c-synd/home.rss" class="navlink">RSS</a><span class="navText">)</span></li> + +<li><a href="/News/Public/" class="navlink">Weekly Public Newsletter</a></li> + +<li><a href="/Press/" class="navlink">Press Releases</a></li> + +<li><a href="/Press/#rss" class="navlink">Multilingual Press Release +RSS</a></li> + +<li><a href="/Press/Articles" class="navlink">W3C in the Press</a></li> +</ul> + +<h2 class="navhead"><a name="Offices" id="Offices">World +Offices</a></h2> + +<p class="navPara">The <a href="/Consortium/Offices/" class="navlink">W3C Offices</a>, part of the <a href="/2007/IntlRel.html">W3C +International Relations team</a> translate many W3C home page news +items. W3C Offices are located in these parts of the world:</p> + +<ul> +<li><a href="http://www.w3c.org.au/" class="navlink" title="Australia">Australia</a></li> + +<li><a href="http://www.w3c.nl/index.shtml.nl" class="navlink" hreflang="nl" title="Benelux"><span xml:lang="nl" lang="nl">Benelux</span></a>/<a href="http://www.w3c.nl/index.shtml.fr" class="navlink" title="Benelux" hreflang="fr"><span xml:lang="fr" lang="fr">Bénélux</span></a></li> + +<li><a href="http://www.w3c.br/" class="navlink" title="Brazil" hreflang="pt-br"><span xml:lang="pt-br" lang="pt-br">Brasil</span> +(Brazil)</a></li> + +<li><a href="http://www.chinaw3c.org/" class="navlink" title="China" hreflang="zh-hans"><span xml:lang="zh-hans" lang="zh-hans">ä¸å›½</span> +(China)</a></li> + +<li><a href="http://www.w3c.tut.fi/" class="navlink" title="Finland" hreflang="fi"><span xml:lang="fi" lang="fi">Suomi</span> +(Finland)</a></li> + +<li><a href="http://www.w3c.de/" class="navlink" title="German and Austria" hreflang="de"><span xml:lang="de" lang="de">Deutschland und Österreich</span> (Germany and Austria)</a></li> + +<li><a href="http://www.w3c.gr/" class="navlink" title="Greece" hreflang="el"><span xml:lang="el" lang="el">Ελλάδα</span> +(Greece)</a></li> + +<li><a href="http://www.w3c.hu/" class="navlink" title="Hungary" hreflang="hu"><span xml:lang="hu" lang="hu">Magyarország</span> +(Hungary)</a></li> + +<li><a href="http://www.w3cindia.in/" class="navlink" title="India" hreflang="en"><span xml:lang="hi" lang="hi">à¤à¤¾à¤°à¤¤</span> +(India)</a></li> + +<li><a href="http://www.w3c.org.il/" class="navlink" title="Israel" hreflang="he"><span xml:lang="he" lang="he">ישר×ל</span> +(Israel)</a></li> + +<li><a href="http://www.w3c.it/" class="navlink" title="Italy" hreflang="it"><span xml:lang="it" lang="it">Italia</span> +(Italy)</a></li> + +<li><a href="http://www.w3c.or.kr/" class="navlink" title="Korea" hreflang="ko"><span xml:lang="ko" lang="ko">í•œêµ</span> (Korea)</a></li> + +<li><a href="http://www.w3c.org.ma/" class="navlink" title="Morocco" hreflang="ar"><span xml:lang="ar" lang="ar">المغرب</span> +(Morocco)</a></li> + +<li><a href="http://www.w3c.org.za/" class="navlink" title="Southern Africa" hreflang="en">Southern Africa</a></li> + +<li><a href="http://www.w3c.es/" class="navlink" title="Spain" hreflang="es"><span xml:lang="es" lang="es">España</span> +(Spain)</a></li> + +<li><a href="http://www.w3c.se" class="navlink" title="Sweden" hreflang="sv"><span xml:lang="sv" lang="sv">Sverige</span> +(Sweden)</a></li> + +<li><a href="http://www.w3c.rl.ac.uk/" class="navlink" title="UK and Ireland" hreflang="en-uk">United Kingdom and Ireland</a></li> +</ul> + +<h2 class="navhead"><a name="systems" id="systems">Systems</a></h2> + +<ul> +<li><a href="/Help/Account/" class="navlink">Get Password</a></li> + +<li><a href="/2003/08/system-status" class="navlink">System +Status</a></li> +</ul> +</div> +<hr class="hide" /> + +<p class="small">W3C would like to thank the <a name="donors" id="donors" href="/Consortium/sup">Supporters</a> who have contributed +financially or through a donation of goods to W3C.</p> + +<p class="small"><a name="footnotes" id="footnotes">Read</a> <a href="/2002/11/homepage">about the layout</a> and <a href="http://lists.w3.org/Archives/Public/site-comments/">send comments</a> +about this page. <a href="/2000/08/w3c-synd/home.rss">Syndicate</a> +this page with <a href="http://purl.org/rss/1.0/">RSS 1.0</a>, an +<a href="/RDF/">RDF</a> vocabulary used for <a href="/2000/08/w3c-synd/#">site summaries</a>. </p> + +<address class="small"> +<a href="/Help/Webmaster">Webmaster</a> · Last modified: + $Date: 2008/06/05 17:06:19 $ + <span class="whiteout">|</span><br /> +<a href="http://validator.w3.org/check?uri=referer"><img src="/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a> <span class="whiteout">|</span> <a href="http://jigsaw.w3.org/css-validator/"><img src="/Icons/valid-css" alt="Valid CSS!" height="31" width="88" /></a> <span class="whiteout">|</span> <a href="/WAI/WCAG1AA-Conformance" title="Explanation of Level Double-A Conformance"><img class="conform" height="31" width="88" src="/WAI/wcag1AA" alt="Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0" /> +</a> <span class="whiteout">|</span> +</address> + +<p class="copyright"><a rel="Copyright" href="/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 1994-2007 +<a href="/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, +<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C +<a href="/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, +<a href="/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>, +<a rel="Copyright" href="/Consortium/Legal/copyright-documents">document use</a> and <a rel="Copyright" href="/Consortium/Legal/copyright-software">software +licensing</a> rules apply. Your interactions with this site are in +accordance with our <a href="/Consortium/Legal/privacy-statement#Public">public</a> and <a href="/Consortium/Legal/privacy-statement#Members">Member</a> privacy +statements.</p> +</body> +</html> diff --git a/examples/xml/htmlinfo/youtube_com.html b/examples/xml/htmlinfo/youtube_com.html new file mode 100644 index 0000000..1de65a3 --- /dev/null +++ b/examples/xml/htmlinfo/youtube_com.html @@ -0,0 +1,1585 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> + + + <html lang="en"> + +<!-- machid: 519 --> +<head> + + <title>YouTube - Broadcast Yourself.</title> + + <link rel="stylesheet" href="http://s.ytimg.com/yt/css/base_all-vfl42327.css" type="text/css"> + + <link rel="search" type="application/opensearchdescription+xml" href="/opensearch?locale=en_US" title="YouTube Video Search"> + <link rel="icon" href="http://s.ytimg.com/yt/favicon-vfl1123.ico" type="image/x-icon"> + <link rel="shortcut icon" href="http://s.ytimg.com/yt/favicon-vfl1123.ico" type="image/x-icon"> + + + <meta name="description" content="Share your videos with friends and family"> + <meta name="keywords" content="video,sharing,camera phone,video phone,free"> + + <link rel="alternate" type="application/rss+xml" title="YouTube - [RSS]" href="/rssls"> + + <link rel="alternate" media="handheld" href="http://m.youtube.com/index?desktop_uri=%2F&"> + + <script type="text/javascript"> + window.google={kHL:"en"}; + </script> + + <script type="text/javascript" src="http://s.ytimg.com/yt/js/base_all_with_bidi-vfl42302.js"></script> + + <script type="text/javascript"> + + function _hbLink (a,b) { return false; } + function urchinTracker (a,b) { } + + + var gXSRF_token = ''; + var gXSRF_field_name = ''; + var gXSRF_ql_pair = ''; + + gXSRF_token = 'fZg-xPKpfj11aUrz_5__moOGiAp8MTIxMjg1OTQ4OA=='; + gXSRF_field_name = 'session_token'; + onLoadFunctionList.push(populate_session_token); + + gXSRF_ql_pair = 'session_token=kVjpl8qnfp7RPuqnTrIu6Q8BT5d8MA=='; + + + var gQuickListTooltipText = 'Add Video to QuickList'; + var gPartnerVideoText = 'Partner Video'; + var gGoogleSuggest = true; + var gPixelGif = 'http://s.ytimg.com/yt/img/pixel-vfl73.gif'; + + var gInQuickListText = 'in <a href="/watch_queue?all">QuickList</a>'; + var gIsResultsPage = false; + </script> + + + +<script type="text/javascript"> + +function swapVideoList(linkObj) +{ + var linkId = linkObj.id; + var queryData = ''; + var newDivId = ''; + var headlineObj = document.getElementById('hpVideoListHead'); + var moreLinkObj = document.getElementById('homepage-featured-more-top'); + var bottomMoreLinkObj = document.getElementById('homepage-featured-more-bottom'); + + if (linkId == 'hpMostViewedLink') { + queryData = 'videoListType=mostViewed'; + newDivId = 'hpMostViewed'; + headlineObj.innerHTML = "Most Viewed Videos"; + moreLinkObj.innerHTML = "<a href=\"/browse?s=mp\">See More Most Viewed Videos</a>"; + bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=mp\">See More Most Viewed Videos</a>"; + } + else if (linkId == 'hpMostDiscussedLink') { + queryData = 'videoListType=mostDiscussed'; + newDivId = 'hpMostDiscussed'; + headlineObj.innerHTML = "Most Discussed Videos"; + moreLinkObj.innerHTML = "<a href=\"/browse?s=md\">See More Most Discussed Videos</a>"; + bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=md\">See More Most Discussed Videos</a>"; + } + else if (linkId == 'hpTopFavoritesLink') { + queryData = 'videoListType=topFavorites'; + newDivId = 'hpTopFavorites'; + headlineObj.innerHTML = "Top Favorites"; + moreLinkObj.innerHTML = "<a href=\"/browse?s=mf\">See More Top Favorites</a>"; + bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=mf\">See More Top Favorites</a>"; + } + else if (linkId == 'hpFeaturedLink') { + newDivId = 'hpFeatured'; + headlineObj.innerHTML = "Featured Videos"; + moreLinkObj.innerHTML = "<a href=\"/browse?s=rf\">See More Featured Videos</a>"; + bottomMoreLinkObj.innerHTML = "<a href=\"/browse?s=rf\">See More Featured Videos</a>"; + } + self.containerDiv = 'homepage-video-list' + self.fillDiv = fillDiv + self.linkId = linkId + self.newDivId = newDivId + addClass(_gel(newDivId + 'Link'), 'hilite'); + if (newDivId != 'hpMostViewed') { + removeClass(_gel('hpMostViewedLink'), 'hilite'); + } + if (newDivId != 'hpMostDiscussed') { + removeClass(_gel('hpMostDiscussedLink'), 'hilite'); + } + if (newDivId != 'hpTopFavorites') { + removeClass(_gel('hpTopFavoritesLink'), 'hilite'); + } + if (newDivId != 'hpFeatured') { + removeClass(_gel('hpFeaturedLink'), 'hilite'); + } + if (document.getElementById(newDivId)) + { + document.getElementById(newDivId).style.display = 'block'; + if (newDivId != 'hpMostViewed' && document.getElementById('hpMostViewed')) document.getElementById('hpMostViewed').style.display = 'none'; + if (newDivId != 'hpMostDiscussed' && document.getElementById('hpMostDiscussed')) document.getElementById('hpMostDiscussed').style.display = 'none'; + if (newDivId != 'hpTopFavorites' && document.getElementById('hpTopFavorites')) document.getElementById('hpTopFavorites').style.display = 'none'; + if (newDivId != 'hpFeatured' && document.getElementById('hpFeatured')) document.getElementById('hpFeatured').style.display = 'none'; + } + else if (queryData != '') { + postUrlXMLResponse('/ajax_video_list',queryData,self.fillDiv); + } +} +function fillDiv(req) +{ + if (document.getElementById('hpMostViewed')) document.getElementById('hpMostViewed').style.display = 'none'; + if (document.getElementById('hpMostDiscussed')) document.getElementById('hpMostDiscussed').style.display = 'none'; + if (document.getElementById('hpTopFavorites')) document.getElementById('hpTopFavorites').style.display = 'none'; + if (document.getElementById('hpFeatured')) document.getElementById('hpFeatured').style.display = 'none'; + var newContent = getNodeValue(req.responseXML, "html_content"); + var newdiv = document.createElement('div'); + newdiv.setAttribute("id",self.newDivId); + newdiv.innerHTML = newContent; + var container = document.getElementById(self.containerDiv); + container.appendChild(newdiv); + addQLIcons(container); +} + +function hide_active_sharing() { + hideDiv("active_sharing_div"); +} +</script> + +</head> + + +<body onload="performOnLoadFunctions();" class="en_US is-english"> + +<div id="baseDiv" class="date-20080606"> + + <div id="masthead"> + <a href="/" class="logo"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" width="132" height="63" border="0" alt=""/></a> + <div class="user-info"> + + <div id="loginBoxZ"> + <div class="contentBox"> + <div> + <div id="loginBoxZ-signup"> + <a href="/signup">Sign Up</a> + | <a href="http://help.youtube.com/support/youtube/bin/topic.py?topic=10546&hl=en_US">Help</a> + </div> + <div id="loginBoxZ-login"> + Login + </div> + <div class="clear"></div> + </div> + + <form method="post" name="loginForm" id="loginFormZ" action="/signup"> + <input type="hidden" name="next" value="/" id="loginNextZ"/> + <input type="hidden" name="current_form" value="loginForm" /> + <input type="hidden" name="action_login" value="1"> + <div id="loginBoxZ-container"> + <div id="loginBoxZ-labels" class="floatL"> + <label for="loginUserZ" class="nowrap">Username:</label> + <label for="loginPassZ" class="nowrap">Password:</label> + </div> + <div class="floatL"> + <input id="loginUserZ" class="loginBoxZ-input" type="text" size="16" name="username" value=""><br/> + <input id="loginPassZ" class="loginBoxZ-input" type="password" size="16" name="password"><br/> + <input type="submit" class="smallText" value="Login"> + </div> + <div class="clearL"></div> + </div> + </form> + <div id="loginBoxZ-forgot"> + <a href="/forgot_username?next=/">Forgot Username</a> + | <wbr><nobr><a href="/forgot?next=/">Forgot Password</a></nobr> + </div> + <div id="loginBoxZ-gaia"> + <a href="https://www.google.com/accounts/ServiceLogin?service=youtube&hl=en_US&continue=http%3A//www.youtube.com/signup%3Fhl%3Den_US&passive=true">Login with your Google account</a> + <a href="#" onClick="window.open('/t/help_gaia','login_help','width=580,height=480,resizable=yes,scrollbars=yes,status=0').focus();" rel="nofollow"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" border="0" class="alignMid gaiaHelpBtn" alt=""></a> + </div> + </div> + </div> + + <div id="localePickerBox"> + <div id="flagDiv"> + <script type="text/javascript"> + var gLocales = [ + ['ru_RU','Россия'] , ['zh_TW','台灣'] , ['ja_JP','日本'] , ['zh_HK','香港'] , ['ko_KR','한국'] , ['en_AU','Australia'] , ['pt_BR','Brasil'] , ['en_CA','Canada'] , ['de_DE','Deutschland'] , ['es_ES','España'] , ['fr_FR','France'] , ['en_US','Global'] , ['en_IN','India'] , ['en_IE','Ireland'] , ['it_IT','Italia'] , ['es_MX','México'] , ['nl_NL','Nederland'] , ['en_NZ','New Zealand'] , ['pl_PL','Polska'] , ['en_GB','United Kingdom'] + ]; + </script> + <div id="flagDivInner"> + </div> + + <div class="alignR smallText"><a href="#" onclick="closeLocalePicker(); return false;">Close</a></div> + </div> + </div> + + + + + + + <div id="util-links" class="normal-utility-links"> + + <span class="util-item first"><b><a href="/signup" onclick="_hbLink('SignUp','UtilityLinks');">Sign Up</a></b></span> + <span class="util-item"><a href="/watch_queue?all">QuickList</a> (<span id="quicklist-utility">0</span>)</span> + <span class="util-item"><a href="http://help.youtube.com/support/youtube/bin/static.py?page=start.cs&hl=en_US">Help</a></span> + <span class="util-item"><a href="#" class="loginBoxZ eLink" onclick="return openLoginBox(event);">Log In</a></span> + <span class="util-item"><a href="#" class="localePickerLink eLink" onclick="loadFlagImgs();toggleDisplay('localePickerBox');return false;">Site:</a></span> + <span class="util-item first"> <a href="#" class="localePickerLink" onclick="loadFlagImgs();toggleDisplay('localePickerBox');return false;"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="currentFlag globalFlag" alt="Site:"></a></span> + </div> + + <form name="logoutForm" method="post" target="_top" action="/index"> + <input type="hidden" name="action_logout" value="1"> + </form> + + + </div> + <div class="nav"> + <div class="nav-item first selected" id="nav-item-home"> + <span class="leftcap"></span> + <a class="content" href="/">Home</a> + <span class="rightcap"></span> + </div> + <div class="nav-item" id="nav-item-videos"> + <div class="nav-tab"> + <span class="leftcap"></span> + <a class="content" href="/browse?s=mp">Videos</a> + <span class="rightcap"></span> + </div> + </div> + <div class="nav-item" id="nav-item-channels"> + <div class="nav-tab"> + <span class="leftcap"></span> + <a class="content" href="/members">Channels</a> + <span class="rightcap"></span> + </div> + </div> + <div class="nav-item" id="nav-item-community"> + <div class="nav-tab"> + <span class="leftcap"></span> + <a class="content" href="/community">Community</a> + <span class="rightcap"></span> + </div> + </div> + </div> + + <form autocomplete="off" action="/results" method="get" name="searchForm" onsubmit="return submitRegularSearchRequest()"> + + <div class="bar"> + <span class="leftcap"></span> + <div class="search-bar"> + <a href="/my_videos_upload" id="upload-button" class="action-button"> + <span class="action-button-leftcap"></span> + <span class="action-button-text">Upload</span> + <span class="action-button-rightcap"></span> + </a> + <div id="search-form"> + <input id="search-term" name="search_query" type="text" tabindex="1" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" value="" maxlength="128" /> + <select class="search-type" name="search_type"> + <option value="">Videos</option> + <option value="search_users" >Channels</option> + </select> + <input id="search-button" type="submit" value="Search" /> + </div> + <div class="search-settings-link"> + <a href="#" class="eLink" onClick="return toggleAdvSearch('', '', '', '', '', '')"> + advanced + </a></div> + </div> + <span class="rightcap"></span> + </div> + + </form> + + <div id="search-advanced-form" class="hid"> + <div class="search-setting-inner alignC">Loading...</div> + </div> + + <div class="clear"></div> + </div> + <div id="search-settings-clr" class="hid"></div> + + + + + + +<div id="homepage-main-content"> + <div> + <div id="active_sharing_div" name="active_sharing_div" style="display:block"></div> + <script type="text/javascript"> + // <![CDATA[ + var fo = new SWFObject("active_sharing.swf", "active_sharing", "550", "115", 7, "#FFFFFF"); + var showstr = "Videos being watched right now..."; + fo.addParam('wmode', 'opaque'); + fo.addVariable("t", showstr); + fo.write("active_sharing_div"); + // ]]> + </script> +</div> + + <div class="homepage-content-block" style="margin-left:18px; border:0px #CCC solid;"> + <div class="homepage-block-heading homepage-block-heading-gray">Promoted Videos</div> + <div> + <div class="homepage-sponsored-video marB0"> + <div class="videoIconWrapperOuter"> + <div class="videoIconWrapperInner"> + <div class="vstill"><a href="/cthru?key=YSqt3w6VDhuNgxUzVZsryt0JX30ll7tCIrBT--_pvAtRC3KmvsBYFaUNR1qT0d0BnBJYjHz_G7LIr21ufG7W6gJL7zPdHNbcmuIxaafL1yry8cdcqeEOTitWLXkpm2q2QnTAlp4chC1jus7JLVCnCdacl0xUeDk4Vk8e6q9htmGbDZPN9QMnHsrX2RZnvDMx-3Im14C3GKi4jI8ee-jnOQ==" name="&lid=DV+-+BasiaBulatInTheNight+-+beggars&lpos=hp-s0"><img src="http://i.ytimg.com/vi/CebHAvPHyyU/default.jpg" class="vimg120"></a></div> + </div> + </div> + + <div class="vtitle smallText"> + <a href="/cthru?key=YSqt3w6VDhuNgxUzVZsryt0JX30ll7tCIrBT--_pvAtRC3KmvsBYFaUNR1qT0d0BnBJYjHz_G7LIr21ufG7W6gJL7zPdHNbcmuIxaafL1yry8cdcqeEOTitWLXkpm2q2QnTAlp4chC1jus7JLVCnCdacl0xUeDk4Vk8e6q9htmGbDZPN9QMnHsrX2RZnvDMx-3Im14C3GKi4jI8ee-jnOQ==" name="&lid=DV+-+BasiaBulatInTheNight+-+beggars&lpos=hp-s0">Basia Bulat - In Th...</a> + </div> + <div class="vfacets" style="margin-bottom: 0px;"> + <a href="/user/beggars" class="dg">beggars</a> + </div> + </div> + <div class="homepage-sponsored-video marB0"> + <div class="videoIconWrapperOuter"> + <div class="videoIconWrapperInner"> + <div class="vstill"><a href="/cthru?key=FIUXMxdvOKhDw2_wpR7bE9L-XUsHMZBHRpS_s21B0Kq0RTWlGXSqQ8bjw6tBQOUczUtO8b6_mktukdd5ChseYAl10dE5JQrlpiOQE6HNMOAsszaA0M9qhzFnOkWPrkFGMDW5vvaAOkIwas6ksi4e_R8wkiIhlNYPDiqi2f4LpVzB2jpe0LobjIEF9czWjFx9ymrPg8wx2x6w00jF-BzRfQ==" name="&lid=DV+-+Perfection+-+corporalcadet&lpos=hp-s1"><img src="http://i.ytimg.com/vi/Np4bhsmr3iE/default.jpg" class="vimg120"></a></div> + </div> + </div> + + <div class="vtitle smallText"> + <a href="/cthru?key=FIUXMxdvOKhDw2_wpR7bE9L-XUsHMZBHRpS_s21B0Kq0RTWlGXSqQ8bjw6tBQOUczUtO8b6_mktukdd5ChseYAl10dE5JQrlpiOQE6HNMOAsszaA0M9qhzFnOkWPrkFGMDW5vvaAOkIwas6ksi4e_R8wkiIhlNYPDiqi2f4LpVzB2jpe0LobjIEF9czWjFx9ymrPg8wx2x6w00jF-BzRfQ==" name="&lid=DV+-+Perfection+-+corporalcadet&lpos=hp-s1">Perfection</a> + </div> + <div class="vfacets" style="margin-bottom: 0px;"> + <a href="/user/corporalcadet" class="dg">corporalcadet</a> + </div> + </div> + <div class="homepage-sponsored-video marB0"> + <div class="videoIconWrapperOuter"> + <div class="videoIconWrapperInner"> + <div class="vstill"><a href="/cthru?key=1W2J508g9g7Bjsvodsvq3GHZo25JkqX7Js5JSHnyP1yZYB96KDh2LTC2pCKjeHc7LEiTUU4uhuwsrTzZfns_IR2dsA7leCUYMtvgq3noBHy-G0jTHmgiQtFUVTDU3jT2EkS39J6Ur2qxtHwAmybMcU83hK1guqpPdryKOfcbHovo-Kbwglzbbl28LrK1iNdz5E6NZ5CZCVZrYxldbWyjEA==" name="&lid=DV+-+WhatmatterstoyoumeVFS+-+Jr0canest&lpos=hp-s2"><img src="http://i.ytimg.com/vi/KExoP97KUnY/default.jpg" class="vimg120"></a></div> + </div> + </div> + + <div class="vtitle smallText"> + <a href="/cthru?key=1W2J508g9g7Bjsvodsvq3GHZo25JkqX7Js5JSHnyP1yZYB96KDh2LTC2pCKjeHc7LEiTUU4uhuwsrTzZfns_IR2dsA7leCUYMtvgq3noBHy-G0jTHmgiQtFUVTDU3jT2EkS39J6Ur2qxtHwAmybMcU83hK1guqpPdryKOfcbHovo-Kbwglzbbl28LrK1iNdz5E6NZ5CZCVZrYxldbWyjEA==" name="&lid=DV+-+WhatmatterstoyoumeVFS+-+Jr0canest&lpos=hp-s2">What matters to you...</a> + </div> + <div class="vfacets" style="margin-bottom: 0px;"> + <a href="/user/Jr0canest" class="dg">Jr0canest</a> + </div> + </div> + <div class="homepage-sponsored-video marB0"> + <div class="videoIconWrapperOuter"> + <div class="videoIconWrapperInner"> + <div class="vstill"><a href="/cthru?key=idL1slcMKbuzX2MFZaS-nifq5PWrCKLUZMXEPqCthRVET6PQSkxlmKQVMNmQvlYpQlFISkRprfO113rH-ER0ytYh0zSMWI4XbaO74zcrIZiSpB3oISku9zIGUwS5WI03Y0ZiHbGAC9GIYziEcRcgzcEYuizlUwNvTWDgNSvrCJHcyPYokMUjLjcwqD2wEEAe7jfIfcJRNl3sW7ODuiN_MA==" name="&lid=DV+-+LIfeisaMasquerade+-+bananaruthy&lpos=hp-s3"><img src="http://i.ytimg.com/vi/l9gjk5hHiGM/default.jpg" class="vimg120"></a></div> + </div> + </div> + + <div class="vtitle smallText"> + <a href="/cthru?key=idL1slcMKbuzX2MFZaS-nifq5PWrCKLUZMXEPqCthRVET6PQSkxlmKQVMNmQvlYpQlFISkRprfO113rH-ER0ytYh0zSMWI4XbaO74zcrIZiSpB3oISku9zIGUwS5WI03Y0ZiHbGAC9GIYziEcRcgzcEYuizlUwNvTWDgNSvrCJHcyPYokMUjLjcwqD2wEEAe7jfIfcJRNl3sW7ODuiN_MA==" name="&lid=DV+-+LIfeisaMasquerade+-+bananaruthy&lpos=hp-s3">LIfe is a Masquerade.</a> + </div> + <div class="vfacets" style="margin-bottom: 0px;"> + <a href="/user/bananaruthy" class="dg">bananaruthy</a> + </div> + </div> + <div class="clearL" style="height: 1px;"></div> + </div> + </div> + + + <div id="homepage-featured-heading"> + <div id="homepage-featured-more-top"><a id="hpVideoListMoreLink" href="/browse?s=rf">See More Featured Videos</a></div> + <h1 id="hpVideoListHead">Featured Videos</h1> + </div> + + <div id="homepage-featured-tabs"> + <a href="#" id="hpTopFavoritesLink" name="&lid=hpTopFavoritesTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Top Favorites</a> + <a href="#" id="hpMostDiscussedLink" name="&lid=hpMostDiscussedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Most Discussed</a> + <a href="#" id="hpMostViewedLink" name="&lid=hpMostViewedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;">Most Viewed</a> + <a href="#" id="hpFeaturedLink" name="&lid=hpFeaturedTab&lpos=hpTabs" onclick="swapVideoList(this); return false;" class="first hilite">Featured</a> + <div class="clear"></div> + </div> + + + + <div id="homepage-video-list" class="browseListView"> + <div id="hpFeatured"> + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=uu-NTSZ27b0"><img src="http://i.ytimg.com/vi/uu-NTSZ27b0/default.jpg" class="vimg120" title="Caribbean PVC Marimba Children's Orchestra" qliconalt="uu-NTSZ27b0" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=uu-NTSZ27b0" title="Caribbean PVC Marimba Children's Orchestra" onclick="_hbLink('CaribbeanPVCMarimbaChildrensOrchestra','VidVert');">Caribbean PVC Marimba Children's...</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=uu-NTSZ27b0" title="Caribbean PVC Marimba Children's Orchestra" onclick="_hbLink('CaribbeanPVCMarimbaChildrensOrchestra','VidVert');">Caribbean PVC Marimba Children's Orchestra</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescuuNTSZ27b0"> + Michael Greiner who is a neighbor and good friend of mine asked me to upload several Marim + </span> + + <span id="RemainvidDescuuNTSZ27b0" style="display: none">Michael Greiner who is a neighbor and good friend of mine asked me to upload several Marimba videos for him (that's him on the left in the middle row). He currently teaches the music program at Aveson Charter School http://aveson.org/ and constructs musical instruments in classes with students' participation.<br/><br/>Michael Greiner created this set of plastic pipe marimbas. On this clip are three generations of prototypes designed to be low cost for use by childrens' programming. The top one bass version costs around $200 in materials. The mallets are home made using foam flip-flops mounted to sticks. Filmed at Norma Coombs primary school in Altadena CA in 2007.<br/><br/>*** Edited to Add ****<br/>Wow, it looks like this video's hit YouTube's front page. Thank you for all the wonderfully kind and supportive comments!</span> + <span id="MorevidDescuuNTSZ27b0" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescuuNTSZ27b0'); hideDiv('MorevidDescuuNTSZ27b0'); hideDiv('BeginvidDescuuNTSZ27b0'); showDiv('LessvidDescuuNTSZ27b0'); return false;">more</a>)</span> + <span id="LessvidDescuuNTSZ27b0" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescuuNTSZ27b0'); hideDiv('LessvidDescuuNTSZ27b0'); showDiv('BeginvidDescuuNTSZ27b0'); showDiv('MorevidDescuuNTSZ27b0'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/PlayHanghang">PlayHanghang</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 3,853<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-5.0" alt="4.84814814815" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">01:46</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=24">Entertainment</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=CFJRn7akXeQ"><img src="http://i.ytimg.com/vi/CFJRn7akXeQ/default.jpg" class="vimg120" title=""Sharp Teeth" Excerpt #1" qliconalt="CFJRn7akXeQ" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=CFJRn7akXeQ" title=""Sharp Teeth" Excerpt #1" onclick="_hbLink('SharpTeethExcerpt1','VidVert');">"Sharp Teeth" Excerpt #1</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=CFJRn7akXeQ" title=""Sharp Teeth" Excerpt #1" onclick="_hbLink('SharpTeethExcerpt1','VidVert');">"Sharp Teeth" Excerpt #1</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescCFJRn7akXeQ"> + Check out the book "Sharp Teeth" on Amazon:<br/>http://www.amazon.com/Sharp-Teeth-Toby-Barlow + </span> + + <span id="RemainvidDescCFJRn7akXeQ" style="display: none">Check out the book "Sharp Teeth" on Amazon:<br/>http://www.amazon.com/Sharp-Teeth-Toby-Barlow/dp/0061430226/ ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1212767529&sr=8-1<br/><br/>Animation directed by Limbert Fabian. Produced by Matt Thunell. For more information go to sharpteeththebook.com</span> + <span id="MorevidDescCFJRn7akXeQ" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescCFJRn7akXeQ'); hideDiv('MorevidDescCFJRn7akXeQ'); hideDiv('BeginvidDescCFJRn7akXeQ'); showDiv('LessvidDescCFJRn7akXeQ'); return false;">more</a>)</span> + <span id="LessvidDescCFJRn7akXeQ" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescCFJRn7akXeQ'); hideDiv('LessvidDescCFJRn7akXeQ'); showDiv('BeginvidDescCFJRn7akXeQ'); showDiv('MorevidDescCFJRn7akXeQ'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/tobybarlowny">tobybarlowny</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 67,438<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.39928057554" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">01:33</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=1">Film & Animation</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=sNROaXA6OSI"><img src="http://i.ytimg.com/vi/sNROaXA6OSI/default.jpg" class="vimg120" title="Touring to Alaska on Vegetable Oil!" qliconalt="sNROaXA6OSI" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=sNROaXA6OSI" title="Touring to Alaska on Vegetable Oil!" onclick="_hbLink('TouringtoAlaskaonVegetableOil','VidVert');">Touring to Alaska on Vegetable Oil!</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=sNROaXA6OSI" title="Touring to Alaska on Vegetable Oil!" onclick="_hbLink('TouringtoAlaskaonVegetableOil','VidVert');">Touring to Alaska on Vegetable Oil!</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescsNROaXA6OSI"> + This video is for Mrs. Aderman's 1st Period Environmental Science Class.<br/><br/>We are Mose Gi + </span> + + <span id="RemainvidDescsNROaXA6OSI" style="display: none">This video is for Mrs. Aderman's 1st Period Environmental Science Class.<br/><br/>We are Mose Giganticus and The Emotron and this year we are touring to Alaska on Vegetable Oil.</span> + <span id="MorevidDescsNROaXA6OSI" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescsNROaXA6OSI'); hideDiv('MorevidDescsNROaXA6OSI'); hideDiv('BeginvidDescsNROaXA6OSI'); showDiv('LessvidDescsNROaXA6OSI'); return false;">more</a>)</span> + <span id="LessvidDescsNROaXA6OSI" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescsNROaXA6OSI'); hideDiv('LessvidDescsNROaXA6OSI'); showDiv('BeginvidDescsNROaXA6OSI'); showDiv('MorevidDescsNROaXA6OSI'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/kylemotron">kylemotron</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 122,748<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.44329896907" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">04:02</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=27">Education</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=6iC3b5JnSIE"><img src="http://i.ytimg.com/vi/6iC3b5JnSIE/default.jpg" class="vimg120" title="JCJC" qliconalt="6iC3b5JnSIE" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=6iC3b5JnSIE" title="JCJC" onclick="_hbLink('JCJC','VidVert');">JCJC</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=6iC3b5JnSIE" title="JCJC" onclick="_hbLink('JCJC','VidVert');">JCJC</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDesc6iC3b5JnSIE"> + His name is Okotanpe. <br/>His mail addless is fuseloopa@hotmail.com <br/><br/>The name of this son + </span> + + <span id="RemainvidDesc6iC3b5JnSIE" style="display: none">His name is Okotanpe. <br/>His mail addless is fuseloopa@hotmail.com <br/><br/>The name of this song is 300ml(milk).<br/>An artist name is Rei harakami. <br/>Check it out!</span> + <span id="MorevidDesc6iC3b5JnSIE" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesc6iC3b5JnSIE'); hideDiv('MorevidDesc6iC3b5JnSIE'); hideDiv('BeginvidDesc6iC3b5JnSIE'); showDiv('LessvidDesc6iC3b5JnSIE'); return false;">more</a>)</span> + <span id="LessvidDesc6iC3b5JnSIE" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesc6iC3b5JnSIE'); hideDiv('LessvidDesc6iC3b5JnSIE'); showDiv('BeginvidDesc6iC3b5JnSIE'); showDiv('MorevidDesc6iC3b5JnSIE'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/YoneyaYu">YoneyaYu</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 532,447<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-5.0" alt="4.83995523223" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">05:26</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=24">Entertainment</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=L9Wu1V1JAHw"><img src="http://i.ytimg.com/vi/L9Wu1V1JAHw/default.jpg" class="vimg120" title="Certainty In Freedom ~ A Song for Burma (Original Song)" qliconalt="L9Wu1V1JAHw" partner="true" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=L9Wu1V1JAHw" title="Certainty In Freedom ~ A Song for Burma (Original Song)" onclick="_hbLink('CertaintyInFreedomASongforBurmaOriginalSong','VidVert');">Certainty In Freedom ~ A Song fo...</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=L9Wu1V1JAHw" title="Certainty In Freedom ~ A Song for Burma (Original Song)" onclick="_hbLink('CertaintyInFreedomASongforBurmaOriginalSong','VidVert');">Certainty In Freedom ~ A Song for Burma (Original Song)</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescL9Wu1V1JAHw"> + I'm not a particularly political person, by which I mean I'd sooner just not get involved + </span> + + <span id="RemainvidDescL9Wu1V1JAHw" style="display: none">I'm not a particularly political person, by which I mean I'd sooner just not get involved in conflict, but I realise that, at times, things happen outside your control which will you to say something or do something.<br/><br/>I got a comment on my last song from 'gersing' asking me if I'd sing a song for the monks and people of Burma. At first I misunderstood the comment but then it clicked and I felt compelled to offer something.. anything. <br/><br/>I know this song is going to change nothing; and I'm cautious calling it a protest song as I don't understand the situation fully (and I wouldn't want to upset anyone), but this is a tune I wrote in response to being repressed (I'm whatever guise) and how beautiful 'freedom' really is. I don't think anyone will ever understand that term fully but by singing and writing and thinking and speaking we can come somewhere close I'm sure. <br/><br/>As a disclaimer, I'd say that, personally, the chords and melody are arbitrary; merely the carrier of the sentiment...<br/><br/>Changing the subject ever so slightly I just wanted to say a big thank you to everyone that's shown support; it's overwhelming. An apology to anyone I've not yet responded to.. I've never been very good at juggling my time but I will be in touch.<br/><br/>Thanks again...<br/><br/>_________________<br/>Certainty In Freedom<br/><br/>If I had the will to talk<br/>I wonder if you'd give a thought <br/>To what I had to say - help make it go away<br/><br/>Cos there's certainty in freedom<br/>And in that we must believe in<br/>Cos I saw on the news today<br/><br/>If I saw you in the street now<br/>Would I look the other way?<br/>I hope I'm strong enough to say - help make it go away<br/><br/>When all you see is hatred<br/>Spirits crushed and souls deflated<br/>Easy to leave it for another day<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>So this, my only voice to speak<br/>My message strong, my tone is weak<br/>I find it hard to say - help make it go away<br/><br/>And if I come across obtuse<br/>I urge you now to cut the noose<br/>Don't leave it for another day<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>If I had the will to talk<br/>I wonder if you'd give a thought <br/>To what I had to say - help make it go away<br/><br/>Cos there's certainty in freedom<br/>And in that we must believe in<br/>Cos I saw on the news today<br/><br/>Peace is pushing for love<br/>Love is leading the way<br/>You should follow its path<br/>Darkness leads you astray<br/>Peace is pushing for love<br/>Love is leading the way<br/><br/>_____________________<br/>Peace<br/><br/>Available on the 'Unequal Measures', available through http://www.krisrowley.com<br/>© Kris Rowley 2007</span> + <span id="MorevidDescL9Wu1V1JAHw" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescL9Wu1V1JAHw'); hideDiv('MorevidDescL9Wu1V1JAHw'); hideDiv('BeginvidDescL9Wu1V1JAHw'); showDiv('LessvidDescL9Wu1V1JAHw'); return false;">more</a>)</span> + <span id="LessvidDescL9Wu1V1JAHw" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescL9Wu1V1JAHw'); hideDiv('LessvidDescL9Wu1V1JAHw'); showDiv('BeginvidDescL9Wu1V1JAHw'); showDiv('MorevidDescL9Wu1V1JAHw'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/zzzzzzzzap">zzzzzzzzap</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 136,222<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.65044814341" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">03:55</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=10">Music</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=gQNY7Sti8FY"><img src="http://s4.ytimg.com/vi/gQNY7Sti8FY/default.jpg" class="vimg120" title="the world is at your fingertips" qliconalt="gQNY7Sti8FY" partner="true" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=gQNY7Sti8FY" title="the world is at your fingertips" onclick="_hbLink('theworldisatyourfingertips','VidVert');">the world is at your fingertips</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=gQNY7Sti8FY" title="the world is at your fingertips" onclick="_hbLink('theworldisatyourfingertips','VidVert');">the world is at your fingertips</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescgQNY7Sti8FY"> + for the taking. + </span> + + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/SupaDupaFlyGirl">SupaDupaFlyGirl</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 509,825<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.0" alt="3.91057134971" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">05:15</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=28">Science & Technology</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=rGUt7ropzNA"><img src="http://i.ytimg.com/vi/rGUt7ropzNA/default.jpg" class="vimg120" title="Aimee Mann Freeway Video Contest" qliconalt="rGUt7ropzNA" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=rGUt7ropzNA" title="Aimee Mann Freeway Video Contest" onclick="_hbLink('AimeeMannFreewayVideoContest','VidVert');">Aimee Mann Freeway Video Contest</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=rGUt7ropzNA" title="Aimee Mann Freeway Video Contest" onclick="_hbLink('AimeeMannFreewayVideoContest','VidVert');">Aimee Mann Freeway Video Contest</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescrGUt7ropzNA"> + Want a chance to sing with Aimee Mann live? Go to http://www.youtube.com/group/aimeemannco + </span> + + <span id="RemainvidDescrGUt7ropzNA" style="display: none">Want a chance to sing with Aimee Mann live? Go to http://www.youtube.com/group/aimeemanncontest and upload a video of yourself singing Aimee Mann's new song "Freeway."<br/><br/>Aimee Mann and SuperEgo Records will pick their favorite entry to be featured on YouTube and www.aimeemann.com. The winner will have an opportunity to sing live with Aimee at one of her upcoming shows. Ten runners-up will receive an autographed copy of Aimee's new CD, @#%&*! Smilers.<br/><br/>Entrants can get the lyrics, the instrumental version of "Freeway" and contest details at: http://www.aimeemann.com/freewaycontest/<br/>Submissions must be received by July 7th 2008</span> + <span id="MorevidDescrGUt7ropzNA" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescrGUt7ropzNA'); hideDiv('MorevidDescrGUt7ropzNA'); hideDiv('BeginvidDescrGUt7ropzNA'); showDiv('LessvidDescrGUt7ropzNA'); return false;">more</a>)</span> + <span id="LessvidDescrGUt7ropzNA" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescrGUt7ropzNA'); hideDiv('LessvidDescrGUt7ropzNA'); showDiv('BeginvidDescrGUt7ropzNA'); showDiv('MorevidDescrGUt7ropzNA'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/aimeemann">aimeemann</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 283,776<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.0" alt="3.79036827195" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">02:22</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=10">Music</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=tbEei0I3kMQ"><img src="http://i.ytimg.com/vi/tbEei0I3kMQ/default.jpg" class="vimg120" title="Interactive card trick" qliconalt="tbEei0I3kMQ" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=tbEei0I3kMQ" title="Interactive card trick" onclick="_hbLink('Interactivecardtrick','VidVert');">Interactive card trick</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=tbEei0I3kMQ" title="Interactive card trick" onclick="_hbLink('Interactivecardtrick','VidVert');">Interactive card trick</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDesctbEei0I3kMQ"> + This is the first interactive video on YouTube!<br/>Have fun and enjoy the show<br/>you can see + </span> + + <span id="RemainvidDesctbEei0I3kMQ" style="display: none">This is the first interactive video on YouTube!<br/>Have fun and enjoy the show<br/>you can see our magician site:<br/>orenshalom.co.il</span> + <span id="MorevidDesctbEei0I3kMQ" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesctbEei0I3kMQ'); hideDiv('MorevidDesctbEei0I3kMQ'); hideDiv('BeginvidDesctbEei0I3kMQ'); showDiv('LessvidDesctbEei0I3kMQ'); return false;">more</a>)</span> + <span id="LessvidDesctbEei0I3kMQ" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesctbEei0I3kMQ'); hideDiv('LessvidDesctbEei0I3kMQ'); showDiv('BeginvidDesctbEei0I3kMQ'); showDiv('MorevidDesctbEei0I3kMQ'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/werneroi">werneroi</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 3,155,063<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-3.5" alt="3.41263230956" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">01:10</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=22">People & Blogs</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=irDEzQovftM"><img src="http://i.ytimg.com/vi/irDEzQovftM/default.jpg" class="vimg120" title="Biggest drawing in the world" qliconalt="irDEzQovftM" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=irDEzQovftM" title="Biggest drawing in the world" onclick="_hbLink('Biggestdrawingintheworld','VidVert');">Biggest drawing in the world</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=irDEzQovftM" title="Biggest drawing in the world" onclick="_hbLink('Biggestdrawingintheworld','VidVert');">Biggest drawing in the world</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescirDEzQovftM"> + making the biggest drawing in the world + </span> + + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/erikbjgn">erikbjgn</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 971,773<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.54770783066" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">04:04</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=1">Film & Animation</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=iAKJKBCyPUY"><img src="http://i.ytimg.com/vi/iAKJKBCyPUY/default.jpg" class="vimg120" title="Checkmate" qliconalt="iAKJKBCyPUY" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=iAKJKBCyPUY" title="Checkmate" onclick="_hbLink('Checkmate','VidVert');">Checkmate</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=iAKJKBCyPUY" title="Checkmate" onclick="_hbLink('Checkmate','VidVert');">Checkmate</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDesciAKJKBCyPUY"> + The Internets Celebrities Dallas Penn and Rafi Kam go in for an investigative report on Ch + </span> + + <span id="RemainvidDesciAKJKBCyPUY" style="display: none">The Internets Celebrities Dallas Penn and Rafi Kam go in for an investigative report on Check-Cashing. Themes explored include usury, economic instability, commercial banks and their profit line, and the cycle of poverty. <br/><br/>Oh yeah, it's a comedy.<br/><br/>The video is shot on location in Bushwick and Carroll Gardens in Brooklyn, New York. Also stars special guest Internets Celebrity Ben Popken of Consumerist.com.<br/><br/>Directed by Casimir Nozkowski<br/>Shot by Ian Savage, Josh Weisbrot<br/>Music by El Keter; instrumental from song "The Bottom Line" off Sankofa's album The Tortoise Hustle. Used with full permission.<br/><br/>http://www.internetscelebrities.com</span> + <span id="MorevidDesciAKJKBCyPUY" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDesciAKJKBCyPUY'); hideDiv('MorevidDesciAKJKBCyPUY'); hideDiv('BeginvidDesciAKJKBCyPUY'); showDiv('LessvidDesciAKJKBCyPUY'); return false;">more</a>)</span> + <span id="LessvidDesciAKJKBCyPUY" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDesciAKJKBCyPUY'); hideDiv('LessvidDesciAKJKBCyPUY'); showDiv('BeginvidDesciAKJKBCyPUY'); showDiv('MorevidDesciAKJKBCyPUY'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/InternetsCelebrities">InternetsCel...</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 412,830<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.52936962751" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">09:45</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=yLCl0xIg5-0"><img src="http://i.ytimg.com/vi/yLCl0xIg5-0/default.jpg" class="vimg120" title="Stories from the Front lines, Part 1" qliconalt="yLCl0xIg5-0" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=yLCl0xIg5-0" title="Stories from the Front lines, Part 1" onclick="_hbLink('StoriesfromtheFrontlinesPart1','VidVert');">Stories from the Front lines, Pa...</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=yLCl0xIg5-0" title="Stories from the Front lines, Part 1" onclick="_hbLink('StoriesfromtheFrontlinesPart1','VidVert');">Stories from the Front lines, Part 1</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescyLCl0xIg50"> + Stories from the men and women of the miltary, stationed in the Al Anbar Province. Right f + </span> + + <span id="RemainvidDescyLCl0xIg50" style="display: none">Stories from the men and women of the miltary, stationed in the Al Anbar Province. Right from the mouths of the troops themselves. Part 1 of 4</span> + <span id="MorevidDescyLCl0xIg50" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescyLCl0xIg50'); hideDiv('MorevidDescyLCl0xIg50'); hideDiv('BeginvidDescyLCl0xIg50'); showDiv('LessvidDescyLCl0xIg50'); return false;">more</a>)</span> + <span id="LessvidDescyLCl0xIg50" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescyLCl0xIg50'); hideDiv('LessvidDescyLCl0xIg50'); showDiv('BeginvidDescyLCl0xIg50'); showDiv('MorevidDescyLCl0xIg50'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/3rdID8487">3rdID8487</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 367,189<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.0" alt="4.2188365651" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">10:35</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + + + + + <div class="vlentry" > + + <div class="vlcontainer"><div class="v120WideEntry"><div class="v120WrapperOuter"><div class="v120WrapperInner"><a href="/watch?v=rFItE14EeSU"><img src="http://i.ytimg.com/vi/rFItE14EeSU/default.jpg" class="vimg120" title="Amazing video of multiple tornadoes in Northwest Kansas" qliconalt="rFItE14EeSU" partner="true" alt="video"></a></div></div> </div> + + <div class="vldescbox"> + <div class="vltitle"> + <div class="vlshortTitle"> + <a href="/watch?v=rFItE14EeSU" title="Amazing video of multiple tornadoes in Northwest Kansas" onclick="_hbLink('AmazingvideoofmultipletornadoesinNorthwestKansas','VidVert');">Amazing video of multiple tornad...</a> + </div> + <div class="vllongTitle"> + <a href="/watch?v=rFItE14EeSU" title="Amazing video of multiple tornadoes in Northwest Kansas" onclick="_hbLink('AmazingvideoofmultipletornadoesinNorthwestKansas','VidVert');">Amazing video of multiple tornadoes in Northwest Kansas</a> + </div> + </div> + + <div class="vldesc"> + + + <span id="BeginvidDescrFItE14EeSU"> + Video from TornadoVideos.net Live Stream Unit 3 of several tornadoes from close range.. In + </span> + + <span id="RemainvidDescrFItE14EeSU" style="display: none">Video from TornadoVideos.net Live Stream Unit 3 of several tornadoes from close range.. Including one beautiful but strong rope and a large wedge tornado from within 1/2 mile. Check out TornadoVdeos.net for live streaming video, breaking weather news, and more extreme tornado footage.</span> + <span id="MorevidDescrFItE14EeSU" class="smallText">(<a href="#" class="eLink" onclick="showDiv('RemainvidDescrFItE14EeSU'); hideDiv('MorevidDescrFItE14EeSU'); hideDiv('BeginvidDescrFItE14EeSU'); showDiv('LessvidDescrFItE14EeSU'); return false;">more</a>)</span> + <span id="LessvidDescrFItE14EeSU" style="display: none" class="smallText">(<a href="#" class="eLink" onclick="hideDiv('RemainvidDescrFItE14EeSU'); hideDiv('LessvidDescrFItE14EeSU'); showDiv('BeginvidDescrFItE14EeSU'); showDiv('MorevidDescrFItE14EeSU'); return false;">less</a>)</span> + + + + </div> + </div> + + <div class="vlclearaltl"></div> + + + </div> + + <div class="vlfacets"> + <div class="vladded"> + </div> + <div><span class="grayText vlfromlbl">From:</span><span class="vlfrom"><a href="/user/TornadoVideosdotnet">TornadoVideo...</a></span></div> + <div class="clearL"></div> + <span class="grayText">Views:</span> 797,370<br/> + + <div class="video-thumb-duration-rating"> + + + <div> + + <img class="ratingVS ratingVS-4.5" alt="4.28912552436" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> + + + + </div> + + + + <div class="runtime">07:10</div> + </div> + + <div class="clear"></div> + <div class="vlcategory"> + <span class="smgrayText">More in</span> <a href="/results?search_query=None&search_category=25">News & Politics</a> + </div> + </div> + + <div class="vlclearaltl"></div> + + + + </div> <!-- end vEntry --> + + + </div> + </div> <!-- end Video List --> + <div id="homepage-featured-more-bottom"> + <div class="floatR"><a href="/browse?s=rf">See More Featured Videos</a></div> + <div class="clear"></div> + </div> +</div> + + +<div id="homepage-side-content" style="white-space: normal;"> + <div> + + + + + <!-- Begin ad tag --> + + <input type="hidden" id="pvaHl" value="en"/> + <input type="hidden" id="pvaTag" value="http://n4061ad.doubleclick.net/adj/com.ythome/_default;sz=399x299;kl=N;kga=-1;kgg=-1;tile=1;dcopt=ist;"/> + <input type="hidden" id="burl" value="http://www.youtube.com/pva/"/> + <input type="hidden" id="canv" value="False"/> + <div id="myAd_banner" style="visibility:hidden;height:35px;"></div> + <div id="myAd_pva"> + + + + + <script type="text/javascript"> + ord=Math.random()*10000000000000000 + 3; + if (false) { + ord = 1234567890; + } + document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/_default;sz=399x299;kl=N;kga=-1;kgg=-1;tile=1;dcopt=ist;ord=' + ord + '?" type="text/javascript"><\/script>'); + </script> + <noscript><a + href="http://n4061ad.doubleclick.net/jump/_default;sz=399x299;ord=123456789?" target="_blank"><img + src="http://n4061ad.doubleclick.net/ad/_default;sz=399x299;ord=123456789?" width="399" height="299" border="0" alt=""></a> + </noscript> + + </div> + + + <!-- End ad tag --> + + </div> + + <div class="homepage-content-block"> + <div class="contentBox"> + <div> + <div class="floatR"><span class="smallText"><b><a href="/signup">Sign Up</a> | <a href="http://help.youtube.com/support/youtube/bin/topic.py?topic=10546&hl=en_US">Help</a></b></div> + <div class="floatL"> + <span class="headerTitle homepage-block-heading-gray"> Login </span> + </div> + <div class="clear"></div> + </div> + + <form method="post" name="loginForm" id="loginForm" action="signup"> + <input type="hidden" name="action_login" value="1"> + <table width="270"> + <tr> + <td align="right"><label for="homeUsername"><span class="smallText"><b>Username:</b></span></label></td> + <td align="left"><input id="homeUsername" tabindex="101" class="smallText" type="text" size="16" name="username" value=""></td> + </tr> + <tr> + <td align="right"><label for="homePassword"><span class="smallText"><b>Password:</b></span></label></td> + <td align="left"><input id="homePassword" tabindex="102" class="smallText" type="password" size="16" name="password"> + </tr> + <tr> + <td></td> + <td align="left"> + <span><input type="submit" class="smallText" value="Login"></span> + </td> + </tr> + </table> + </form> + <div class="padT10 smallText"> + <p align="center" class="marT0 marB0"><a href="/forgot_username?next=/">Forgot Username</a> | <a href="/forgot?next=/">Forgot Password</a></p> + </div> + <div class="homepage-border-dotted"></div> + <div class="alignC"><span class="smallText"><b><a href=" +https://www.google.com/accounts/ServiceLogin?service=youtube&hl=en_US&continue=http%3A//www.youtube.com/signup%3Fhl%3Den_US&passive=true">Login with your Google account</a> <a href="#" onClick="window.open('/t/help_gaia','login_help','width=580,height=480,resizable=yes,scrollbars=yes,status=0').focus();" rel="nofollow"><img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" border="0" class="alignMid gaiaHelpBtn" alt=""></a></b></span></div> + </div> + </div> <!-- end homepage-content-block --> + + + <div class="homepage-content-block padT10"> + + + + + <!-- Begin ad tag --> + + + + <script type="text/javascript"> + ord=Math.random()*10000000000000000 + 6; + if (false) { + ord = 1234567890; + } + document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo1;sz=300x50;kl=N;kga=-1;kgg=-1;tile=2;ord=' + ord + '?" type="text/javascript"><\/script>'); + </script> + <noscript><a + href="http://n4061ad.doubleclick.net/jump/promo1;sz=300x50;ord=123456789?" target="_blank"><img + src="http://n4061ad.doubleclick.net/ad/promo1;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a> + </noscript> + + + <!-- End ad tag --> + + </div> + + <div class="homepage-content-block padT10"> + + + + + <!-- Begin ad tag --> + + + + <script type="text/javascript"> + ord=Math.random()*10000000000000000 + 6; + if (false) { + ord = 1234567890; + } + document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo3;sz=300x50;kl=N;kga=-1;kgg=-1;tile=4;ord=' + ord + '?" type="text/javascript"><\/script>'); + </script> + <noscript><a + href="http://n4061ad.doubleclick.net/jump/promo3;sz=300x50;ord=123456789?" target="_blank"><img + src="http://n4061ad.doubleclick.net/ad/promo3;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a> + </noscript> + + + <!-- End ad tag --> + + </div> + + <div class="homepage-side-block padT10"> + <div class="homepage-yellow-block"> + <div class="homepage-block-heading" style="color:#CC6600">What's New</div> + + <div class="homepage-whatsnew-entry"> + <div class="homepage-whatsnew-image"><a href="/t/annotations_about"><img src="http://s.ytimg.com/yt/img/whats_new/annotation-vfl42087.gif" border="0" width="30" height="37"/></a></div> + <div class="homepage-whatsnew-desc"> + <b><a href="/t/annotations_about">Video Annotations</a></b><br/>Add interactive commentary and links to your videos + </div> + </div><div class="clear"></div> + + <div class="homepage-whatsnew-entry"> + <div class="homepage-whatsnew-image"><a href="/address_book"><img src="http://s.ytimg.com/yt/img/whats_new/addybook-vfl39351.gif" border="0" width="30" height="37"/></a></div> + <div class="homepage-whatsnew-desc"> + <b><a href="/address_book">New Address Book</a></b><br/>Organizing your YouTube friends and contacts just got a lot simpler + </div> + </div><div class="clear"></div> + + <div class="homepage-whatsnew-entry"> + <div class="homepage-whatsnew-image"><a href="/inbox"><img src="http://s.ytimg.com/yt/img/whats_new/inbox-vfl39351.gif" border="0" width="30" height="37"/></a></div> + <div class="homepage-whatsnew-desc"> + <b><a href="/inbox">Updated Inbox</a></b><br/>Manage your messages and invites with ease + </div> + </div><div class="clear"></div> + + + <div class="homepage-whatsnew-entry"> + <div class="homepage-whatsnew-image"><a href="/mobile"><img src="http://s.ytimg.com/yt/img/whats_new/pic_home_mobile_30x37-vfl37458.gif" border="0" width="30" height="37"/></a></div> + <div class="homepage-whatsnew-desc"> + <b><a href="/mobile">YouTube Mobile</a></b><br/> Watch and upload YouTube videos on your mobile device. + </div> + </div><div class="clear"></div> + + <div class="bottomBorderDotted"></div> + <b><a href="/blog" style="color:#CC6600">Hear Ye, Hear Ye: Calling all Reporters</a></b><br> + Today we announce the launch of a new type of YouTube account: the Reporter. Reporter channels are just like the other YouTube channel types, but are specifically intended for citizens and profess... + <div class="alignR padT5"> + <a href="/blog" style="color:#CC6600">Read more in our Blog</a> + </div> + <div style="font-size: 1px; height: 1px;"><br/></div> + </div><img class="homepage-yellow-block-bot" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" /> +</div> + + + <div class="homepage-side-block"> + + + + + <!-- Begin ad tag --> + + + + <script type="text/javascript"> + ord=Math.random()*10000000000000000 + 6; + if (false) { + ord = 1234567890; + } + document.write('<script language="JavaScript" src="http://n4061ad.doubleclick.net/adj/com.ythome/promo2;sz=300x50;kl=N;kga=-1;kgg=-1;tile=3;ord=' + ord + '?" type="text/javascript"><\/script>'); + </script> + <noscript><a + href="http://n4061ad.doubleclick.net/jump/promo2;sz=300x50;ord=123456789?" target="_blank"><img + src="http://n4061ad.doubleclick.net/ad/promo2;sz=300x50;ord=123456789?" width="300" height="50" border="0" alt=""></a> + </noscript> + + + <!-- End ad tag --> + + </div> + + +</div> <!-- end homepage-side-content --> + +<div class="clear"></div> + + + + <div class="clear"></div> + <div id="footer"> + <div class="search"> + <div class="promo"> + <a href="/youchoose" onclick="_hbLink('FooterPromo','Footer');"><img id="debates_footer_img" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" alt="footer-promo" /></a> + <a href="/youchoose" onclick="_hbLink('FooterPromo','Footer');">Face The Candidates</a> + </div> + <form autocomplete="off" name="footer-search-form" method="get" action="/results" style="width: 73.5%;"> + <a href="http://www.google.com/webmasters/igoogle/youtube.html"><img id="igoogle_footer_img" src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" alt=""/> <em id="igoogle_footer_text">Add to iGoogle</em></a> + <input type="text" name="search_query" maxlength="128" class="query" onkeyup="goog.i18n.bidi.setDirAttribute(event,this)" value="" id="footer-search-term"> + <select class="search-type" name="search_type"> + <option value="">Videos</option> + <option value="search_users" >Channels</option> + </select> + <input type="submit" name="search" value="Search" class="submit-button"> + </form> + </div> + <div class="links"> + <table cellpadding="0" cellspacing="0"> + <tr> + <th colspan="2">Your Account</th> + <th class="separator" colspan="2">Help & Info</th> + <th class="separator" colspan="2">YouTube</th> + </tr> + <tr> + <td><a href="/my_videos">Videos</a></td> + <td><a href="/inbox">Inbox</a></td> + <td class="separator"><a href="http://help.youtube.com/support/youtube/bin/static.py?page=start.cs&hl=en_US">Help Resources</a></td> + <td><a href="/t/safety">Safety Tips</a></td> + <td class="separator"><a href="/t/about">Company Info</a></td> + <td><a href="/press_room">Press</a></td> + </tr> + <tr> + <td><a href="/my_favorites">Favorites</a></td> + <td><a href="/subscription_center">Subscriptions</a></td> + <td class="separator"><a href="/t/video_toolbox">Video Toolbox</a></td> + <td><a href="/t/dmca_policy">Copyright Notices</a></td> + <td class="separator"><a href="/testtube">TestTube</a></td> + <td><a href="/t/contact_us">Contact</a></td> + </tr> + <tr> + <td><a href="/my_playlists">Playlists</a></td> + <td><a href="/my_account">more...</a></td> + <td class="separator"><a href="/dev">Developer APIs</a></td> + <td><a href="/t/community_guidelines">Community Guidelines</a></td> + <td class="separator"><a href="/t/terms">Terms of Use</a></td> + <td> + <a href="/blog">Blog</a> + </td> + </tr> + <tr> + <td colspan="2"> </td> + <td class="separator"><a href="/advertise">Advertising</a></td> + <td><a href="/youtubeonyoursite">YouTube On Your Site</a></td> + <td class="separator"><a href="/t/privacy">Privacy Policy</a></td> + <td> + <a href="http://www.google.com/jobs/youtube">Jobs</a><br/> + </td> + </tr> + + + + </table> + </div> + </div> + <div id="copyright"> + © 2008 YouTube, LLC + </div> + + +</div> <!-- end baseDiv --> + +</body> +<script type="text/javascript"> + window.setTimeout('window.google.ac.install(document.searchForm,document.searchForm.search_query,"yt",true,"close",true,"Suggestions")',100); +</script> + + + +</html>
\ No newline at end of file diff --git a/examples/xml/rsslisting/main.cpp b/examples/xml/rsslisting/main.cpp index 9888166..7110379 100644 --- a/examples/xml/rsslisting/main.cpp +++ b/examples/xml/rsslisting/main.cpp @@ -58,6 +58,7 @@ Provides the main function for the RSS news reader example. int main(int argc, char **argv) { QApplication app(argc, argv); + qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager."); RSSListing *rsslisting = new RSSListing; rsslisting->show(); return app.exec(); diff --git a/examples/xml/rsslisting/rsslisting.pro b/examples/xml/rsslisting/rsslisting.pro index 95a23e9..e93cad0 100644 --- a/examples/xml/rsslisting/rsslisting.pro +++ b/examples/xml/rsslisting/rsslisting.pro @@ -8,3 +8,5 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS rsslisting.pro sources.path = $$[QT_INSTALL_EXAMPLES]/xml/rsslisting INSTALLS += target sources +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + diff --git a/examples/xml/saxbookmarks/jennifer.xbel b/examples/xml/saxbookmarks/jennifer.xbel index 36256fd..d6a5b41 100644 --- a/examples/xml/saxbookmarks/jennifer.xbel +++ b/examples/xml/saxbookmarks/jennifer.xbel @@ -49,7 +49,7 @@ <title>Qt Quarterly</title> </bookmark> <bookmark href="http://qt.nokia.com/"> - <title>Qt home page</title> + <title>qt home page</title> </bookmark> <bookmark href="http://qt.nokia.com/doc/4.0/"> <title>Qt 4.0 documentation</title> diff --git a/examples/xml/saxbookmarks/main.cpp b/examples/xml/saxbookmarks/main.cpp index a864b2d..dc676e0 100644 --- a/examples/xml/saxbookmarks/main.cpp +++ b/examples/xml/saxbookmarks/main.cpp @@ -47,7 +47,11 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mainWin; +#if defined(Q_OS_SYMBIAN) + mainWin.showFullScreen(); +#else mainWin.show(); +#endif mainWin.open(); return app.exec(); } diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp index ea33a7e..cdc9e72 100644 --- a/examples/xml/saxbookmarks/mainwindow.cpp +++ b/examples/xml/saxbookmarks/mainwindow.cpp @@ -66,6 +66,9 @@ MainWindow::MainWindow() void MainWindow::open() { +#if defined(Q_OS_SYMBIAN) + QDir::setCurrent("/Data/qt/saxbookmarks"); +#endif QString fileName = QFileDialog::getOpenFileName(this, tr("Open Bookmark File"), QDir::currentPath(), @@ -128,15 +131,15 @@ void MainWindow::about() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAsAct = new QAction(tr("&Save As..."), this); - saveAsAct->setShortcut(tr("Ctrl+S")); + saveAsAct->setShortcuts(QKeySequence::SaveAs); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro index d0eec44..16ef184 100644 --- a/examples/xml/saxbookmarks/saxbookmarks.pro +++ b/examples/xml/saxbookmarks/saxbookmarks.pro @@ -18,3 +18,11 @@ wince*: { addFiles.path = \My Documents DEPLOYMENT += addFiles } + +symbian: { + include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) + TARGET.UID3 = 0xA000C60A + addFiles.sources = frank.xbel jennifer.xbel + addFiles.path = /data/qt/saxbookmarks + DEPLOYMENT += addFiles +} diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp index 988f019..f9d05c8 100644 --- a/examples/xml/streambookmarks/mainwindow.cpp +++ b/examples/xml/streambookmarks/mainwindow.cpp @@ -91,10 +91,8 @@ void MainWindow::open() XbelReader reader(treeWidget); if (!reader.read(&file)) { QMessageBox::warning(this, tr("QXmlStream Bookmarks"), - tr("Parse error in file %1 at line %2, column %3:\n%4") + tr("Parse error in file %1:\n\n%2") .arg(fileName) - .arg(reader.lineNumber()) - .arg(reader.columnNumber()) .arg(reader.errorString())); } else { statusBar()->showMessage(tr("File loaded"), 2000); @@ -141,15 +139,15 @@ void MainWindow::about() void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); - openAct->setShortcut(tr("Ctrl+O")); + openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAsAct = new QAction(tr("&Save As..."), this); - saveAsAct->setShortcut(tr("Ctrl+S")); + saveAsAct->setShortcuts(QKeySequence::SaveAs); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); exitAct = new QAction(tr("E&xit"), this); - exitAct->setShortcut(tr("Ctrl+Q")); + exitAct->setShortcuts(QKeySequence::Quit); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); aboutAct = new QAction(tr("&About"), this); diff --git a/examples/xml/streambookmarks/streambookmarks.pro b/examples/xml/streambookmarks/streambookmarks.pro index e66b95a..2b1841f 100644 --- a/examples/xml/streambookmarks/streambookmarks.pro +++ b/examples/xml/streambookmarks/streambookmarks.pro @@ -12,3 +12,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xml/streambookmarks sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS streambookmarks.pro *.xbel sources.path = $$[QT_INSTALL_EXAMPLES]/xml/streambookmarks INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp index 7729cb3..fbe2f96 100644 --- a/examples/xml/streambookmarks/xbelreader.cpp +++ b/examples/xml/streambookmarks/xbelreader.cpp @@ -60,61 +60,43 @@ XbelReader::XbelReader(QTreeWidget *treeWidget) //! [1] bool XbelReader::read(QIODevice *device) { - setDevice(device); + xml.setDevice(device); - while (!atEnd()) { - readNext(); - - if (isStartElement()) { - if (name() == "xbel" && attributes().value("version") == "1.0") - readXBEL(); - else - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); - } + if (xml.readNextStartElement()) { + if (xml.name() == "xbel" && xml.attributes().value("version") == "1.0") + readXBEL(); + else + xml.raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); } - return !error(); + return !xml.error(); } //! [1] //! [2] -void XbelReader::readUnknownElement() +QString XbelReader::errorString() const { - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - readUnknownElement(); - } + return QObject::tr("%1\nLine %2, column %3") + .arg(xml.errorString()) + .arg(xml.lineNumber()) + .arg(xml.columnNumber()); } //! [2] //! [3] void XbelReader::readXBEL() { - Q_ASSERT(isStartElement() && name() == "xbel"); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "folder") - readFolder(0); - else if (name() == "bookmark") - readBookmark(0); - else if (name() == "separator") - readSeparator(0); - else - readUnknownElement(); - } + Q_ASSERT(xml.isStartElement() && xml.name() == "xbel"); + + while (xml.readNextStartElement()) { + if (xml.name() == "folder") + readFolder(0); + else if (xml.name() == "bookmark") + readBookmark(0); + else if (xml.name() == "separator") + readSeparator(0); + else + xml.skipCurrentElement(); } } //! [3] @@ -122,9 +104,9 @@ void XbelReader::readXBEL() //! [4] void XbelReader::readTitle(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "title"); + Q_ASSERT(xml.isStartElement() && xml.name() == "title"); - QString title = readElementText(); + QString title = xml.readElementText(); item->setText(0, title); } //! [4] @@ -132,63 +114,52 @@ void XbelReader::readTitle(QTreeWidgetItem *item) //! [5] void XbelReader::readSeparator(QTreeWidgetItem *item) { + Q_ASSERT(xml.isStartElement() && xml.name() == "separator"); + QTreeWidgetItem *separator = createChildItem(item); separator->setFlags(item->flags() & ~Qt::ItemIsSelectable); separator->setText(0, QString(30, 0xB7)); - readElementText(); + xml.skipCurrentElement(); } //! [5] void XbelReader::readFolder(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "folder"); + Q_ASSERT(xml.isStartElement() && xml.name() == "folder"); QTreeWidgetItem *folder = createChildItem(item); - bool folded = (attributes().value("folded") != "no"); + bool folded = (xml.attributes().value("folded") != "no"); treeWidget->setItemExpanded(folder, !folded); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "title") - readTitle(folder); - else if (name() == "folder") - readFolder(folder); - else if (name() == "bookmark") - readBookmark(folder); - else if (name() == "separator") - readSeparator(folder); - else - readUnknownElement(); - } + while (xml.readNextStartElement()) { + if (xml.name() == "title") + readTitle(folder); + else if (xml.name() == "folder") + readFolder(folder); + else if (xml.name() == "bookmark") + readBookmark(folder); + else if (xml.name() == "separator") + readSeparator(folder); + else + xml.skipCurrentElement(); } } void XbelReader::readBookmark(QTreeWidgetItem *item) { - Q_ASSERT(isStartElement() && name() == "bookmark"); + Q_ASSERT(xml.isStartElement() && xml.name() == "bookmark"); QTreeWidgetItem *bookmark = createChildItem(item); bookmark->setFlags(bookmark->flags() | Qt::ItemIsEditable); bookmark->setIcon(0, bookmarkIcon); bookmark->setText(0, QObject::tr("Unknown title")); - bookmark->setText(1, attributes().value("href").toString()); - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == "title") - readTitle(bookmark); - else - readUnknownElement(); - } + bookmark->setText(1, xml.attributes().value("href").toString()); + + while (xml.readNextStartElement()) { + if (xml.name() == "title") + readTitle(bookmark); + else + xml.skipCurrentElement(); } } @@ -200,6 +171,6 @@ QTreeWidgetItem *XbelReader::createChildItem(QTreeWidgetItem *item) } else { childItem = new QTreeWidgetItem(treeWidget); } - childItem->setData(0, Qt::UserRole, name().toString()); + childItem->setData(0, Qt::UserRole, xml.name().toString()); return childItem; } diff --git a/examples/xml/streambookmarks/xbelreader.h b/examples/xml/streambookmarks/xbelreader.h index 727b57c..d5ca934f 100644 --- a/examples/xml/streambookmarks/xbelreader.h +++ b/examples/xml/streambookmarks/xbelreader.h @@ -51,7 +51,7 @@ class QTreeWidgetItem; QT_END_NAMESPACE //! [0] -class XbelReader : public QXmlStreamReader +class XbelReader { public: //! [1] @@ -60,9 +60,10 @@ public: bool read(QIODevice *device); + QString errorString() const; + private: //! [2] - void readUnknownElement(); void readXBEL(); void readTitle(QTreeWidgetItem *item); void readSeparator(QTreeWidgetItem *item); @@ -71,6 +72,7 @@ private: QTreeWidgetItem *createChildItem(QTreeWidgetItem *item); + QXmlStreamReader xml; QTreeWidget *treeWidget; //! [2] diff --git a/examples/xml/streambookmarks/xbelwriter.cpp b/examples/xml/streambookmarks/xbelwriter.cpp index 3a3c891..a5180ea 100644 --- a/examples/xml/streambookmarks/xbelwriter.cpp +++ b/examples/xml/streambookmarks/xbelwriter.cpp @@ -47,23 +47,23 @@ XbelWriter::XbelWriter(QTreeWidget *treeWidget) : treeWidget(treeWidget) { - setAutoFormatting(true); + xml.setAutoFormatting(true); } //! [0] //! [1] bool XbelWriter::writeFile(QIODevice *device) { - setDevice(device); + xml.setDevice(device); - writeStartDocument(); - writeDTD("<!DOCTYPE xbel>"); - writeStartElement("xbel"); - writeAttribute("version", "1.0"); + xml.writeStartDocument(); + xml.writeDTD("<!DOCTYPE xbel>"); + xml.writeStartElement("xbel"); + xml.writeAttribute("version", "1.0"); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) writeItem(treeWidget->topLevelItem(i)); - writeEndDocument(); + xml.writeEndDocument(); return true; } //! [1] @@ -74,20 +74,20 @@ void XbelWriter::writeItem(QTreeWidgetItem *item) QString tagName = item->data(0, Qt::UserRole).toString(); if (tagName == "folder") { bool folded = !treeWidget->isItemExpanded(item); - writeStartElement(tagName); - writeAttribute("folded", folded ? "yes" : "no"); - writeTextElement("title", item->text(0)); + xml.writeStartElement(tagName); + xml.writeAttribute("folded", folded ? "yes" : "no"); + xml.writeTextElement("title", item->text(0)); for (int i = 0; i < item->childCount(); ++i) writeItem(item->child(i)); - writeEndElement(); + xml.writeEndElement(); } else if (tagName == "bookmark") { - writeStartElement(tagName); + xml.writeStartElement(tagName); if (!item->text(1).isEmpty()) - writeAttribute("href", item->text(1)); - writeTextElement("title", item->text(0)); - writeEndElement(); + xml.writeAttribute("href", item->text(1)); + xml.writeTextElement("title", item->text(0)); + xml.writeEndElement(); } else if (tagName == "separator") { - writeEmptyElement(tagName); + xml.writeEmptyElement(tagName); } } //! [2] diff --git a/examples/xml/streambookmarks/xbelwriter.h b/examples/xml/streambookmarks/xbelwriter.h index e881e55..53806be 100644 --- a/examples/xml/streambookmarks/xbelwriter.h +++ b/examples/xml/streambookmarks/xbelwriter.h @@ -50,7 +50,7 @@ class QTreeWidgetItem; QT_END_NAMESPACE //! [0] -class XbelWriter : public QXmlStreamWriter +class XbelWriter { public: XbelWriter(QTreeWidget *treeWidget); @@ -58,6 +58,7 @@ public: private: void writeItem(QTreeWidgetItem *item); + QXmlStreamWriter xml; QTreeWidget *treeWidget; }; //! [0] diff --git a/examples/xml/xml.pro b/examples/xml/xml.pro index 866b0cc..0bc6dd9 100644 --- a/examples/xml/xml.pro +++ b/examples/xml/xml.pro @@ -1,12 +1,17 @@ TEMPLATE = subdirs SUBDIRS = dombookmarks \ + htmlinfo \ rsslisting \ saxbookmarks \ streambookmarks \ xmlstreamlint +symbian: SUBDIRS = htmlinfo saxbookmarks + # install target.path = $$[QT_INSTALL_EXAMPLES]/xml sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS xml.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/xml INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xml/xmlstreamlint/xmlstreamlint.pro b/examples/xml/xmlstreamlint/xmlstreamlint.pro index 7034e7b..6a09f1a 100644 --- a/examples/xml/xmlstreamlint/xmlstreamlint.pro +++ b/examples/xml/xmlstreamlint/xmlstreamlint.pro @@ -8,3 +8,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xml/xmlstreamlint sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS xmlstreamlint.pro sources.path = $$[QT_INSTALL_EXAMPLES]/xml/xmlstreamlint INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xmlpatterns/filetree/filetree.pro b/examples/xmlpatterns/filetree/filetree.pro index 469ee8d..0238c23 100644 --- a/examples/xmlpatterns/filetree/filetree.pro +++ b/examples/xmlpatterns/filetree/filetree.pro @@ -11,3 +11,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/filetree sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xq *.html sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/filetree INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xmlpatterns/recipes/recipes.pro b/examples/xmlpatterns/recipes/recipes.pro index 87708a9..f02a018 100644 --- a/examples/xmlpatterns/recipes/recipes.pro +++ b/examples/xmlpatterns/recipes/recipes.pro @@ -9,3 +9,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/recipes sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xq *.html forms files sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/recipes INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xmlpatterns/schema/files/contact.xsd b/examples/xmlpatterns/schema/files/contact.xsd new file mode 100644 index 0000000..3e1b570 --- /dev/null +++ b/examples/xmlpatterns/schema/files/contact.xsd @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="contact"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="givenName" type="xsd:string"/> + <xsd:element name="familyName" type="xsd:string"/> + <xsd:element name="birthdate" type="xsd:date" minOccurs="0"/> + <xsd:element name="homeAddress" type="address"/> + <xsd:element name="workAddress" type="address" minOccurs="0"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="address"> + <xsd:sequence> + <xsd:element name="street" type="xsd:string"/> + <xsd:element name="zipCode" type="xsd:string"/> + <xsd:element name="city" type="xsd:string"/> + <xsd:element name="country" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/examples/xmlpatterns/schema/files/invalid_contact.xml b/examples/xmlpatterns/schema/files/invalid_contact.xml new file mode 100644 index 0000000..42f1edd --- /dev/null +++ b/examples/xmlpatterns/schema/files/invalid_contact.xml @@ -0,0 +1,11 @@ +<contact> + <givenName>John</givenName> + <familyName>Doe</familyName> + <title>Prof.</title> + <workAddress> + <street>Sandakerveien 116</street> + <zipCode>N-0550</zipCode> + <city>Oslo</city> + <country>Norway</country> + </workAddress> +</contact> diff --git a/examples/xmlpatterns/schema/files/invalid_order.xml b/examples/xmlpatterns/schema/files/invalid_order.xml new file mode 100644 index 0000000..8ffc5fd --- /dev/null +++ b/examples/xmlpatterns/schema/files/invalid_order.xml @@ -0,0 +1,13 @@ +<order> + <customerId>234219</customerId> + <article> + <articleId>21692</articleId> + <count>3</count> + </article> + <article> + <articleId>24749</articleId> + <count>9</count> + </article> + <deliveryDate>2009-01-23</deliveryDate> + <payed>yes</payed> +</order> diff --git a/examples/xmlpatterns/schema/files/invalid_recipe.xml b/examples/xmlpatterns/schema/files/invalid_recipe.xml new file mode 100644 index 0000000..4d75af6 --- /dev/null +++ b/examples/xmlpatterns/schema/files/invalid_recipe.xml @@ -0,0 +1,14 @@ +<recipe> + <title>Cheese on Toast</title> + <ingredient name="Bread" quantity="2" unit="slices"/> + <ingredient name="Cheese" quantity="2" unit="slices"/> + <time quantity="3" unit="days"/> + <method> + <step>1. Slice the bread and cheese.</step> + <step>2. Grill one side of each slice of bread.</step> + <step>3. Turn over the bread and place a slice of cheese on each piece.</step> + <step>4. Grill until the cheese has started to melt.</step> + <step>5. Serve and enjoy!</step> + </method> + <comment>Tell your friends about it!</comment> +</recipe> diff --git a/examples/xmlpatterns/schema/files/order.xsd b/examples/xmlpatterns/schema/files/order.xsd new file mode 100644 index 0000000..405cafe --- /dev/null +++ b/examples/xmlpatterns/schema/files/order.xsd @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="order"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerId" type="xsd:positiveInteger"/> + <xsd:element name="article" type="articleType" maxOccurs="unbounded"/> + <xsd:element name="deliveryDate" type="xsd:date"/> + <xsd:element name="payed" type="xsd:boolean"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="articleType"> + <xsd:sequence> + <xsd:element name="articleId" type="xsd:positiveInteger"/> + <xsd:element name="count" type="xsd:positiveInteger"/> + <xsd:element name="comment" type="xsd:string" minOccurs="0"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/examples/xmlpatterns/schema/files/recipe.xsd b/examples/xmlpatterns/schema/files/recipe.xsd new file mode 100644 index 0000000..bbbafd9 --- /dev/null +++ b/examples/xmlpatterns/schema/files/recipe.xsd @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="recipe"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="title" type="xsd:string"/> + <xsd:element name="ingredient" type="ingredientType" maxOccurs="unbounded"/> + <xsd:element name="time" type="timeType"/> + <xsd:element name="method"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="step" type="xsd:string" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="ingredientType"> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="quantity" type="xsd:positiveInteger"/> + <xsd:attribute name="unit" type="xsd:string"/> + </xsd:complexType> + + <xsd:complexType name="timeType"> + <xsd:attribute name="quantity" type="xsd:positiveInteger"/> + <xsd:attribute name="unit"> + <xsd:simpleType> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="seconds"/> + <xsd:enumeration value="minutes"/> + <xsd:enumeration value="hours"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + </xsd:complexType> + +</xsd:schema> diff --git a/examples/xmlpatterns/schema/files/valid_contact.xml b/examples/xmlpatterns/schema/files/valid_contact.xml new file mode 100644 index 0000000..53c04d4 --- /dev/null +++ b/examples/xmlpatterns/schema/files/valid_contact.xml @@ -0,0 +1,11 @@ +<contact> + <givenName>John</givenName> + <familyName>Doe</familyName> + <birthdate>1977-12-25</birthdate> + <homeAddress> + <street>Sandakerveien 116</street> + <zipCode>N-0550</zipCode> + <city>Oslo</city> + <country>Norway</country> + </homeAddress> +</contact> diff --git a/examples/xmlpatterns/schema/files/valid_order.xml b/examples/xmlpatterns/schema/files/valid_order.xml new file mode 100644 index 0000000..f83c36c --- /dev/null +++ b/examples/xmlpatterns/schema/files/valid_order.xml @@ -0,0 +1,18 @@ +<order> + <customerId>194223</customerId> + <article> + <articleId>22242</articleId> + <count>5</count> + </article> + <article> + <articleId>32372</articleId> + <count>12</count> + <comment>without stripes</comment> + </article> + <article> + <articleId>23649</articleId> + <count>2</count> + </article> + <deliveryDate>2009-01-23</deliveryDate> + <payed>true</payed> +</order> diff --git a/examples/xmlpatterns/schema/files/valid_recipe.xml b/examples/xmlpatterns/schema/files/valid_recipe.xml new file mode 100644 index 0000000..f6499ba --- /dev/null +++ b/examples/xmlpatterns/schema/files/valid_recipe.xml @@ -0,0 +1,13 @@ +<recipe> + <title>Cheese on Toast</title> + <ingredient name="Bread" quantity="2" unit="slices"/> + <ingredient name="Cheese" quantity="2" unit="slices"/> + <time quantity="3" unit="minutes"/> + <method> + <step>1. Slice the bread and cheese.</step> + <step>2. Grill one side of each slice of bread.</step> + <step>3. Turn over the bread and place a slice of cheese on each piece.</step> + <step>4. Grill until the cheese has started to melt.</step> + <step>5. Serve and enjoy!</step> + </method> +</recipe> diff --git a/examples/xmlpatterns/schema/main.cpp b/examples/xmlpatterns/schema/main.cpp new file mode 100644 index 0000000..65b749e --- /dev/null +++ b/examples/xmlpatterns/schema/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include "mainwindow.h" + +//! [0] +int main(int argc, char* argv[]) +{ + Q_INIT_RESOURCE(schema); + QApplication app(argc, argv); + MainWindow* const window = new MainWindow; + window->show(); + return app.exec(); +} +//! [0] diff --git a/examples/xmlpatterns/schema/mainwindow.cpp b/examples/xmlpatterns/schema/mainwindow.cpp new file mode 100644 index 0000000..4bd9795 --- /dev/null +++ b/examples/xmlpatterns/schema/mainwindow.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui> +#include <QtXmlPatterns> + +#include "mainwindow.h" +#include "xmlsyntaxhighlighter.h" + +//! [4] +class MessageHandler : public QAbstractMessageHandler +{ + public: + MessageHandler() + : QAbstractMessageHandler(0) + { + } + + QString statusMessage() const + { + return m_description; + } + + int line() const + { + return m_sourceLocation.line(); + } + + int column() const + { + return m_sourceLocation.column(); + } + + protected: + virtual void handleMessage(QtMsgType type, const QString &description, + const QUrl &identifier, const QSourceLocation &sourceLocation) + { + Q_UNUSED(type); + Q_UNUSED(identifier); + + m_messageType = type; + m_description = description; + m_sourceLocation = sourceLocation; + } + + private: + QtMsgType m_messageType; + QString m_description; + QSourceLocation m_sourceLocation; +}; +//! [4] + +//! [0] +MainWindow::MainWindow() +{ + setupUi(this); + + new XmlSyntaxHighlighter(schemaView->document()); + new XmlSyntaxHighlighter(instanceEdit->document()); + + schemaSelection->addItem(tr("Contact Schema")); + schemaSelection->addItem(tr("Recipe Schema")); + schemaSelection->addItem(tr("Order Schema")); + + instanceSelection->addItem(tr("Valid Contact Instance")); + instanceSelection->addItem(tr("Invalid Contact Instance")); + + connect(schemaSelection, SIGNAL(currentIndexChanged(int)), SLOT(schemaSelected(int))); + connect(instanceSelection, SIGNAL(currentIndexChanged(int)), SLOT(instanceSelected(int))); + connect(validateButton, SIGNAL(clicked()), SLOT(validate())); + connect(instanceEdit, SIGNAL(textChanged()), SLOT(textChanged())); + + validationStatus->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); + + schemaSelected(0); + instanceSelected(0); +} +//! [0] + +//! [1] +void MainWindow::schemaSelected(int index) +{ + instanceSelection->clear(); + if (index == 0) { + instanceSelection->addItem(tr("Valid Contact Instance")); + instanceSelection->addItem(tr("Invalid Contact Instance")); + } else if (index == 1) { + instanceSelection->addItem(tr("Valid Recipe Instance")); + instanceSelection->addItem(tr("Invalid Recipe Instance")); + } else if (index == 2) { + instanceSelection->addItem(tr("Valid Order Instance")); + instanceSelection->addItem(tr("Invalid Order Instance")); + } + textChanged(); + + QFile schemaFile(QString(":/schema_%1.xsd").arg(index)); + schemaFile.open(QIODevice::ReadOnly); + const QString schemaText(QString::fromUtf8(schemaFile.readAll())); + schemaView->setPlainText(schemaText); + + validate(); +} +//! [1] + +//! [2] +void MainWindow::instanceSelected(int index) +{ + QFile instanceFile(QString(":/instance_%1.xml").arg((2*schemaSelection->currentIndex()) + index)); + instanceFile.open(QIODevice::ReadOnly); + const QString instanceText(QString::fromUtf8(instanceFile.readAll())); + instanceEdit->setPlainText(instanceText); + + validate(); +} +//! [2] + +//! [3] +void MainWindow::validate() +{ + const QByteArray schemaData = schemaView->toPlainText().toUtf8(); + const QByteArray instanceData = instanceEdit->toPlainText().toUtf8(); + + MessageHandler messageHandler; + + QXmlSchema schema; + schema.setMessageHandler(&messageHandler); + + schema.load(schemaData); + + bool errorOccurred = false; + if (!schema.isValid()) { + errorOccurred = true; + } else { + QXmlSchemaValidator validator(schema); + if (!validator.validate(instanceData)) + errorOccurred = true; + } + + if (errorOccurred) { + validationStatus->setText(messageHandler.statusMessage()); + moveCursor(messageHandler.line(), messageHandler.column()); + } else { + validationStatus->setText(tr("validation successful")); + } + + const QString styleSheet = QString("QLabel {background: %1; padding: 3px}") + .arg(errorOccurred ? QColor(Qt::red).lighter(160).name() : + QColor(Qt::green).lighter(160).name()); + validationStatus->setStyleSheet(styleSheet); +} +//! [3] + +void MainWindow::textChanged() +{ + instanceEdit->setExtraSelections(QList<QTextEdit::ExtraSelection>()); +} + +void MainWindow::moveCursor(int line, int column) +{ + instanceEdit->moveCursor(QTextCursor::Start); + for (int i = 1; i < line; ++i) + instanceEdit->moveCursor(QTextCursor::Down); + + for (int i = 1; i < column; ++i) + instanceEdit->moveCursor(QTextCursor::Right); + + QList<QTextEdit::ExtraSelection> extraSelections; + QTextEdit::ExtraSelection selection; + + const QColor lineColor = QColor(Qt::red).lighter(160); + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = instanceEdit->textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + + instanceEdit->setExtraSelections(extraSelections); + + instanceEdit->setFocus(); +} diff --git a/examples/xmlpatterns/schema/mainwindow.h b/examples/xmlpatterns/schema/mainwindow.h new file mode 100644 index 0000000..580e47e --- /dev/null +++ b/examples/xmlpatterns/schema/mainwindow.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples 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 http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +#include "ui_schema.h" + +//! [0] +class MainWindow : public QMainWindow, + private Ui::SchemaMainWindow +{ + Q_OBJECT + + public: + MainWindow(); + + private Q_SLOTS: + void schemaSelected(int index); + void instanceSelected(int index); + void validate(); + void textChanged(); + + private: + void moveCursor(int line, int column); +}; +//! [0] +#endif diff --git a/examples/xmlpatterns/schema/schema.pro b/examples/xmlpatterns/schema/schema.pro new file mode 100644 index 0000000..af32e0a --- /dev/null +++ b/examples/xmlpatterns/schema/schema.pro @@ -0,0 +1,11 @@ +QT += xmlpatterns +FORMS += schema.ui +HEADERS = mainwindow.h ../shared/xmlsyntaxhighlighter.h +RESOURCES = schema.qrc +SOURCES = main.cpp mainwindow.cpp ../shared/xmlsyntaxhighlighter.cpp +INCLUDEPATH += ../shared/ + +target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/schema +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.xq *.html files +sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/schema +INSTALLS += target sources diff --git a/examples/xmlpatterns/schema/schema.qrc b/examples/xmlpatterns/schema/schema.qrc new file mode 100644 index 0000000..eb7ddfd --- /dev/null +++ b/examples/xmlpatterns/schema/schema.qrc @@ -0,0 +1,13 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file alias="schema_0.xsd">files/contact.xsd</file> + <file alias="schema_1.xsd">files/recipe.xsd</file> + <file alias="schema_2.xsd">files/order.xsd</file> + <file alias="instance_0.xml">files/valid_contact.xml</file> + <file alias="instance_1.xml">files/invalid_contact.xml</file> + <file alias="instance_2.xml">files/valid_recipe.xml</file> + <file alias="instance_3.xml">files/invalid_recipe.xml</file> + <file alias="instance_4.xml">files/valid_order.xml</file> + <file alias="instance_5.xml">files/invalid_order.xml</file> +</qresource> +</RCC> diff --git a/examples/xmlpatterns/schema/schema.ui b/examples/xmlpatterns/schema/schema.ui new file mode 100644 index 0000000..b67f444 --- /dev/null +++ b/examples/xmlpatterns/schema/schema.ui @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SchemaMainWindow</class> + <widget class="QMainWindow" name="SchemaMainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>417</width> + <height>594</height> + </rect> + </property> + <property name="windowTitle"> + <string>XML Schema Validation</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="schemaLabel"> + <property name="text"> + <string>XML Schema Document:</string> + </property> + </widget> + </item> + <item row="0" column="2" colspan="2"> + <widget class="QComboBox" name="schemaSelection"/> + </item> + <item row="1" column="0" colspan="4"> + <widget class="QTextBrowser" name="schemaView"/> + </item> + <item row="2" column="0" colspan="2"> + <widget class="QLabel" name="instanceLabel"> + <property name="text"> + <string>XML Instance Document:</string> + </property> + </widget> + </item> + <item row="2" column="2" colspan="2"> + <widget class="QComboBox" name="instanceSelection"/> + </item> + <item row="3" column="0" colspan="4"> + <widget class="QTextEdit" name="instanceEdit"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Status:</string> + </property> + </widget> + </item> + <item row="4" column="1" colspan="2"> + <widget class="QLabel" name="validationStatus"> + <property name="text"> + <string>not validated</string> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QPushButton" name="validateButton"> + <property name="text"> + <string>Validate</string> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp index 1356c26..26d5b33 100644 --- a/examples/xmlpatterns/trafficinfo/mainwindow.cpp +++ b/examples/xmlpatterns/trafficinfo/mainwindow.cpp @@ -55,7 +55,7 @@ MainWindow::MainWindow() : QWidget(0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) { QAction *quitAction = new QAction(tr("E&xit"), this); - quitAction->setShortcut(tr("Ctrl+Q")); + quitAction->setShortcuts(QKeySequence::Quit); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QAction *configAction = new QAction(tr("&Select station..."), this); @@ -165,8 +165,7 @@ void MainWindow::resizeEvent(QResizeEvent*) void MainWindow::updateTimeInformation() { - TimeQuery query; - m_times = query.query(m_station.id(), m_lines, QDateTime::currentDateTime()); + m_times = TimeQuery::query(m_station.id(), m_lines, QDateTime::currentDateTime()); update(); } diff --git a/examples/xmlpatterns/trafficinfo/stationdialog.cpp b/examples/xmlpatterns/trafficinfo/stationdialog.cpp index 41e74b4..cae3ffc 100644 --- a/examples/xmlpatterns/trafficinfo/stationdialog.cpp +++ b/examples/xmlpatterns/trafficinfo/stationdialog.cpp @@ -157,8 +157,6 @@ QStringList StationDialog::lineNumbers() const void StationDialog::searchStations() { - StationQuery query; - - m_model->setStations(query.query(m_ui.m_input->text())); + m_model->setStations(StationQuery::query(m_ui.m_input->text())); m_ui.m_view->keyboardSearch(m_ui.m_input->text()); } diff --git a/examples/xmlpatterns/xmlpatterns.pro b/examples/xmlpatterns/xmlpatterns.pro index 1a57005..2ad4798 100644 --- a/examples/xmlpatterns/xmlpatterns.pro +++ b/examples/xmlpatterns/xmlpatterns.pro @@ -2,7 +2,8 @@ TEMPLATE = subdirs SUBDIRS = recipes \ trafficinfo \ xquery \ - filetree + filetree \ + schema # This example depends on QtWebkit as well. contains(QT_CONFIG, webkit):SUBDIRS += qobjectxmlmodel @@ -12,3 +13,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS xmlpatterns.pro README sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro b/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro index 8ca900b..8520606 100644 --- a/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro +++ b/examples/xmlpatterns/xquery/globalVariables/globalVariables.pro @@ -7,3 +7,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/xquery/globalVariables sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.cpp *.pro *.xq *.html globals.gccxml sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/xquery/globalVariables INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/xmlpatterns/xquery/xquery.pro b/examples/xmlpatterns/xquery/xquery.pro index f7ac5ef..70b215c 100644 --- a/examples/xmlpatterns/xquery/xquery.pro +++ b/examples/xmlpatterns/xquery/xquery.pro @@ -6,3 +6,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/xquery sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS xquery.pro sources.path = $$[QT_INSTALL_EXAMPLES]/xmlpatterns/xquery INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) |