From cc73c1e80b480e378a54ad976933f477ee7a5b9c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:08:22 +1000 Subject: Fix smooth scaling --- src/declarative/fx/qfxwebview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 7c05088..05730f9 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -589,7 +589,8 @@ void QFxWebView::paintGLContents(GLPainter &p) #if defined(QFX_RENDER_QPAINTER) bool wasAA = p.testRenderHint(QPainter::Antialiasing); - p.setRenderHints(QPainter::Antialiasing, d->smooth); + bool wasSM = p.testRenderHint(QPainter::SmoothPixmapTransform); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); QRectF clipf = p.clipRegion().boundingRect(); const QRect clip = p.clipRegion().isEmpty() ? content : clipf.toRect(); #elif defined(QFX_RENDER_OPENGL) @@ -656,6 +657,7 @@ void QFxWebView::paintGLContents(GLPainter &p) } #if defined(QFX_RENDER_QPAINTER) p.setRenderHints(QPainter::Antialiasing, wasAA); + p.setRenderHints(QPainter::SmoothPixmapTransform, wasSM); #endif } -- cgit v0.12 From 63fd040014fa21a9e59466781b835d4188965559 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:42:33 +1000 Subject: Don't delay initial resize (otherwise "default" widget size happens first) --- src/declarative/util/qfxview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 42047b6..5611bca 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -265,7 +265,7 @@ void QFxView::continueExecute() d->root = item; connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); - sizeChanged(); + emit sceneResized(QSize(d->root->width(),d->root->height())); } else if (QWidget *wid = qobject_cast(obj)) { window()->setAttribute(Qt::WA_OpaquePaintEvent, false); window()->setAttribute(Qt::WA_NoSystemBackground, false); -- cgit v0.12 From 4e01e6107c4228912fba90ba682a7c0620d92dcb Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:47:01 +1000 Subject: fix --- examples/declarative/slideswitch/Switch.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml index a3f75e8..5862646 100644 --- a/examples/declarative/slideswitch/Switch.qml +++ b/examples/declarative/slideswitch/Switch.qml @@ -46,7 +46,7 @@ Item { MouseRegion { anchors.fill: Knob onClicked: { toggle() } - onReleased: { if (!isClick) dorelease() } + onReleased: { dorelease() } drag.target: Knob drag.axis: "x" drag.xmin: 1 -- cgit v0.12 From 26a6905e8feed42c0886b9ceef96456f2375deee Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:47:41 +1000 Subject: Change syntax --- examples/declarative/webview/autosize.qml | 101 +++++++++++++++----------- examples/declarative/webview/inline-html.qml | 25 +++---- examples/declarative/webview/inline-xhtml.qml | 14 ---- examples/declarative/webview/qml-in-html.qml | 50 ++++++++----- examples/declarative/webview/transparent.qml | 17 +++-- 5 files changed, 112 insertions(+), 95 deletions(-) delete mode 100644 examples/declarative/webview/inline-xhtml.qml diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index fedd497..c32b752 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -1,42 +1,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// The WebView size is determined by the width, height, +// idealWidth, and idealHeight properties. +Rect { + id: Rect + color: "white" + width: 200 + height: Layout.height + VerticalLayout { + id: Layout + spacing: 2 + WebView { + html: "No width defined." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: Rect.width + html: "The width is full." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: Rect.width/2 + html: "The width is half." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + idealWidth: Rect.width/2 + html: "The idealWidth is half." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + idealWidth: Rect.width/2 + html: "The_idealWidth_is_half." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + WebView { + width: Rect.width/2 + html: "The_width_is_half." + Rect { + color: "#10000000" + anchors.fill: parent + } + } + } +} diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml index 701db41..5f6d410 100644 --- a/examples/declarative/webview/inline-html.qml +++ b/examples/declarative/webview/inline-html.qml @@ -1,13 +1,12 @@ - - - - -
OneTwoThree -
1X1X -
20X0 -
3X1X -
- ]]> -
+// Inline HTML with loose formatting can be +// set on the html property. +WebView { + html:"\ + \ + \ +
OneTwoThree\ +
1X1X\ +
20X0\ +
3X1X\ +
" +} diff --git a/examples/declarative/webview/inline-xhtml.qml b/examples/declarative/webview/inline-xhtml.qml deleted file mode 100644 index 4acb417..0000000 --- a/examples/declarative/webview/inline-xhtml.qml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - -
OneTwoThree
1X1X
20X0
3X1X
- - -
diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qml-in-html.qml index 8c1c06f..29dded5 100644 --- a/examples/declarative/webview/qml-in-html.qml +++ b/examples/declarative/webview/qml-in-html.qml @@ -1,20 +1,30 @@ - - - - - - These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75% - and placed in a Flickable area... - -
Duration Color Plugin -
500 red -
2000 blue -
1000 green -
- - - ]]> -
-
+// The WebView supports QML data through the HTML OBJECT tag +Rect { + color:"blue" + Flickable { + width: parent.width + height: parent.height/2 + viewportWidth: Web.width*Web.scale + viewportHeight: Web.height*Web.scale + WebView { + id: Web + width: 250 + height: 420 + scale: 0.75 + smooth: true + settings.pluginsEnabled: true + html: "\ + \ + These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75%\ + and placed in a Flickable area...\ + \ +
Duration Color Plugin\ +
500 red \ +
2000 blue \ +
1000 green \ +
\ + \ + " + } + } +} diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml index 71e1621..8614822 100644 --- a/examples/declarative/webview/transparent.qml +++ b/examples/declarative/webview/transparent.qml @@ -1,6 +1,11 @@ - - - - - +// The WebView background is transparent +// if the HTML does not specify a background +Rect { + color: "green" + width: Web.width + height: Web.height + WebView { + id: Web + html: "Hello World!" + } +} -- cgit v0.12 From 7ab8748f4b95c257dc5aebeb9f83a568aeca9910 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:52:14 +1000 Subject: Port syntax --- examples/declarative/follow/pong.qml | 180 +++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 52 deletions(-) diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml index 4fbf323..b6695bd 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/pong.qml @@ -1,55 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - if (y <= 0) +Rect { + id: Page + width: 640 + height: 480 + color: "#000000" + + // Make a ball to bounce + Rect { + id: Ball + x: 20 + width: 20 + height: 20 + color: "#00ee00" + z: 1 + + // Add a property for the target y coordinate + properties: Property { + name: "targetY" + value: Page.height-10 + } + properties: Property { + name: "direction" + value: "right" + } + + // Move the ball to the right and back to the left repeatedly + x: SequentialAnimation { + running: true + repeat: true + NumericAnimation { + to: Page.width-40 + duration: 2000 + } + SetPropertyAction { + target: Ball + property: "direction" + value: "left" + } + NumericAnimation { + to: 20 + duration: 2000 + } + SetPropertyAction { + target: Ball + property: "direction" + value: "right" + } + } + + // Make y follow the target y coordinate, with a velocity of 200 + y: Follow { + source: Ball.targetY + velocity: 200 + } + + // Detect the ball hitting the top or bottom of the view and bounce it + onTopChanged: { + if (y <= 0) targetY = Page.height-20; - else if (y >= Page.height-20) + else if (y >= Page.height-20) targetY = 0; - - - - - - - - - - - - - + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rect { + id: LeftBat + color: "#00ee00" + x: 2 + width: 20 + height: 90 + y: Follow { + source: Ball.y-45 + velocity: 300 + enabled: Ball.direction == 'left' + } + } + Rect { + id: RightBat + x: Page.width-22 + color: "#00ee00" + width: 20 + height: 90 + y: Follow { + source: Ball.y-45 + velocity: 300 + enabled: Ball.direction == 'right' + } + } - - - - - - - - - + // The rest, to make it look realistic, if neither ever scores... + Rect { + color: "#00ee00" + x: 320-80 + y: 0 + width: 40 + height: 60 + } + Rect { + color: "#000000" + x: 320-70 + y: 10 + width: 20 + height: 40 + } + Rect { + color: "#00ee00" + x: 320+40 + y: 0 + width: 40 + height: 60 + } + Rect { + color: "#000000" + x: 320+50 + y: 10 + width: 20 + height: 40 + } + Repeater { + dataSource: 24 + Rect { + color: "#00ee00" + x: 320-5 + y: index*20 + width: 10 + height: 10 + } + } +} -- cgit v0.12 From 5ddb12ac5babbdabe9375fa79f80655e987f459d Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:57:02 +1000 Subject: Port syntax --- .../declarative/webview/content/SpinSquare.qml | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/examples/declarative/webview/content/SpinSquare.qml b/examples/declarative/webview/content/SpinSquare.qml index ced45d5..5c14506 100644 --- a/examples/declarative/webview/content/SpinSquare.qml +++ b/examples/declarative/webview/content/SpinSquare.qml @@ -1,12 +1,29 @@ - - - - - - - - - - - - +Item { + id: Root + properties: Property { + name: "period" + value: 250 + } + properties: Property { + name: "color" + value: "black" + } + Item { + x: Root.width/2 + y: Root.height/2 + Rect { + color: Root.color + x: -width/2 + y: -height/2 + width: Root.width + height: width + } + rotation: NumericAnimation { + from: 0 + to: 360 + repeat: true + running: true + duration: Root.period + } + } +} -- cgit v0.12 From 9b08198a1bac0347767a426ddc53d5ebe903b1a7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 13:57:20 +1000 Subject: Namespaces not needed in new syntax. --- examples/declarative/namespaces/BlueStuff/Rect.qml | 1 - examples/declarative/namespaces/Local.qml | 1 - examples/declarative/namespaces/components.qml | 17 ----------------- examples/declarative/namespaces/lib/Chronos/Clock.qml | 15 --------------- examples/declarative/namespaces/lib/Chronos/Hand.qml | 9 --------- .../namespaces/lib/Chronos/pics/clockface.png | Bin 46895 -> 0 bytes .../declarative/namespaces/lib/Path/PathLabel.qml | 1 - examples/declarative/namespaces/lib/RedStuff/Rect.qml | 1 - examples/declarative/namespaces/lib/Wrong/Wrong.qml | 3 --- examples/declarative/namespaces/library.qml | 12 ------------ examples/declarative/namespaces/path.qml | 18 ------------------ examples/declarative/namespaces/simple.qml | 5 ----- examples/declarative/namespaces/wrong1.qml | 4 ---- 13 files changed, 87 deletions(-) delete mode 100644 examples/declarative/namespaces/BlueStuff/Rect.qml delete mode 100644 examples/declarative/namespaces/Local.qml delete mode 100644 examples/declarative/namespaces/components.qml delete mode 100644 examples/declarative/namespaces/lib/Chronos/Clock.qml delete mode 100644 examples/declarative/namespaces/lib/Chronos/Hand.qml delete mode 100644 examples/declarative/namespaces/lib/Chronos/pics/clockface.png delete mode 100644 examples/declarative/namespaces/lib/Path/PathLabel.qml delete mode 100644 examples/declarative/namespaces/lib/RedStuff/Rect.qml delete mode 100644 examples/declarative/namespaces/lib/Wrong/Wrong.qml delete mode 100644 examples/declarative/namespaces/library.qml delete mode 100644 examples/declarative/namespaces/path.qml delete mode 100644 examples/declarative/namespaces/simple.qml delete mode 100644 examples/declarative/namespaces/wrong1.qml diff --git a/examples/declarative/namespaces/BlueStuff/Rect.qml b/examples/declarative/namespaces/BlueStuff/Rect.qml deleted file mode 100644 index 94e066c..0000000 --- a/examples/declarative/namespaces/BlueStuff/Rect.qml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/declarative/namespaces/Local.qml b/examples/declarative/namespaces/Local.qml deleted file mode 100644 index 5fb2aef..0000000 --- a/examples/declarative/namespaces/Local.qml +++ /dev/null @@ -1 +0,0 @@ -This is a local component diff --git a/examples/declarative/namespaces/components.qml b/examples/declarative/namespaces/components.qml deleted file mode 100644 index ea5e2d9..0000000 --- a/examples/declarative/namespaces/components.qml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/examples/declarative/namespaces/lib/Chronos/Clock.qml b/examples/declarative/namespaces/lib/Chronos/Clock.qml deleted file mode 100644 index 959d193..0000000 --- a/examples/declarative/namespaces/lib/Chronos/Clock.qml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/declarative/namespaces/lib/Chronos/Hand.qml b/examples/declarative/namespaces/lib/Chronos/Hand.qml deleted file mode 100644 index 3662e74..0000000 --- a/examples/declarative/namespaces/lib/Chronos/Hand.qml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/examples/declarative/namespaces/lib/Chronos/pics/clockface.png b/examples/declarative/namespaces/lib/Chronos/pics/clockface.png deleted file mode 100644 index a885950..0000000 Binary files a/examples/declarative/namespaces/lib/Chronos/pics/clockface.png and /dev/null differ diff --git a/examples/declarative/namespaces/lib/Path/PathLabel.qml b/examples/declarative/namespaces/lib/Path/PathLabel.qml deleted file mode 100644 index c4b08b0..0000000 --- a/examples/declarative/namespaces/lib/Path/PathLabel.qml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/declarative/namespaces/lib/RedStuff/Rect.qml b/examples/declarative/namespaces/lib/RedStuff/Rect.qml deleted file mode 100644 index 3429b09..0000000 --- a/examples/declarative/namespaces/lib/RedStuff/Rect.qml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/declarative/namespaces/lib/Wrong/Wrong.qml b/examples/declarative/namespaces/lib/Wrong/Wrong.qml deleted file mode 100644 index 3af55f6..0000000 --- a/examples/declarative/namespaces/lib/Wrong/Wrong.qml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/declarative/namespaces/library.qml b/examples/declarative/namespaces/library.qml deleted file mode 100644 index ae10ed8..0000000 --- a/examples/declarative/namespaces/library.qml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/examples/declarative/namespaces/path.qml b/examples/declarative/namespaces/path.qml deleted file mode 100644 index 795447b..0000000 --- a/examples/declarative/namespaces/path.qml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/declarative/namespaces/simple.qml b/examples/declarative/namespaces/simple.qml deleted file mode 100644 index 16d9815..0000000 --- a/examples/declarative/namespaces/simple.qml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/namespaces/wrong1.qml b/examples/declarative/namespaces/wrong1.qml deleted file mode 100644 index 721c45a..0000000 --- a/examples/declarative/namespaces/wrong1.qml +++ /dev/null @@ -1,4 +0,0 @@ - - - - -- cgit v0.12 From 0204346fb91eaf73893b651438980cb9ca5f1f51 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Apr 2009 14:06:50 +1000 Subject: Make custom parsers internal. Custom parsers still have a way to go before they fully fit the QML 2.0 language. --- src/declarative/qml/qml.pri | 2 +- src/declarative/qml/qmlcompiler.cpp | 2 +- src/declarative/qml/qmlcustomparser.cpp | 3 +- src/declarative/qml/qmlcustomparser.h | 128 ------------------------------ src/declarative/qml/qmlcustomparser_p.h | 87 +++++++++++++++----- src/declarative/qml/qmlcustomparser_p_p.h | 79 ++++++++++++++++++ src/declarative/qml/qmlmetatype.cpp | 2 +- src/declarative/qml/qmlvme.cpp | 2 +- src/declarative/qml/qmlxmlparser.cpp | 2 +- src/declarative/util/qmllistmodel.cpp | 2 +- 10 files changed, 155 insertions(+), 154 deletions(-) delete mode 100644 src/declarative/qml/qmlcustomparser.h create mode 100644 src/declarative/qml/qmlcustomparser_p_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 40b854f..9067039 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -32,8 +32,8 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlmetaproperty.h \ qml/qmlcomponent.h \ qml/qmlcomponent_p.h \ - qml/qmlcustomparser.h \ qml/qmlcustomparser_p.h \ + qml/qmlcustomparser_p_p.h \ qml/qmlpropertyvaluesource.h \ qml/qmlboundsignal_p.h \ qml/qmlxmlparser_p.h \ diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 4433286..c9bdfec 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -59,7 +59,7 @@ #include #include #include -#include "private/qmlcustomparser_p.h" +#include "private/qmlcustomparser_p_p.h" #include "qmlscriptparser_p.h" diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index fe0c3a8..544c469 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmlcustomparser.h" #include "qmlcustomparser_p.h" +#include "qmlcustomparser_p_p.h" #include "qmlparser_p.h" QT_BEGIN_NAMESPACE @@ -50,6 +50,7 @@ using namespace QmlParser; /*! \class QmlCustomParser \brief The QmlCustomParser class allows you to add new arbitrary types to QML. + \internal By subclassing QmlCustomParser, you can add an XML parser for building a particular type. diff --git a/src/declarative/qml/qmlcustomparser.h b/src/declarative/qml/qmlcustomparser.h deleted file mode 100644 index 0e6a619..0000000 --- a/src/declarative/qml/qmlcustomparser.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLCUSTOMPARSER_H -#define QMLCUSTOMPARSER_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlCustomParserPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlCustomParserProperty -{ -public: - QmlCustomParserProperty(); - QmlCustomParserProperty(const QmlCustomParserProperty &); - QmlCustomParserProperty &operator=(const QmlCustomParserProperty &); - ~QmlCustomParserProperty(); - - QByteArray name() const; - - bool isList() const; - QList assignedValues() const; - -private: - friend class QmlCustomParserNodePrivate; - friend class QmlCustomParserPropertyPrivate; - QmlCustomParserPropertyPrivate *d; -}; -Q_DECLARE_METATYPE(QmlCustomParserProperty); - -class QmlCustomParserNodePrivate; -class Q_DECLARATIVE_EXPORT QmlCustomParserNode -{ -public: - QmlCustomParserNode(); - QmlCustomParserNode(const QmlCustomParserNode &); - QmlCustomParserNode &operator=(const QmlCustomParserNode &); - ~QmlCustomParserNode(); - - QByteArray name() const; - - QList properties() const; - -private: - friend class QmlCustomParserNodePrivate; - QmlCustomParserNodePrivate *d; -}; -Q_DECLARE_METATYPE(QmlCustomParserNode); - -class Q_DECLARATIVE_EXPORT QmlCustomParser -{ -public: - virtual ~QmlCustomParser() {} - - virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0; - virtual QByteArray compile(const QList &, bool *ok); - virtual QVariant create(const QByteArray &)=0; - virtual void setCustomData(QObject *, const QByteArray &); - - struct Register { - Register(const char *name, QmlCustomParser *parser) { - qmlRegisterCustomParser(name, parser); - } - }; - template - struct Define { - static Register instance; - }; -}; -#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define::instance(# name, new parserClass); -#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \ - template<> QmlCustomParser::Register QmlCustomParser::Define::instance(namespacestring "/" # name, new parserClass); - -#define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterCustomType(#NAME, #TYPE, new CUSTOMTYPE)); - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 63d148c..0e6a619 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -39,41 +39,90 @@ ** ****************************************************************************/ -#ifndef QMLCUSTOMPARSER_P_H -#define QMLCUSTOMPARSER_P_H +#ifndef QMLCUSTOMPARSER_H +#define QMLCUSTOMPARSER_H -#include -#include "qmlcustomparser.h" +#include +#include +#include +#include + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -namespace QmlParser +QT_MODULE(Declarative) + +class QmlCustomParserPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlCustomParserProperty { - class Object; - class Property; +public: + QmlCustomParserProperty(); + QmlCustomParserProperty(const QmlCustomParserProperty &); + QmlCustomParserProperty &operator=(const QmlCustomParserProperty &); + ~QmlCustomParserProperty(); + + QByteArray name() const; + + bool isList() const; + QList assignedValues() const; + +private: + friend class QmlCustomParserNodePrivate; + friend class QmlCustomParserPropertyPrivate; + QmlCustomParserPropertyPrivate *d; }; +Q_DECLARE_METATYPE(QmlCustomParserProperty); -class QmlCustomParserNodePrivate +class QmlCustomParserNodePrivate; +class Q_DECLARATIVE_EXPORT QmlCustomParserNode { public: - QByteArray name; - QList properties; + QmlCustomParserNode(); + QmlCustomParserNode(const QmlCustomParserNode &); + QmlCustomParserNode &operator=(const QmlCustomParserNode &); + ~QmlCustomParserNode(); - static QmlCustomParserNode fromObject(QmlParser::Object *); - static QmlCustomParserProperty fromProperty(QmlParser::Property *); + QByteArray name() const; + + QList properties() const; + +private: + friend class QmlCustomParserNodePrivate; + QmlCustomParserNodePrivate *d; }; +Q_DECLARE_METATYPE(QmlCustomParserNode); -class QmlCustomParserPropertyPrivate +class Q_DECLARATIVE_EXPORT QmlCustomParser { public: - QmlCustomParserPropertyPrivate() - : isList(false) {} + virtual ~QmlCustomParser() {} + + virtual QByteArray compile(QXmlStreamReader&, bool *ok)=0; + virtual QByteArray compile(const QList &, bool *ok); + virtual QVariant create(const QByteArray &)=0; + virtual void setCustomData(QObject *, const QByteArray &); - QByteArray name; - bool isList; - QList values; + struct Register { + Register(const char *name, QmlCustomParser *parser) { + qmlRegisterCustomParser(name, parser); + } + }; + template + struct Define { + static Register instance; + }; }; +#define QML_DEFINE_CUSTOM_PARSER(name, parserClass) \ + template<> QmlCustomParser::Register QmlCustomParser::Define::instance(# name, new parserClass); +#define QML_DEFINE_CUSTOM_PARSER_NS(namespacestring, name, parserClass) \ + template<> QmlCustomParser::Register QmlCustomParser::Define::instance(namespacestring "/" # name, new parserClass); + +#define QML_DEFINE_CUSTOM_TYPE(TYPE, NAME, CUSTOMTYPE) \ + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterCustomType(#NAME, #TYPE, new CUSTOMTYPE)); QT_END_NAMESPACE -#endif // QMLCUSTOMPARSER_P_H +QT_END_HEADER + +#endif diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h new file mode 100644 index 0000000..96e9b32 --- /dev/null +++ b/src/declarative/qml/qmlcustomparser_p_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLCUSTOMPARSER_P_H +#define QMLCUSTOMPARSER_P_H + +#include +#include "qmlcustomparser_p.h" + +QT_BEGIN_NAMESPACE + +namespace QmlParser +{ + class Object; + class Property; +}; + +class QmlCustomParserNodePrivate +{ +public: + QByteArray name; + QList properties; + + static QmlCustomParserNode fromObject(QmlParser::Object *); + static QmlCustomParserProperty fromProperty(QmlParser::Property *); +}; + +class QmlCustomParserPropertyPrivate +{ +public: + QmlCustomParserPropertyPrivate() + : isList(false) {} + + QByteArray name; + bool isList; + QList values; +}; + +QT_END_NAMESPACE + +#endif // QMLCUSTOMPARSER_P_H diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index fbfeca0..63e5c58 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -57,7 +57,7 @@ #include #include #include -#include +#include QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 7b3291e..e6235e4 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -45,7 +45,7 @@ #include #include "private/qmetaobjectbuilder_p.h" #include -#include +#include #include #include #include diff --git a/src/declarative/qml/qmlxmlparser.cpp b/src/declarative/qml/qmlxmlparser.cpp index b3565a0..35d2c0e 100644 --- a/src/declarative/qml/qmlxmlparser.cpp +++ b/src/declarative/qml/qmlxmlparser.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "qmlxmlparser_p.h" -#include "qmlcustomparser.h" +#include "qmlcustomparser_p.h" #include #include #include diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 968e17b..4837180 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -42,7 +42,7 @@ #include #include #include -#include "qmlcustomparser.h" +#include #include "qmlopenmetaobject.h" #include #include -- cgit v0.12 From d107f39df40990d4cbd1fc5983c5de7ae46bb374 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Apr 2009 14:09:20 +1000 Subject: More work on transform elements. AxisRotation/AxisTranslation have been renamed Rotation3D/Translation3D. Squish has gained a raster implementation and basic docs. --- doc/src/declarative/pics/squish.png | Bin 0 -> 8590 bytes src/declarative/fx/qfxflipable.cpp | 2 +- src/declarative/fx/qfxtransform.cpp | 202 +++++++++++++++++++++++------------- src/declarative/fx/qfxtransform.h | 22 ++-- 4 files changed, 137 insertions(+), 89 deletions(-) create mode 100644 doc/src/declarative/pics/squish.png diff --git a/doc/src/declarative/pics/squish.png b/doc/src/declarative/pics/squish.png new file mode 100644 index 0000000..73bf292 Binary files /dev/null and b/doc/src/declarative/pics/squish.png differ diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 1d15827..81ed750 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -58,7 +58,7 @@ public: QFxItem *front; QFxItem *back; QFxAxis *axis; - QFxRotation axisRotation; + QFxRotation3D axisRotation; qreal rotation; }; diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index c355158..2bed170 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -178,8 +178,8 @@ void QFxAxis::setEndZ(qreal z) } /*! - \qmlclass AxisRotation - \brief The AxisRotation element provides a way to rotate an Item around an axis. + \qmlclass Rotation3D + \brief The Rotation3D element provides a way to rotate an Item around an axis. Here is an example of various rotations applied to an \l Image. \code @@ -187,22 +187,22 @@ void QFxAxis::setEndZ(qreal z) - + - + - + - + @@ -211,58 +211,58 @@ void QFxAxis::setEndZ(qreal z) \image axisrotation.png */ -QML_DEFINE_TYPE(QFxRotation,AxisRotation); +QML_DEFINE_TYPE(QFxRotation3D,Rotation3D); -QFxRotation::QFxRotation(QObject *parent) -: QFxTransform(parent), _angle(0), _distanceToPlane(1024.), _dirty(true) +QFxRotation3D::QFxRotation3D(QObject *parent) +: QFxTransform(parent), _angle(0), _dirty(true) { connect(&_axis, SIGNAL(updated()), this, SLOT(update())); } -QFxRotation::~QFxRotation() +QFxRotation3D::~QFxRotation3D() { } /*! - \qmlproperty real AxisRotation::axis.startX - \qmlproperty real AxisRotation::axis.startY - \qmlproperty real AxisRotation::axis.endX - \qmlproperty real AxisRotation::axis.endY - \qmlproperty real AxisRotation::axis.endZ + \qmlproperty real Rotation3D::axis.startX + \qmlproperty real Rotation3D::axis.startY + \qmlproperty real Rotation3D::axis.endX + \qmlproperty real Rotation3D::axis.endY + \qmlproperty real Rotation3D::axis.endZ A rotation axis is specified by 2 points in 3D space: a start point and an end point. The z-position of the start point is assumed to be 0, and cannot be changed. */ -QFxAxis *QFxRotation::axis() +QFxAxis *QFxRotation3D::axis() { return &_axis; } /*! - \qmlproperty real AxisRotation::angle + \qmlproperty real Rotation3D::angle The angle, in degrees, to rotate around the specified axis. */ -qreal QFxRotation::angle() const +qreal QFxRotation3D::angle() const { return _angle; } -void QFxRotation::setAngle(qreal angle) +void QFxRotation3D::setAngle(qreal angle) { _angle = angle; update(); } -bool QFxRotation::isIdentity() const +bool QFxRotation3D::isIdentity() const { return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } #if defined(QFX_RENDER_QPAINTER) const qreal inv_dist_to_plane = 1. / 1024.; -QTransform QFxRotation::transform() const +QTransform QFxRotation3D::transform() const { if (_dirty) { _transform = QTransform(); @@ -282,10 +282,6 @@ QTransform QFxRotation::transform() const qreal y = _axis.endY() - _axis.startY(); qreal z = _axis.endZ(); - qreal idtp = inv_dist_to_plane; - if (distanceToPlane() != 1024.) - idtp = 1. / distanceToPlane(); - qreal len = x * x + y * y + z * z; if (len != 1.) { len = ::sqrt(len); @@ -294,8 +290,8 @@ QTransform QFxRotation::transform() const z /= len; } - QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*idtp, - y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*idtp, + QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, + y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, 0, 0, 1); _transform *= rotTrans; @@ -310,7 +306,7 @@ QTransform QFxRotation::transform() const return _transform; } #elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation::transform() const +QMatrix4x4 QFxRotation3D::transform() const { if (_dirty) { _dirty = false; @@ -333,21 +329,7 @@ QMatrix4x4 QFxRotation::transform() const } #endif -/*! - \qmlproperty real AxisRotation::distanceToPlane -*/ -qreal QFxRotation::distanceToPlane() const -{ - return _distanceToPlane; -} - -void QFxRotation::setDistanceToPlane(qreal d) -{ - _distanceToPlane = d; - update(); -} - -void QFxRotation::update() +void QFxRotation3D::update() { _dirty = true; QFxItem *item = qobject_cast(parent()); @@ -356,77 +338,77 @@ void QFxRotation::update() } /*! - \qmlclass AxisTranslation - \brief The AxisTranslation element provides a way to move an Item along an axis. + \qmlclass Translation3D + \brief The Translation3D element provides a way to move an Item along an axis. The following example translates the image to 10, 3. \code - + \endcode */ -QML_DEFINE_TYPE(QFxTranslation,AxisTranslation); +QML_DEFINE_TYPE(QFxTranslation3D,Translation3D); -QFxTranslation::QFxTranslation(QObject *parent) +QFxTranslation3D::QFxTranslation3D(QObject *parent) : QFxTransform(parent), _distance(0), _dirty(true) { connect(&_axis, SIGNAL(updated()), this, SLOT(update())); } -QFxTranslation::~QFxTranslation() +QFxTranslation3D::~QFxTranslation3D() { } /*! - \qmlproperty real AxisTranslation::axis.startX - \qmlproperty real AxisTranslation::axis.startY - \qmlproperty real AxisTranslation::axis.endX - \qmlproperty real AxisTranslation::axis.endY - \qmlproperty real AxisTranslation::axis.endZ + \qmlproperty real Translation3D::axis.startX + \qmlproperty real Translation3D::axis.startY + \qmlproperty real Translation3D::axis.endX + \qmlproperty real Translation3D::axis.endY + \qmlproperty real Translation3D::axis.endZ A translation axis is specified by 2 points in 3D space: a start point and an end point. The z-position of the start point is assumed to be 0, and cannot be changed. Changing the z-position of the end point is only valid when running under OpenGL. */ -QFxAxis *QFxTranslation::axis() +QFxAxis *QFxTranslation3D::axis() { return &_axis; } /*! - \qmlproperty real AxisTranslation::distance + \qmlproperty real Translation3D::distance The distance to translate along the specified axis. distance is a multiplier; in the example below, a distance of 1 would translate to 100, 50, while a distance of 0.5 would translate to 50, 25. \code - + \endcode */ -qreal QFxTranslation::distance() const +qreal QFxTranslation3D::distance() const { return _distance; } -void QFxTranslation::setDistance(qreal distance) +void QFxTranslation3D::setDistance(qreal distance) { _distance = distance; update(); } -bool QFxTranslation::isIdentity() const +bool QFxTranslation3D::isIdentity() const { return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX()); } #if defined(QFX_RENDER_QPAINTER) -QTransform QFxTranslation::transform() const +QTransform QFxTranslation3D::transform() const { if (_dirty) { _transform = QTransform(); @@ -446,7 +428,7 @@ QTransform QFxTranslation::transform() const return _transform; } #elif defined(QFX_RENDER_OPENGL) -QMatrix4x4 QFxRotation::transform() const +QMatrix4x4 QFxTranslation3D::transform() const { if (_dirty) { _dirty = false; @@ -465,7 +447,7 @@ QMatrix4x4 QFxRotation::transform() const } #endif -void QFxTranslation::update() +void QFxTranslation3D::update() { _dirty = true; @@ -541,8 +523,62 @@ QMatrix4x4 QFxPerspective::transform() const \qmlclass Squish \brief The Squish element allows you to distort an items appearance by 'squishing' it. - A Squish transform only affects an item when running under OpenGL; when running under software - rasterization it has no effect. + Here is an example of various \l Image squishes. + \code + Rect { + id: Screen + width: 360; height: 80 + color: "white" + + HorizontalLayout { + margin: 10 + spacing: 10 + Image { src: "qt.png" } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:0 + topRightX:50; topRightY:10 + bottomLeftX:0; bottomLeftY:60 + bottomRightX: 60; bottomRightY:60 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:0 + topRightX:50; topRightY:0 + bottomLeftX:10; bottomLeftY:50 + bottomRightX: 60; bottomRightY:60 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:0; topLeftY:10 + topRightX:60; topRightY:10 + bottomLeftX:0; bottomLeftY:50 + bottomRightX: 60; bottomRightY:50 + } + } + Image { + src: "qt.png" + transform: Squish { + x:0; y:0; width:60; height:60 + topLeftX:10; topLeftY:0 + topRightX:50; topRightY:0 + bottomLeftX:10; bottomLeftY:60 + bottomRightX: 50; bottomRightY:60 + } + } + } + } + \endcode + + \image squish.png */ QML_DEFINE_TYPE(QFxSquish,Squish); @@ -557,6 +593,11 @@ QFxSquish::~QFxSquish() /*! \qmlproperty real Squish::x + \qmlproperty real Squish::y + \qmlproperty real Squish::width + \qmlproperty real Squish::height + + This is usually set to the original geometry of the item being squished. */ qreal QFxSquish::x() const { @@ -569,9 +610,6 @@ void QFxSquish::setX(qreal v) update(); } -/*! - \qmlproperty real Squish::y -*/ qreal QFxSquish::y() const { return p.y(); @@ -583,9 +621,6 @@ void QFxSquish::setY(qreal v) update(); } -/*! - \qmlproperty real Squish::width -*/ qreal QFxSquish::width() const { return s.width(); @@ -597,9 +632,6 @@ void QFxSquish::setWidth(qreal v) update(); } -/*! - \qmlproperty real Squish::height -*/ qreal QFxSquish::height() const { return s.height(); @@ -614,6 +646,8 @@ void QFxSquish::setHeight(qreal v) /*! \qmlproperty real Squish::topLeftX \qmlproperty real Squish::topLeftY + + The top left point for the squish. */ qreal QFxSquish::topLeft_x() const { @@ -640,6 +674,8 @@ void QFxSquish::settopLeft_y(qreal v) /*! \qmlproperty real Squish::topRightX \qmlproperty real Squish::topRightY + + The top right point for the squish. */ qreal QFxSquish::topRight_x() const { @@ -666,6 +702,8 @@ void QFxSquish::settopRight_y(qreal v) /*! \qmlproperty real Squish::bottomLeftX \qmlproperty real Squish::bottomLeftY + + The bottom left point for the squish. */ qreal QFxSquish::bottomLeft_x() const { @@ -692,6 +730,8 @@ void QFxSquish::setbottomLeft_y(qreal v) /*! \qmlproperty real Squish::bottomRightX \qmlproperty real Squish::bottomRightY + + The bottom right point for the squish. */ qreal QFxSquish::bottomRight_x() const { @@ -722,12 +762,24 @@ void QFxSquish::update() item->updateTransform(); } -#if defined(QFX_RENDER_OPENGL) bool QFxSquish::isIdentity() const { return false; } +#if defined(QFX_RENDER_QPAINTER) +QTransform QFxSquish::transform() const +{ + QPolygonF poly; + poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height()); + QPolygonF poly2; + poly2 << p1 << p2 << p4 << p3; + + QTransform t; + QTransform::quadToQuad(poly, poly2, t); + return t; +} +#elif defined(QFX_RENDER_OPENGL) QMatrix4x4 QFxSquish::transform() const { QPolygonF poly; diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index 8a4eab1..14bce9b 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -109,16 +109,15 @@ private: }; QML_DECLARE_TYPE(QFxAxis); -class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform +class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform { Q_OBJECT Q_PROPERTY(QFxAxis *axis READ axis) Q_PROPERTY(qreal angle READ angle WRITE setAngle) - Q_PROPERTY(qreal distanceToPlane READ distanceToPlane WRITE setDistanceToPlane) public: - QFxRotation(QObject *parent=0); - ~QFxRotation(); + QFxRotation3D(QObject *parent=0); + ~QFxRotation3D(); QFxAxis *axis(); @@ -136,22 +135,21 @@ private Q_SLOTS: private: QFxAxis _axis; qreal _angle; - qreal _distanceToPlane; mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxRotation); +QML_DECLARE_TYPE(QFxRotation3D); -class Q_DECLARATIVE_EXPORT QFxTranslation : public QFxTransform +class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform { Q_OBJECT Q_PROPERTY(QFxAxis *axis READ axis) Q_PROPERTY(qreal distance READ distance WRITE setDistance) public: - QFxTranslation(QObject *parent=0); - ~QFxTranslation(); + QFxTranslation3D(QObject *parent=0); + ~QFxTranslation3D(); QFxAxis *axis(); @@ -170,7 +168,7 @@ private: mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxTranslation); +QML_DECLARE_TYPE(QFxTranslation3D); class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform { @@ -269,10 +267,8 @@ public: qreal bottomRight_x() const; void setbottomRight_x(qreal); -#if defined(QFX_RENDER_OPENGL) virtual bool isIdentity() const; - virtual QMatrix4x4 transform() const; -#endif + virtual QSimpleCanvas::Matrix transform() const; private: void update(); -- cgit v0.12 From 4eefc8ada9e6849bb9383d75b04cad835f2f9cbf Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 14:26:37 +1000 Subject: Port syntax --- .../webbrowser/content/RectSoftShadow.qml | 40 +- demos/declarative/webbrowser/webbrowser.qml | 612 +++++++++++++++------ 2 files changed, 479 insertions(+), 173 deletions(-) diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml index 2b39422..5817f00 100644 --- a/demos/declarative/webbrowser/content/RectSoftShadow.qml +++ b/demos/declarative/webbrowser/content/RectSoftShadow.qml @@ -1,10 +1,30 @@ - - - - - - +Item { + Image { + source: "pics/softshadow-left.sci" + x: -16 + y: -16 + width: 16 + height: parent.height+32 + } + Image { + source: "pics/softshadow-right.sci" + x: parent.width + y: -16 + width: 16 + height: parent.height+32 + } + Image { + source: "pics/softshadow-top.png" + x: 0 + y: -16 + width: parent.width + height: 16 + } + Image { + source: "pics/softshadow-bottom.png" + x: 0 + y: parent.height + width: webview.width*webview.scale + height: 16 + } +} diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index cf96b3f..79fd1cd 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -1,7 +1,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + } + + Item { + id: WebPanel + anchors.fill: parent + clip: true + Rect { + color: "#555555" + anchors.fill: parent + } + Image { + source: "content/pics/softshadow-bottom.png" + width: WebPanel.width + height: 16 + } + Image { + source: "content/pics/softshadow-top.png" + width: WebPanel.width + height: 16 + anchors.bottom: Footer.top + } + RectSoftShadow { + x: -Flick.xPosition + y: -Flick.yPosition + width: WebView.width*WebView.scale + height: Flick.y+WebView.height*WebView.scale + } + Item { + id: HeaderSpace + width: parent.width + height: 60 + z: 1 + + Image { + id: Header + source: "content/pics/header.png" + width: parent.width + height: 64 + state: "Normal" + x: Flick.xPosition < 0 ? -Flick.xPosition : Flick.xPosition > Flick.viewportWidth-Flick.width + ? -Flick.xPosition+Flick.viewportWidth-Flick.width : 0 + y: Flick.yPosition < 0 ? -Flick.yPosition : progressOff* + (Flick.yPosition>height?-height:-Flick.yPosition) + Text { + id: HeaderText + + text: WebView.title!='' || WebView.progress == 1.0 ? WebView.title : 'Loading...' + elide: "ElideRight" + + color: "white" + styleColor: "black" + style: Raised + + font.family: "Helvetica" + font.size: 10 + font.bold: true + + anchors.left: Header.left + anchors.right: Header.right + anchors.leftMargin: 4 + anchors.rightMargin: 4 + anchors.top: Header.top + anchors.topMargin: 4 + hAlign: AlignHCenter + } + Item { + width: parent.width + anchors.top: HeaderText.bottom + anchors.topMargin: 2 + anchors.bottom: parent.bottom + + Item { + id: UrlBox + height: 31 + anchors.left: parent.left + anchors.leftMargin: 12 + anchors.right: parent.right + anchors.rightMargin: 12 + anchors.top: parent.top + clip: true + Image { + source: "content/pics/addressbar.sci" + anchors.fill: UrlBox + } + Image { + id: UrlBoxhl + source: "content/pics/addressbar-filled.sci" + width: parent.width*WebView.progress + height: parent.height + opacity: 1-Header.progressOff + clip: true + } + /* + KeyProxy { + id: proxy + anchors.left: UrlBox.left + anchors.fill: UrlBox + focusable: true + targets: [keyActions,EditUrl] + } + KeyActions { + id: keyActions + return: "WebBrowser.url = EditUrl.text; proxy.focus=false;" + } + */ + TextEdit { + id: EditUrl + + text: WebView.url == '' ? ' ' : WebView.url + wrap: false + font.size: 11 + color: "#555555" + + anchors.left: UrlBox.left + anchors.right: UrlBox.right + anchors.leftMargin: 6 + anchors.verticalCenter: UrlBox.verticalCenter + anchors.verticalCenterOffset: 1 + + opacity: 0 + } + Text { + id: ShowUrl + text: WebView.url == '' ? ' ' : WebView.url + font.size: 11 + color: "#555555" + anchors.left: UrlBox.left + anchors.right: UrlBox.right + anchors.leftMargin: 6 + anchors.verticalCenter: UrlBox.verticalCenter + anchors.verticalCenterOffset: 1 + } + } + MouseRegion { + anchors.fill: UrlBox + onClicked: { proxy.focus=true } + } + } + properties: Property { + name: "progressOff" + value: 1 + type: "Real" + } + states: [ + State { + name: "Normal" + when: WebView.progress == 1.0 + SetProperty { + target: Header + property: "progressOff" + value: 1 + } + }, + State { + name: "ProgressShown" + when: WebView.progress < 1.0 + SetProperty { + target: Header + property: "progressOff" + value: 0 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + target: Header + properties: "progressOff" + easing: "easeInOutQuad" + duration: 300 + } + } + ] + } + } + Flickable { + id: Flick + width: parent.width + viewportWidth: Math.max(parent.width,WebView.width*WebView.scale) + viewportHeight: Math.max(parent.height,WebView.height*WebView.scale) + anchors.top: HeaderSpace.bottom + anchors.bottom: Footer.top + anchors.left: parent.left + anchors.right: parent.right + + properties: Property { + name: "centerX" + value: 0 + type: "Real" + } + properties: Property { + name: "centerY" + value: 0 + type: "Real" + } + + WebView { + id: WebView + cacheSize: 4000000 + + url: WebBrowser.url + smooth: true + focusable: true + focus: true + + idealWidth: Flick.width + idealHeight: Flick.height/scale + scale: (width > 0) ? Flick.width/width*zoomedOut+(1-zoomedOut) : 1 + + onUrlChanged: { Flick.xPosition=0; Flick.yPosition=0; zoomOut() } + onDoubleClick: { toggleZoom() } + + properties: Property { + name: "zoomedOut" + type: "real" + value: 1 + } + } + Rect { + id: WebViewTint + color: "black" + opacity: 0 + anchors.fill: WebView + MouseRegion { + anchors.fill: WebViewTint + onClicked: { proxy.focus=false } + } + } + } + Image { + id: Footer + source: "content/pics/footer.sci" + width: parent.width + height: 43 + anchors.bottom: parent.bottom + Rect { + y: -1 + width: parent.width + height: 1 + color: "#555555" + } + Item { + id: backbutton + width: back_e.width + height: back_e.height + anchors.right: reload.left + anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + Image { + id: back_e + source: "content/pics/back.png" + anchors.fill: parent + } + Image { + id: back_d + source: "content/pics/back-disabled.png" + anchors.fill: parent + } + states: [ + State { + name: "Enabled" + when: WebView.back.enabled==true + SetProperty { + target: back_e + property: "opacity" + value: 1 + } + SetProperty { + target: back_d + property: "opacity" + value: 0 + } + }, + State { + name: "Disabled" + when: WebView.back.enabled==false + SetProperty { + target: back_e + property: "opacity" + value: 0 + } + SetProperty { + target: back_d + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "opacity" + easing: "easeInOutQuad" + duration: 300 + } + } + ] + MouseRegion { + anchors.fill: back_e + onClicked: { if (WebView.back.enabled) WebView.back.trigger() } + } + } + Image { + id: reload + source: "content/pics/reload.png" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + MouseRegion { + anchors.fill: reload + onClicked: { WebView.reload.trigger() } + } + Item { + id: forwardbutton + width: forward_e.width + height: forward_e.height + anchors.left: reload.right + anchors.leftMargin: 10 + anchors.verticalCenter: parent.verticalCenter + Image { + id: forward_e + source: "content/pics/forward.png" + anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter + } + Image { + id: forward_d + source: "content/pics/forward-disabled.png" + anchors.fill: parent + } + states: [ + State { + name: "Enabled" + when: WebView.forward.enabled==true + SetProperty { + target: forward_e + property: "opacity" + value: 1 + } + SetProperty { + target: forward_d + property: "opacity" + value: 0 + } + }, + State { + name: "Disabled" + when: WebView.forward.enabled==false + SetProperty { + target: forward_e + property: "opacity" + value: 0 + } + SetProperty { + target: forward_d + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "opacity" + easing: "easeInOutQuad" + duration: 320 + } + } + ] + MouseRegion { + anchors.fill: parent + onClicked: { if (WebView.forward.enabled) WebView.forward.trigger() } + } + } + } + } + states: [ + State { + name: "Normal" + SetProperty { + target: WebView + property: "zoomedOut" + value: 0 + } + SetProperty { + target: Flick + property: "xPosition" + value: Math.min(WebView.width-Flick.width,Math.max(0,Flick.centerX-Flick.width/2)) + } + SetProperty { + target: Flick + property: "yPosition" + value: Math.min(WebView.height-Flick.height,Math.max(0,Flick.centerY-Flick.height/2)) + } + }, + State { + name: "ZoomedOut" + SetProperty { + target: WebView + property: "zoomedOut" + value: 1 + } + } + ] + transitions: [ + Transition { + SequentialAnimation { + SetPropertyAction { + target: WebView + property: "smooth" + value: false + } + ParallelAnimation { + NumericAnimation { + target: WebView + properties: "zoomedOut" + easing: "easeInOutQuad" + duration: 200 + } + NumericAnimation { + target: Flick + properties: "xPosition,yPosition" + easing: "easeInOutQuad" + duration: 200 + } + } + SetPropertyAction { + target: WebView + property: "smooth" + value: true + } + } + } + ] +} -- cgit v0.12 From f2fb6b63c6e5572d02245c64da652f13174588b9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Apr 2009 14:54:49 +1000 Subject: Convert all examples and demos from XML format --- .../webbrowser/content/RectSoftShadow.qml | 40 +- demos/declarative/webbrowser/webbrowser.qml | 591 +++++++++++++++------ .../contacts/dummydata/contactModel.qml | 206 +++---- examples/declarative/easing/easing.qml | 157 +++--- examples/declarative/follow/pong.qml | 173 ++++-- .../declarative/listview/dummydata/MyPetsModel.qml | 101 ++-- .../declarative/listview/dummydata/Recipies.qml | 199 +++---- examples/declarative/minehunt/minehunt.qml | 239 ++++++--- examples/declarative/mouseregion/mouse.qml | 72 ++- examples/declarative/velocity/Day.qml | 156 ++++-- examples/declarative/velocity/velocity.qml | 194 ++++--- examples/declarative/xmldata/daringfireball.qml | 84 ++- examples/declarative/xmldata/yahoonews.qml | 149 ++++-- src/declarative/fx/qfxkeyactions.cpp | 2 +- src/declarative/fx/qfxkeyactions.h | 2 +- 15 files changed, 1522 insertions(+), 843 deletions(-) diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml index 2b39422..5817f00 100644 --- a/demos/declarative/webbrowser/content/RectSoftShadow.qml +++ b/demos/declarative/webbrowser/content/RectSoftShadow.qml @@ -1,10 +1,30 @@ - - - - - - +Item { + Image { + source: "pics/softshadow-left.sci" + x: -16 + y: -16 + width: 16 + height: parent.height+32 + } + Image { + source: "pics/softshadow-right.sci" + x: parent.width + y: -16 + width: 16 + height: parent.height+32 + } + Image { + source: "pics/softshadow-top.png" + x: 0 + y: -16 + width: parent.width + height: 16 + } + Image { + source: "pics/softshadow-bottom.png" + x: 0 + y: parent.height + width: webview.width*webview.scale + height: 16 + } +} diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index cf96b3f..2b49c11 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -1,7 +1,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + } + Item { + id: WebPanel + anchors.fill: parent + clip: true + Rect { + color: "#555555" + anchors.fill: parent + } + Image { + source: "content/pics/softshadow-bottom.png" + width: WebPanel.width + height: 16 + } + Image { + source: "content/pics/softshadow-top.png" + width: WebPanel.width + anchors.bottom: Footer.top + height: 16 + } + RectSoftShadow { + x: -Flick.xPosition + y: -Flick.yPosition + width: WebView.width*WebView.scale + height: Flick.y+WebView.height*WebView.scale + } + Item { + id: HeaderSpace + width: parent.width + height: 60 + z: 1 + Image { + id: Header + width: parent.width + state: "Normal" + x: Flick.xPosition < 0 ? -Flick.xPosition : Flick.xPosition > Flick.viewportWidth-Flick.width ? -Flick.xPosition+Flick.viewportWidth-Flick.width : 0 + y: Flick.yPosition < 0 ? -Flick.yPosition : progressOff*(Flick.yPosition>height?-height:-Flick.yPosition) + height: 64 + source: "content/pics/header.png" + Text { + id: HeaderText + text: WebView.title!='' || WebView.progress == 1.0 ? WebView.title : 'Loading...' + color: "white" + styleColor: "black" + style: Raised + font.family: "Helvetica" + font.size: 10 + font.bold: true + elide: "ElideRight" + anchors.left: Header.left + anchors.right: Header.right + anchors.leftMargin: 4 + anchors.rightMargin: 4 + anchors.top: Header.top + anchors.topMargin: 4 + hAlign: AlignHCenter + } + Item { + anchors.top: HeaderText.bottom + anchors.topMargin: 2 + anchors.bottom: parent.bottom + width: parent.width + Item { + id: UrlBox + anchors.left: parent.left + anchors.leftMargin: 12 + anchors.right: parent.right + anchors.rightMargin: 12 + height: 31 + anchors.top: parent.top + clip: true + Image { + source: "content/pics/addressbar.sci" + anchors.fill: UrlBox + } + Image { + id: UrlBoxhl + source: "content/pics/addressbar-filled.sci" + opacity: 1-Header.progressOff + clip: true + width: parent.width*WebView.progress + height: parent.height + } + KeyProxy { + id: proxy + anchors.left: UrlBox.left + anchors.fill: UrlBox + focusable: true + targets: {[keyActions,EditUrl]} + } + KeyActions { + id: keyActions + keyReturn: "WebBrowser.url = EditUrl.text; proxy.focus=false;" + } + TextEdit { + id: EditUrl + color: "#555555" + text: WebView.url == '' ? ' ' : WebView.url + anchors.left: UrlBox.left + anchors.right: UrlBox.right + anchors.leftMargin: 6 + anchors.verticalCenter: UrlBox.verticalCenter + anchors.verticalCenterOffset: 1 + font.size: 11 + wrap: false + opacity: 0 + } + Text { + id: ShowUrl + color: "#555555" + text: WebView.url == '' ? ' ' : WebView.url + anchors.left: UrlBox.left + anchors.right: UrlBox.right + anchors.leftMargin: 6 + anchors.verticalCenter: UrlBox.verticalCenter + anchors.verticalCenterOffset: 1 + font.size: 11 + } + } + MouseRegion { + anchors.fill: UrlBox + onClicked: { proxy.focus=true } + } + } + properties: Property { + name: "progressOff" + value: 1 + type: "Real" + } + states: [ + State { + name: "Normal" + when: WebView.progress == 1.0 + SetProperty { + target: Header + property: "progressOff" + value: 1 + } + }, + State { + name: "ProgressShown" + when: WebView.progress < 1.0 + SetProperty { + target: Header + property: "progressOff" + value: 0 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + target: Header + properties: "progressOff" + easing: "easeInOutQuad" + duration: 300 + } + } + ] + } + } + Flickable { + id: Flick + anchors.top: HeaderSpace.bottom + anchors.bottom: Footer.top + anchors.left: parent.left + anchors.right: parent.right + width: parent.width + viewportWidth: Math.max(parent.width,WebView.width*WebView.scale) + viewportHeight: Math.max(parent.height,WebView.height*WebView.scale) + properties: Property { + name: "centerX" + value: 0 + type: "Real" + } + properties: Property { + name: "centerY" + value: 0 + type: "Real" + } + WebView { + id: WebView + cacheSize: 4000000 + smooth: true + url: WebBrowser.url + onDoubleClick: { toggleZoom() } + focusable: true + focus: true + idealWidth: Flick.width + idealHeight: Flick.height/scale + onUrlChanged: { Flick.xPosition=0; Flick.yPosition=0; zoomOut() } + scale: (width > 0) ? Flick.width/width*zoomedOut+(1-zoomedOut) : 1 + properties: Property { + name: "zoomedOut" + type: "real" + value: 1 + } + } + Rect { + id: WebViewTint + anchors.fill: WebView + color: "black" + opacity: 0 + MouseRegion { + anchors.fill: WebViewTint + onClicked: { proxy.focus=false } + } + } + } + Image { + id: Footer + width: parent.width + anchors.bottom: parent.bottom + height: 43 + source: "content/pics/footer.sci" + Rect { + y: -1 + width: parent.width + height: 1 + color: "#555555" + } + Item { + id: backbutton + anchors.right: reload.left + anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + width: back_e.width + height: back_e.height + Image { + anchors.fill: parent + id: back_e + source: "content/pics/back.png" + } + Image { + anchors.fill: parent + id: back_d + source: "content/pics/back-disabled.png" + } + states: [ + State { + name: "Enabled" + when: WebView.back.enabled==true + SetProperty { + target: back_e + property: "opacity" + value: 1 + } + SetProperty { + target: back_d + property: "opacity" + value: 0 + } + }, + State { + name: "Disabled" + when: WebView.back.enabled==false + SetProperty { + target: back_e + property: "opacity" + value: 0 + } + SetProperty { + target: back_d + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "opacity" + easing: "easeInOutQuad" + duration: 300 + } + } + ] + MouseRegion { + anchors.fill: back_e + onClicked: { if (WebView.back.enabled) WebView.back.trigger() } + } + } + Image { + id: reload + source: "content/pics/reload.png" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + MouseRegion { + anchors.fill: reload + onClicked: { WebView.reload.trigger() } + } + Item { + id: forwardbutton + anchors.left: reload.right + anchors.leftMargin: 10 + anchors.verticalCenter: parent.verticalCenter + width: forward_e.width + height: forward_e.height + Image { + anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter + id: forward_e + source: "content/pics/forward.png" + } + Image { + anchors.fill: parent + id: forward_d + source: "content/pics/forward-disabled.png" + } + states: [ + State { + name: "Enabled" + when: WebView.forward.enabled==true + SetProperty { + target: forward_e + property: "opacity" + value: 1 + } + SetProperty { + target: forward_d + property: "opacity" + value: 0 + } + }, + State { + name: "Disabled" + when: WebView.forward.enabled==false + SetProperty { + target: forward_e + property: "opacity" + value: 0 + } + SetProperty { + target: forward_d + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "opacity" + easing: "easeInOutQuad" + duration: 320 + } + } + ] + MouseRegion { + anchors.fill: parent + onClicked: { if (WebView.forward.enabled) WebView.forward.trigger() } + } + } + } + } + states: [ + State { + name: "Normal" + SetProperty { + target: WebView + property: "zoomedOut" + value: 0 + } + SetProperty { + target: Flick + property: "xPosition" + value: Math.min(WebView.width-Flick.width,Math.max(0,Flick.centerX-Flick.width/2)) + } + SetProperty { + target: Flick + property: "yPosition" + value: Math.min(WebView.height-Flick.height,Math.max(0,Flick.centerY-Flick.height/2)) + } + }, + State { + name: "ZoomedOut" + SetProperty { + target: WebView + property: "zoomedOut" + value: 1 + } + } + ] + transitions: [ + Transition { + SequentialAnimation { + SetPropertyAction { + target: WebView + property: "smooth" + value: false + } + ParallelAnimation { + NumericAnimation { + target: WebView + properties: "zoomedOut" + easing: "easeInOutQuad" + duration: 200 + } + NumericAnimation { + target: Flick + properties: "xPosition,yPosition" + easing: "easeInOutQuad" + duration: 200 + } + } + SetPropertyAction { + target: WebView + property: "smooth" + value: true + } + } + } + ] +} diff --git a/examples/declarative/contacts/dummydata/contactModel.qml b/examples/declarative/contacts/dummydata/contactModel.qml index 341b7a6..48b2fd9 100644 --- a/examples/declarative/contacts/dummydata/contactModel.qml +++ b/examples/declarative/contacts/dummydata/contactModel.qml @@ -1,103 +1,103 @@ - - - Aaron - Kennedy - contact.png - - - - - - - Contact - 1 - contact.png - - - Contact - 2 - contact.png - - - Contact - 3 - contact.png - - - Contact - 4 - contact.png - - - Contact - 5 - contact.png - - - Contact - 6 - contact.png - - - Contact - 7 - contact.png - - - Contact - 8 - contact.png - - - Contact - 9 - contact.png - - - Alan - Alpert - contact.png - - - Betty - Boo - contact.png - - - Foo - Bar - contact.png - - - Marius - Bugge Monsen - contact.png - - - Martin - Jones - contact.png - - - - - - - Michael - Brasser - contact.png - - - - - - Yann - Bodson - contact.png - - - Yogi - Bear - contact.png - - +ListModel2 { + ListElement { + firstName: "Aaron" + lastName: "Kennedy" + portrait: "contact.png" + emails: [ + ListElement { address: "akennedy@trolltech.com" }, + ListElement { address: "aaron.kennedy@trolltech.com" } + ] + } + ListElement { + firstName: "ListElement" + lastName: 1 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 2 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 3 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 4 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 5 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 6 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 7 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 8 + portrait: "contact.png" + } + ListElement { + firstName: "ListElement" + lastName: 9 + portrait: "contact.png" + } + ListElement { + firstName: "Alan" + lastName: "Alpert" + portrait: "contact.png" + } + ListElement { + firstName: "Betty" + lastName: "Boo" + portrait: "contact.png" + } + ListElement { + firstName: "Foo" + lastName: "Bar" + portrait: "contact.png" + } + ListElement { + firstName: "Marius" + lastName: "Bugge Monsen" + portrait: "contact.png" + } + ListElement { + firstName: "Martin" + lastName: "Jones" + portrait: "contact.png" + emails: [ + ListElement { address: "mjones@trolltech.com" }, + ListElement { address: "martin.jones@trolltech.com" } + ] + } + ListElement { + firstName: "Michael" + lastName: "Brasser" + portrait: "contact.png" + emails: ListElement { + address: "mbrasser@trolltech.com" + } + } + ListElement { + firstName: "Yann" + lastName: "Bodson" + portrait: "contact.png" + } + ListElement { + firstName: "Yogi" + lastName: "Bear" + portrait: "contact.png" + } +} diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml index f95d8c6..32c1b9b 100644 --- a/examples/declarative/easing/easing.qml +++ b/examples/declarative/easing/easing.qml @@ -1,67 +1,92 @@ - +Rect { + id: Window + width: 640 + height: Layout.height + color: "white" - - - easeLinear - easeInQuad - easeOutQuad - easeInOutQuad - easeOutInQuad - easeInCubic - easeOutCubic - easeInOutCubic - easeOutInCubic - easeInQuart - easeOutQuart - easeInOutQuart - easeOutInQuart - easeInQuint - easeOutQuint - easeInOutQuint - easeOutInQuint - easeInSine - easeOutSine - easeInOutSine - easeOutInSine - easeInExpo - easeOutExpo - easeInOutExpo - easeOutInExpo - easeInCirc - easeOutCirc - easeInOutCirc - easeOutInCirc - easeInElastic - easeOutElastic - easeInOutElastic - easeOutInElastic - easeInBack - easeOutBack - easeInOutBack - easeOutInBack - easeOutBounce - easeInBounce - easeInOutBounce - easeOutInBounce - - - - - - - - - - - - - - - - - - - - - - + ListModel2 { + id: EasingTypes + ListElement { type: "easeLinear" } + ListElement { type: "easeInQuad" } + ListElement { type: "easeOutQuad" } + ListElement { type: "easeInOutQuad" } + ListElement { type: "easeOutInQuad" } + ListElement { type: "easeInCubic" } + ListElement { type: "easeOutCubic" } + ListElement { type: "easeInOutCubic" } + ListElement { type: "easeOutInCubic" } + ListElement { type: "easeInQuart" } + ListElement { type: "easeOutQuart" } + ListElement { type: "easeInOutQuart" } + ListElement { type: "easeOutInQuart" } + ListElement { type: "easeInQuint" } + ListElement { type: "easeOutQuint" } + ListElement { type: "easeInOutQuint" } + ListElement { type: "easeOutInQuint" } + ListElement { type: "easeInSine" } + ListElement { type: "easeOutSine" } + ListElement { type: "easeInOutSine" } + ListElement { type: "easeOutInSine" } + ListElement { type: "easeInExpo" } + ListElement { type: "easeOutExpo" } + ListElement { type: "easeInOutExpo" } + ListElement { type: "easeOutInExpo" } + ListElement { type: "easeInCirc" } + ListElement { type: "easeOutCirc" } + ListElement { type: "easeInOutCirc" } + ListElement { type: "easeOutInCirc" } + ListElement { type: "easeInElastic" } + ListElement { type: "easeOutElastic" } + ListElement { type: "easeInOutElastic" } + ListElement { type: "easeOutInElastic" } + ListElement { type: "easeInBack" } + ListElement { type: "easeOutBack" } + ListElement { type: "easeInOutBack" } + ListElement { type: "easeOutInBack" } + ListElement { type: "easeOutBounce" } + ListElement { type: "easeInBounce" } + ListElement { type: "easeInOutBounce" } + ListElement { type: "easeOutInBounce" } + } + + VerticalLayout { + id: Layout + anchors.left: Window.left + anchors.right: Window.right + Repeater { + dataSource: EasingTypes + Component { + Text { + id: Text + text: type + height: 18 + font.italic: true + x: SequentialAnimation { + id: Anim + NumericAnimation { + from: 0 + to: Window.width / 2 + easing: type + duration: 1000 + } + PauseAnimation { + duration: 300 + } + NumericAnimation { + to: 0 + from: Window.width / 2 + easing: type + duration: 1000 + } + } + children: [ + MouseRegion { + onClicked: { Anim.running=true } + anchors.fill: parent + } + ] + } + } + } + } +} diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml index 4fbf323..ed4a652 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/pong.qml @@ -1,55 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - if (y <= 0) +Rect { + id: Page + width: 640 + height: 480 + color: "#000000" + // Make a ball to bounce + Rect { + id: Ball + x: 20 + width: 20 + height: 20 + color: "#00ee00" + z: 1 + // Add a property for the target y coordinate + properties: Property { + name: "targetY" + value: Page.height-10 + } + properties: Property { + name: "direction" + value: "right" + } + // Move the ball to the right and back to the left repeatedly + x: SequentialAnimation { + running: true + repeat: true + NumericAnimation { + to: Page.width-40 + duration: 2000 + } + SetPropertyAction { + target: Ball + property: "direction" + value: "left" + } + NumericAnimation { + to: 20 + duration: 2000 + } + SetPropertyAction { + target: Ball + property: "direction" + value: "right" + } + } + // Make y follow the target y coordinate, with a velocity of 200 + y: Follow { + source: Ball.targetY + velocity: 200 + } + // Detect the ball hitting the top or bottom of the view and bounce it + onTopChanged: { if (y <= 0) targetY = Page.height-20; - else if (y >= Page.height-20) - targetY = 0; - - - - - - - - - - - - - - - - - - - - - - - + else if (y >= Page.height-20) + targetY = 0; } + } + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rect { + id: LeftBat + color: "#00ee00" + x: 2 + width: 20 + height: 90 + y: Follow { + source: Ball.y-45 + velocity: 300 + enabled: Ball.direction == 'left' + } + } + Rect { + id: RightBat + x: Page.width-22 + color: "#00ee00" + width: 20 + height: 90 + y: Follow { + source: Ball.y-45 + velocity: 300 + enabled: Ball.direction == 'right' + } + } + // The rest, to make it look realistic, if neither ever scores... + Rect { + color: "#00ee00" + width: 40 + height: 60 + x: 320-80 + } + Rect { + color: "#000000" + width: 20 + height: 40 + x: 320-70 + y: 10 + } + Rect { + color: "#00ee00" + width: 40 + height: 60 + x: 320+40 + } + Rect { + color: "#000000" + width: 20 + height: 40 + x: 320+50 + y: 10 + } + Repeater { + dataSource: 24 + Rect { + color: "#00ee00" + width: 10 + height: 10 + x: 320-5 + y: index*20 + } + } +} diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index 5af7fbf..def8cf3 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -1,51 +1,50 @@ - - - - Rover - Dog - 5 - - - Whiskers - Cat - 2 - - - Warren - Rabbit - 2 - - - Polly - Parrot - 12 - - - Spot - Dog - 9 - - - Tiny - Elephant - 15 - - - Penny - Turtle - 4 - - - Joey - Kangaroo - 1 - - - Kimba - Bunny - 65 - - +// ListModel allows free form list models to be defined and populated. +// Be sure to name the file the same as the id. +ListModel2 { + id: MyPetsModel + ListElement { + name: "Rover" + type: "Dog" + age: 5 + } + ListElement { + name: "Whiskers" + type: "Cat" + age: 2 + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + } + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + } +} diff --git a/examples/declarative/listview/dummydata/Recipies.qml b/examples/declarative/listview/dummydata/Recipies.qml index 49bc610..6b20409 100644 --- a/examples/declarative/listview/dummydata/Recipies.qml +++ b/examples/declarative/listview/dummydata/Recipies.qml @@ -1,112 +1,87 @@ - - - - -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- - ]]> -
- - -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- ]]> -
-
- - - * Seasonal Fruit - - - * Chop fruit and place in a bowl. - - - - - -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- - ]]> -
- - -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- - ]]> -
-
- - - -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- - ]]> -
- - -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- - ]]> -
-
- - - -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- - ]]> -
- - -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- - ]]> -
-
-
+ListModel2 { + id: Recipies + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " \ +
    \ +
  • 1 cup (150g) self-raising flour \ +
  • 1 tbs caster sugar \ +
  • 3/4 cup (185ml) milk \ +
  • 1 egg \ +
\ + " + method: " \ +
    \ +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. \ +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. \ +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. \ +
  4. Turn over and cook other side until golden. \ +
" + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " \ +
    \ +
  • 1 onion \ +
  • 1 turnip \ +
  • 1 potato \ +
  • 1 carrot \ +
  • 1 head of celery \ +
  • 1 1/2 litres of water \ +
\ + " + method: " \ +
    \ +
  1. Chop vegetables. \ +
  2. Boil in water until vegetables soften. \ +
  3. Season with salt and pepper to taste. \ +
\ + " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " \ +
    \ +
  • 500g minced beef \ +
  • Seasoning \ +
  • lettuce, tomato, onion, cheese \ +
  • 1 hamburger bun for each burger \ +
\ + " + method: " \ +
    \ +
  1. Mix the beef, together with seasoning, in a food processor. \ +
  2. Shape the beef into burgers. \ +
  3. Grill the burgers for about 5 mins on each side (until cooked through) \ +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. \ +
\ + " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " \ +
    \ +
  • 1 cup Lemon Juice \ +
  • 1 cup Sugar \ +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) \ +
\ + " + method: " \ +
    \ +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. \ +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. \ +
  3. Chill or serve over ice cubes. \ +
\ + " + } +} diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index fb65fa3..cde2612 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -1,73 +1,166 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - In play: - - - - - - - - - - +Item { + id: field + width: 370 + height: 480 + properties: Property { + name: "clickx" + type: "Int" + value: 0 + } + properties: Property { + name: "clicky" + type: "Int" + value: 0 + } + resources: [ + Component { + id: tile + Flipable { + id: flipable + width: 40 + height: 40 + axis: Axis { + startX: 20 + startY: 20 + endX: 20 + endY: 0 + } + front: Image { + source: "pics/front.png" + width: 40 + height: 40 + Image { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + source: "pics/flag.png" + opacity: modelData.hasFlag + opacity: Behaviour { + NumericAnimation { + property: "opacity" + duration: 250 + } + } + } + } + back: Image { + source: "pics/back.png" + width: 40 + height: 40 + Text { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + text: modelData.hint + color: "white" + font.bold: true + opacity: modelData.hasMine == false && modelData.hint > 0 + } + Image { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + source: "pics/bomb.png" + opacity: modelData.hasMine + } + Explosion { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + explode: modelData.hasMine==true && modelData.flipped==true + } + } + states: [ + State { + name: "back" + when: modelData.flipped == true + SetProperty { + target: flipable + property: "rotation" + value: 180 + } + } + ] + transitions: [ + Transition { + SequentialAnimation { + PauseAnimation { + duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} + } + NumericAnimation { + easing: "easeInOutQuad" + properties: "rotation" + } + } + } + ] + MouseRegion { + anchors.fill: parent + onClicked: { field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);} } + } + } + } + ] + Image { + source: "pics/No-Ones-Laughing-3.jpg" + tile: true + } + Description { + text: "Use the 'minehunt' executable to run this demo!" + width: 300 + opacity: tiles?0:1 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + Repeater { + dataSource: tiles + x: 1 + y: 1 + Component { + ComponentInstance { + component: tile + x: (index - (Math.floor(index/9) * 9)) * 41 + y: Math.floor(index/9) * 41 + } + } + } + Item { + id: gamedata + width: 370 + height: 100 + y: 380 + Text { + color: "white" + font.size: 18 + x: 20 + y: 20 + } + Image { + x: 100 + y: 20 + source: "pics/bomb-color.png" + } + Text { + x: 100 + y: 60 + color: "white" + text: numMines + } + Image { + x: 140 + y: 20 + source: "pics/flag-color.png" + } + Text { + x: 140 + y: 60 + color: "white" + text: numFlags + } + Image { + x: 240 + y: 0 + source: if(isPlaying==true){'pics/smile.png'}else{if(hasWon==true){'pics/glee.png'}else{'pics/frown.png'}} + MouseRegion { + anchors.fill: parent + onClicked: { reset() } + } + } + } +} diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index 7aaf51a..6d10425 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -1,24 +1,48 @@ - - - - - - - - - - +Rect { + color: "white" + width: 200 + height: 200 + Rect { + width: 50 + height: 50 + color: "red" + Text { + text: "Click" + anchors.centeredIn: parent + } + MouseRegion { + onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') } + onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') } + onPressAndHold: { print('press and hold') } + onExitedWhilePressed: { print('exiting while pressed') } + onReenteredWhilePressed: { print('reentering while pressed') } + anchors.fill: parent + } + } + Rect { + y: 100 + width: 50 + height: 50 + color: "blue" + Text { + text: "Drag" + anchors.centeredIn: parent + } + MouseRegion { + drag.target: parent + drag.axis: "x" + drag.xmin: 0 + drag.xmax: 150 + onPressed: { print('press') } + onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } + onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') } + onDoubleClicked: { print('double click') } + onPressAndHold: { print('press and hold') } + onExitedWhilePressed: { print('exiting while pressed') } + onReenteredWhilePressed: { print('reentering while pressed') } + anchors.fill: parent + } + } +} diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index b65f2bc..7d26e88 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -1,41 +1,115 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Rect { + width: 400 + height: 500 + radius: 7 + pen.color: "black" + id: Page + properties: Property { + name: "day" + type: "string" + } + properties: Property { + name: "stickies" + } + Image { + x: 10 + y: 10 + source: "cork.jpg" + opaque: true + } + Text { + x: 20 + y: 20 + height: 40 + font.size: 14 + font.bold: true + width: 370 + text: day + style: Outline + styleColor: "#dedede" + } + Repeater { + dataSource: Page.stickies + Item { + x: Math.random() * 200 + 100 + y: Math.random() * 300 + 50 + id: StickyPage + rotation: Follow { + source: -Flick.xVelocity / 100 + spring: 2.0 + damping: 0.1 + } + Item { + id: Sticky + scale: 0.5 + Image { + id: StickyImage + source: "sticky.png" + smooth: true + y: -20 + x: 8 + -width * 0.6 / 2 + scale: 0.6 + } + TextEdit { + id: MyText + smooth: true + font.size: 28 + readOnly: false + x: -104 + y: 36 + wrap: true + rotation: -8 + text: noteText + width: 195 + height: 172 + } + Item { + y: -20 + x: StickyImage.x + width: StickyImage.width * StickyImage.scale + height: StickyImage.height * StickyImage.scale + MouseRegion { + id: Mouse + onClicked: { MyText.focus = true } + anchors.fill: parent + drag.target: StickyPage + drag.axis: "xy" + drag.ymin: 0 + drag.ymax: 500 + drag.xmin: 0 + drag.xmax: 400 + } + } + } + Image { + source: "tack.png" + x: -width / 2 + y: -height * 0.7 / 2 + scale: 0.7 + } + states: [ + State { + name: "pressed" + when: Mouse.pressed + SetProperties { + target: Sticky + rotation: 8 + scale: 1 + } + SetProperties { + target: Page + z: 8 + } + } + ] + transitions: [ + Transition { + NumericAnimation { + properties: "rotation,scale" + duration: 200 + } + } + ] + } + } +} diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index 0215d37..ff95527 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -1,81 +1,113 @@ - - - - Sunday - #808080 - - - - - - - Monday - blue - - - - - - - - Tuesday - yellow - - - - - - - Wednesday - purple - - - - - - - Thursday - blue - - - - - - - Friday - green - - - - - - - Saturday - orange - - - - - - - - - - - - - - - - - - - +Rect { + color: "lightSteelBlue" + width: 800 + height: 600 + ListModel2 { + id: List + ListElement { + name: "Sunday" + dayColor: "#808080" + notes: [ + ListElement { + noteText: "Lunch" + }, + ListElement { + noteText: "Party" + } + ] + } + ListElement { + name: "Monday" + dayColor: "blue" + notes: [ + ListElement { + noteText: "Pickup kids" + }, + ListElement { + noteText: "Checkout kinetic" + }, + ListElement { + noteText: "Read email" + } + ] + } + ListElement { + name: "Tuesday" + dayColor: "yellow" + notes: [ + ListElement { + noteText: "Walk dog" + }, + ListElement { + noteText: "Buy newspaper" + } + ] + } + ListElement { + name: "Wednesday" + dayColor: "purple" + notes: [ + ListElement { + noteText: "Cook dinner" + }, + ListElement { + noteText: "Eat dinner" + } + ] + } + ListElement { + name: "Thursday" + dayColor: "blue" + notes: [ + ListElement { + noteText: "5:30pm Meeting" + }, + ListElement { + noteText: "Weed garden" + } + ] + } + ListElement { + name: "Friday" + dayColor: "green" + notes: [ + ListElement { + noteText: "Still work" + }, + ListElement { + noteText: "Drink" + } + ] + } + ListElement { + name: "Saturday" + dayColor: "orange" + notes: [ + ListElement { + noteText: "Drink" + }, + ListElement { + noteText: "Drink" + } + ] + } + } + Flickable { + id: Flick + anchors.fill: parent + viewportWidth: Lay.width + HorizontalLayout { + id: Lay + Repeater { + dataSource: List + Component { + Day { + day: name + color: dayColor + stickies: notes + } + } + } + } + } +} diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 5e98d1b..3877adf 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -1,25 +1,59 @@ - - - - - declare default element namespace 'http://www.w3.org/2005/Atom'; - - - - - - - - - - - print('link clicked: ' + link) - - - - - - - +Rect { + color: "white" + width: 600 + height: 600 + resources: [ + XmlListModel { + id: feedModel + source: "http://daringfireball.net/index.xml" + query: "doc($src)/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + Role { + name: "title" + query: "title/string()" + } + Role { + name: "tagline" + query: "author/name/string()" + } + Role { + name: "content" + query: "content/string()" + isCData: true + } + }, + Component { + id: feedDelegate + Item { + height: contents.height + 20 + Text { + x: 10 + id: TitleText + text: title + font.bold: true + } + Text { + text: 'by ' + tagline + anchors.left: TitleText.right + anchors.leftMargin: 10 + font.italic: true + } + Text { + x: 10 + text: content + anchors.top: TitleText.bottom + width: 580 + wrap: true + onLinkActivated: { print('link clicked: ' + link) } + } + } + } + ] + ListView { + id: list + anchors.fill: parent + clip: true + model: feedModel + delegate: feedDelegate + } +} diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index 32a706e..a465cdd 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -1,38 +1,111 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Rect { + color: "black" + gradientColor: "#AAAAAA" + width: 600 + height: 600 + resources: [ + XmlListModel { + id: feedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "doc($src)/rss/channel/item" + Role { + name: "title" + query: "title/string()" + } + Role { + name: "link" + query: "link/string()" + } + Role { + name: "description" + query: "description/string()" + isCData: true + } + }, + Component { + id: feedDelegate + Item { + id: Delegate + height: Wrapper.height + 10 + MouseRegion { + anchors.fill: Wrapper + onPressed: { Delegate.ListView.list.currentIndex = index; } + onClicked: { if (Wrapper.state == 'Details') { Wrapper.state = '';} else {Wrapper.state = 'Details';} } + } + Rect { + id: Wrapper + y: 5 + height: TitleText.height + 10 + width: 580 + color: "#F0F0F0" + radius: 5 + Text { + x: 10 + y: 5 + id: TitleText + text: '' + title + '' + font.bold: true + font.family: "Helvetica" + font.size: 14 + onLinkActivated: { print('link clicked: ' + link) } + } + Text { + x: 10 + id: Description + text: description + width: 560 + wrap: true + font.family: "Helvetica" + anchors.top: TitleText.bottom + anchors.topMargin: 5 + opacity: 0 + } + states: [ + State { + name: "Details" + SetProperty { + target: Wrapper + property: "height" + binding: "contents.height + 10" + } + SetProperty { + target: Description + property: "opacity" + value: 1 + } + } + ] + transitions: [ + Transition { + fromState: "*" + toState: "Details" + reversible: true + SequentialAnimation { + NumericAnimation { + duration: 200 + properties: "height" + easing: "easeOutQuad" + } + NumericAnimation { + duration: 200 + properties: "opacity" + } + } + } + ] + } + } + } + ] + ListView { + id: list + x: 10 + y: 10 + width: parent.width - 20 + height: parent.height - 20 + clip: true + model: feedModel + delegate: feedDelegate + currentItemPositioning: "Snap" + } +} diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp index 69d4679..d2739ea 100644 --- a/src/declarative/fx/qfxkeyactions.cpp +++ b/src/declarative/fx/qfxkeyactions.cpp @@ -736,7 +736,7 @@ void QFxKeyActions::setKey_Space(const QString &s) /*! \qmlproperty string KeyActions::escape - \qmlproperty string KeyActions::return + \qmlproperty string KeyActions::keyReturn \qmlproperty string KeyActions::enter \qmlproperty string KeyActions::delete \qmlproperty string KeyActions::space diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h index 7ad323a..b0d002d 100644 --- a/src/declarative/fx/qfxkeyactions.h +++ b/src/declarative/fx/qfxkeyactions.h @@ -101,7 +101,7 @@ class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem Q_PROPERTY(QString digit9 READ key_9 WRITE setKey_9) Q_PROPERTY(QString asterisk READ key_Asterisk WRITE setKey_Asterisk) Q_PROPERTY(QString escape READ key_Escape WRITE setKey_Escape) - Q_PROPERTY(QString return READ key_Return WRITE setKey_Return) + Q_PROPERTY(QString keyReturn READ key_Return WRITE setKey_Return) Q_PROPERTY(QString enter READ key_Enter WRITE setKey_Enter) Q_PROPERTY(QString delete READ key_Delete WRITE setKey_Delete) Q_PROPERTY(QString space READ key_Space WRITE setKey_Space) -- cgit v0.12 From 72afedd7fad133b390cc63fd04e3cf0cee757e2e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Apr 2009 14:58:56 +1000 Subject: Rename duiviewer to qmlviewer. --- doc/src/declarative/examples.qdoc | 9 +- doc/src/declarative/focus.qdoc | 2 +- doc/src/declarative/tutorial1.qdoc | 4 +- doc/src/duiviewer.qdoc | 80 -------- doc/src/qmlviewer.qdoc | 79 ++++++++ doc/src/tutorials/declarative.qdoc | 2 +- tools/duiviewer/duiviewer.pro | 12 -- tools/duiviewer/main.cpp | 135 -------------- tools/duiviewer/qfxviewer.cpp | 367 ------------------------------------- tools/duiviewer/qfxviewer.h | 72 -------- tools/qmlviewer/main.cpp | 135 ++++++++++++++ tools/qmlviewer/qmlviewer.cpp | 366 ++++++++++++++++++++++++++++++++++++ tools/qmlviewer/qmlviewer.h | 72 ++++++++ tools/qmlviewer/qmlviewer.pro | 12 ++ tools/tools.pro | 2 +- 15 files changed, 673 insertions(+), 676 deletions(-) delete mode 100644 doc/src/duiviewer.qdoc create mode 100644 doc/src/qmlviewer.qdoc delete mode 100644 tools/duiviewer/duiviewer.pro delete mode 100644 tools/duiviewer/main.cpp delete mode 100644 tools/duiviewer/qfxviewer.cpp delete mode 100644 tools/duiviewer/qfxviewer.h create mode 100644 tools/qmlviewer/main.cpp create mode 100644 tools/qmlviewer/qmlviewer.cpp create mode 100644 tools/qmlviewer/qmlviewer.h create mode 100644 tools/qmlviewer/qmlviewer.pro diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index e65808f..fa9f05b 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -3,18 +3,18 @@ \target qmlexamples \title QML Examples -A viewer application is included that allows you to quickly explore many of the +A \l {qmlviewer}{viewer} application is included that allows you to quickly explore many of the examples. It has some useful options, revealed by: \code - bin/duiviewer -help + bin/qmlviewer -help \endcode -There are several illustrative XML examples available. From your build +There are several illustrative QML examples available. From your build directory, \code - bin/duiviewer $QT_SOURCE_DIR/examples/declarative/mediabrowser/mediabrowser.qml + bin/qmlviewer $QT_SOURCE_DIR/demos/declarative/phonebrowser/phonebrowser.qml \endcode Many other simple examples can be found under the \c examples/declarative sub @@ -32,5 +32,4 @@ own QML-based applications. software rasterizer, a simple canvas backend is used by default. To use Graphics View instead, set \c QML_USE_GRAPHICSVIEW=1. - */ diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e0d4ca3..fc747a9 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -48,7 +48,7 @@ element whose text is determined by whether or not it has \e {active focus}. An \l Item requests focus by setting the \c {Item::focus} property to true. For very simple cases simply setting the \c {Item::focus} property is sometimes -sufficient. If we run the following example in the \c duiviewer, we see that +sufficient. If we run the following example in the \c qmlviewer, we see that the \c {} element has \e {active focus} and pressing the \e A, \e B, or \e C keys modifies the text appropriately. diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index caadbf5..aa94c06 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -43,10 +43,10 @@ The \c anchors.horizontalCenter property refers to the horizontal center of an e \section2 Viewing the example -To view what you have created, run the duiviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: +To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: \code -bin/duiviewer examples/tutorials/t1/tutorial1.qml +bin/qmlviewer examples/tutorials/t1/tutorial1.qml \endcode [\l tutorial] [Next: \l tutorial2] diff --git a/doc/src/duiviewer.qdoc b/doc/src/duiviewer.qdoc deleted file mode 100644 index f967f87..0000000 --- a/doc/src/duiviewer.qdoc +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page duiviewer.html - \title Declarative UI Viewer (duiviewer) - \ingroup qttools - \keyword duiviewer - - This page documents the \e{Declarative UI Viewer} for the Qt GUI - toolkit. The \c duiviewer reads an XML format declarative user interface definition - (\c .qml) file - and displays the user interface it describes. - - \section1 Options - - When run with the \c -help option, duiviewer shows available options. - - \section1 Dummy Data - - One use of duiviewer is to allow QML files to be viewed stand-alone, - rather than being loaded from within a Qt program. Qt applications will - usually bind objects and properties into the execution context before - running the QML. To stand-in for such bindings, you can provide dummy - data: create a directory called "dummydata" in the same directory as - the target QML file and create files there with the "qml" extension. - All such files will be loaded as QML objects and bound to the root - context as a property with the name of the file (without ".qml"). - - For example, if the Qt application has a "clock.time" property - that is a qreal from 0 to 86400 representing the number of seconds since - midnight, dummy data for this could be provided by \c dummydata/clock.qml: - \code - - - - - - \endcode - Any QML can be used in the dummy data files. You could even animate the - fictional data! -*/ diff --git a/doc/src/qmlviewer.qdoc b/doc/src/qmlviewer.qdoc new file mode 100644 index 0000000..e8fdec4 --- /dev/null +++ b/doc/src/qmlviewer.qdoc @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qmlviewer.html + \title Qt Declarative UI Viewer (qmlviewer) + \ingroup qttools + \keyword qmlviewer + + This page documents the \e{Declarative UI Viewer} for the Qt GUI + toolkit. The \c qmlviewer reads a declarative user interface definition + (\c .qml) file and displays the user interface it describes. + + \section1 Options + + When run with the \c -help option, qmlviewer shows available options. + + \section1 Dummy Data + + One use of qmlviewer is to allow QML files to be viewed stand-alone, + rather than being loaded from within a Qt program. Qt applications will + usually bind objects and properties into the execution context before + running the QML. To stand-in for such bindings, you can provide dummy + data: create a directory called "dummydata" in the same directory as + the target QML file and create files there with the "qml" extension. + All such files will be loaded as QML objects and bound to the root + context as a property with the name of the file (without ".qml"). + + For example, if the Qt application has a "clock.time" property + that is a qreal from 0 to 86400 representing the number of seconds since + midnight, dummy data for this could be provided by \c dummydata/clock.qml: + \code + + + + + + \endcode + Any QML can be used in the dummy data files. You could even animate the + fictional data! +*/ diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index 3724b10..16dad6e 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -77,7 +77,7 @@ sub directory the files are numbered in an order of increasing features. The code in this example is not compiled, but interpreted at run time. - This means you should use the duiviewer application provided with + This means you should use the qmlviewer application provided with Qt to run the examples. \list diff --git a/tools/duiviewer/duiviewer.pro b/tools/duiviewer/duiviewer.pro deleted file mode 100644 index eae313e..0000000 --- a/tools/duiviewer/duiviewer.pro +++ /dev/null @@ -1,12 +0,0 @@ -DESTDIR = ../../bin -QT += declarative script network sql -# Input -HEADERS += qfxviewer.h -SOURCES += main.cpp qfxviewer.cpp - -include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) - -target.path=$$[QT_INSTALL_BINS] -INSTALLS += target - -CONFIG += console diff --git a/tools/duiviewer/main.cpp b/tools/duiviewer/main.cpp deleted file mode 100644 index cb4ba05..0000000 --- a/tools/duiviewer/main.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qt Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "qml.h" -#include "qfxviewer.h" -#include -#include -#include "qfxtestengine.h" -#include - - -void usage() -{ - qWarning("Usage: duiviewer [options] "); - qWarning(" "); - qWarning(" options:"); - qWarning(" -v, -version ............................. display version"); - qWarning(" -frameless ............................... run with no window frame"); - qWarning(" -skin ...................... run with a skin window frame"); - qWarning(" -recorddither ordered|threshold|floyd .... set dither mode used for recording"); - qWarning(" -recordperiod ............. set time between recording frames"); - qWarning(" -autorecord [from-] ...... set recording to start and stop automatically"); - qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -cache ................................... enable a disk cache of remote content"); - qWarning(" -recordtest .................. record an autotest"); - qWarning(" -runtest ..................... run a previously recorded test"); - qWarning(" "); - qWarning(" Press F1 for interactive help"); - exit(1); -} - -int main(int argc, char ** argv) -{ - //### default to using raster graphics backend for now - int newargc = argc + 2; - char **newargv; - newargv = new char * [newargc]; - for (int i = 0; i < argc; ++i) { - newargv[i] = argv[i]; - if (!qstrcmp(argv[i], "-graphicssystem")) { - newargc -= 2; - break; - } - } - char system[] = "-graphicssystem"; - newargv[argc] = system; - char raster[] = "raster"; - newargv[argc+1] = raster; - - - QApplication app(newargc, newargv); - app.setApplicationName("viewer"); - - bool frameless = false; - QString fileName; - int period = 0; - int autorecord_from = 0; - int autorecord_to = 0; - QString dither = "threshold"; - QString skin; - bool devkeys = false; - bool cache = false; - QFxTestEngine::TestMode testMode = QFxTestEngine::NoTest; - QString testDir; - - for (int i = 1; i < newargc; ++i) { - QString arg = newargv[i]; - if (arg == "-frameless") { - frameless = true; - } else if (arg == "-skin") { - skin = QString(argv[++i]); - } else if (arg == "-cache") { - cache = true; - } else if (arg == "-recordperiod") { - period = QString(argv[++i]).toInt(); - } else if (arg == "-autorecord") { - QString range = QString(argv[++i]); - int dash = range.indexOf('-'); - if (dash > 0) - autorecord_from = range.left(dash).toInt(); - autorecord_to = range.mid(dash+1).toInt(); - } else if (arg == "-devicekeys") { - devkeys = true; - } else if (arg == "-recordtest") { - testMode = QFxTestEngine::RecordTest; - if(i + 1 >= newargc) - usage(); - testDir = newargv[i + 1]; - ++i; - } else if (arg == "-runtest") { - testMode = QFxTestEngine::PlaybackTest; - if(i + 1 >= newargc) - usage(); - testDir = newargv[i + 1]; - ++i; - } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { - fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); - return 0; - } else if (arg[0] != '-') { - fileName = arg; - } else if (1 || arg == "-help") { - usage(); - } - } - - if (fileName.isEmpty()) - usage(); - - QFxViewer viewer(testMode, testDir, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); - viewer.setCacheEnabled(cache); - viewer.openXml(fileName); - if (period>0) - viewer.setRecordPeriod(period); - if (autorecord_to) - viewer.setAutoRecord(autorecord_from,autorecord_to); - if (QDir(skin).exists()) - viewer.setSkin(skin); - if (devkeys) - viewer.setDeviceKeys(true); - viewer.setRecordDither(dither); - viewer.show(); - - return app.exec(); -} - diff --git a/tools/duiviewer/qfxviewer.cpp b/tools/duiviewer/qfxviewer.cpp deleted file mode 100644 index b15a8bf..0000000 --- a/tools/duiviewer/qfxviewer.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qt Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include - -#include "qmlbindablevalue.h" -#include "qfxviewer.h" -#include -#include -#include "qml.h" -#include "qperformancelog.h" -#include "qfxtestengine.h" -#include "deviceskin.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QFxViewer::QFxViewer(QFxTestEngine::TestMode testMode, const QString &testDir, QWidget *parent, Qt::WindowFlags flags) - : QWidget(parent, flags) -{ - testEngine = 0; - devicemode = false; - skin = 0; - canvas = 0; - record_autotime = 0; - record_period = 20; - - int width=240; - int height=320; - setAttribute(Qt::WA_OpaquePaintEvent); - setAttribute(Qt::WA_NoSystemBackground); - - canvas = new QFxView(this); - if(testMode != QFxTestEngine::NoTest) - testEngine = new QFxTestEngine(testMode, testDir, canvas, this); - - QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); - canvas->setFixedSize(width, height); - resize(width, height); -} - -void QFxViewer::reload() -{ - openXml(currentFileName); -} - -void QFxViewer::openXml(const QString& fileName) -{ - setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName)); - - canvas->reset(); - - currentFileName = fileName; - QUrl url(fileName); - QFileInfo fi(fileName); - if (fi.exists()) { - url = QUrl::fromLocalFile(fi.absoluteFilePath()); - QmlContext *ctxt = canvas->rootContext(); - QDir dir(fi.path()+"/dummydata", "*.qml"); - QStringList list = dir.entryList(); - for (int i = 0; i < list.size(); ++i) { - QString qml = list.at(i); - QFile f(dir.filePath(qml)); - f.open(QIODevice::ReadOnly); - QByteArray data = f.readAll(); - QmlComponent comp(canvas->engine()); - comp.setData(data, QUrl()); - QObject *dummyData = comp.create(); - if (dummyData) { - qWarning() << "Loaded dummy data:" << dir.filePath(qml); - qml.truncate(qml.length()-4); - ctxt->setContextProperty(qml, dummyData); - dummyData->setParent(this); - } - } - } - - canvas->setUrl(url); - - QTime t; - t.start(); - canvas->execute(); - qWarning() << "Wall startup time:" << t.elapsed(); -#ifdef QTOPIA - show(); -#endif -} - -class PreviewDeviceSkin : public DeviceSkin -{ - Q_OBJECT -public: - explicit PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent); - - void setPreview(QWidget *formWidget); - void setScreenSize(const QSize& size) - { - QMatrix fit; - fit = fit.scale(qreal(size.width())/m_screenSize.width(), - qreal(size.height())/m_screenSize.height()); - setTransform(fit); - } - -private slots: - void slotSkinKeyPressEvent(int code, const QString& text, bool autorep); - void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep); - void slotPopupMenu(); - -private: - void populateContextMenu(QMenu *menu); - const QSize m_screenSize; -}; - - -PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent) : - DeviceSkin(parameters, parent), - m_screenSize(parameters.screenSize()) -{ - connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)), - this, SLOT(slotSkinKeyPressEvent(int,QString,bool))); - connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)), - this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool))); - connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu())); -} - -void PreviewDeviceSkin::setPreview(QWidget *formWidget) -{ - formWidget->setFixedSize(m_screenSize); - formWidget->setParent(this, Qt::SubWindow); - formWidget->setAutoFillBackground(true); - setView(formWidget); -} - -void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep) -{ - if (QWidget *focusWidget = QApplication::focusWidget()) { - QKeyEvent e(QEvent::KeyPress,code,0,text,autorep); - QApplication::sendEvent(focusWidget, &e); - } - -} - -void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep) -{ - if (QWidget *focusWidget = QApplication::focusWidget()) { - QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep); - QApplication::sendEvent(focusWidget, &e); - } -} - -void PreviewDeviceSkin::slotPopupMenu() -{ - QMenu menu(this); - populateContextMenu(&menu); - menu.exec(QCursor::pos()); -} - -void PreviewDeviceSkin::populateContextMenu(QMenu *menu) -{ - connect(menu->addAction(tr("&Close")), SIGNAL(triggered()), parentWidget(), SLOT(close())); -} - - -void QFxViewer::setSkin(const QString& skinDirectory) -{ - DeviceSkinParameters parameters; - QString err; - if (parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { - delete skin; - if (!err.isEmpty()) - qWarning() << err; - skin = new PreviewDeviceSkin(parameters,this); - skin->setScreenSize(canvas->size()); - canvas->setParent(skin, Qt::SubWindow); - canvas->setAutoFillBackground(true); - skin->setView(canvas); - delete layout(); - - canvas->show(); - } -} - -void QFxViewer::setAutoRecord(int from, int to) -{ - record_autotime = to-from; - if (from) { - autoStartTimer.start(from,this); - } else { - autoTimer.start(); - setRecording(true); - } -} - -void QFxViewer::setRecordPeriod(int ms) -{ - record_period = ms; -} - -void QFxViewer::sceneResized(QSize size) -{ - if (size.width() > 0 && size.height() > 0) { - canvas->setFixedSize(size.width(), size.height()); - if (skin) - skin->setScreenSize(size); - else - resize(size); - } -} - -void QFxViewer::resizeEvent(QResizeEvent *) -{ - if (!skin) - canvas->setFixedSize(width(),height()); -} - -void QFxViewer::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_0 && devicemode) - exit(0); - else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) { - qDebug() << "F1 - help\n" - << "F2 - toggle GIF recording\n" - << "F3 - take PNG snapshot\n" - << "F4 - show items and state\n" - << "F5 - reload XML\n" - << "F6 - show object tree\n" - << "F7 - show timing\n" - << "F8 - show performance (if available)\n" - << "device keys: 0=quit, 1..8=F1..F8" - ; - } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { - setRecording(!recordTimer.isActive()); - } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { - setRecording(!recordTimer.isActive()); - canvas->asImage().save("snapshot.png"); - qDebug() << "Wrote snapshot.png"; - } else if (event->key() == Qt::Key_F4 || (event->key() == Qt::Key_4 && devicemode)) { - canvas->dumpItems(); - canvas->checkState(); - } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) { - reload(); - } else if (event->key() == Qt::Key_F6 || (event->key() == Qt::Key_6 && devicemode)) { - canvas->dumpRoot(); - } else if (event->key() == Qt::Key_F7 || (event->key() == Qt::Key_7 && devicemode)) { - canvas->dumpTiming(); - } else if (event->key() == Qt::Key_F8 || (event->key() == Qt::Key_8 && devicemode)) { - QPerformanceLog::displayData(); - QPerformanceLog::clear(); - } else if (event->key() == Qt::Key_F9) { - if(testEngine) testEngine->save(); - } else if (event->key() == Qt::Key_F10) { - if(testEngine) testEngine->captureFullFrame(); - } - - QWidget::keyPressEvent(event); -} - -void QFxViewer::setRecording(bool on) -{ - if (on == recordTimer.isActive()) - return; - - if (on) { - recordTimer.start(record_period,this); - } else { - recordTimer.stop(); - int frame=0; - QStringList inputs; - qDebug() << "Saving frames..."; - - foreach (QImage* img, frames) { - QString name; - name.sprintf("tmp-frame%04d.png",frame++); - if (record_dither=="ordered") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); - else if (record_dither=="threshold") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name); - else if (record_dither=="floyd") - img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name); - else - img->convertToFormat(QImage::Format_Indexed8).save(name); - inputs << name; - delete img; - } - QString output="animation.gif"; - - QStringList args; - - args << "-delay" << QString::number(record_period/10); - args << inputs; - args << output; - qDebug() << "Converting..." << output; - if (0!=QProcess::execute("convert", args)) { - qWarning() << "Cannot run ImageMagick 'convert' - not converted to gif"; - inputs.clear(); // don't remove them - qDebug() << "Wrote frames tmp-frame*.png"; - } else { - qDebug() << "Compressing..." << output; - if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << output << output)) - qWarning() << "Cannot run 'gifsicle' - not compressed"; - qDebug() << "Wrote" << output; - } - - foreach (QString name, inputs) - QFile::remove(name); - - frames.clear(); - } - qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); -} - -void QFxViewer::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == recordTimer.timerId()) { - frames.append(new QImage(canvas->asImage())); - if (record_autotime && autoTimer.elapsed() >= record_autotime) - setRecording(false); - } else if (event->timerId() == autoStartTimer.timerId()) { - autoTimer.start(); - autoStartTimer.stop(); - setRecording(true); - } else { - QWidget::timerEvent(event); - } -} - -void QFxViewer::setDeviceKeys(bool on) -{ - devicemode = on; -} - -void QFxViewer::setCacheEnabled(bool on) -{ - QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - if (on == !!nam->cache()) - return; - if (on) { - // Setup a caching network manager - QNetworkDiskCache *cache = new QNetworkDiskCache; - cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); - cache->setMaximumCacheSize(8000000); - nam->setCache(cache); - } else { - nam->setCache(0); - } -} - -#include "qfxviewer.moc" diff --git a/tools/duiviewer/qfxviewer.h b/tools/duiviewer/qfxviewer.h deleted file mode 100644 index 7a190c5..0000000 --- a/tools/duiviewer/qfxviewer.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qt Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef QFXVIEWER_H -#define QFXVIEWER_H - -#include -#include -#include -#include -#include - - -class QFxView; -class PreviewDeviceSkin; -class QFxTestEngine; - -class QFxViewer : public QWidget -{ -Q_OBJECT -public: - QFxViewer(QFxTestEngine::TestMode = QFxTestEngine::NoTest, const QString &testDir = QString(), QWidget *parent=0, Qt::WindowFlags flags=0); - - void setRecordDither(const QString& s) { record_dither = s; } - void setRecordPeriod(int ms); - int recordPeriod() const { return record_period; } - void setRecording(bool on); - bool isRecording() const { return recordTimer.isActive(); } - void setAutoRecord(int from, int to); - void setSkin(const QString& skinDirectory); - void setDeviceKeys(bool); - void setCacheEnabled(bool); - -public slots: - void sceneResized(QSize size); - void openXml(const QString& fileName); - void reload(); - -protected: - virtual void keyPressEvent(QKeyEvent *); - virtual void timerEvent(QTimerEvent *); - virtual void resizeEvent(QResizeEvent *); - -private: - QString currentFileName; - PreviewDeviceSkin *skin; - QSize skinscreensize; - QFxView *canvas; - void init(QFxTestEngine::TestMode, const QString &, const QString& fileName); - QBasicTimer recordTimer; - QList frames; - QBasicTimer autoStartTimer; - QTime autoTimer; - QString record_dither; - int record_period; - int record_autotime; - bool devicemode; - - QFxTestEngine *testEngine; -}; - -#endif diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp new file mode 100644 index 0000000..c5676ab --- /dev/null +++ b/tools/qmlviewer/main.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "qml.h" +#include "qmlviewer.h" +#include +#include +#include "qfxtestengine.h" +#include + + +void usage() +{ + qWarning("Usage: qmlviewer [options] "); + qWarning(" "); + qWarning(" options:"); + qWarning(" -v, -version ............................. display version"); + qWarning(" -frameless ............................... run with no window frame"); + qWarning(" -skin ...................... run with a skin window frame"); + qWarning(" -recorddither ordered|threshold|floyd .... set dither mode used for recording"); + qWarning(" -recordperiod ............. set time between recording frames"); + qWarning(" -autorecord [from-] ...... set recording to start and stop automatically"); + qWarning(" -devicekeys .............................. use numeric keys (see F1)"); + qWarning(" -cache ................................... enable a disk cache of remote content"); + qWarning(" -recordtest .................. record an autotest"); + qWarning(" -runtest ..................... run a previously recorded test"); + qWarning(" "); + qWarning(" Press F1 for interactive help"); + exit(1); +} + +int main(int argc, char ** argv) +{ + //### default to using raster graphics backend for now + int newargc = argc + 2; + char **newargv; + newargv = new char * [newargc]; + for (int i = 0; i < argc; ++i) { + newargv[i] = argv[i]; + if (!qstrcmp(argv[i], "-graphicssystem")) { + newargc -= 2; + break; + } + } + char system[] = "-graphicssystem"; + newargv[argc] = system; + char raster[] = "raster"; + newargv[argc+1] = raster; + + + QApplication app(newargc, newargv); + app.setApplicationName("viewer"); + + bool frameless = false; + QString fileName; + int period = 0; + int autorecord_from = 0; + int autorecord_to = 0; + QString dither = "threshold"; + QString skin; + bool devkeys = false; + bool cache = false; + QFxTestEngine::TestMode testMode = QFxTestEngine::NoTest; + QString testDir; + + for (int i = 1; i < newargc; ++i) { + QString arg = newargv[i]; + if (arg == "-frameless") { + frameless = true; + } else if (arg == "-skin") { + skin = QString(argv[++i]); + } else if (arg == "-cache") { + cache = true; + } else if (arg == "-recordperiod") { + period = QString(argv[++i]).toInt(); + } else if (arg == "-autorecord") { + QString range = QString(argv[++i]); + int dash = range.indexOf('-'); + if (dash > 0) + autorecord_from = range.left(dash).toInt(); + autorecord_to = range.mid(dash+1).toInt(); + } else if (arg == "-devicekeys") { + devkeys = true; + } else if (arg == "-recordtest") { + testMode = QFxTestEngine::RecordTest; + if(i + 1 >= newargc) + usage(); + testDir = newargv[i + 1]; + ++i; + } else if (arg == "-runtest") { + testMode = QFxTestEngine::PlaybackTest; + if(i + 1 >= newargc) + usage(); + testDir = newargv[i + 1]; + ++i; + } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { + fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); + return 0; + } else if (arg[0] != '-') { + fileName = arg; + } else if (1 || arg == "-help") { + usage(); + } + } + + if (fileName.isEmpty()) + usage(); + + QmlViewer viewer(testMode, testDir, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); + viewer.setCacheEnabled(cache); + viewer.openQml(fileName); + if (period>0) + viewer.setRecordPeriod(period); + if (autorecord_to) + viewer.setAutoRecord(autorecord_from,autorecord_to); + if (QDir(skin).exists()) + viewer.setSkin(skin); + if (devkeys) + viewer.setDeviceKeys(true); + viewer.setRecordDither(dither); + viewer.show(); + + return app.exec(); +} + diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp new file mode 100644 index 0000000..87bebfa --- /dev/null +++ b/tools/qmlviewer/qmlviewer.cpp @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include + +#include "qmlbindablevalue.h" +#include "qmlviewer.h" +#include +#include +#include "qml.h" +#include "qperformancelog.h" +#include "qfxtestengine.h" +#include "deviceskin.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QmlViewer::QmlViewer(QFxTestEngine::TestMode testMode, const QString &testDir, QWidget *parent, Qt::WindowFlags flags) + : QWidget(parent, flags) +{ + testEngine = 0; + devicemode = false; + skin = 0; + canvas = 0; + record_autotime = 0; + record_period = 20; + + int width=240; + int height=320; + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_NoSystemBackground); + + canvas = new QFxView(this); + if(testMode != QFxTestEngine::NoTest) + testEngine = new QFxTestEngine(testMode, testDir, canvas, this); + + QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); + canvas->setFixedSize(width, height); + resize(width, height); +} + +void QmlViewer::reload() +{ + openQml(currentFileName); +} + +void QmlViewer::openQml(const QString& fileName) +{ + setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(fileName)); + + canvas->reset(); + + currentFileName = fileName; + QUrl url(fileName); + QFileInfo fi(fileName); + if (fi.exists()) { + url = QUrl::fromLocalFile(fi.absoluteFilePath()); + QmlContext *ctxt = canvas->rootContext(); + QDir dir(fi.path()+"/dummydata", "*.qml"); + QStringList list = dir.entryList(); + for (int i = 0; i < list.size(); ++i) { + QString qml = list.at(i); + QFile f(dir.filePath(qml)); + f.open(QIODevice::ReadOnly); + QByteArray data = f.readAll(); + QmlComponent comp(canvas->engine()); + comp.setData(data, QUrl()); + QObject *dummyData = comp.create(); + if (dummyData) { + qWarning() << "Loaded dummy data:" << dir.filePath(qml); + qml.truncate(qml.length()-4); + ctxt->setContextProperty(qml, dummyData); + dummyData->setParent(this); + } + } + } + + canvas->setUrl(url); + + QTime t; + t.start(); + canvas->execute(); + qWarning() << "Wall startup time:" << t.elapsed(); +#ifdef QTOPIA + show(); +#endif +} + +class PreviewDeviceSkin : public DeviceSkin +{ + Q_OBJECT +public: + explicit PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent); + + void setPreview(QWidget *formWidget); + void setScreenSize(const QSize& size) + { + QMatrix fit; + fit = fit.scale(qreal(size.width())/m_screenSize.width(), + qreal(size.height())/m_screenSize.height()); + setTransform(fit); + } + +private slots: + void slotSkinKeyPressEvent(int code, const QString& text, bool autorep); + void slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep); + void slotPopupMenu(); + +private: + void populateContextMenu(QMenu *menu); + const QSize m_screenSize; +}; + + +PreviewDeviceSkin::PreviewDeviceSkin(const DeviceSkinParameters ¶meters, QWidget *parent) : + DeviceSkin(parameters, parent), + m_screenSize(parameters.screenSize()) +{ + connect(this, SIGNAL(skinKeyPressEvent(int,QString,bool)), + this, SLOT(slotSkinKeyPressEvent(int,QString,bool))); + connect(this, SIGNAL(skinKeyReleaseEvent(int,QString,bool)), + this, SLOT(slotSkinKeyReleaseEvent(int,QString,bool))); + connect(this, SIGNAL(popupMenu()), this, SLOT(slotPopupMenu())); +} + +void PreviewDeviceSkin::setPreview(QWidget *formWidget) +{ + formWidget->setFixedSize(m_screenSize); + formWidget->setParent(this, Qt::SubWindow); + formWidget->setAutoFillBackground(true); + setView(formWidget); +} + +void PreviewDeviceSkin::slotSkinKeyPressEvent(int code, const QString& text, bool autorep) +{ + if (QWidget *focusWidget = QApplication::focusWidget()) { + QKeyEvent e(QEvent::KeyPress,code,0,text,autorep); + QApplication::sendEvent(focusWidget, &e); + } + +} + +void PreviewDeviceSkin::slotSkinKeyReleaseEvent(int code, const QString& text, bool autorep) +{ + if (QWidget *focusWidget = QApplication::focusWidget()) { + QKeyEvent e(QEvent::KeyRelease,code,0,text,autorep); + QApplication::sendEvent(focusWidget, &e); + } +} + +void PreviewDeviceSkin::slotPopupMenu() +{ + QMenu menu(this); + populateContextMenu(&menu); + menu.exec(QCursor::pos()); +} + +void PreviewDeviceSkin::populateContextMenu(QMenu *menu) +{ + connect(menu->addAction(tr("&Close")), SIGNAL(triggered()), parentWidget(), SLOT(close())); +} + + +void QmlViewer::setSkin(const QString& skinDirectory) +{ + DeviceSkinParameters parameters; + QString err; + if (parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { + delete skin; + if (!err.isEmpty()) + qWarning() << err; + skin = new PreviewDeviceSkin(parameters,this); + skin->setScreenSize(canvas->size()); + canvas->setParent(skin, Qt::SubWindow); + canvas->setAutoFillBackground(true); + skin->setView(canvas); + delete layout(); + + canvas->show(); + } +} + +void QmlViewer::setAutoRecord(int from, int to) +{ + record_autotime = to-from; + if (from) { + autoStartTimer.start(from,this); + } else { + autoTimer.start(); + setRecording(true); + } +} + +void QmlViewer::setRecordPeriod(int ms) +{ + record_period = ms; +} + +void QmlViewer::sceneResized(QSize size) +{ + if (size.width() > 0 && size.height() > 0) { + canvas->setFixedSize(size.width(), size.height()); + if (skin) + skin->setScreenSize(size); + else + resize(size); + } +} + +void QmlViewer::resizeEvent(QResizeEvent *) +{ + if (!skin) + canvas->setFixedSize(width(),height()); +} + +void QmlViewer::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_0 && devicemode) + exit(0); + else if (event->key() == Qt::Key_F1 || (event->key() == Qt::Key_1 && devicemode)) { + qDebug() << "F1 - help\n" + << "F2 - toggle GIF recording\n" + << "F3 - take PNG snapshot\n" + << "F4 - show items and state\n" + << "F5 - reload XML\n" + << "F6 - show object tree\n" + << "F7 - show timing\n" + << "F8 - show performance (if available)\n" + << "device keys: 0=quit, 1..8=F1..F8" + ; + } else if (event->key() == Qt::Key_F2 || (event->key() == Qt::Key_2 && devicemode)) { + setRecording(!recordTimer.isActive()); + } else if (event->key() == Qt::Key_F3 || (event->key() == Qt::Key_3 && devicemode)) { + canvas->asImage().save("snapshot.png"); + qDebug() << "Wrote snapshot.png"; + } else if (event->key() == Qt::Key_F4 || (event->key() == Qt::Key_4 && devicemode)) { + canvas->dumpItems(); + canvas->checkState(); + } else if (event->key() == Qt::Key_F5 || (event->key() == Qt::Key_5 && devicemode)) { + reload(); + } else if (event->key() == Qt::Key_F6 || (event->key() == Qt::Key_6 && devicemode)) { + canvas->dumpRoot(); + } else if (event->key() == Qt::Key_F7 || (event->key() == Qt::Key_7 && devicemode)) { + canvas->dumpTiming(); + } else if (event->key() == Qt::Key_F8 || (event->key() == Qt::Key_8 && devicemode)) { + QPerformanceLog::displayData(); + QPerformanceLog::clear(); + } else if (event->key() == Qt::Key_F9) { + if(testEngine) testEngine->save(); + } else if (event->key() == Qt::Key_F10) { + if(testEngine) testEngine->captureFullFrame(); + } + + QWidget::keyPressEvent(event); +} + +void QmlViewer::setRecording(bool on) +{ + if (on == recordTimer.isActive()) + return; + + if (on) { + recordTimer.start(record_period,this); + } else { + recordTimer.stop(); + int frame=0; + QStringList inputs; + qDebug() << "Saving frames..."; + + foreach (QImage* img, frames) { + QString name; + name.sprintf("tmp-frame%04d.png",frame++); + if (record_dither=="ordered") + img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::OrderedDither).save(name); + else if (record_dither=="threshold") + img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither|Qt::ThresholdDither).save(name); + else if (record_dither=="floyd") + img->convertToFormat(QImage::Format_Indexed8,Qt::PreferDither).save(name); + else + img->convertToFormat(QImage::Format_Indexed8).save(name); + inputs << name; + delete img; + } + QString output="animation.gif"; + + QStringList args; + + args << "-delay" << QString::number(record_period/10); + args << inputs; + args << output; + qDebug() << "Converting..." << output; + if (0!=QProcess::execute("convert", args)) { + qWarning() << "Cannot run ImageMagick 'convert' - not converted to gif"; + inputs.clear(); // don't remove them + qDebug() << "Wrote frames tmp-frame*.png"; + } else { + qDebug() << "Compressing..." << output; + if (0!=QProcess::execute("gifsicle", QStringList() << "-O2" << "-o" << output << output)) + qWarning() << "Cannot run 'gifsicle' - not compressed"; + qDebug() << "Wrote" << output; + } + + foreach (QString name, inputs) + QFile::remove(name); + + frames.clear(); + } + qDebug() << "Recording: " << (recordTimer.isActive()?"ON":"OFF"); +} + +void QmlViewer::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == recordTimer.timerId()) { + frames.append(new QImage(canvas->asImage())); + if (record_autotime && autoTimer.elapsed() >= record_autotime) + setRecording(false); + } else if (event->timerId() == autoStartTimer.timerId()) { + autoTimer.start(); + autoStartTimer.stop(); + setRecording(true); + } else { + QWidget::timerEvent(event); + } +} + +void QmlViewer::setDeviceKeys(bool on) +{ + devicemode = on; +} + +void QmlViewer::setCacheEnabled(bool on) +{ + QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); + if (on == !!nam->cache()) + return; + if (on) { + // Setup a caching network manager + QNetworkDiskCache *cache = new QNetworkDiskCache; + cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-duiviewer-network-cache")); + cache->setMaximumCacheSize(8000000); + nam->setCache(cache); + } else { + nam->setCache(0); + } +} + +#include "qmlviewer.moc" diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h new file mode 100644 index 0000000..0fa879d --- /dev/null +++ b/tools/qmlviewer/qmlviewer.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef QMLVIEWER_H +#define QMLVIEWER_H + +#include +#include +#include +#include +#include + + +class QFxView; +class PreviewDeviceSkin; +class QFxTestEngine; + +class QmlViewer : public QWidget +{ +Q_OBJECT +public: + QmlViewer(QFxTestEngine::TestMode = QFxTestEngine::NoTest, const QString &testDir = QString(), QWidget *parent=0, Qt::WindowFlags flags=0); + + void setRecordDither(const QString& s) { record_dither = s; } + void setRecordPeriod(int ms); + int recordPeriod() const { return record_period; } + void setRecording(bool on); + bool isRecording() const { return recordTimer.isActive(); } + void setAutoRecord(int from, int to); + void setSkin(const QString& skinDirectory); + void setDeviceKeys(bool); + void setCacheEnabled(bool); + +public slots: + void sceneResized(QSize size); + void openQml(const QString& fileName); + void reload(); + +protected: + virtual void keyPressEvent(QKeyEvent *); + virtual void timerEvent(QTimerEvent *); + virtual void resizeEvent(QResizeEvent *); + +private: + QString currentFileName; + PreviewDeviceSkin *skin; + QSize skinscreensize; + QFxView *canvas; + void init(QFxTestEngine::TestMode, const QString &, const QString& fileName); + QBasicTimer recordTimer; + QList frames; + QBasicTimer autoStartTimer; + QTime autoTimer; + QString record_dither; + int record_period; + int record_autotime; + bool devicemode; + + QFxTestEngine *testEngine; +}; + +#endif diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro new file mode 100644 index 0000000..08d2d2b --- /dev/null +++ b/tools/qmlviewer/qmlviewer.pro @@ -0,0 +1,12 @@ +DESTDIR = ../../bin +QT += declarative script network sql +# Input +HEADERS += qmlviewer.h +SOURCES += main.cpp qmlviewer.cpp + +include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) + +target.path=$$[QT_INSTALL_BINS] +INSTALLS += target + +CONFIG += console diff --git a/tools/tools.pro b/tools/tools.pro index 12da18c..2c83580 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -24,7 +24,7 @@ mac { SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += duiviewer qmlconv +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmlconv contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns embedded: SUBDIRS += makeqpf -- cgit v0.12 From 500474fcd985893da0b675e24298ac98c29f8a76 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 30 Apr 2009 15:22:33 +1000 Subject: Fix crash in QmlDomDocument::load() --- src/declarative/qml/qmlcompositetypemanager_p.h | 2 ++ src/declarative/qml/qmldom.cpp | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index ffa4fda..bc86fcf 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -52,6 +52,7 @@ class QmlEngine; class QmlCompiledComponent; class QmlComponentPrivate; class QmlComponent; +class QmlDomDocument; struct QmlCompositeTypeData : public QmlRefCount { QmlCompositeTypeData(); @@ -98,6 +99,7 @@ struct QmlCompositeTypeData : public QmlRefCount private: friend class QmlCompositeTypeManager; friend class QmlCompiler; + friend class QmlDomDocument; QmlScriptParser data; QList waiters; diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 72c1c76..4e8e1f7 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -42,6 +42,7 @@ #include "qmldom.h" #include "qmldom_p.h" #include "private/qmlcompiler_p.h" +#include "private/qmlengine_p.h" #include "qmlcompiledcomponent_p.h" #include #include @@ -159,15 +160,28 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data) QmlCompiledComponent component; QmlCompiler compiler; - // ### -// compiler.compile(engine, parser, &component); + + QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, QUrl());; + + if(td->status == QmlCompositeTypeData::Error) { + d->error = td->errorDescription; + td->release(); + return false; + } else if(td->status == QmlCompositeTypeData::Waiting) { + d->error = QLatin1String("QmlDomDocument supports local types only"); + td->release(); + return false; + } + + compiler.compile(engine, td, &component); if (compiler.isError()) { d->error = compiler.errorDescription(); + td->release(); return false; } - if (parser.tree()) { + if (td->data.tree()) { component.dump(0, parser.tree()); d->root = parser.tree(); d->root->addref(); -- cgit v0.12 From 6409c4256c8f63a981c5448ded84246134ac2a40 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 16:18:20 +1000 Subject: whitespace --- demos/declarative/webbrowser/webbrowser.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 79fd1cd..709d649 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -1,4 +1,5 @@ import "content" + Item { id: WebBrowser -- cgit v0.12 From a26c1cbe326f59162cd6549b8da479c4a7f198da Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 30 Apr 2009 16:18:50 +1000 Subject: Documentation work. --- doc/src/declarative/basictypes.qdoc | 210 +++++++-------------------------- doc/src/declarative/elements.qdoc | 4 +- doc/src/declarative/index.qdoc | 2 +- doc/src/declarative/qtprogrammers.qdoc | 2 +- doc/src/declarative/tutorial3.qdoc | 2 +- src/declarative/fx/qfxgridview.cpp | 6 +- src/declarative/fx/qfximage.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 2 +- src/declarative/fx/qfxlistview.cpp | 8 +- src/declarative/fx/qfxpathview.cpp | 4 +- src/declarative/fx/qfxtext.cpp | 50 ++++---- tools/qdoc3/test/classic.css | 49 ++++---- tools/qmlviewer/qmlviewer.cpp | 2 +- 13 files changed, 111 insertions(+), 232 deletions(-) diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index a6b9177..0000c37 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -1,20 +1,16 @@ /*! - \page basicxmltypes.html + \page basicqmltypes.html \title Common QML Types QML uses a range of property types, which you will see referenced throughout the element documentation. Almost all of them are exactly what you would expect. - \target basicxmlint + \target basicqmlint \raw HTML -
-
- - +
int
+
int
-
-
\endraw ints are whole numbers - things like 0, 10 and -20. The possible int @@ -30,25 +26,16 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlbool + \target basicqmlbool \raw HTML
-
-
- - +
bool
+
bool
-
-
\endraw bools are a binary true/false value, represented by the strings - "true" and "false" in XML. + "true" and "false" in QML. Setting bools looks like this: \code @@ -58,21 +45,12 @@ \note Technically bool treats an empty string, "false" and "0" as false and everything else as true. Seriously, though, use "true" and "false". - \raw HTML -
-
- \endraw - - \target basicxmlreal + \target basicqmlreal \raw HTML
-
-
- - +
real
+
real
-
-
\endraw reals are numbers - either whole numbers like ints, or fractional numbers @@ -85,21 +63,12 @@ \note In QML all reals are stored in single precision, \l {http://en.wikipedia.org/wiki/IEEE_754}{IEEE floating point} format. - \raw HTML -
-
- \endraw - - \target basicxmlstring + \target basicqmlstring \raw HTML
-
-
- - +
string
+
string
-
-
\endraw strings are free form text, like "hello world", "QML is cool" and @@ -111,20 +80,14 @@ \endcode \raw HTML -
-
\endraw - \target basicxmlcolor + \target basicqmlcolor \raw HTML
-
-
- - +
color
+
color
-
-
\endraw Colors are most commonly specified as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color name}. These names include colors like @@ -143,21 +106,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlpoint + \target basicqmlpoint \raw HTML
-
-
- - +
point
+
point
-
-
\endraw Points are specified in \c "x,y" format. @@ -167,21 +121,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlsize + \target basicqmlsize \raw HTML
-
-
- - +
size
+
size
-
-
\endraw Sizes are specified in \c "widthxheight" format. @@ -191,21 +136,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlrectangle + \target basicqmlrectangle \raw HTML
-
-
- - +
rectangle
+
rectangle
-
-
\endraw Rectangles are specified in \c "x,y,widthxheight" format. @@ -215,21 +151,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmldate + \target basicqmldate \raw HTML
-
-
- - +
date
+
date
-
-
\endraw Dates are specified in \c "YYYY-MM-DD" format. @@ -239,21 +166,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmltime + \target basicqmltime \raw HTML
-
-
- - +
time
+
time
-
-
\endraw Times are specified in \c "hh:mm:ss" format. @@ -263,21 +181,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlfont + \target basicqmlfont \raw HTML
-
-
- - +
font
+
font
-
-
\endraw The font type has components: @@ -293,21 +202,12 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlaction + \target basicqmlaction \raw HTML
-
-
- - +
action
+
action
-
-
\endraw The action type has all the properties of QAction, in particular: @@ -325,42 +225,24 @@ \endcode - \raw HTML -
-
- \endraw - - \target basicxmlany + \target basicqmlany \raw HTML
-
-
- - +
any
+
any
-
-
\endraw The any type can accept any basic type, object or list. Generally this is only used in very special cases. The documentation for elements that use the any type will explain the constraints in that particular case. - \raw HTML -
-
- \endraw - - \target basicxmllist + \target basicqmllist \raw HTML
-
-
- - +
Lists
+
Lists
-
-
\endraw While not technically a basic type, QML also supports lists of object @@ -380,8 +262,4 @@ \endcode \c child1, \c child2 and \c child3 will all be added to the children list in the order in which they appear. - \raw HTML -
-
- \endraw */ diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 8955587..3e88e5a 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -7,7 +7,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \bold {Standard Qt Declarative Elements} -\table +\table 100% \header \o \bold {States} \o \bold {Animation and Transitions} @@ -51,7 +51,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \bold {Fluid UI Primitives} -\table +\table 100% \header \o \bold {Basic Items} \o \bold {Utility} diff --git a/doc/src/declarative/index.qdoc b/doc/src/declarative/index.qdoc index 22195ba..b5e9001 100644 --- a/doc/src/declarative/index.qdoc +++ b/doc/src/declarative/index.qdoc @@ -13,7 +13,7 @@ user-interfaces. Building fluid applications is done declaratively, rather than procedurally. That is, you specify \e what the UI should look like and how it should behave -in an XML-based format called QML instead of specifying step-by-step \e how to +in an declarative format called QML instead of specifying step-by-step \e how to build it in a language like C++ or JavaScript. Specifying a UI declaratively does not just include the layout of the interface items, but also the way each individual item looks and behaves and the overall flow of the application. diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 92caa3f..b63ebbb 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -14,7 +14,7 @@ an application with a UI defined in QML also uses Qt for all the non-UI logic. QML provides direct access to the following concepts from Qt: \list - \o QAction - the \l {basicxmlaction}{action} type + \o QAction - the \l {basicqmlaction}{action} type \o QObject signals and slots - available as functions to call in JavaScript \o QObject properties - available as variables in JavaScript \o QWidget - QFxView is a QML-displaying widget diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 91ab9f0..533e179 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -52,7 +52,7 @@ Here is the QML code: \endcode -First, we create a new state \e down for our text element. This state will be activated when \l {xmlMouseRegion}{MouseRegion} is pressed, and deactivated when it is released. +First, we create a new state \e down for our text element. This state will be activated when MouseRegion is pressed, and deactivated when it is released. The \e down state includes a set of property changes from our implicit \e {default state} (the items as they were initially defined in the QML). Specifically, we set the \c y property of the text to 160 and the \c color to red. diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index c8b8d27..b8acea2 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -650,12 +650,12 @@ void QFxGridViewPrivate::updateCurrent(int modelIndex) \brief The GridView element provides a grid view of items provided by a model. The model is typically provided by a QAbstractListModel "C++ model object", - but can also be created directly in XML. + but can also be created directly in QML. The items are laid out top to bottom (vertically) or left to right (horizontally) and may be flicked to scroll. - The below example creates a very simple grid, using an XML model. + The below example creates a very simple grid, using a QML model. \code @@ -706,7 +706,7 @@ QFxGridView::~QFxGridView() The C++ model object must be a \l QListModelInterface subclass, a \l VisualModel, or a simple list. - Models can also be created directly in XML, using the \l ListModel element. For example: + Models can also be created directly in QML, using the \l ListModel element. For example: \code diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index a34cd12..74ba8b8 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -135,7 +135,7 @@ QFxImage::~QFxImage() This property contains the image currently being displayed by this item, which may be an empty pixmap if nothing is currently displayed. If this property is set, the src property will be unset. This property is intended - to be used only in C++, not in XML. + to be used only in C++, not in QML. */ QPixmap QFxImage::pixmap() const { diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 11b7dd3..38b5713 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1676,7 +1676,7 @@ QmlList* QFxItem::transitions() the item, or giving it a \l Reflection. Some filters may not be available on all canvases; if a filter is not available on a certain canvas, it will simply not be applied for - that canvas (but the XML will still be considered valid). + that canvas (but the QML will still be considered valid). \qml diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 13e5b21..6d11764 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -797,10 +797,10 @@ void QFxListViewPrivate::fixupX() \inherits Flickable \brief The ListView element provides a list view of items provided by a model. - The model is typically provided by a QAbstractListModel "C++ model object", but can also be created directly in XML. + The model is typically provided by a QAbstractListModel "C++ model object", but can also be created directly in QML. The items are laid out vertically or horizontally and may be flicked to scroll. - The below example creates a very simple vertical list, using an XML model. + The below example creates a very simple vertical list, using a QML model. \image trivialListView.png The user interface defines a delegate to display an item, a highlight, @@ -808,7 +808,7 @@ void QFxListViewPrivate::fixupX() \snippet doc/src/snippets/declarative/listview/listview.qml 3 - The model is defined as a ListModel using XML: + The model is defined as a ListModel using QML: \quotefromfile doc/src/snippets/declarative/listview/dummydata/ContactModel.qml \skipto diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 5cb31e1..f1aefb9 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -67,16 +67,12 @@ QML_DEFINE_TYPE(QFxText,Text); It can display both plain and rich text. For example: \code - - - Hello World!]]]]> - + Text { text: "Hello World!"; font.family: "Helvetica"; font.size: 24; color: "red" } + Text { text: "Hello World!" } \endcode \image declarative-text.png - Additional examples can be found in examples/poc/text.xml - If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). @@ -99,26 +95,19 @@ QML_DEFINE_TYPE(QFxText,Text); It can display both plain and rich text. For example: \code - - - Hello World!]]> - + Text { text: "Hello World!"; font.family: "Helvetica"; font.size: 24; color: "red" } + Text { text: "Hello World!" } \endcode \image text.png - Note that the 'styling' properties such as color and outline are ignored for rich text, styling - of rich text should be done within the text itself. - - Additional examples can be found in examples/poc/text.xml - If height and width are not explicitly set, Text will attempt to determine how much room is needed and set it accordingly. Unless \c wrap is set, it will always prefer width to height (all text will be placed on a single line). The \c elideMode can alternatively be used to fit a line of plain text to a set width. - A QFxText object can be instantiated in Qml using the tag \c <Text>. + A QFxText object can be instantiated in Qml using the tag \c Text. */ QFxText::QFxText(QFxItem *parent) : QFxItem(*(new QFxTextPrivate), parent) @@ -143,9 +132,14 @@ QFxText::~QFxText() } /*! - \qmlproperty font Text::font + \qmlproperty string Text::font.family + \qmlproperty bool Text::font.bold + \qmlproperty bool Text::font.italic + \qmlproperty real Text::font.size - Set the Text's font attributes. \c font.size sets the font's point size. + Set the Text's font attributes. + + \note \c font.size sets the font's point size (not pixel size). */ /*! @@ -219,11 +213,11 @@ void QFxText::setColor(const QColor &color) The text color. \code - - + //green text using hexadecimal notation + Text { color: "#00FF00"; ... } - - + //steelblue text using SVG color name + Text { color: "steelblue"; ... } \endcode */ @@ -241,12 +235,12 @@ QColor QFxText::color() const Supported text styles are \c Normal, \c Outline, \c Raised and \c Sunken. \code - - - - - - + HorizontalLayout { + Text { font.size: 24; text: "Normal" } + Text { font.size: 24; text: "Raised"; style: "Raised"; styleColor: "#AAAAAA" } + Text { font.size: 24; text: "Outline"; style: "Outline"; styleColor: "red" } + Text { font.size: 24; text: "Sunken"; style: "Sunken"; styleColor: "#AAAAAA" } + } \endcode \image declarative-textstyle.png diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css index 92a90d4..757d64e 100644 --- a/tools/qdoc3/test/classic.css +++ b/tools/qdoc3/test/classic.css @@ -139,43 +139,50 @@ span.string,span.char } .qmlitem { - padding: 0; + padding: 0; } .qmlname { - white-space: nowrap; - font-weight: bold; + white-space: nowrap; + font-weight: bold; + font-size: 125%; +} + +.qmltype { + font-weight: bold; + font-size: 125%; } .qmlproto, .qmldoc { - border: 1px solid #84b0c7; + // border-top: 1px solid #84b0c7; } .qmlproto { - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; + padding: 0; + //background-color: #e4e4e4;//#d5e1e8; + //font-weight: bold; + //-webkit-border-top-left-radius: 8px; + //-webkit-border-top-right-radius: 8px; + //-moz-border-radius-topleft: 8px; + //-moz-border-radius-topright: 8px; } .qmldoc { - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; + border-top: 1px solid #e4e4e4; + //padding: 2px 5px; + //background-color: #eef3f5; + //border-top-width: 0; + //-webkit-border-bottom-left-radius: 8px; + //-webkit-border-bottom-right-radius: 8px; + //-moz-border-radius-bottomleft: 8px; + //-moz-border-radius-bottomright: 8px; } .qmldoc p, .qmldoc dl, .qmldoc ul { - margin: 6px 0; + //margin: 6px 0; } *.qmlitem p { - margin-top: 0px; - margin-bottom: 0px; + //margin-top: 0px; + //margin-bottom: 0px; } diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 87bebfa..3c52cfe 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -241,7 +241,7 @@ void QmlViewer::keyPressEvent(QKeyEvent *event) << "F2 - toggle GIF recording\n" << "F3 - take PNG snapshot\n" << "F4 - show items and state\n" - << "F5 - reload XML\n" + << "F5 - reload QML\n" << "F6 - show object tree\n" << "F7 - show timing\n" << "F8 - show performance (if available)\n" -- cgit v0.12 From 8cd3c8f83b72a988a2d6a99924dda97504c9c24e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 16:23:46 +1000 Subject: port syntax --- .../declarative/listview/content/MediaButton.qml | 61 ++++++++++++++-------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml index 6c672ea..bb2510a 100644 --- a/examples/declarative/listview/content/MediaButton.qml +++ b/examples/declarative/listview/content/MediaButton.qml @@ -1,21 +1,40 @@ - - - - - - - - - - - - - - {Image.width} - - - - - - - +Item { + id: Container + signals: Signal { + name: "clicked" + } + properties: Property { + name: "text" + } + Image { + id: Image + source: "pics/button.png" + } + Image { + id: Pressed + source: "pics/button-pressed.png" + opacity: 0 + } + MouseRegion { + id: MouseRegion + anchors.fill: Image + onClicked: { Container.clicked.emit(); } + } + Text { + font.bold: true + color: "white" + anchors.centeredIn: Image + text: Container.text + } + width: Image.width + states: [ + State { + name: "Pressed" + when: MouseRegion.pressed == true + SetProperties { + target: Pressed + opacity: 1 + } + } + ] +} -- cgit v0.12 From cc4c8562890784e1b4ca55612f8963e59f2e6bce Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 16:42:11 +1000 Subject: doc --- src/declarative/fx/qfxwebview.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 05730f9..fe694ea 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -221,7 +221,13 @@ public: if the idealHeight is changed after the content is loaded. \code - + WebView { + url: "http://www.nokia.com" + width: 490 + height: 400 + scale: 0.5 + smooth: true + } \endcode \image webview.png @@ -998,23 +1004,12 @@ QString QFxWebView::html() const \qmlproperty string WebView::html This property holds HTML text set directly - The html property can be set as a string (using CDATA for large blocks), - or as xhtml inline using the XML namespace http://www.w3.org/1999/xhtml: + The html property can be set as a string. \code - - -

This is valid xHTML.

- -
- \endcode - - \code - - <CDATA[ -

This is just HTML. - ]]>html> - + WebView { + html: "

This is HTML." + } \endcode */ void QFxWebView::setHtml(const QString &html, const QUrl &baseUrl) -- cgit v0.12 From 0e664dabc5b7325634e54d120eb374940497ca0f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 30 Apr 2009 16:42:28 +1000 Subject: Support stdin --- tools/qmlconv/qmlconv.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tools/qmlconv/qmlconv.cpp b/tools/qmlconv/qmlconv.cpp index 3ba40a4..3457a4f 100644 --- a/tools/qmlconv/qmlconv.cpp +++ b/tools/qmlconv/qmlconv.cpp @@ -442,24 +442,26 @@ int main(int argc, char *argv[]) QStringList args = a.arguments(); args.removeFirst(); -again: - if (args.isEmpty()) { - qWarning() << "Usage: qmlconf [-i] filename"; - exit(1); - } - - if (args.first() == QLatin1String("-i")) { + if (!args.isEmpty() && args.first() == QLatin1String("-i")) { optionInPlace = true; args.removeFirst(); - goto again; } - const QString fileName = args.first(); + if (args.isEmpty() && optionInPlace) { + qWarning() << "Usage: qmlconf [ [-i] filename ]"; + exit(1); + } + + const QString fileName = args.isEmpty() ? QString("-") : args.first(); QFile file(fileName); - if (! file.open(QIODevice::ReadOnly)) { - qWarning() << "qmlconv: no input file"; - exit(1); + if (fileName == "-") { + file.open(0,QIODevice::ReadOnly); + } else { + if (! file.open(QIODevice::ReadOnly)) { + qWarning() << "qmlconv: no input file"; + exit(1); + } } Reader r(&file); -- cgit v0.12