diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:18:55 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:18:55 (GMT) |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /demos/embedded | |
download | Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2 |
Long live Qt 4.5!
Diffstat (limited to 'demos/embedded')
50 files changed, 4461 insertions, 0 deletions
diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro new file mode 100644 index 0000000..7428b9f --- /dev/null +++ b/demos/embedded/embedded.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs +SUBDIRS = styledemo + +contains(QT_CONFIG, svg) { + SUBDIRS += embeddedsvgviewer \ + fluidlauncher +} + +# install +sources.files = README *.pro +sources.path = $$[QT_INSTALL_DEMOS]/embedded +INSTALLS += sources + diff --git a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp new file mode 100644 index 0000000..1bd99c9 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QPainter> +#include <QApplication> + +#include "embeddedsvgviewer.h" + + + +EmbeddedSvgViewer::EmbeddedSvgViewer(const QString &filePath) +{ + qApp->setStyleSheet(" QSlider:vertical { width: 50px; } \ + QSlider::groove:vertical { border: 1px solid black; border-radius: 3px; width: 6px; } \ + QSlider::handle:vertical { height: 25px; margin: 0 -22px; image: url(':/files/v-slider-handle.svg'); } \ + "); + + m_renderer = new QSvgRenderer(filePath); + m_imageSize = m_renderer->viewBox().size(); + + m_viewBoxCenter = (QPointF(m_imageSize.width() / qreal(2.0), m_imageSize.height() / qreal(2.0))); + + m_zoomSlider = new QSlider(Qt::Vertical, this); + m_zoomSlider->setMaximum(150); + m_zoomSlider->setMinimum(1); + + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoom(int))); + m_zoomSlider->setValue(100); + + m_quitButton = new QPushButton("Quit", this); + + connect(m_quitButton, SIGNAL(pressed()), QApplication::instance(), SLOT(quit())); + + if (m_renderer->animated()) + connect(m_renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); + +} + +void EmbeddedSvgViewer::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + QPainter painter(this); + m_renderer->setViewBox(m_viewBox); + m_renderer->render(&painter); +} + + +void EmbeddedSvgViewer::mouseMoveEvent ( QMouseEvent * event ) +{ + int incX = int((event->globalX() - m_mousePress.x()) * m_imageScale); + int incY = int((event->globalY() - m_mousePress.y()) * m_imageScale); + + QPointF newCenter; + newCenter.setX(m_viewBoxCenterOnMousePress.x() - incX); + newCenter.setY(m_viewBoxCenterOnMousePress.y() - incY); + + QRectF newViewBox = getViewBox(newCenter); + + + // Do a bounded move on the horizontal: + if ( (newViewBox.left() >= m_viewBoxBounds.left()) && + (newViewBox.right() <= m_viewBoxBounds.right()) ) + { + m_viewBoxCenter.setX(newCenter.x()); + m_viewBox.setLeft(newViewBox.left()); + m_viewBox.setRight(newViewBox.right()); + } + + // do a bounded move on the vertical: + if ( (newViewBox.top() >= m_viewBoxBounds.top()) && + (newViewBox.bottom() <= m_viewBoxBounds.bottom()) ) + { + m_viewBoxCenter.setY(newCenter.y()); + m_viewBox.setTop(newViewBox.top()); + m_viewBox.setBottom(newViewBox.bottom()); + } + + update(); +} + +void EmbeddedSvgViewer::mousePressEvent ( QMouseEvent * event ) +{ + m_viewBoxCenterOnMousePress = m_viewBoxCenter; + m_mousePress = event->globalPos(); +} + + +QRectF EmbeddedSvgViewer::getViewBox(QPointF viewBoxCenter) +{ + QRectF result; + result.setLeft(viewBoxCenter.x() - (m_viewBoxSize.width() / 2)); + result.setTop(viewBoxCenter.y() - (m_viewBoxSize.height() / 2)); + result.setRight(viewBoxCenter.x() + (m_viewBoxSize.width() / 2)); + result.setBottom(viewBoxCenter.y() + (m_viewBoxSize.height() / 2)); + return result; +} + +void EmbeddedSvgViewer::updateImageScale() +{ + m_imageScale = qMax( (qreal)m_imageSize.width() / (qreal)width(), + (qreal)m_imageSize.height() / (qreal)height())*m_zoomLevel; + + m_viewBoxSize.setWidth((qreal)width() * m_imageScale); + m_viewBoxSize.setHeight((qreal)height() * m_imageScale); +} + + +void EmbeddedSvgViewer::resizeEvent ( QResizeEvent * event ) +{ + qreal origZoom = m_zoomLevel; + + // Get the new bounds: + m_zoomLevel = 1.0; + updateImageScale(); + m_viewBoxBounds = getViewBox(QPointF(m_imageSize.width() / 2.0, m_imageSize.height() / 2.0)); + + m_zoomLevel = origZoom; + updateImageScale(); + m_viewBox = getViewBox(m_viewBoxCenter); + + QRect sliderRect; + sliderRect.setLeft(width() - m_zoomSlider->sizeHint().width()); + sliderRect.setRight(width()); + sliderRect.setTop(height()/4); + sliderRect.setBottom(height() - (height()/4)); + m_zoomSlider->setGeometry(sliderRect); +} + + +void EmbeddedSvgViewer::setZoom(int newZoom) +{ + m_zoomLevel = qreal(newZoom) / qreal(100); + + updateImageScale(); + m_viewBox = getViewBox(m_viewBoxCenter); + + update(); +} + + + + + diff --git a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.h b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.h new file mode 100644 index 0000000..c0af3cf --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EMBEDDED_SVG_VIEWER_H +#define EMBEDDED_SVG_VIEWER_H + +#include <QWidget> +#include <QString> +#include <QSvgRenderer> +#include <QSize> +#include <QMouseEvent> +#include <QSlider> +#include <QPushButton> + +class EmbeddedSvgViewer : public QWidget +{ + Q_OBJECT +public: + EmbeddedSvgViewer(const QString& filePath); + virtual void paintEvent(QPaintEvent *event); + void mouseMoveEvent ( QMouseEvent * event ); + void mousePressEvent ( QMouseEvent * event ); + void resizeEvent ( QResizeEvent * event ); + +public slots: + void setZoom(int); // 100 <= newZoom < 0 + +private: + QSvgRenderer* m_renderer; + QSlider* m_zoomSlider; + QPushButton* m_quitButton; + QSize m_imageSize; + qreal m_zoomLevel; + qreal m_imageScale; // How many Image coords 1 widget pixel is worth + + QRectF m_viewBox; + QRectF m_viewBoxBounds; + QSizeF m_viewBoxSize; + QPointF m_viewBoxCenter; + QPointF m_viewBoxCenterOnMousePress; + QPoint m_mousePress; + + void updateImageScale(); + QRectF getViewBox(QPointF viewBoxCenter); +}; + + + +#endif diff --git a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro new file mode 100644 index 0000000..505e607 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +QT += svg + +# Input +HEADERS += embeddedsvgviewer.h +SOURCES += embeddedsvgviewer.cpp main.cpp +RESOURCES += embeddedsvgviewer.qrc + +target.path = $$[QT_INSTALL_DEMOS]/embedded/embeddedsvgviewer +sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html *.svg files +sources.path = $$[QT_INSTALL_DEMOS]/embedded/embeddedsvgviewer +INSTALLS += target sources + +wince*: { + DEPLOYMENT_PLUGIN += qsvg +} diff --git a/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc new file mode 100644 index 0000000..bb02118 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/embeddedsvgviewer.qrc @@ -0,0 +1,7 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>files/v-slider-handle.svg</file> + <file>files/default.svg</file> +</qresource> +</RCC> + diff --git a/demos/embedded/embeddedsvgviewer/files/default.svg b/demos/embedded/embeddedsvgviewer/files/default.svg new file mode 100644 index 0000000..c28a711 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/files/default.svg @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="400px" + height="400px" + baseProfile="tiny" + id="svg8268" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docname="simple2.svg" + sodipodi:docbase="/nfs/OpenMoko/SVGs" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata8283"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs8281" /> + <sodipodi:namedview + inkscape:window-height="917" + inkscape:window-width="1324" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:zoom="2.1452345" + inkscape:cx="185.25" + inkscape:cy="214.75" + inkscape:window-x="0" + inkscape:window-y="30" + inkscape:current-layer="svg8268" /> + <g + stroke="DarkBlue" + stroke-width="10" + id="g8270"> + <rect + fill="blue" + fill-opacity="0.5" + x="25" + y="25" + width="175" + height="175" + id="rect8272" /> + </g> + <circle + cx="200" + cy="200" + r="75" + id="circle8274" + sodipodi:cx="200" + sodipodi:cy="200" + sodipodi:rx="75" + sodipodi:ry="75" + transform="translate(-26.104372,21.909027)" + style="fill:#ffff00;fill-opacity:0.5;stroke:#000000" /> + <polygon + fill="green" + stroke="black" + fill-opacity="0.5" + stroke-width="1" + points="200,225 350,225 275,350" + id="polygon8276" /> + <path + style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.50196081" + d="M 303.7037,50.705207 C 173.88522,56.588264 90.320951,92.710345 162.85059,120.82533 C 211.91719,139.84524 196.63811,214.12391 233.86243,192.59259 C 284.31755,163.4083 299.34345,193.75691 311.11111,187.30159 C 347.88407,167.12924 269.34382,134.85785 303.81608,114.5167 C 394.71183,60.881583 332.47907,46.043712 303.7037,50.705207 z " + id="path8289" + sodipodi:nodetypes="cssssc" /> +</svg> diff --git a/demos/embedded/embeddedsvgviewer/files/v-slider-handle.svg b/demos/embedded/embeddedsvgviewer/files/v-slider-handle.svg new file mode 100644 index 0000000..4ee87f8 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/files/v-slider-handle.svg @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="50" + height="25" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.45.1" + version="1.0" + sodipodi:docbase="/home/tcooksey/Projects/qt-4.4/demos/embedded/embeddedsvgviewer/files" + sodipodi:docname="v-slider-handle.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <defs + id="defs4"> + <linearGradient + inkscape:collect="always" + id="linearGradient2158"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop2160" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop2162" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient2158" + id="linearGradient2164" + x1="26.10779" + y1="9.1025448" + x2="26.10779" + y2="-0.01334004" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.9876687,0,0,2.5969342,0.3086332,-0.476397)" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="12.256878" + inkscape:cx="42.920885" + inkscape:cy="4.2252457" + inkscape:document-units="px" + inkscape:current-layer="layer1" + width="50px" + height="25px" + inkscape:window-width="1282" + inkscape:window-height="879" + inkscape:window-x="137" + inkscape:window-y="30" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:url(#linearGradient2164);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.60153389px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 10.191803,24.254577 C 26.804559,24.254577 25.309299,24.303278 39.985656,24.303278 C 52.503796,24.303278 51.963217,0.91536797 40.722957,0.91536797 C 13.837108,0.91536797 16.298612,0.86901372 10.385089,0.86901372 C -2.0345215,0.86901372 -2.5249912,24.254577 10.191803,24.254577 z " + id="path2162" + sodipodi:nodetypes="csssc" /> + <path + sodipodi:type="arc" + style="fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#868686;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + id="path2166" + sodipodi:cx="9.4232807" + sodipodi:cy="13.169908" + sodipodi:rx="2.2436383" + sodipodi:ry="1.9580842" + d="M 9.4232808,15.127992 A 2.2436383,1.9580842 0 1 1 9.4232808,11.211823 L 9.4232807,13.169908 z" + sodipodi:start="1.5707963" + sodipodi:end="4.712389" + transform="matrix(4.3804554,0,0,2.228386,-25.247974,-16.463284)" /> + </g> +</svg> diff --git a/demos/embedded/embeddedsvgviewer/main.cpp b/demos/embedded/embeddedsvgviewer/main.cpp new file mode 100644 index 0000000..80f92d6 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QDebug> + +#include "embeddedsvgviewer.h" + +int main(int argc, char** argv) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(embeddedsvgviewer); + + QString filePath; + + if (argc == 1) + filePath = QLatin1String(":/files/default.svg"); + else if (argc == 2) + filePath = argv[1]; + else { + qDebug() << QLatin1String("Please specify an svg file!"); + return -1; + } + + EmbeddedSvgViewer viewer(filePath); + + viewer.showFullScreen(); + + return app.exec(); +} diff --git a/demos/embedded/embeddedsvgviewer/shapes.svg b/demos/embedded/embeddedsvgviewer/shapes.svg new file mode 100644 index 0000000..c28a711 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/shapes.svg @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="400px" + height="400px" + baseProfile="tiny" + id="svg8268" + sodipodi:version="0.32" + inkscape:version="0.45.1" + sodipodi:docname="simple2.svg" + sodipodi:docbase="/nfs/OpenMoko/SVGs" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <metadata + id="metadata8283"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs8281" /> + <sodipodi:namedview + inkscape:window-height="917" + inkscape:window-width="1324" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + guidetolerance="10.0" + gridtolerance="10.0" + objecttolerance="10.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:zoom="2.1452345" + inkscape:cx="185.25" + inkscape:cy="214.75" + inkscape:window-x="0" + inkscape:window-y="30" + inkscape:current-layer="svg8268" /> + <g + stroke="DarkBlue" + stroke-width="10" + id="g8270"> + <rect + fill="blue" + fill-opacity="0.5" + x="25" + y="25" + width="175" + height="175" + id="rect8272" /> + </g> + <circle + cx="200" + cy="200" + r="75" + id="circle8274" + sodipodi:cx="200" + sodipodi:cy="200" + sodipodi:rx="75" + sodipodi:ry="75" + transform="translate(-26.104372,21.909027)" + style="fill:#ffff00;fill-opacity:0.5;stroke:#000000" /> + <polygon + fill="green" + stroke="black" + fill-opacity="0.5" + stroke-width="1" + points="200,225 350,225 275,350" + id="polygon8276" /> + <path + style="fill:#000000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.50196081" + d="M 303.7037,50.705207 C 173.88522,56.588264 90.320951,92.710345 162.85059,120.82533 C 211.91719,139.84524 196.63811,214.12391 233.86243,192.59259 C 284.31755,163.4083 299.34345,193.75691 311.11111,187.30159 C 347.88407,167.12924 269.34382,134.85785 303.81608,114.5167 C 394.71183,60.881583 332.47907,46.043712 303.7037,50.705207 z " + id="path8289" + sodipodi:nodetypes="cssssc" /> +</svg> diff --git a/demos/embedded/embeddedsvgviewer/spheres.svg b/demos/embedded/embeddedsvgviewer/spheres.svg new file mode 100644 index 0000000..e108777 --- /dev/null +++ b/demos/embedded/embeddedsvgviewer/spheres.svg @@ -0,0 +1,81 @@ +<?xml version="1.0" standalone="no"?> +<svg width="8cm" height="8cm" viewBox="0 0 400 400" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink/" + baseProfile="tiny" version="1.2"> + <title>Spheres</title> + <desc>Gradient filled spheres with different colors.</desc> + <defs> + <!-- Create radial gradients for each circle to make them look like + spheres. --> + <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="blue" /> + <stop offset="100%" stop-color="#222244" /> + </radialGradient> + <radialGradient id="redSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="red" /> + <stop offset="100%" stop-color="#442222" /> + </radialGradient> + <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="green" /> + <stop offset="100%" stop-color="#113311" /> + </radialGradient> + <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse" + cx="0" cy="0" r="100" fx="-50" fy="-50"> + <stop offset="0%" stop-color="white" /> + <stop offset="75%" stop-color="yellow" /> + <stop offset="100%" stop-color="#444422" /> + </radialGradient> + <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" /> + </radialGradient> + + <!-- Define a shadow for each sphere. --> + <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" /> + </defs> + <g fill="#ffee99" stroke="none" > + <rect x="0" y="0" width="400" height="400" /> + </g> + <g fill="white" stroke="none" > + <rect x="0" y="175" width="400" height="225" /> + </g> + <g transform="translate(200,290) scale(2.0,1.0) rotate(45)" > + <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" /> + <circle fill="black" cx="0" cy="0" r="50" /> + <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" + begin="0s" dur="10s" fill="freeze" /> + </g> + <g transform="translate(200,175)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" /> + </g> + <g transform="translate(315,240)"> + <g transform="scale(0.5,0.5)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#redSphere)" cx="0" cy="0" r="100" /> + </g> + </g> + <g transform="translate(80,275)"> + <g transform="scale(0.65,0.65)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" /> + </g> + </g> + <g transform="translate(255,325)"> + <g transform="scale(0.3,0.3)"> + <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" /> + <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" /> + </g> + </g> +</svg> diff --git a/demos/embedded/fluidlauncher/config.xml b/demos/embedded/fluidlauncher/config.xml new file mode 100644 index 0000000..6cb4be7 --- /dev/null +++ b/demos/embedded/fluidlauncher/config.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<demolauncher> + <demos> + <example filename="../embeddedsvgviewer/embeddedsvgviewer" name="SVG Viewer" image="screenshots/embeddedsvgviewer.png" args="../embeddedsvgviewer/shapes.svg"/> + <example filename="../styledemo/styledemo" name="Stylesheets" image="screenshots/styledemo.png"/> + <example filename="../../deform/deform" name="Vector Deformation" image="screenshots/deform.png" args="-small-screen"/> + <example filename="../../pathstroke/pathstroke" name="Path Stroking" image="screenshots/pathstroke.png" args="-small-screen"/> + <example filename="../../../examples/widgets/wiggly/wiggly" name="Wiggly Text" image="screenshots/wiggly.png"/> + <example filename="../../../examples/painting/concentriccircles/concentriccircles" name="Concentric Circles" image="screenshots/concentriccircles.png"/> +<!-- + <example filename="../../../examples/graphicsview/elasticnodes/elasticnodes" name="Elastic Nodes" image="screenshots/elasticnodes.png" args="-maximize"/> + <example filename="../../../examples/assistant/simpletextviewer/simpletextviewer" name="Simple Text Viewer" image="../../../doc/html/images/simpletextviewer-mainwindow.png"/> + <example filename="../../../examples/dialogs/trivialwizard/trivialwizard" name="Trivial Wizard" image="../../../doc/html/images/trivialwizard-example-conclusion.png"/> + <example filename="../../../examples/draganddrop/draggableicons/draggableicons" name="Draggable Icons" image="../../../doc/html/images/draggableicons-example.png"/> + <example filename="../../../examples/draganddrop/draggabletext/draggabletext" name="Draggable Text" image="../../../doc/html/images/draggabletext-example.png"/> + <example filename="../../../examples/draganddrop/fridgemagnets/fridgemagnets" name="Fridge Magnets" image="../../../doc/html/images/fridgemagnets-example.png"/> + <example filename="../../../examples/graphicsview/collidingmice/collidingmice" name="Colliding Mice" image="../../../doc/html/images/collidingmice-example.png"/> + <example filename="../../../examples/graphicsview/padnavigator/padnavigator" name="Pad Navigator" image="../../../doc/html/images/padnavigator-example.png"/> + <example filename="../../../examples/itemviews/coloreditorfactory/coloreditorfactory" name="Color Editor" image="../../../doc/html/images/coloreditorfactoryimage.png"/> +--> + + </demos> + <slideshow timeout="60000" interval="10000"> + <imagedir dir="slides"/> + </slideshow> +</demolauncher> diff --git a/demos/embedded/fluidlauncher/config_wince/config.xml b/demos/embedded/fluidlauncher/config_wince/config.xml new file mode 100644 index 0000000..3b57770 --- /dev/null +++ b/demos/embedded/fluidlauncher/config_wince/config.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<demolauncher> + <demos> + <example filename="embeddedsvgviewer" name="SVG Viewer" image="screenshots/embeddedsvgviewer.png" args="shapes.svg"/> + <example filename="styledemo" name="Stylesheets" image="screenshots/styledemo.png"/> + <example filename="deform" name="Vector Deformation" image="screenshots/deform.png" args="-small-screen"/> + <example filename="pathstroke" name="Path Stroking" image="screenshots/pathstroke.png" args="-small-screen"/> + <example filename="wiggly" name="Wiggly Text" image="screenshots/wiggly.png"/> + </demos> + <slideshow timeout="60000" interval="10000"> + <imagedir dir="slides"/> + </slideshow> +</demolauncher> diff --git a/demos/embedded/fluidlauncher/demoapplication.cpp b/demos/embedded/fluidlauncher/demoapplication.cpp new file mode 100644 index 0000000..c5abfb9 --- /dev/null +++ b/demos/embedded/fluidlauncher/demoapplication.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QDebug> +#include <QDir> + +#include "demoapplication.h" + + + +DemoApplication::DemoApplication(QString executableName, QString caption, QString imageName, QStringList args) +{ + imagePath = imageName; + appCaption = caption; + + if (executableName[0] == QLatin1Char('/')) + executablePath = executableName; + else + executablePath = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + executableName); + + arguments = args; + + process.setProcessChannelMode(QProcess::ForwardedChannels); + + QObject::connect( &process, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(processFinished(int, QProcess::ExitStatus))); + + QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(processError(QProcess::ProcessError))); + + QObject::connect( &process, SIGNAL(started()), this, SLOT(processStarted())); +} + + +void DemoApplication::launch() +{ + process.start(executablePath, arguments); +} + +QImage* DemoApplication::getImage() +{ + return new QImage(imagePath); +} + +QString DemoApplication::getCaption() +{ + return appCaption; +} + +void DemoApplication::processFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + Q_UNUSED(exitCode); + Q_UNUSED(exitStatus); + + emit demoFinished(); + + QObject::disconnect(this, SIGNAL(demoStarted()), 0, 0); + QObject::disconnect(this, SIGNAL(demoFinished()), 0, 0); +} + +void DemoApplication::processError(QProcess::ProcessError err) +{ + qDebug() << "Process error: " << err; + if (err == QProcess::Crashed) + emit demoFinished(); +} + + +void DemoApplication::processStarted() +{ + emit demoStarted(); +} + + + + + + diff --git a/demos/embedded/fluidlauncher/demoapplication.h b/demos/embedded/fluidlauncher/demoapplication.h new file mode 100644 index 0000000..84ce1d4 --- /dev/null +++ b/demos/embedded/fluidlauncher/demoapplication.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DEMO_APPLICATION_H +#define DEMO_APPLICATION_H + +#include <QPixmap> +#include <QImage> +#include <QProcess> +#include <QObject> + +class DemoApplication : public QObject +{ + Q_OBJECT + +public: + DemoApplication(QString executableName, QString caption, QString imageName, QStringList args); + void launch(); + QImage* getImage(); + QString getCaption(); + +public slots: + void processStarted(); + void processFinished(int exitCode, QProcess::ExitStatus exitStatus); + void processError(QProcess::ProcessError err); + +signals: + void demoStarted(); + void demoFinished(); + +private: + QString imagePath; + QString appCaption; + QString executablePath; + QStringList arguments; + QProcess process; +}; + + + + +#endif + + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.cpp b/demos/embedded/fluidlauncher/fluidlauncher.cpp new file mode 100644 index 0000000..f80e6ca --- /dev/null +++ b/demos/embedded/fluidlauncher/fluidlauncher.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtXml> + +#include "fluidlauncher.h" + + +#define DEFAULT_INPUT_TIMEOUT 10000 + +FluidLauncher::FluidLauncher(QStringList* args) +{ + pictureFlowWidget = new PictureFlow(); + slideShowWidget = new SlideShow(); + inputTimer = new QTimer(); + + QRect screen_size = QApplication::desktop()->screenGeometry(); + + QObject::connect(pictureFlowWidget, SIGNAL(itemActivated(int)), this, SLOT(launchApplication(int))); + QObject::connect(pictureFlowWidget, SIGNAL(inputReceived()), this, SLOT(resetInputTimeout())); + QObject::connect(slideShowWidget, SIGNAL(inputReceived()), this, SLOT(switchToLauncher())); + QObject::connect(inputTimer, SIGNAL(timeout()), this, SLOT(inputTimedout())); + + inputTimer->setSingleShot(true); + inputTimer->setInterval(DEFAULT_INPUT_TIMEOUT); + + pictureFlowWidget->setSlideSize(QSize( (screen_size.width()*2)/5, (screen_size.height()*2)/5 )); + + bool success; + int configIndex = args->indexOf("-config"); + if ( (configIndex != -1) && (configIndex != args->count()-1) ) + success = loadConfig(args->at(configIndex+1)); + else + success = loadConfig("config.xml"); + + if (success) { + populatePictureFlow(); + + pictureFlowWidget->showFullScreen(); + inputTimer->start(); + } else { + pictureFlowWidget->setAttribute(Qt::WA_DeleteOnClose, true); + pictureFlowWidget->close(); + } + +} + +FluidLauncher::~FluidLauncher() +{ + delete pictureFlowWidget; + delete slideShowWidget; +} + +bool FluidLauncher::loadConfig(QString configPath) +{ + QFile xmlFile(configPath); + + if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) { + qDebug() << "ERROR: Unable to open config file " << configPath; + return false; + } + + slideShowWidget->clearImages(); + + QDomDocument xmlDoc; + xmlDoc.setContent(&xmlFile, true); + + QDomElement rootElement = xmlDoc.documentElement(); + + // Process the demos node: + QDomNodeList demoNodes = rootElement.firstChildElement("demos").elementsByTagName("example"); + for (int i=0; i<demoNodes.size(); i++) { + QDomElement element = demoNodes.item(i).toElement(); + + if (element.hasAttribute("filename")) { + DemoApplication* newDemo = new DemoApplication( + element.attribute("filename"), + element.attribute("name", "Unamed Demo"), + element.attribute("image"), + element.attribute("args").split(" ")); + demoList.append(newDemo); + } + } + + + // Process the slideshow node: + QDomElement slideshowElement = rootElement.firstChildElement("slideshow"); + + if (slideshowElement.hasAttribute("timeout")) { + bool valid; + int timeout = slideshowElement.attribute("timeout").toInt(&valid); + if (valid) + inputTimer->setInterval(timeout); + } + + if (slideshowElement.hasAttribute("interval")) { + bool valid; + int interval = slideshowElement.attribute("interval").toInt(&valid); + if (valid) + slideShowWidget->setSlideInterval(interval); + } + + for (QDomNode node=slideshowElement.firstChild(); !node.isNull(); node=node.nextSibling()) { + QDomElement element = node.toElement(); + + if (element.tagName() == "imagedir") + slideShowWidget->addImageDir(element.attribute("dir")); + else if (element.tagName() == "image") + slideShowWidget->addImage(element.attribute("image")); + } + + // Append an exit Item + DemoApplication* exitItem = new DemoApplication(QString(), QLatin1String("Exit Embedded Demo"), QString(), QStringList()); + demoList.append(exitItem); + + return true; +} + + +void FluidLauncher::populatePictureFlow() +{ + pictureFlowWidget->setSlideCount(demoList.count()); + + for (int i=demoList.count()-1; i>=0; --i) { + pictureFlowWidget->setSlide(i, *(demoList[i]->getImage())); + pictureFlowWidget->setSlideCaption(i, demoList[i]->getCaption()); + } + + pictureFlowWidget->setCurrentSlide(demoList.count()/2); +} + + +void FluidLauncher::launchApplication(int index) +{ + // NOTE: Clearing the caches will free up more memory for the demo but will cause + // a delay upon returning, as items are reloaded. + //pictureFlowWidget->clearCaches(); + + if (index == demoList.size() -1) { + qApp->quit(); + return; + } + + inputTimer->stop(); + pictureFlowWidget->hide(); + + QObject::connect(demoList[index], SIGNAL(demoFinished()), this, SLOT(demoFinished())); + + demoList[index]->launch(); +} + + +void FluidLauncher::switchToLauncher() +{ + slideShowWidget->stopShow(); + inputTimer->start(); +} + + +void FluidLauncher::resetInputTimeout() +{ + if (inputTimer->isActive()) + inputTimer->start(); +} + +void FluidLauncher::inputTimedout() +{ + switchToSlideshow(); +} + + +void FluidLauncher::switchToSlideshow() +{ + inputTimer->stop(); + slideShowWidget->startShow(); +} + +void FluidLauncher::demoFinished() +{ + pictureFlowWidget->showFullScreen(); + inputTimer->start(); +} + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.h b/demos/embedded/fluidlauncher/fluidlauncher.h new file mode 100644 index 0000000..3f4c1fe --- /dev/null +++ b/demos/embedded/fluidlauncher/fluidlauncher.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FLUID_LAUNCHER_H +#define FLUID_LAUNCHER_H + +#include <QtGui> +#include <QTimer> + +#include "pictureflow.h" +#include "slideshow.h" +#include "demoapplication.h" + +class FluidLauncher : public QObject +{ + Q_OBJECT + +public: + FluidLauncher(QStringList* args); + ~FluidLauncher(); + +public slots: + void launchApplication(int index); + void switchToLauncher(); + void resetInputTimeout(); + void inputTimedout(); + void demoFinished(); + +private: + PictureFlow* pictureFlowWidget; + SlideShow* slideShowWidget; + QTimer* inputTimer; + QList<DemoApplication*> demoList; + + bool loadConfig(QString configPath); + void populatePictureFlow(); + void switchToSlideshow(); + + +}; + + +#endif diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro new file mode 100644 index 0000000..76d12ad --- /dev/null +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -0,0 +1,56 @@ +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT += xml + +# Input +HEADERS += \ + demoapplication.h \ + fluidlauncher.h \ + pictureflow.h \ + slideshow.h + +SOURCES += \ + demoapplication.cpp \ + fluidlauncher.cpp \ + main.cpp \ + pictureflow.cpp \ + slideshow.cpp + +embedded{ + target.path = $$[QT_INSTALL_DEMOS]/embedded/fluidlauncher + sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro *.html config.xml screenshots slides + sources.path = $$[QT_INSTALL_DEMOS]/embedded/fluidlauncher + INSTALLS += target sources +} + +wince*{ + QT += svg + + BUILD_DIR = release + if(!debug_and_release|build_pass):CONFIG(debug, debug|release) { + BUILD_DIR = debug + } + + executables.sources = \ + $$QT_BUILD_TREE/demos/embedded/embeddedsvgviewer/$${BUILD_DIR}/embeddedsvgviewer.exe \ + $$QT_BUILD_TREE/demos/embedded/styledemo/$${BUILD_DIR}/styledemo.exe \ + $$QT_BUILD_TREE/demos/deform/$${BUILD_DIR}/deform.exe \ + $$QT_BUILD_TREE/demos/pathstroke/$${BUILD_DIR}/pathstroke.exe \ + $$QT_BUILD_TREE/examples/graphicsview/elasticnodes/$${BUILD_DIR}/elasticnodes.exe \ + $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/wiggly.exe \ + $$QT_BUILD_TREE/examples/painting/concentriccircles/$${BUILD_DIR}/concentriccircles.exe + + executables.path = . + + files.sources = $$PWD/screenshots $$PWD/slides $$PWD/../embeddedsvgviewer/shapes.svg + files.path = . + + config.sources = $$PWD/config_wince/config.xml + config.path = . + + DEPLOYMENT += config files executables + + DEPLOYMENT_PLUGIN += qgif qjpeg qmng qsvg +} diff --git a/demos/embedded/fluidlauncher/main.cpp b/demos/embedded/fluidlauncher/main.cpp new file mode 100644 index 0000000..05e820e --- /dev/null +++ b/demos/embedded/fluidlauncher/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QStringList> + +#include "fluidlauncher.h" + + +int main(int argc, char** argv) +{ + QStringList originalArgs; + + for (int i=0; i<argc; i++) + originalArgs << argv[i]; + + QApplication app(argc, argv); + FluidLauncher launcher(&originalArgs); + + + return app.exec(); +} diff --git a/demos/embedded/fluidlauncher/pictureflow.cpp b/demos/embedded/fluidlauncher/pictureflow.cpp new file mode 100644 index 0000000..04bbf05 --- /dev/null +++ b/demos/embedded/fluidlauncher/pictureflow.cpp @@ -0,0 +1,1420 @@ +/**************************************************************************** +** +* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) +* This is version of the Pictureflow animated image show widget modified by Nokia. +* +* $QT_BEGIN_LICENSE:LGPL$ +* No Commercial Usage +* This file contains pre-release code and may not be distributed. +* You may use this file in accordance with the terms and conditions +* contained in the either Technology Preview License Agreement or the +* Beta Release License Agreement. +* +* GNU Lesser General Public License Usage +* Alternatively, this file may be used under the terms of the GNU Lesser +* General Public License version 2.1 as published by the Free Software +* Foundation and appearing in the file LICENSE.LGPL included in the +* packaging of this file. Please review the following information to +* ensure the GNU Lesser General Public License version 2.1 requirements +* will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +* +* In addition, as a special exception, Nokia gives you certain +* additional rights. These rights are described in the Nokia Qt LGPL +* Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +* package. +* +* GNU General Public License Usage +* Alternatively, this file may be used under the terms of the GNU +* General Public License version 3.0 as published by the Free Software +* Foundation and appearing in the file LICENSE.GPL included in the +* packaging of this file. Please review the following information to +* ensure the GNU General Public License version 3.0 requirements will be +* met: http://www.gnu.org/copyleft/gpl.html. +* +* If you are unsure which license is appropriate for your use, please +* contact the sales department at qt-sales@nokia.com. +* $QT_END_LICENSE$ +* +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the <organization> nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY TROLLTECH ASA ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +****************************************************************************/ + +/* + ORIGINAL COPYRIGHT HEADER + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#include "pictureflow.h" + +#include <QBasicTimer> +#include <QCache> +#include <QImage> +#include <QKeyEvent> +#include <QPainter> +#include <QPixmap> +#include <QTimer> +#include <QVector> +#include <QWidget> +#include <QTime> + +#ifdef Q_WS_QWS +#include <QScreen> +#endif + +#include <QDebug> + +// uncomment this to enable bilinear filtering for texture mapping +// gives much better rendering, at the cost of memory space +// #define PICTUREFLOW_BILINEAR_FILTER + +// for fixed-point arithmetic, we need minimum 32-bit long +// long long (64-bit) might be useful for multiplication and division +typedef long PFreal; + +typedef unsigned short QRgb565; + +#define RGB565_RED_MASK 0xF800 +#define RGB565_GREEN_MASK 0x07E0 +#define RGB565_BLUE_MASK 0x001F + +#define RGB565_RED(col) ((col&RGB565_RED_MASK)>>11) +#define RGB565_GREEN(col) ((col&RGB565_GREEN_MASK)>>5) +#define RGB565_BLUE(col) (col&RGB565_BLUE_MASK) + +#define PFREAL_SHIFT 10 +#define PFREAL_FACTOR (1 << PFREAL_SHIFT) +#define PFREAL_ONE (1 << PFREAL_SHIFT) +#define PFREAL_HALF (PFREAL_ONE >> 1) + +inline PFreal fmul(PFreal a, PFreal b) +{ + return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT; +} + +inline PFreal fdiv(PFreal num, PFreal den) +{ + long long p = (long long)(num) << (PFREAL_SHIFT*2); + long long q = p / (long long)den; + long long r = q >> PFREAL_SHIFT; + + return r; +} + +inline float fixedToFloat(PFreal val) +{ + return ((float)val) / (float)PFREAL_ONE; +} + +inline PFreal floatToFixed(float val) +{ + return (PFreal)(val*PFREAL_ONE); +} + +#define IANGLE_MAX 1024 +#define IANGLE_MASK 1023 + +// warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! +static const PFreal sinTable[IANGLE_MAX] = { + 3, 9, 15, 21, 28, 34, 40, 47, + 53, 59, 65, 72, 78, 84, 90, 97, + 103, 109, 115, 122, 128, 134, 140, 147, + 153, 159, 165, 171, 178, 184, 190, 196, + 202, 209, 215, 221, 227, 233, 239, 245, + 251, 257, 264, 270, 276, 282, 288, 294, + 300, 306, 312, 318, 324, 330, 336, 342, + 347, 353, 359, 365, 371, 377, 383, 388, + 394, 400, 406, 412, 417, 423, 429, 434, + 440, 446, 451, 457, 463, 468, 474, 479, + 485, 491, 496, 501, 507, 512, 518, 523, + 529, 534, 539, 545, 550, 555, 561, 566, + 571, 576, 581, 587, 592, 597, 602, 607, + 612, 617, 622, 627, 632, 637, 642, 647, + 652, 656, 661, 666, 671, 675, 680, 685, + 690, 694, 699, 703, 708, 712, 717, 721, + 726, 730, 735, 739, 743, 748, 752, 756, + 760, 765, 769, 773, 777, 781, 785, 789, + 793, 797, 801, 805, 809, 813, 816, 820, + 824, 828, 831, 835, 839, 842, 846, 849, + 853, 856, 860, 863, 866, 870, 873, 876, + 879, 883, 886, 889, 892, 895, 898, 901, + 904, 907, 910, 913, 916, 918, 921, 924, + 927, 929, 932, 934, 937, 939, 942, 944, + 947, 949, 951, 954, 956, 958, 960, 963, + 965, 967, 969, 971, 973, 975, 977, 978, + 980, 982, 984, 986, 987, 989, 990, 992, + 994, 995, 997, 998, 999, 1001, 1002, 1003, + 1004, 1006, 1007, 1008, 1009, 1010, 1011, 1012, + 1013, 1014, 1015, 1015, 1016, 1017, 1018, 1018, + 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, + 1022, 1023, 1023, 1023, 1023, 1023, 1023, 1023, + 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1022, + 1022, 1022, 1021, 1021, 1020, 1020, 1019, 1019, + 1018, 1018, 1017, 1016, 1015, 1015, 1014, 1013, + 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1004, + 1003, 1002, 1001, 999, 998, 997, 995, 994, + 992, 990, 989, 987, 986, 984, 982, 980, + 978, 977, 975, 973, 971, 969, 967, 965, + 963, 960, 958, 956, 954, 951, 949, 947, + 944, 942, 939, 937, 934, 932, 929, 927, + 924, 921, 918, 916, 913, 910, 907, 904, + 901, 898, 895, 892, 889, 886, 883, 879, + 876, 873, 870, 866, 863, 860, 856, 853, + 849, 846, 842, 839, 835, 831, 828, 824, + 820, 816, 813, 809, 805, 801, 797, 793, + 789, 785, 781, 777, 773, 769, 765, 760, + 756, 752, 748, 743, 739, 735, 730, 726, + 721, 717, 712, 708, 703, 699, 694, 690, + 685, 680, 675, 671, 666, 661, 656, 652, + 647, 642, 637, 632, 627, 622, 617, 612, + 607, 602, 597, 592, 587, 581, 576, 571, + 566, 561, 555, 550, 545, 539, 534, 529, + 523, 518, 512, 507, 501, 496, 491, 485, + 479, 474, 468, 463, 457, 451, 446, 440, + 434, 429, 423, 417, 412, 406, 400, 394, + 388, 383, 377, 371, 365, 359, 353, 347, + 342, 336, 330, 324, 318, 312, 306, 300, + 294, 288, 282, 276, 270, 264, 257, 251, + 245, 239, 233, 227, 221, 215, 209, 202, + 196, 190, 184, 178, 171, 165, 159, 153, + 147, 140, 134, 128, 122, 115, 109, 103, + 97, 90, 84, 78, 72, 65, 59, 53, + 47, 40, 34, 28, 21, 15, 9, 3, + -4, -10, -16, -22, -29, -35, -41, -48, + -54, -60, -66, -73, -79, -85, -91, -98, + -104, -110, -116, -123, -129, -135, -141, -148, + -154, -160, -166, -172, -179, -185, -191, -197, + -203, -210, -216, -222, -228, -234, -240, -246, + -252, -258, -265, -271, -277, -283, -289, -295, + -301, -307, -313, -319, -325, -331, -337, -343, + -348, -354, -360, -366, -372, -378, -384, -389, + -395, -401, -407, -413, -418, -424, -430, -435, + -441, -447, -452, -458, -464, -469, -475, -480, + -486, -492, -497, -502, -508, -513, -519, -524, + -530, -535, -540, -546, -551, -556, -562, -567, + -572, -577, -582, -588, -593, -598, -603, -608, + -613, -618, -623, -628, -633, -638, -643, -648, + -653, -657, -662, -667, -672, -676, -681, -686, + -691, -695, -700, -704, -709, -713, -718, -722, + -727, -731, -736, -740, -744, -749, -753, -757, + -761, -766, -770, -774, -778, -782, -786, -790, + -794, -798, -802, -806, -810, -814, -817, -821, + -825, -829, -832, -836, -840, -843, -847, -850, + -854, -857, -861, -864, -867, -871, -874, -877, + -880, -884, -887, -890, -893, -896, -899, -902, + -905, -908, -911, -914, -917, -919, -922, -925, + -928, -930, -933, -935, -938, -940, -943, -945, + -948, -950, -952, -955, -957, -959, -961, -964, + -966, -968, -970, -972, -974, -976, -978, -979, + -981, -983, -985, -987, -988, -990, -991, -993, + -995, -996, -998, -999, -1000, -1002, -1003, -1004, + -1005, -1007, -1008, -1009, -1010, -1011, -1012, -1013, + -1014, -1015, -1016, -1016, -1017, -1018, -1019, -1019, + -1020, -1020, -1021, -1021, -1022, -1022, -1023, -1023, + -1023, -1024, -1024, -1024, -1024, -1024, -1024, -1024, + -1024, -1024, -1024, -1024, -1024, -1024, -1024, -1023, + -1023, -1023, -1022, -1022, -1021, -1021, -1020, -1020, + -1019, -1019, -1018, -1017, -1016, -1016, -1015, -1014, + -1013, -1012, -1011, -1010, -1009, -1008, -1007, -1005, + -1004, -1003, -1002, -1000, -999, -998, -996, -995, + -993, -991, -990, -988, -987, -985, -983, -981, + -979, -978, -976, -974, -972, -970, -968, -966, + -964, -961, -959, -957, -955, -952, -950, -948, + -945, -943, -940, -938, -935, -933, -930, -928, + -925, -922, -919, -917, -914, -911, -908, -905, + -902, -899, -896, -893, -890, -887, -884, -880, + -877, -874, -871, -867, -864, -861, -857, -854, + -850, -847, -843, -840, -836, -832, -829, -825, + -821, -817, -814, -810, -806, -802, -798, -794, + -790, -786, -782, -778, -774, -770, -766, -761, + -757, -753, -749, -744, -740, -736, -731, -727, + -722, -718, -713, -709, -704, -700, -695, -691, + -686, -681, -676, -672, -667, -662, -657, -653, + -648, -643, -638, -633, -628, -623, -618, -613, + -608, -603, -598, -593, -588, -582, -577, -572, + -567, -562, -556, -551, -546, -540, -535, -530, + -524, -519, -513, -508, -502, -497, -492, -486, + -480, -475, -469, -464, -458, -452, -447, -441, + -435, -430, -424, -418, -413, -407, -401, -395, + -389, -384, -378, -372, -366, -360, -354, -348, + -343, -337, -331, -325, -319, -313, -307, -301, + -295, -289, -283, -277, -271, -265, -258, -252, + -246, -240, -234, -228, -222, -216, -210, -203, + -197, -191, -185, -179, -172, -166, -160, -154, + -148, -141, -135, -129, -123, -116, -110, -104, + -98, -91, -85, -79, -73, -66, -60, -54, + -48, -41, -35, -29, -22, -16, -10, -4 +}; + +// this is the program the generate the above table +#if 0 +#include <stdio.h> +#include <math.h> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define PFREAL_ONE 1024 +#define IANGLE_MAX 1024 + +int main(int, char**) +{ + FILE*f = fopen("table.c","wt"); + fprintf(f,"PFreal sinTable[] = {\n"); + for(int i = 0; i < 128; i++) + { + for(int j = 0; j < 8; j++) + { + int iang = j+i*8; + double ii = (double)iang + 0.5; + double angle = ii * 2 * M_PI / IANGLE_MAX; + double sinAngle = sin(angle); + fprintf(f,"%6d, ", (int)(floor(PFREAL_ONE*sinAngle))); + } + fprintf(f,"\n"); + } + fprintf(f,"};\n"); + fclose(f); + + return 0; +} +#endif + +inline PFreal fsin(int iangle) +{ + while(iangle < 0) + iangle += IANGLE_MAX; + return sinTable[iangle & IANGLE_MASK]; +} + +inline PFreal fcos(int iangle) +{ + // quarter phase shift + return fsin(iangle + (IANGLE_MAX >> 2)); +} + +struct SlideInfo +{ + int slideIndex; + int angle; + PFreal cx; + PFreal cy; +}; + +class PictureFlowPrivate +{ +public: + PictureFlowPrivate(PictureFlow* widget); + + int slideCount() const; + void setSlideCount(int count); + + QSize slideSize() const; + void setSlideSize(QSize size); + + int zoomFactor() const; + void setZoomFactor(int z); + + QImage slide(int index) const; + void setSlide(int index, const QImage& image); + + int currentSlide() const; + void setCurrentSlide(int index); + + int getTarget() const; + + void showPrevious(); + void showNext(); + void showSlide(int index); + + void resize(int w, int h); + + void render(); + void startAnimation(); + void updateAnimation(); + + void clearSurfaceCache(); + + QImage buffer; + QBasicTimer animateTimer; + + bool singlePress; + int singlePressThreshold; + QPoint firstPress; + QPoint previousPos; + QTime previousPosTimestamp; + int pixelDistanceMoved; + int pixelsToMovePerSlide; + + QVector<QString> captions; + +private: + PictureFlow* widget; + + int slideWidth; + int slideHeight; + int zoom; + + QVector<QImage> slideImages; + int centerIndex; + SlideInfo centerSlide; + QVector<SlideInfo> leftSlides; + QVector<SlideInfo> rightSlides; + + QVector<PFreal> rays; + int itilt; + int spacing; + PFreal offsetX; + PFreal offsetY; + + QImage blankSurface; + QCache<int, QImage> surfaceCache; + QTimer triggerTimer; + + int slideFrame; + int step; + int target; + int fade; + + void recalc(int w, int h); + QRect renderSlide(const SlideInfo &slide, int alpha=256, int col1=-1, int col=-1); + QImage* surface(int slideIndex); + void triggerRender(); + void resetSlides(); +}; + +PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w) +{ + widget = w; + + slideWidth = 200; + slideHeight = 200; + zoom = 100; + + centerIndex = 0; + + slideFrame = 0; + step = 0; + target = 0; + fade = 256; + + triggerTimer.setSingleShot(true); + triggerTimer.setInterval(0); + QObject::connect(&triggerTimer, SIGNAL(timeout()), widget, SLOT(render())); + + recalc(200, 200); + resetSlides(); +} + +int PictureFlowPrivate::slideCount() const +{ + return slideImages.count(); +} + +void PictureFlowPrivate::setSlideCount(int count) +{ + slideImages.resize(count); + captions.resize(count); + surfaceCache.clear(); + resetSlides(); + triggerRender(); +} + +QSize PictureFlowPrivate::slideSize() const +{ + return QSize(slideWidth, slideHeight); +} + +void PictureFlowPrivate::setSlideSize(QSize size) +{ + slideWidth = size.width(); + slideHeight = size.height(); + recalc(buffer.width(), buffer.height()); + triggerRender(); +} + +int PictureFlowPrivate::zoomFactor() const +{ + return zoom; +} + +void PictureFlowPrivate::setZoomFactor(int z) +{ + if(z <= 0) + return; + + zoom = z; + recalc(buffer.width(), buffer.height()); + triggerRender(); +} + +QImage PictureFlowPrivate::slide(int index) const +{ + return slideImages[index]; +} + +void PictureFlowPrivate::setSlide(int index, const QImage& image) +{ + if((index >= 0) && (index < slideImages.count())) + { + slideImages[index] = image; + surfaceCache.remove(index); + triggerRender(); + } +} + +int PictureFlowPrivate::getTarget() const +{ + return target; +} + +int PictureFlowPrivate::currentSlide() const +{ + return centerIndex; +} + +void PictureFlowPrivate::setCurrentSlide(int index) +{ + step = 0; + centerIndex = qBound(index, 0, slideImages.count()-1); + target = centerIndex; + slideFrame = index << 16; + resetSlides(); + triggerRender(); +} + +void PictureFlowPrivate::showPrevious() +{ + if(step >= 0) + { + if(centerIndex > 0) + { + target--; + startAnimation(); + } + } + else + { + target = qMax(0, centerIndex - 2); + } +} + +void PictureFlowPrivate::showNext() +{ + if(step <= 0) + { + if(centerIndex < slideImages.count()-1) + { + target++; + startAnimation(); + } + } + else + { + target = qMin(centerIndex + 2, slideImages.count()-1); + } +} + +void PictureFlowPrivate::showSlide(int index) +{ + index = qMax(index, 0); + index = qMin(slideImages.count()-1, index); + if(index == centerSlide.slideIndex) + return; + + target = index; + startAnimation(); +} + +void PictureFlowPrivate::resize(int w, int h) +{ + recalc(w, h); + resetSlides(); + triggerRender(); +} + + +// adjust slides so that they are in "steady state" position +void PictureFlowPrivate::resetSlides() +{ + centerSlide.angle = 0; + centerSlide.cx = 0; + centerSlide.cy = 0; + centerSlide.slideIndex = centerIndex; + + leftSlides.clear(); + leftSlides.resize(3); + for(int i = 0; i < leftSlides.count(); i++) + { + SlideInfo& si = leftSlides[i]; + si.angle = itilt; + si.cx = -(offsetX + spacing*i*PFREAL_ONE); + si.cy = offsetY; + si.slideIndex = centerIndex-1-i; + //qDebug() << "Left[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; + } + + rightSlides.clear(); + rightSlides.resize(3); + for(int i = 0; i < rightSlides.count(); i++) + { + SlideInfo& si = rightSlides[i]; + si.angle = -itilt; + si.cx = offsetX + spacing*i*PFREAL_ONE; + si.cy = offsetY; + si.slideIndex = centerIndex+1+i; + //qDebug() << "Right[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; + } +} + +#define BILINEAR_STRETCH_HOR 4 +#define BILINEAR_STRETCH_VER 4 + +static QImage prepareSurface(QImage img, int w, int h) +{ + Qt::TransformationMode mode = Qt::SmoothTransformation; + img = img.scaled(w, h, Qt::IgnoreAspectRatio, mode); + + // slightly larger, to accomodate for the reflection + int hs = h * 2; + int hofs = h / 3; + + // offscreen buffer: black is sweet + QImage result(hs, w, QImage::Format_RGB16); + result.fill(0); + + // transpose the image, this is to speed-up the rendering + // because we process one column at a time + // (and much better and faster to work row-wise, i.e in one scanline) + for(int x = 0; x < w; x++) + for(int y = 0; y < h; y++) + result.setPixel(hofs + y, x, img.pixel(x, y)); + + // create the reflection + int ht = hs - h - hofs; + int hte = ht; + for(int x = 0; x < w; x++) + for(int y = 0; y < ht; y++) + { + QRgb color = img.pixel(x, img.height()-y-1); + //QRgb565 color = img.scanLine(img.height()-y-1) + x*sizeof(QRgb565); //img.pixel(x, img.height()-y-1); + int a = qAlpha(color); + int r = qRed(color) * a / 256 * (hte - y) / hte * 3/5; + int g = qGreen(color) * a / 256 * (hte - y) / hte * 3/5; + int b = qBlue(color) * a / 256 * (hte - y) / hte * 3/5; + result.setPixel(h+hofs+y, x, qRgb(r, g, b)); + } + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int hh = BILINEAR_STRETCH_VER*hs; + int ww = BILINEAR_STRETCH_HOR*w; + result = result.scaled(hh, ww, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); +#endif + + return result; +} + + +// get transformed image for specified slide +// if it does not exist, create it and place it in the cache +QImage* PictureFlowPrivate::surface(int slideIndex) +{ + if(slideIndex < 0) + return 0; + if(slideIndex >= slideImages.count()) + return 0; + + if(surfaceCache.contains(slideIndex)) + return surfaceCache[slideIndex]; + + QImage img = widget->slide(slideIndex); + if(img.isNull()) + { + if(blankSurface.isNull()) + { + blankSurface = QImage(slideWidth, slideHeight, QImage::Format_RGB16); + + QPainter painter(&blankSurface); + QPoint p1(slideWidth*4/10, 0); + QPoint p2(slideWidth*6/10, slideHeight); + QLinearGradient linearGrad(p1, p2); + linearGrad.setColorAt(0, Qt::black); + linearGrad.setColorAt(1, Qt::white); + painter.setBrush(linearGrad); + painter.fillRect(0, 0, slideWidth, slideHeight, QBrush(linearGrad)); + + painter.setPen(QPen(QColor(64,64,64), 4)); + painter.setBrush(QBrush()); + painter.drawRect(2, 2, slideWidth-3, slideHeight-3); + painter.end(); + blankSurface = prepareSurface(blankSurface, slideWidth, slideHeight); + } + return &blankSurface; + } + + surfaceCache.insert(slideIndex, new QImage(prepareSurface(img, slideWidth, slideHeight))); + return surfaceCache[slideIndex]; +} + + +// Schedules rendering the slides. Call this function to avoid immediate +// render and thus cause less flicker. +void PictureFlowPrivate::triggerRender() +{ + triggerTimer.start(); +} + +// Render the slides. Updates only the offscreen buffer. +void PictureFlowPrivate::render() +{ + buffer.fill(0); + + int nleft = leftSlides.count(); + int nright = rightSlides.count(); + + QRect r = renderSlide(centerSlide); + int c1 = r.left(); + int c2 = r.right(); + + if(step == 0) + { + // no animation, boring plain rendering + for(int index = 0; index < nleft-1; index++) + { + int alpha = (index < nleft-2) ? 256 : 128; + QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); + if(!rs.isEmpty()) + c1 = rs.left(); + } + for(int index = 0; index < nright-1; index++) + { + int alpha = (index < nright-2) ? 256 : 128; + QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); + if(!rs.isEmpty()) + c2 = rs.right(); + } + + QPainter painter; + painter.begin(&buffer); + + QFont font("Arial", 14); + font.setBold(true); + painter.setFont(font); + painter.setPen(Qt::white); + //painter.setPen(QColor(255,255,255,127)); + + if (!captions.isEmpty()) + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2), + Qt::AlignCenter, captions[centerIndex]); + + painter.end(); + + } + else + { + // the first and last slide must fade in/fade out + for(int index = 0; index < nleft; index++) + { + int alpha = 256; + if(index == nleft-1) + alpha = (step > 0) ? 0 : 128-fade/2; + if(index == nleft-2) + alpha = (step > 0) ? 128-fade/2 : 256-fade/2; + if(index == nleft-3) + alpha = (step > 0) ? 256-fade/2 : 256; + QRect rs = renderSlide(leftSlides[index], alpha, 0, c1-1); + if(!rs.isEmpty()) + c1 = rs.left(); + + alpha = (step > 0) ? 256-fade/2 : 256; + } + for(int index = 0; index < nright; index++) + { + int alpha = (index < nright-2) ? 256 : 128; + if(index == nright-1) + alpha = (step > 0) ? fade/2 : 0; + if(index == nright-2) + alpha = (step > 0) ? 128+fade/2 : fade/2; + if(index == nright-3) + alpha = (step > 0) ? 256 : 128+fade/2; + QRect rs = renderSlide(rightSlides[index], alpha, c2+1, buffer.width()); + if(!rs.isEmpty()) + c2 = rs.right(); + } + + + + QPainter painter; + painter.begin(&buffer); + + QFont font("Arial", 14); + font.setBold(true); + painter.setFont(font); + + int leftTextIndex = (step>0) ? centerIndex : centerIndex-1; + + painter.setPen(QColor(255,255,255, (255-fade) )); + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2), + Qt::AlignCenter, captions[leftTextIndex]); + + painter.setPen(QColor(255,255,255, fade)); + painter.drawText( QRect(0,0, buffer.width(), (buffer.height() - slideSize().height())/2), + Qt::AlignCenter, captions[leftTextIndex+1]); + + + painter.end(); + } +} + + +static inline uint BYTE_MUL_RGB16(uint x, uint a) { + a += 1; + uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0; + t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f; + return t; +} + +static inline uint BYTE_MUL_RGB16_32(uint x, uint a) { + uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0; + t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f; + return t; +} + + +// Renders a slide to offscreen buffer. Returns a rect of the rendered area. +// alpha=256 means normal, alpha=0 is fully black, alpha=128 half transparent +// col1 and col2 limit the column for rendering. +QRect PictureFlowPrivate::renderSlide(const SlideInfo &slide, int alpha, +int col1, int col2) +{ + QImage* src = surface(slide.slideIndex); + if(!src) + return QRect(); + + QRect rect(0, 0, 0, 0); + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int sw = src->height() / BILINEAR_STRETCH_HOR; + int sh = src->width() / BILINEAR_STRETCH_VER; +#else + int sw = src->height(); + int sh = src->width(); +#endif + int h = buffer.height(); + int w = buffer.width(); + + if(col1 > col2) + { + int c = col2; + col2 = col1; + col1 = c; + } + + col1 = (col1 >= 0) ? col1 : 0; + col2 = (col2 >= 0) ? col2 : w-1; + col1 = qMin(col1, w-1); + col2 = qMin(col2, w-1); + + int distance = h * 100 / zoom; + PFreal sdx = fcos(slide.angle); + PFreal sdy = fsin(slide.angle); + PFreal xs = slide.cx - slideWidth * sdx/2; + PFreal ys = slide.cy - slideWidth * sdy/2; + PFreal dist = distance * PFREAL_ONE; + + int xi = qMax((PFreal)0, ((w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys)) >> PFREAL_SHIFT); + if(xi >= w) + return rect; + + bool flag = false; + rect.setLeft(xi); + for(int x = qMax(xi, col1); x <= col2; x++) + { + PFreal hity = 0; + PFreal fk = rays[x]; + if(sdy) + { + fk = fk - fdiv(sdx,sdy); + hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk); + } + + dist = distance*PFREAL_ONE + hity; + if(dist < 0) + continue; + + PFreal hitx = fmul(dist, rays[x]); + PFreal hitdist = fdiv(hitx - slide.cx, sdx); + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int column = sw*BILINEAR_STRETCH_HOR/2 + (hitdist*BILINEAR_STRETCH_HOR >> PFREAL_SHIFT); + if(column >= sw*BILINEAR_STRETCH_HOR) + break; +#else + int column = sw/2 + (hitdist >> PFREAL_SHIFT); + if(column >= sw) + break; +#endif + if(column < 0) + continue; + + rect.setRight(x); + if(!flag) + rect.setLeft(x); + flag = true; + + int y1 = h/2; + int y2 = y1+ 1; + QRgb565* pixel1 = (QRgb565*)(buffer.scanLine(y1)) + x; + QRgb565* pixel2 = (QRgb565*)(buffer.scanLine(y2)) + x; + int pixelstep = pixel2 - pixel1; + +#ifdef PICTUREFLOW_BILINEAR_FILTER + int center = (sh*BILINEAR_STRETCH_VER/2); + int dy = dist*BILINEAR_STRETCH_VER / h; +#else + int center = (sh/2); + int dy = dist / h; +#endif + int p1 = center*PFREAL_ONE - dy/2; + int p2 = center*PFREAL_ONE + dy/2; + + const QRgb565 *ptr = (const QRgb565*)(src->scanLine(column)); + if(alpha == 256) + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + *pixel1 = ptr[p1 >> PFREAL_SHIFT]; + *pixel2 = ptr[p2 >> PFREAL_SHIFT]; + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + else + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + QRgb565 c1 = ptr[p1 >> PFREAL_SHIFT]; + QRgb565 c2 = ptr[p2 >> PFREAL_SHIFT]; + + *pixel1 = BYTE_MUL_RGB16(c1, alpha); + *pixel2 = BYTE_MUL_RGB16(c2, alpha); + +/* + int r1 = qRed(c1) * alpha/256; + int g1 = qGreen(c1) * alpha/256; + int b1 = qBlue(c1) * alpha/256; + int r2 = qRed(c2) * alpha/256; + int g2 = qGreen(c2) * alpha/256; + int b2 = qBlue(c2) * alpha/256; + *pixel1 = qRgb(r1, g1, b1); + *pixel2 = qRgb(r2, g2, b2); +*/ + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + } + + rect.setTop(0); + rect.setBottom(h-1); + return rect; +} + +// Updates look-up table and other stuff necessary for the rendering. +// Call this when the viewport size or slide dimension is changed. +void PictureFlowPrivate::recalc(int ww, int wh) +{ + int w = (ww+1)/2; + int h = (wh+1)/2; + buffer = QImage(ww, wh, QImage::Format_RGB16); + buffer.fill(0); + + rays.resize(w*2); + + for(int i = 0; i < w; i++) + { + PFreal gg = (PFREAL_HALF + i * PFREAL_ONE) / (2*h); + rays[w-i-1] = -gg; + rays[w+i] = gg; + } + + // pointer must move more than 1/15 of the window to enter drag mode + singlePressThreshold = ww / 15; +// qDebug() << "singlePressThreshold now set to " << singlePressThreshold; + + pixelsToMovePerSlide = ww / 3; +// qDebug() << "pixelsToMovePerSlide now set to " << pixelsToMovePerSlide; + + itilt = 80 * IANGLE_MAX / 360; // approx. 80 degrees tilted + + offsetY = slideWidth/2 * fsin(itilt); + offsetY += slideWidth * PFREAL_ONE / 4; + +// offsetX = slideWidth/2 * (PFREAL_ONE-fcos(itilt)); +// offsetX += slideWidth * PFREAL_ONE; + + // center slide + side slide + offsetX = slideWidth*PFREAL_ONE; +// offsetX = 150*PFREAL_ONE;//(slideWidth/2)*PFREAL_ONE + ( slideWidth*fcos(itilt) )/2; +// qDebug() << "center width = " << slideWidth; +// qDebug() << "side width = " << fixedToFloat(slideWidth/2 * (PFREAL_ONE-fcos(itilt))); +// qDebug() << "offsetX now " << fixedToFloat(offsetX); + + spacing = slideWidth/5; + + surfaceCache.clear(); + blankSurface = QImage(); +} + +void PictureFlowPrivate::startAnimation() +{ + if(!animateTimer.isActive()) + { + step = (target < centerSlide.slideIndex) ? -1 : 1; + animateTimer.start(30, widget); + } +} + +// Updates the animation effect. Call this periodically from a timer. +void PictureFlowPrivate::updateAnimation() +{ + if(!animateTimer.isActive()) + return; + if(step == 0) + return; + + int speed = 16384; + + // deaccelerate when approaching the target + if(true) + { + const int max = 2 * 65536; + + int fi = slideFrame; + fi -= (target << 16); + if(fi < 0) + fi = -fi; + fi = qMin(fi, max); + + int ia = IANGLE_MAX * (fi-max/2) / (max*2); + speed = 512 + 16384 * (PFREAL_ONE+fsin(ia))/PFREAL_ONE; + } + + slideFrame += speed*step; + + int index = slideFrame >> 16; + int pos = slideFrame & 0xffff; + int neg = 65536 - pos; + int tick = (step < 0) ? neg : pos; + PFreal ftick = (tick * PFREAL_ONE) >> 16; + + // the leftmost and rightmost slide must fade away + fade = pos / 256; + + if(step < 0) + index++; + if(centerIndex != index) + { + centerIndex = index; + slideFrame = index << 16; + centerSlide.slideIndex = centerIndex; + for(int i = 0; i < leftSlides.count(); i++) + leftSlides[i].slideIndex = centerIndex-1-i; + for(int i = 0; i < rightSlides.count(); i++) + rightSlides[i].slideIndex = centerIndex+1+i; + } + + centerSlide.angle = (step * tick * itilt) >> 16; + centerSlide.cx = -step * fmul(offsetX, ftick); + centerSlide.cy = fmul(offsetY, ftick); + + if(centerIndex == target) + { + resetSlides(); + animateTimer.stop(); + triggerRender(); + step = 0; + fade = 256; + return; + } + + for(int i = 0; i < leftSlides.count(); i++) + { + SlideInfo& si = leftSlides[i]; + si.angle = itilt; + si.cx = -(offsetX + spacing*i*PFREAL_ONE + step*spacing*ftick); + si.cy = offsetY; + } + + for(int i = 0; i < rightSlides.count(); i++) + { + SlideInfo& si = rightSlides[i]; + si.angle = -itilt; + si.cx = offsetX + spacing*i*PFREAL_ONE - step*spacing*ftick; + si.cy = offsetY; + } + + if(step > 0) + { + PFreal ftick = (neg * PFREAL_ONE) >> 16; + rightSlides[0].angle = -(neg * itilt) >> 16; + rightSlides[0].cx = fmul(offsetX, ftick); + rightSlides[0].cy = fmul(offsetY, ftick); + } + else + { + PFreal ftick = (pos * PFREAL_ONE) >> 16; + leftSlides[0].angle = (pos * itilt) >> 16; + leftSlides[0].cx = -fmul(offsetX, ftick); + leftSlides[0].cy = fmul(offsetY, ftick); + } + + // must change direction ? + if(target < index) if(step > 0) + step = -1; + if(target > index) if(step < 0) + step = 1; + + triggerRender(); +} + + +void PictureFlowPrivate::clearSurfaceCache() +{ + surfaceCache.clear(); +} + +// ----------------------------------------- + +PictureFlow::PictureFlow(QWidget* parent): QWidget(parent) +{ + d = new PictureFlowPrivate(this); + + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + +#ifdef Q_WS_QWS + if (QScreen::instance()->pixelFormat() != QImage::Format_Invalid) + setAttribute(Qt::WA_PaintOnScreen, true); +#endif +} + +PictureFlow::~PictureFlow() +{ + delete d; +} + +int PictureFlow::slideCount() const +{ + return d->slideCount(); +} + +void PictureFlow::setSlideCount(int count) +{ + d->setSlideCount(count); +} + +QSize PictureFlow::slideSize() const +{ + return d->slideSize(); +} + +void PictureFlow::setSlideSize(QSize size) +{ + d->setSlideSize(size); +} + +int PictureFlow::zoomFactor() const +{ + return d->zoomFactor(); +} + +void PictureFlow::setZoomFactor(int z) +{ + d->setZoomFactor(z); +} + +QImage PictureFlow::slide(int index) const +{ + return d->slide(index); +} + +void PictureFlow::setSlide(int index, const QImage& image) +{ + d->setSlide(index, image); +} + +void PictureFlow::setSlide(int index, const QPixmap& pixmap) +{ + d->setSlide(index, pixmap.toImage()); +} + +void PictureFlow::setSlideCaption(int index, QString caption) +{ + d->captions[index] = caption; +} + + +int PictureFlow::currentSlide() const +{ + return d->currentSlide(); +} + +void PictureFlow::setCurrentSlide(int index) +{ + d->setCurrentSlide(index); +} + +void PictureFlow::clear() +{ + d->setSlideCount(0); +} + +void PictureFlow::clearCaches() +{ + d->clearSurfaceCache(); +} + +void PictureFlow::render() +{ + d->render(); + update(); +} + +void PictureFlow::showPrevious() +{ + d->showPrevious(); +} + +void PictureFlow::showNext() +{ + d->showNext(); +} + +void PictureFlow::showSlide(int index) +{ + d->showSlide(index); +} + +void PictureFlow::keyPressEvent(QKeyEvent* event) +{ + if(event->key() == Qt::Key_Left) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(currentSlide()-10); + else + showPrevious(); + event->accept(); + return; + } + + if(event->key() == Qt::Key_Right) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(currentSlide()+10); + else + showNext(); + event->accept(); + return; + } + + event->ignore(); +} + +#define SPEED_LOWER_THRESHOLD 10 +#define SPEED_UPPER_LIMIT 40 + +void PictureFlow::mouseMoveEvent(QMouseEvent* event) +{ + int distanceMovedSinceLastEvent = event->pos().x() - d->previousPos.x(); + + // Check to see if we need to switch from single press mode to a drag mode + if (d->singlePress) + { + // Increment the distance moved for this event + d->pixelDistanceMoved += distanceMovedSinceLastEvent; + + // Check against threshold + if (qAbs(d->pixelDistanceMoved) > d->singlePressThreshold) + { + d->singlePress = false; +// qDebug() << "DRAG MODE ON"; + } + } + + if (!d->singlePress) + { + int speed; + // Calculate velocity in a 10th of a window width per second + if (d->previousPosTimestamp.elapsed() == 0) + speed = SPEED_LOWER_THRESHOLD; + else + { + speed = ((qAbs(event->pos().x()-d->previousPos.x())*1000) / d->previousPosTimestamp.elapsed()) + / (d->buffer.width() / 10); + + if (speed < SPEED_LOWER_THRESHOLD) + speed = SPEED_LOWER_THRESHOLD; + else if (speed > SPEED_UPPER_LIMIT) + speed = SPEED_UPPER_LIMIT; + else { + speed = SPEED_LOWER_THRESHOLD + (speed / 3); +// qDebug() << "ACCELERATION ENABLED Speed = " << speed << ", Distance = " << distanceMovedSinceLastEvent; + + } + } + + +// qDebug() << "Speed = " << speed; + +// int incr = ((event->pos().x() - d->previousPos.x())/10) * speed; + +// qDebug() << "Incremented by " << incr; + + int incr = (distanceMovedSinceLastEvent * speed); + + //qDebug() << "(distanceMovedSinceLastEvent * speed) = " << incr; + + if (incr > d->pixelsToMovePerSlide*2) { + incr = d->pixelsToMovePerSlide*2; + //qDebug() << "Limiting incr to " << incr; + } + + + d->pixelDistanceMoved += (distanceMovedSinceLastEvent * speed); + // qDebug() << "distance: " << d->pixelDistanceMoved; + + int slideInc; + + slideInc = d->pixelDistanceMoved / (d->pixelsToMovePerSlide * 10); + + if (slideInc != 0) { + int targetSlide = d->getTarget() - slideInc; + showSlide(targetSlide); +// qDebug() << "TargetSlide = " << targetSlide; + + //qDebug() << "Decrementing pixelDistanceMoved by " << (d->pixelsToMovePerSlide *10) * slideInc; + + d->pixelDistanceMoved -= (d->pixelsToMovePerSlide *10) * slideInc; + +/* + if ( (targetSlide <= 0) || (targetSlide >= d->slideCount()-1) ) + d->pixelDistanceMoved = 0; +*/ + } + + + } + + d->previousPos = event->pos(); + d->previousPosTimestamp.restart(); + + emit inputReceived(); +} + +void PictureFlow::mousePressEvent(QMouseEvent* event) +{ + d->firstPress = event->pos(); + d->previousPos = event->pos(); + d->previousPosTimestamp.start(); + d->singlePress = true; // Initially assume a single press +// d->dragStartSlide = d->getTarget(); + d->pixelDistanceMoved = 0; + + emit inputReceived(); +} + +void PictureFlow::mouseReleaseEvent(QMouseEvent* event) +{ + int sideWidth = (d->buffer.width() - slideSize().width()) /2; + + if (d->singlePress) + { + if (event->x() < sideWidth ) + { + showPrevious(); + } else if ( event->x() > sideWidth + slideSize().width() ) { + showNext(); + } else { + emit itemActivated(d->getTarget()); + } + + event->accept(); + } + + emit inputReceived(); +} + + +void PictureFlow::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, false); + painter.drawImage(QPoint(0,0), d->buffer); +} + +void PictureFlow::resizeEvent(QResizeEvent* event) +{ + d->resize(width(), height()); + QWidget::resizeEvent(event); +} + +void PictureFlow::timerEvent(QTimerEvent* event) +{ + if(event->timerId() == d->animateTimer.timerId()) + { +// QTime now = QTime::currentTime(); + d->updateAnimation(); +// d->animateTimer.start(qMax(0, 30-now.elapsed() ), this); + } + else + QWidget::timerEvent(event); +} diff --git a/demos/embedded/fluidlauncher/pictureflow.h b/demos/embedded/fluidlauncher/pictureflow.h new file mode 100644 index 0000000..fccc7a3 --- /dev/null +++ b/demos/embedded/fluidlauncher/pictureflow.h @@ -0,0 +1,237 @@ +/**************************************************************************** +* +* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) +* This is version of the Pictureflow animated image show widget modified by Nokia. +* +* $QT_BEGIN_LICENSE:LGPL$ +* No Commercial Usage +* This file contains pre-release code and may not be distributed. +* You may use this file in accordance with the terms and conditions +* contained in the either Technology Preview License Agreement or the +* Beta Release License Agreement. +* +* GNU Lesser General Public License Usage +* Alternatively, this file may be used under the terms of the GNU Lesser +* General Public License version 2.1 as published by the Free Software +* Foundation and appearing in the file LICENSE.LGPL included in the +* packaging of this file. Please review the following information to +* ensure the GNU Lesser General Public License version 2.1 requirements +* will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +* +* In addition, as a special exception, Nokia gives you certain +* additional rights. These rights are described in the Nokia Qt LGPL +* Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +* package. +* +* GNU General Public License Usage +* Alternatively, this file may be used under the terms of the GNU +* General Public License version 3.0 as published by the Free Software +* Foundation and appearing in the file LICENSE.GPL included in the +* packaging of this file. Please review the following information to +* ensure the GNU General Public License version 3.0 requirements will be +* met: http://www.gnu.org/copyleft/gpl.html. +* +* If you are unsure which license is appropriate for your use, please +* contact the sales department at qt-sales@nokia.com. +* $QT_END_LICENSE$ +* +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the <organization> nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY TROLLTECH ASA ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +****************************************************************************/ +/* + ORIGINAL COPYRIGHT HEADER + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef PICTUREFLOW_H +#define PICTUREFLOW_H + +#include <QWidget> + +class PictureFlowPrivate; + +/*! + Class PictureFlow implements an image show widget with animation effect + like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form + of slides, one main slide is shown at the center with few slides on + the left and right sides of the center slide. When the next or previous + slide is brought to the front, the whole slides flow to the right or + the right with smooth animation effect; until the new slide is finally + placed at the center. + + */ +class PictureFlow : public QWidget +{ +Q_OBJECT + + Q_PROPERTY(int slideCount READ slideCount WRITE setSlideCount) + Q_PROPERTY(int currentSlide READ currentSlide WRITE setCurrentSlide) + Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) + Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor) + +public: + /*! + Creates a new PictureFlow widget. + */ + PictureFlow(QWidget* parent = 0); + + /*! + Destroys the widget. + */ + ~PictureFlow(); + + /*! + Returns the total number of slides. + */ + int slideCount() const; + + /*! + Sets the total number of slides. + */ + void setSlideCount(int count); + + /*! + Returns the dimension of each slide (in pixels). + */ + QSize slideSize() const; + + /*! + Sets the dimension of each slide (in pixels). + */ + void setSlideSize(QSize size); + + /*! + Sets the zoom factor (in percent). + */ + void setZoomFactor(int zoom); + + /*! + Returns the zoom factor (in percent). + */ + int zoomFactor() const; + + /*! + Clears any caches held to free up memory + */ + void clearCaches(); + + /*! + Returns QImage of specified slide. + This function will be called only whenever necessary, e.g. the 100th slide + will not be retrived when only the first few slides are visible. + */ + virtual QImage slide(int index) const; + + /*! + Sets an image for specified slide. If the slide already exists, + it will be replaced. + */ + virtual void setSlide(int index, const QImage& image); + + virtual void setSlideCaption(int index, QString caption); + + /*! + Sets a pixmap for specified slide. If the slide already exists, + it will be replaced. + */ + virtual void setSlide(int index, const QPixmap& pixmap); + + /*! + Returns the index of slide currently shown in the middle of the viewport. + */ + int currentSlide() const; + +public slots: + + /*! + Sets slide to be shown in the middle of the viewport. No animation + effect will be produced, unlike using showSlide. + */ + void setCurrentSlide(int index); + + /*! + Clears images of all slides. + */ + void clear(); + + /*! + Rerender the widget. Normally this function will be automatically invoked + whenever necessary, e.g. during the transition animation. + */ + void render(); + + /*! + Shows previous slide using animation effect. + */ + void showPrevious(); + + /*! + Shows next slide using animation effect. + */ + void showNext(); + + /*! + Go to specified slide using animation effect. + */ + void showSlide(int index); + +signals: + void itemActivated(int index); + void inputReceived(); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void resizeEvent(QResizeEvent* event); + void timerEvent(QTimerEvent* event); + +private: + PictureFlowPrivate* d; +}; + +#endif // PICTUREFLOW_H diff --git a/demos/embedded/fluidlauncher/screenshots/concentriccircles.png b/demos/embedded/fluidlauncher/screenshots/concentriccircles.png Binary files differnew file mode 100644 index 0000000..fd308b5 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/concentriccircles.png diff --git a/demos/embedded/fluidlauncher/screenshots/deform.png b/demos/embedded/fluidlauncher/screenshots/deform.png Binary files differnew file mode 100644 index 0000000..c22f2ae --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/deform.png diff --git a/demos/embedded/fluidlauncher/screenshots/elasticnodes.png b/demos/embedded/fluidlauncher/screenshots/elasticnodes.png Binary files differnew file mode 100644 index 0000000..bc157e5 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/elasticnodes.png diff --git a/demos/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png b/demos/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png Binary files differnew file mode 100644 index 0000000..522f13b --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/embeddedsvgviewer.png diff --git a/demos/embedded/fluidlauncher/screenshots/mediaplayer.png b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png Binary files differnew file mode 100644 index 0000000..1304a19 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/mediaplayer.png diff --git a/demos/embedded/fluidlauncher/screenshots/pathstroke.png b/demos/embedded/fluidlauncher/screenshots/pathstroke.png Binary files differnew file mode 100644 index 0000000..c3d727e --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/pathstroke.png diff --git a/demos/embedded/fluidlauncher/screenshots/styledemo.png b/demos/embedded/fluidlauncher/screenshots/styledemo.png Binary files differnew file mode 100644 index 0000000..669c488 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/styledemo.png diff --git a/demos/embedded/fluidlauncher/screenshots/wiggly.png b/demos/embedded/fluidlauncher/screenshots/wiggly.png Binary files differnew file mode 100644 index 0000000..b20fbc4 --- /dev/null +++ b/demos/embedded/fluidlauncher/screenshots/wiggly.png diff --git a/demos/embedded/fluidlauncher/slides/demo_1.png b/demos/embedded/fluidlauncher/slides/demo_1.png Binary files differnew file mode 100644 index 0000000..d2952e5 --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_1.png diff --git a/demos/embedded/fluidlauncher/slides/demo_2.png b/demos/embedded/fluidlauncher/slides/demo_2.png Binary files differnew file mode 100644 index 0000000..1899825 --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_2.png diff --git a/demos/embedded/fluidlauncher/slides/demo_3.png b/demos/embedded/fluidlauncher/slides/demo_3.png Binary files differnew file mode 100644 index 0000000..8369bc0 --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_3.png diff --git a/demos/embedded/fluidlauncher/slides/demo_4.png b/demos/embedded/fluidlauncher/slides/demo_4.png Binary files differnew file mode 100644 index 0000000..377e369 --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_4.png diff --git a/demos/embedded/fluidlauncher/slides/demo_5.png b/demos/embedded/fluidlauncher/slides/demo_5.png Binary files differnew file mode 100644 index 0000000..239f08a --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_5.png diff --git a/demos/embedded/fluidlauncher/slides/demo_6.png b/demos/embedded/fluidlauncher/slides/demo_6.png Binary files differnew file mode 100644 index 0000000..0addf37 --- /dev/null +++ b/demos/embedded/fluidlauncher/slides/demo_6.png diff --git a/demos/embedded/fluidlauncher/slideshow.cpp b/demos/embedded/fluidlauncher/slideshow.cpp new file mode 100644 index 0000000..8f643b4 --- /dev/null +++ b/demos/embedded/fluidlauncher/slideshow.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QBasicTimer> +#include <QList> +#include <QImage> +#include <QDir> +#include <QPainter> +#include <QPaintEvent> + +#include <QDebug> + + +#include "slideshow.h" + + +class SlideShowPrivate +{ +public: + SlideShowPrivate(); + + int currentSlide; + int slideInterval; + QBasicTimer interSlideTimer; + QStringList imagePaths; + + void showNextSlide(); +}; + + + +SlideShowPrivate::SlideShowPrivate() +{ + currentSlide = 0; + slideInterval = 10000; // Default to 10 sec interval +} + + +void SlideShowPrivate::showNextSlide() +{ + currentSlide++; + if (currentSlide >= imagePaths.size()) + currentSlide = 0; +} + + + +SlideShow::SlideShow() +{ + d = new SlideShowPrivate; + + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); + + setMouseTracking(true); +} + + +SlideShow::~SlideShow() +{ + delete d; +} + + +void SlideShow::addImageDir(QString dirName) +{ + QDir dir(dirName); + + QStringList fileNames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name); + + for (int i=0; i<fileNames.count(); i++) + d->imagePaths << dir.absoluteFilePath(fileNames[i]); +} + +void SlideShow::addImage(QString filename) +{ + d->imagePaths << filename; +} + + +void SlideShow::clearImages() +{ + d->imagePaths.clear(); +} + + +void SlideShow::startShow() +{ + showFullScreen(); + d->interSlideTimer.start(d->slideInterval, this); + d->showNextSlide(); + update(); +} + + +void SlideShow::stopShow() +{ + hide(); + d->interSlideTimer.stop(); +} + + +int SlideShow::slideInterval() +{ + return d->slideInterval; +} + +void SlideShow::setSlideInterval(int val) +{ + d->slideInterval = val; +} + + +void SlideShow::timerEvent(QTimerEvent* event) +{ + Q_UNUSED(event); + d->showNextSlide(); + update(); +} + + +void SlideShow::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, false); + + if (d->imagePaths.size() > 0) { + QPixmap slide = QPixmap(d->imagePaths[d->currentSlide]); + QSize slideSize = slide.size(); + QSize scaledSize = QSize(qMin(slideSize.width(), size().width()), + qMin(slideSize.height(), size().height())); + if (slideSize != scaledSize) + slide = slide.scaled(scaledSize, Qt::KeepAspectRatio); + + QRect pixmapRect(qMax( (size().width() - slide.width())/2, 0), + qMax( (size().height() - slide.height())/2, 0), + slide.width(), + slide.height()); + + if (pixmapRect.top() > 0) { + // Fill in top & bottom rectangles: + painter.fillRect(0, 0, size().width(), pixmapRect.top(), Qt::black); + painter.fillRect(0, pixmapRect.bottom(), size().width(), size().height(), Qt::black); + } + + if (pixmapRect.left() > 0) { + // Fill in left & right rectangles: + painter.fillRect(0, 0, pixmapRect.left(), size().height(), Qt::black); + painter.fillRect(pixmapRect.right(), 0, size().width(), size().height(), Qt::black); + } + + painter.drawPixmap(pixmapRect, slide); + + } else + painter.fillRect(event->rect(), Qt::black); +} + + +void SlideShow::keyPressEvent(QKeyEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mouseMoveEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mousePressEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::mouseReleaseEvent(QMouseEvent* event) +{ + Q_UNUSED(event); + emit inputReceived(); +} + + +void SlideShow::showEvent(QShowEvent * event ) +{ + Q_UNUSED(event); +#ifndef QT_NO_CURSOR + setCursor(Qt::BlankCursor); +#endif +} + diff --git a/demos/embedded/fluidlauncher/slideshow.h b/demos/embedded/fluidlauncher/slideshow.h new file mode 100644 index 0000000..27fb87b --- /dev/null +++ b/demos/embedded/fluidlauncher/slideshow.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SLIDESHOW_H +#define SLIDESHOW_H + +#include <QWidget> + +class SlideShowPrivate; + +class SlideShow : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(int slideInterval READ slideInterval WRITE setSlideInterval) + +public: + SlideShow(); + ~SlideShow(); + void addImage(QString filename); + void addImageDir(QString dirName); + void clearImages(); + void startShow(); + void stopShow(); + + + int slideInterval(); + void setSlideInterval(int val); + +signals: + void inputReceived(); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void timerEvent(QTimerEvent* event); + void showEvent(QShowEvent * event ); + + +private: + SlideShowPrivate* d; +}; + + + + + + + + + + + + + +#endif diff --git a/demos/embedded/styledemo/files/add.png b/demos/embedded/styledemo/files/add.png Binary files differnew file mode 100755 index 0000000..fc5c16d --- /dev/null +++ b/demos/embedded/styledemo/files/add.png diff --git a/demos/embedded/styledemo/files/application.qss b/demos/embedded/styledemo/files/application.qss new file mode 100644 index 0000000..a632ad1 --- /dev/null +++ b/demos/embedded/styledemo/files/application.qss @@ -0,0 +1,125 @@ +QWidget#StyleWidget +{ + background-color: none; + background-image: url(icons:nature_1.jpg); +} + +QLabel, QAbstractButton +{ + font: 18px bold; + color: beige; +} + +QAbstractButton +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(173,216,230,60%), stop:1 rgba(0,0,139,60%) ); + border-color: black; + border-style: solid; + border-width: 3px; + border-radius: 6px; +} + +QAbstractButton:pressed, QAbstractButton:checked +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) ); +} + +QSpinBox { + padding-left: 24px; + padding-right: 24px; + border-color: darkkhaki; + border-style: solid; + border-radius: 5; + border-width: 3; +} + +QSpinBox::up-button +{ + subcontrol-origin: padding; + subcontrol-position: right; /* position at the top right corner */ + width: 24px; + height: 24px; + border-width: 3px; + +} + +QSpinBox::up-arrow +{ + image: url(icons:add.png); + width: 18px; + height: 18px; +} + + +QSpinBox::down-button +{ + subcontrol-origin: border; + subcontrol-position: left; + width: 24px; + height: 24px; + border-width: 3px; +} + +QSpinBox::down-arrow +{ + image: url(icons:remove.png); + width: 18px; + height: 18px; +} + + +QScrollBar:horizontal +{ + border: 1px solid black; + background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) ); + height: 15px; + margin: 0px 20px 0 20px; +} + +QScrollBar::handle:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + min-width: 20px; +} + +QScrollBar::add-line:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} + +QScrollBar::sub-line:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} + +QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal +{ + border: none; + width: 16px; + height: 16px; +} + +QScrollBar:left-arrow:horizontal +{ + image: url(icons:add.png) +} + +QScrollBar::right-arrow:horizontal +{ + image: url(icons:remove.png) +} + +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal +{ + background: none; +} + diff --git a/demos/embedded/styledemo/files/blue.qss b/demos/embedded/styledemo/files/blue.qss new file mode 100644 index 0000000..aa87277 --- /dev/null +++ b/demos/embedded/styledemo/files/blue.qss @@ -0,0 +1,39 @@ +* +{ + color: beige; +} + +QLabel, QAbstractButton +{ + font: 10pt bold; + color: yellow; +} + +QFrame +{ + background-color: rgba(96,96,255,60%); + border-color: rgb(32,32,196); + border-width: 3px; + border-style: solid; + border-radius: 5; + padding: 3px; +} + +QAbstractButton +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0 lightblue, stop:0.5 darkblue); + border-width: 3px; + border-color: darkblue; + border-style: solid; + border-radius: 5; + padding: 3px; + qproperty-focusPolicy: NoFocus; +} + +QAbstractButton:pressed +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, + stop:0.5 darkblue, stop:1 lightblue); + border-color: beige; +} diff --git a/demos/embedded/styledemo/files/khaki.qss b/demos/embedded/styledemo/files/khaki.qss new file mode 100644 index 0000000..9c0f77c --- /dev/null +++ b/demos/embedded/styledemo/files/khaki.qss @@ -0,0 +1,100 @@ + +QWidget#StartScreen, QWidget#MainWidget { + border: none; +} + +QWidget#StartScreen, .QFrame { + background-color: beige; +} + +QPushButton, QToolButton { + background-color: palegoldenrod; + border-width: 2px; + border-color: darkkhaki; + border-style: solid; + border-radius: 5; + padding: 3px; + /* min-width: 96px; */ + /* min-height: 48px; */ + qproperty-focusPolicy: NoFocus +} + +QPushButton:hover, QToolButton:hover { + background-color: khaki; +} + +QPushButton:pressed, QToolButton:pressed { + padding-left: 5px; + padding-top: 5px; + background-color: #d0d67c; +} + +QLabel, QAbstractButton { + font: italic 11pt "Times New Roman"; +} + +QFrame, QLabel#title { + border-width: 2px; + padding: 1px; + border-style: solid; + border-color: darkkhaki; + border-radius: 5px; +} + +QFrame:focus { + border-width: 3px; + padding: 0px; +} + + +QLabel { + border: none; + padding: 0; + background: none; +} + +QLabel#title { + font: 32px bold; +} + +QSpinBox { + padding-left: 24px; + padding-right: 24px; + border-color: darkkhaki; + border-style: solid; + border-radius: 5; + border-width: 3; +} + +QSpinBox::up-button +{ + subcontrol-origin: padding; + subcontrol-position: right; /* position at the top right corner */ + width: 24px; + height: 24px; + border-width: 3px; + border-image: url(:/files/spindownpng) 1; +} + +QSpinBox::up-arrow { + image: url(:/files/add.png); + width: 12px; + height: 12px; + } + + +QSpinBox::down-button +{ + subcontrol-origin: border; + subcontrol-position: left; + width: 24px; + height: 24px; + border-width: 3px; + border-image: url(:/files/spindownpng) 1; +} + +QSpinBox::down-arrow { + image: url(:/files/remove.png); + width: 12px; + height: 12px; + } diff --git a/demos/embedded/styledemo/files/nature_1.jpg b/demos/embedded/styledemo/files/nature_1.jpg Binary files differnew file mode 100644 index 0000000..3a04edb --- /dev/null +++ b/demos/embedded/styledemo/files/nature_1.jpg diff --git a/demos/embedded/styledemo/files/nostyle.qss b/demos/embedded/styledemo/files/nostyle.qss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/demos/embedded/styledemo/files/nostyle.qss diff --git a/demos/embedded/styledemo/files/remove.png b/demos/embedded/styledemo/files/remove.png Binary files differnew file mode 100755 index 0000000..a0ab1fa --- /dev/null +++ b/demos/embedded/styledemo/files/remove.png diff --git a/demos/embedded/styledemo/files/transparent.qss b/demos/embedded/styledemo/files/transparent.qss new file mode 100644 index 0000000..e3a9912 --- /dev/null +++ b/demos/embedded/styledemo/files/transparent.qss @@ -0,0 +1,140 @@ +QWidget#StyleWidget +{ + background-color: none; + background-image: url(:/files/nature_1.jpg); +} + +QLabel, QAbstractButton +{ + font: 13pt; + color: beige; +} + +QFrame, QLabel#title { + border-width: 2px; + padding: 1px; + border-style: solid; + border-color: black; + border-radius: 5px; +} + +QFrame:focus { + border-width: 3px; + padding: 0px; +} + + + +QAbstractButton +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(173,216,230,60%), stop:1 rgba(0,0,139,60%) ); + border-color: black; + border-style: solid; + border-width: 3px; + border-radius: 6px; +} + +QAbstractButton:pressed, QAbstractButton:checked +{ + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) ); +} + +QSpinBox { + padding-left: 24px; + padding-right: 24px; + border-color: darkkhaki; + border-style: solid; + border-radius: 5; + border-width: 3; +} + +QSpinBox::up-button +{ + subcontrol-origin: padding; + subcontrol-position: right; /* position at the top right corner */ + width: 24px; + height: 24px; + border-width: 3px; + +} + +QSpinBox::up-arrow +{ + image: url(:/files/add.png); + width: 18px; + height: 18px; +} + + +QSpinBox::down-button +{ + subcontrol-origin: border; + subcontrol-position: left; + width: 24px; + height: 24px; + border-width: 3px; +} + +QSpinBox::down-arrow +{ + image: url(:/files/remove.png); + width: 18px; + height: 18px; +} + + +QScrollBar:horizontal +{ + border: 1px solid black; + background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0,0,139,60%), stop:1 rgba(173,216,230,60%) ); + height: 15px; + margin: 0px 20px 0 20px; +} + +QScrollBar::handle:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + min-width: 20px; +} + +QScrollBar::add-line:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + width: 20px; + subcontrol-position: right; + subcontrol-origin: margin; +} + +QScrollBar::sub-line:horizontal +{ + border: 1px solid black; + background: rgba(0,0,139,60%); + width: 20px; + subcontrol-position: left; + subcontrol-origin: margin; +} + +QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal +{ + border: none; + width: 16px; + height: 16px; +} + +QScrollBar:left-arrow:horizontal +{ + image: url(:/files/add.png) +} + +QScrollBar::right-arrow:horizontal +{ + image: url(:/files/remove.png) +} + +QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal +{ + background: none; +} + diff --git a/demos/embedded/styledemo/main.cpp b/demos/embedded/styledemo/main.cpp new file mode 100644 index 0000000..6a7472e --- /dev/null +++ b/demos/embedded/styledemo/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QApplication> + +#include "stylewidget.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(styledemo); + + app.setApplicationName("style"); + app.setOrganizationName("Trolltech"); + app.setOrganizationDomain("com.trolltech"); + + StyleWidget widget; + widget.showFullScreen(); + + return app.exec(); +} + diff --git a/demos/embedded/styledemo/styledemo.pro b/demos/embedded/styledemo/styledemo.pro new file mode 100644 index 0000000..ee5e4d6 --- /dev/null +++ b/demos/embedded/styledemo/styledemo.pro @@ -0,0 +1,12 @@ +TEMPLATE = app + +# Input +HEADERS += stylewidget.h +FORMS += stylewidget.ui +SOURCES += main.cpp stylewidget.cpp +RESOURCES += styledemo.qrc + +target.path = $$[QT_INSTALL_DEMOS]/embedded/styledemo +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.html +sources.path = $$[QT_INSTALL_DEMOS]/embedded/styledemo +INSTALLS += target sources diff --git a/demos/embedded/styledemo/styledemo.qrc b/demos/embedded/styledemo/styledemo.qrc new file mode 100644 index 0000000..96237d4 --- /dev/null +++ b/demos/embedded/styledemo/styledemo.qrc @@ -0,0 +1,13 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>files/add.png</file> + <file>files/blue.qss</file> + <file>files/khaki.qss</file> + <file>files/nostyle.qss</file> + <file>files/transparent.qss</file> + <file>files/application.qss</file> + <file>files/nature_1.jpg</file> + <file>files/remove.png</file> +</qresource> +</RCC> + diff --git a/demos/embedded/styledemo/stylewidget.cpp b/demos/embedded/styledemo/stylewidget.cpp new file mode 100644 index 0000000..304dd36 --- /dev/null +++ b/demos/embedded/styledemo/stylewidget.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QApplication> +#include <QString> +#include <QFile> + +#include "stylewidget.h" + + + +StyleWidget::StyleWidget(QWidget *parent) + : QFrame(parent) +{ + m_ui.setupUi(this); +} + + +void StyleWidget::on_close_clicked() +{ + close(); +} + +void StyleWidget::on_blueStyle_clicked() +{ + QFile styleSheet(":/files/blue.qss"); + + if (!styleSheet.open(QIODevice::ReadOnly)) { + qWarning("Unable to open :/files/blue.qss"); + return; + } + + qApp->setStyleSheet(styleSheet.readAll()); +} + +void StyleWidget::on_khakiStyle_clicked() +{ + QFile styleSheet(":/files/khaki.qss"); + + if (!styleSheet.open(QIODevice::ReadOnly)) { + qWarning("Unable to open :/files/khaki.qss"); + return; + } + + qApp->setStyleSheet(styleSheet.readAll()); +} + + +void StyleWidget::on_noStyle_clicked() +{ + QFile styleSheet(":/files/nostyle.qss"); + + if (!styleSheet.open(QIODevice::ReadOnly)) { + qWarning("Unable to open :/files/nostyle.qss"); + return; + } + + qApp->setStyleSheet(styleSheet.readAll()); +} + + +void StyleWidget::on_transparentStyle_clicked() +{ + QFile styleSheet(":/files/transparent.qss"); + + if (!styleSheet.open(QIODevice::ReadOnly)) { + qWarning("Unable to open :/files/transparent.qss"); + return; + } + + qApp->setStyleSheet(styleSheet.readAll()); +} + + + diff --git a/demos/embedded/styledemo/stylewidget.h b/demos/embedded/styledemo/stylewidget.h new file mode 100644 index 0000000..5ccb418 --- /dev/null +++ b/demos/embedded/styledemo/stylewidget.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef STYLEWIDGET_H +#define STYLEWIDGET_H + +#include <QFrame> + +#include "ui_stylewidget.h" + +class StyleWidget : public QFrame +{ + Q_OBJECT +public: + StyleWidget(QWidget *parent = 0); + +private: + Ui_StyleWidget m_ui; + +private slots: + void on_close_clicked(); + void on_blueStyle_clicked(); + void on_khakiStyle_clicked(); + void on_noStyle_clicked(); + void on_transparentStyle_clicked(); +}; + +#endif diff --git a/demos/embedded/styledemo/stylewidget.ui b/demos/embedded/styledemo/stylewidget.ui new file mode 100644 index 0000000..586faea --- /dev/null +++ b/demos/embedded/styledemo/stylewidget.ui @@ -0,0 +1,429 @@ +<ui version="4.0" > + <class>StyleWidget</class> + <widget class="QWidget" name="StyleWidget" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>339</width> + <height>230</height> + </rect> + </property> + <property name="windowTitle" > + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout" > + <property name="margin" > + <number>3</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Styles</string> + </property> + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>3</number> + </property> + <property name="margin" > + <number>3</number> + </property> + <item> + <widget class="QPushButton" name="noStyle" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>No-Style</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>true</bool> + </property> + <property name="autoExclusive" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="blueStyle" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Blue</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>false</bool> + </property> + <property name="autoExclusive" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="khakiStyle" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Khaki</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>false</bool> + </property> + <property name="autoExclusive" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="transparentStyle" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Transparent</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>false</bool> + </property> + <property name="autoExclusive" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer_3" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QFrame" name="frame" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape" > + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow" > + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="frameLayout" > + <property name="margin" > + <number>3</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout" > + <item> + <widget class="QLabel" name="label" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>My Value is:</string> + </property> + <property name="alignment" > + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Minimum" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="keyboardTracking" > + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QGridLayout" name="gridLayout" > + <item row="0" column="0" > + <widget class="QScrollBar" name="horizontalScrollBar" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Expanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize" > + <size> + <width>0</width> + <height>24</height> + </size> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="0" > + <widget class="QPushButton" name="pushButton_2" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Show Scroller</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>true</bool> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QScrollBar" name="horizontalScrollBar_2" > + <property name="minimumSize" > + <size> + <width>0</width> + <height>24</height> + </size> + </property> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QPushButton" name="pushButton" > + <property name="sizePolicy" > + <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Enable Scroller</string> + </property> + <property name="checkable" > + <bool>true</bool> + </property> + <property name="checked" > + <bool>true</bool> + </property> + <property name="flat" > + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer" > + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0" > + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" > + <item> + <spacer> + <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="close" > + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="text" > + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources> + <include location="StyleDemo.qrc" /> + </resources> + <connections> + <connection> + <sender>horizontalScrollBar</sender> + <signal>valueChanged(int)</signal> + <receiver>horizontalScrollBar_2</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>134</x> + <y>196</y> + </hint> + <hint type="destinationlabel" > + <x>523</x> + <y>193</y> + </hint> + </hints> + </connection> + <connection> + <sender>horizontalScrollBar_2</sender> + <signal>valueChanged(int)</signal> + <receiver>horizontalScrollBar</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>577</x> + <y>199</y> + </hint> + <hint type="destinationlabel" > + <x>127</x> + <y>207</y> + </hint> + </hints> + </connection> + <connection> + <sender>pushButton</sender> + <signal>clicked(bool)</signal> + <receiver>horizontalScrollBar_2</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel" > + <x>566</x> + <y>241</y> + </hint> + <hint type="destinationlabel" > + <x>492</x> + <y>207</y> + </hint> + </hints> + </connection> + <connection> + <sender>pushButton_2</sender> + <signal>clicked(bool)</signal> + <receiver>horizontalScrollBar</receiver> + <slot>setVisible(bool)</slot> + <hints> + <hint type="sourcelabel" > + <x>123</x> + <y>239</y> + </hint> + <hint type="destinationlabel" > + <x>123</x> + <y>184</y> + </hint> + </hints> + </connection> + <connection> + <sender>spinBox</sender> + <signal>valueChanged(int)</signal> + <receiver>horizontalScrollBar_2</receiver> + <slot>setValue(int)</slot> + <hints> + <hint type="sourcelabel" > + <x>603</x> + <y>136</y> + </hint> + <hint type="destinationlabel" > + <x>575</x> + <y>199</y> + </hint> + </hints> + </connection> + </connections> +</ui> |