diff options
23 files changed, 274 insertions, 249 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 @@ -<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"> - <properties> - <!-- Add a property for the target y coordinate --> - <Property name="targetY" value="{Page.height-10}"/> - <Property name="direction" value="right"/> - </properties> - <x> - <!-- Move the ball to the right and back to the left repeatedly --> - <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"/> - </SequentialAnimation> - </x> - <y> - <!-- Make y follow the target y coordinate, with a velocity of 200 --> - <Follow source="{Ball.targetY}" velocity="200"/> - </y> - <onTopChanged> - <!-- Detect the ball hitting the top or bottom of the view and bounce it --> - 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; - </onTopChanged> - </Rect> - <!-- - 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'}"/> - </y> - </Rect> - <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'}"/> - </y> - </Rect> + } + } + + // 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}"/> - </Repeater> -</Rect> + // 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 + } + } +} 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 @@ -<Rect color="blue"/> 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 @@ -<Text>This is a local component</Text> 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 @@ -<Item id="Root"> - <properties> - <Property name="period" value="1000"/> - <Property name="color" value="green"/> - </properties> - - <Component id="SpinSquare"> - <Item> - <Rect color="{Root.color}" width="{Root.width}" height="{width}" x="{-width/2}" y="{-height/2}"/> - <rotation> - <NumericAnimation from="0" to="360" repeat="true" running="true" duration="{Root.period}"/> - </rotation> - </Item> - </Component> - - <ComponentInstance component="{SpinSquare}" x="{Root.width/2}" y="{Root.height/2}"/> -</Item> 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 @@ -<?qtfx namespacepath:http://nokia.com/qml/Chronos=. ?> - -<Image id="clock" source="pics/clockface.png" xmlns:This="http://nokia.com/qml/Chronos"> - <properties> - <Property name="hours" value="0"/> - <Property name="minutes" value="0"/> - <Property name="seconds" value="0"/> - </properties> - <DateTimeFormatter id="format" time="{clock.time}"/> - <Item x="{clock.width/2}" y="{clock.height/2}"> - <This:Hand id="hour" length="{clock.height/4}" rotation="{clock.hours*30+clock.minutes/2+clock.seconds/120}"/> - <This:Hand id="minute" length="{clock.height/3}" thickness="3" rotation="{clock.minutes*6+clock.seconds/10}"/> - <This:Hand id="second" length="{clock.height/2.5}" thickness="1" rotation="{clock.seconds*6}"/> - </Item> -</Image> 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 @@ -<Item id="Hand"> - <properties> - <Property name="length" value="100"/> - <Property name="thickness" value="0"/> - </properties> - <Item rotation="-90"> - <Rect width="{length}" height="{thickness==0 ? length/8 : thickness}" y="{-height/2}"/> - </Item> -</Item> diff --git a/examples/declarative/namespaces/lib/Chronos/pics/clockface.png b/examples/declarative/namespaces/lib/Chronos/pics/clockface.png Binary files differdeleted file mode 100644 index a885950..0000000 --- a/examples/declarative/namespaces/lib/Chronos/pics/clockface.png +++ /dev/null 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 @@ -<Text color="green"/> 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 @@ -<Rect color="red"/> 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 @@ -<Rect> - <Local/> <!-- not allowed - not in this component! --> -</Rect> 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 @@ -<?qtfx namespacepath:http://nokia.com/qml=lib ?> - -<Rect id="obj" width="200" height="200" xmlns:Chronos="http://nokia.com/qml/Chronos"> - <properties> - <Property name="time_sec"/> - </properties> - <time_sec> <!-- simple animation, not bound to the real time --> - <NumericAnimation from="0" to="43200" duration="43200000" running="true" repeat="true"/> - </time_sec> - <Chronos:Clock x="10" y="10" width="{parent.width-20}" height="{parent.height-20}" - hours="{Math.floor(time_sec/3600)}" minutes="{Math.floor(time_sec/60)%60}" seconds="{time_sec%60}"/> -</Rect> 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 @@ -<!-- Empty Namespaces paths allow unqualified Types to be found - in other locations. For file URLs, multiple paths can be - given, forming a file search path. --> - -<?qtfx namespacepath:=lib/Chronos ?> <!-- Clock will be found here --> -<?qtfx namespacepath:=lib/Path ?> <!-- PathLabel will be found here --> - -<Rect id="obj" width="200" height="200"> - <properties> - <Property name="time_sec"/> - </properties> - <time_sec> <!-- simple animation, not bound to the real time --> - <NumericAnimation from="0" to="43200" duration="43200000" running="true" repeat="true"/> - </time_sec> - <Clock x="10" y="10" width="{parent.width-20}" height="{parent.height-20}" - hours="{Math.floor(time_sec/3600)}" minutes="{Math.floor(time_sec/60)%60}" seconds="{time_sec%60}"/> - <PathLabel text="This is a clock"/> -</Rect> 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 @@ -<?qtfx namespacepath:http://nokia.com/qml=lib ?> -<Rect id="obj" width="100" height="100" xmlns:bs="BlueStuff" xmlns:rs="http://nokia.com/qml/RedStuff"> - <bs:Rect x="20" y="20" width="50" height="50"/> - <rs:Rect x="30" y="30" width="50" height="50"/> -</Rect> 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 @@ -<?qtfx namespacepath:http://nokia.com/qml=lib ?> -<Rect id="obj" width="100" height="100" xmlns:w="http://nokia.com/qml/Wrong" color="white"> - <w:Wrong/> -</Rect> 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 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><![CDATA[ - No width defined. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - <WebView width="{Rect.width}"> - <html><![CDATA[ - The width is full. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - <WebView width="{Rect.width/2}"> - <html><![CDATA[ - The width is half. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - <WebView idealWidth="{Rect.width/2}"> - <html><![CDATA[ - The idealWidth is half. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - <WebView idealWidth="{Rect.width/2}"> - <html><![CDATA[ - The_idealWidth_is_half. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - <WebView width="{Rect.width/2}"> - <html><![CDATA[ - The_width_is_half. - ]]></html> - <Rect color="#10000000" anchors.fill="{parent}"/> - </WebView> - </VerticalLayout> -</Rect> +// 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/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"/> - <Property name="color" value="black"/> - </properties> - <Item x="{Root.width/2}" y="{Root.height/2}"> - <Rect color="{Root.color}" width="{Root.width}" height="{width}" x="{-width/2}" y="{-height/2}"/> - <rotation> - <NumericAnimation from="0" to="360" repeat="true" running="true" duration="{Root.period}"/> - </rotation> - </Item> -</Item> +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 + } + } +} 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 @@ -<!-- Inline HTML with loose formatting can be - set on the html property by using CDATA. --> -<WebView> - <html><![CDATA[ - <body bgcolor="white"> - <table border=1> - <tr><th><th>One<th>Two<th>Three - <tr><th>1<td>X<td>1<td>X - <tr><th>2<td>0<td>X<td>0 - <tr><th>3<td>X<td>1<td>X - </table> - ]]></html> -</WebView> +// Inline HTML with loose formatting can be +// set on the html property. +WebView { + html:"\ + <body bgcolor=white>\ + <table border=1>\ + <tr><th><th>One<th>Two<th>Three\ + <tr><th>1<td>X<td>1<td>X\ + <tr><th>2<td>0<td>X<td>0\ + <tr><th>3<td>X<td>1<td>X\ + </table>" +} 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 @@ -<!-- Inline xHTML (with strict XML formatting) can be - set on the html property by giving it the appropriate namespace. --> -<WebView> - <html xmlns="http://www.w3.org/1999/xhtml"> - <body bgcolor="white"> - <table border="1"> - <tr><th></th><th>One</th><th>Two</th><th>Three</th></tr> - <tr><th>1</th><td>X</td><td>1</td><td>X</td></tr> - <tr><th>2</th><td>0</td><td>X</td><td>0</td></tr> - <tr><th>3</th><td>X</td><td>1</td><td>X</td></tr> - </table> - </body> - </html> -</WebView> 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 @@ -<!-- The WebView supports QML data through the HTML OBJECT tag --> -<Flickable width="{250*.75}" height="240" - viewportWidth="{Web.width*Web.scale}" viewportHeight="{Web.height*Web.scale}"> -<WebView id="Web" width="250" height="420" scale="0.75" settings.pluginsEnabled="true"> - <html><![CDATA[ - <html> - <body bgcolor=white> - These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75% - and placed in a Flickable area... - <table border=1> - <tr><th>Duration <th>Color <th>Plugin - <tr><td>500 <td>red <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=500 color=red /> - <tr><td>2000 <td>blue <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=2000 color=blue /> - <tr><td>1000 <td>green <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=1000 color=green /> - </table> - </body> - </html> - ]]></html> -</WebView> -</Flickable> +// 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: "<html>\ + <body bgcolor=white>\ + These are QML plugins, shown in a QML WebView via HTML OBJECT tags, all scaled to 75%\ + and placed in a Flickable area...\ + <table border=1>\ + <tr><th>Duration <th>Color <th>Plugin\ + <tr><td>500 <td>red <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=500 color=red />\ + <tr><td>2000 <td>blue <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=2000 color=blue />\ + <tr><td>1000 <td>green <td><OBJECT data=content/SpinSquare.qml TYPE=application/x-qt-plugin width=100 height=100 period=1000 color=green />\ + </table>\ + </body>\ + </html>" + } + } +} 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 <b>World!</b>"/> -</Rect> +// 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 <b>World!</b>" + } +} 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 } 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<QWidget *>(obj)) { window()->setAttribute(Qt::WA_OpaquePaintEvent, false); window()->setAttribute(Qt::WA_NoSystemBackground, false); |