aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/canvas/bezierCurve/bezierCurve.qml146
-rw-r--r--examples/quick/canvas/canvas.qrc17
-rw-r--r--examples/quick/canvas/clip/clip.qml182
-rw-r--r--examples/quick/canvas/contents/images/button-pressed.pngbin571 -> 0 bytes
-rw-r--r--examples/quick/canvas/contents/images/button.pngbin564 -> 0 bytes
-rw-r--r--examples/quick/canvas/contents/images/default.svg82
-rwxr-xr-xexamples/quick/canvas/contents/images/gloss.pngbin1236 -> 0 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/lineedit.pngbin1415 -> 0 bytes
-rw-r--r--examples/quick/canvas/contents/images/lineedit.sci5
-rwxr-xr-xexamples/quick/canvas/contents/images/quit.pngbin2369 -> 0 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/stripes.pngbin257 -> 0 bytes
-rwxr-xr-xexamples/quick/canvas/contents/images/toolbutton.pngbin2550 -> 0 bytes
-rw-r--r--examples/quick/canvas/contents/images/toolbutton.sci5
-rw-r--r--examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml158
-rw-r--r--examples/quick/canvas/roundedrect/roundedrect.qml142
-rw-r--r--examples/quick/canvas/smile/smile.qml149
-rw-r--r--examples/quick/canvas/squircle/squircle.qml207
-rw-r--r--examples/quick/canvas/tiger/tiger.qml146
-rw-r--r--examples/quick/dialogs/FileDialogs.qml164
-rw-r--r--examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc4
-rw-r--r--examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc2
-rw-r--r--examples/quick/scenegraph/scenegraph.pro7
-rw-r--r--examples/quick/scenegraph/shared/logorenderer.cpp258
-rw-r--r--examples/quick/scenegraph/shared/logorenderer.h (renamed from examples/quick/canvas/contents/Button.qml)76
-rw-r--r--examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc2
-rw-r--r--examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpgbin0 -> 25863 bytes
-rw-r--r--examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc36
-rw-r--r--examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp129
-rw-r--r--examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h59
-rw-r--r--examples/quick/scenegraph/textureinsgnode/main.cpp (renamed from examples/quick/canvas/contents/ToolBar.qml)36
-rw-r--r--examples/quick/scenegraph/textureinsgnode/main.qml132
-rw-r--r--examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro16
-rw-r--r--examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc5
-rw-r--r--examples/quick/scenegraph/textureinthread/doc/images/textureinthread-example.jpgbin0 -> 33269 bytes
-rw-r--r--examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc36
-rw-r--r--examples/quick/scenegraph/textureinthread/main.cpp (renamed from examples/quick/canvas/contents/TitleBar.qml)39
-rw-r--r--examples/quick/scenegraph/textureinthread/main.qml132
-rw-r--r--examples/quick/scenegraph/textureinthread/textureinthread.pro16
-rw-r--r--examples/quick/scenegraph/textureinthread/textureinthread.qrc5
-rw-r--r--examples/quick/scenegraph/textureinthread/threadrenderer.cpp257
-rw-r--r--examples/quick/scenegraph/textureinthread/threadrenderer.h62
-rw-r--r--examples/quick/shared/CheckBox.qml102
-rw-r--r--examples/quick/shared/Slider.qml (renamed from examples/quick/canvas/contents/Slider.qml)96
-rw-r--r--examples/quick/shared/ToolButton.qml (renamed from examples/quick/canvas/contents/ScrollBar.qml)71
-rw-r--r--examples/quick/shared/images/slider_handle.pngbin0 -> 887 bytes
-rw-r--r--examples/quick/shared/qmldir3
-rw-r--r--examples/quick/shared/quick_shared.qrc2
-rw-r--r--examples/quick/shared/shared.qrc4
-rw-r--r--src/imports/dialogs/DefaultFileDialog.qml366
-rw-r--r--src/imports/dialogs/WidgetFileDialog.qml45
-rw-r--r--src/imports/dialogs/dialogs.pro30
-rw-r--r--src/imports/dialogs/images/folder.pngbin0 -> 1841 bytes
-rw-r--r--[-rwxr-xr-x]src/imports/dialogs/images/titlebar.png (renamed from examples/quick/canvas/contents/images/titlebar.png)bin1436 -> 1436 bytes
-rw-r--r--src/imports/dialogs/images/titlebar.sci (renamed from examples/quick/canvas/contents/images/titlebar.sci)0
-rw-r--r--src/imports/dialogs/images/up.pngbin0 -> 662 bytes
-rw-r--r--src/imports/dialogs/plugin.cpp140
-rw-r--r--src/imports/dialogs/plugins.qmltypes72
-rw-r--r--src/imports/dialogs/qml/Button.qml90
-rw-r--r--src/imports/dialogs/qml/TextField.qml77
-rw-r--r--src/imports/dialogs/qml/qmldir2
-rw-r--r--src/imports/dialogs/qmldir2
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog.cpp233
-rw-r--r--src/imports/dialogs/qquickabstractfiledialog_p.h144
-rw-r--r--src/imports/dialogs/qquickfiledialog.cpp230
-rw-r--r--src/imports/dialogs/qquickfiledialog_p.h99
-rw-r--r--src/imports/dialogs/qquickplatformfiledialog.cpp314
-rw-r--r--src/imports/dialogs/qquickplatformfiledialog_p.h78
-rw-r--r--src/imports/imports.pro3
-rw-r--r--src/imports/widgets/plugins.qmltypes72
-rw-r--r--src/imports/widgets/qmldir3
-rw-r--r--src/imports/widgets/qquickqfiledialog.cpp199
-rw-r--r--src/imports/widgets/qquickqfiledialog_p.h78
-rw-r--r--src/imports/widgets/widgets.pro17
-rw-r--r--src/imports/widgets/widgetsplugin.cpp83
-rw-r--r--src/qml/qml/qqmlglobal.cpp33
-rw-r--r--src/qml/qml/qqmlglobal_p.h1
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc26
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp5
-rw-r--r--src/quick/items/qquickscreen.cpp46
-rw-r--r--src/quick/items/qquicktextedit.cpp9
-rw-r--r--src/quick/items/qquicktextedit_p_p.h4
-rw-r--r--src/quick/items/qquicktextinput.cpp2
-rw-r--r--src/quick/items/qquickwindow.cpp13
-rw-r--r--src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h4
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h4
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.h6
-rw-r--r--src/quick/scenegraph/coreapi/qsgnodeupdater_p.h6
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h6
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h4
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p.h6
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode_p_p.h6
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode_p.h4
-rw-r--r--src/quick/scenegraph/qsgdefaultrectanglenode_p.h4
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.h6
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h6
-rw-r--r--src/quick/scenegraph/util/qsgareaallocator_p.h4
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.h4
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgsimplerectnode.h4
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.h6
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.h4
-rw-r--r--src/quick/util/qquickpixmapcache.cpp13
-rw-r--r--tests/auto/quick/dialogs/data/RectWithFileDialog.qml33
-rw-r--r--tests/auto/quick/dialogs/dialogs.pro17
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp156
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml3
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp1
-rw-r--r--tests/auto/quick/quick.pro1
110 files changed, 4904 insertions, 916 deletions
diff --git a/examples/quick/canvas/bezierCurve/bezierCurve.qml b/examples/quick/canvas/bezierCurve/bezierCurve.qml
index 386d1d73d3..281ca9399e 100644
--- a/examples/quick/canvas/bezierCurve/bezierCurve.qml
+++ b/examples/quick/canvas/bezierCurve/bezierCurve.qml
@@ -40,84 +40,88 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
+ id:container
+ width: 320
+ height: 480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+ Column {
+ spacing:5
+ anchors.fill: parent
+ anchors.topMargin: 12
- Canvas {
- id:canvas
- width:320
- height:280
- property string strokeStyle:"red"
- property string fillStyle:"red"
- property int lineWidth:lineWidthCtrl.value
- property bool fill:true
- property bool stroke:true
- property real alpha:alphaCtrl.value
- property real scaleX : scaleXCtrl.value
- property real scaleY : scaleYCtrl.value
- property real rotate : rotateCtrl.value
- antialiasing: true
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Bezier Curve"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
- Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
- Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
- Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Canvas {
+ id:canvas
+ width:320
+ height:280
+ property color strokeStyle: Qt.darker(fillStyle, 1.4)
+ property color fillStyle: "#b40000" // red
+ property int lineWidth: lineWidthCtrl.value
+ property bool fill: true
+ property bool stroke: true
+ property real alpha: 1.0
+ property real scale : scaleCtrl.value
+ property real rotate : rotateCtrl.value
+ antialiasing: true
- onLineWidthChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onAlphaChanged:requestPaint();
- onScaleXChanged:requestPaint();
- onScaleYChanged:requestPaint();
- onRotateChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onScaleChanged:requestPaint();
+ onRotateChanged:requestPaint();
- onPaint: {
- var ctx = canvas.getContext('2d');
- ctx.save();
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.globalAlpha = canvas.alpha;
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.fillStyle = canvas.fillStyle;
- ctx.lineWidth = canvas.lineWidth;
- ctx.scale(canvas.scaleX, canvas.scaleY);
- ctx.rotate(canvas.rotate);
- //! [0]
- ctx.beginPath();
- ctx.moveTo(75,40);
- ctx.bezierCurveTo(75,37,70,25,50,25);
- ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
- ctx.bezierCurveTo(20,80,40,102,75,120);
- ctx.bezierCurveTo(110,102,130,80,130,62.5);
- ctx.bezierCurveTo(130,62.5,130,25,100,25);
- ctx.bezierCurveTo(85,25,75,37,75,40);
- ctx.closePath();
- //! [0]
- if (canvas.fill)
- ctx.fill();
- if (canvas.stroke)
- ctx.stroke();
- ctx.restore();
- }
- }
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ var originX = 85
+ var originY = 75
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.translate(originX, originX);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:lineWidthCtrl; width:300; height:20; min:1; max:10; init:2; name:"Line width"}
- Slider {id:scaleXCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleX"}
- Slider {id:scaleYCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleY"}
- Slider {id:rotateCtrl; width:300; height:20; min:0; max:Math.PI*2; init:0; name:"Rotate"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
+ ctx.translate(originX, originY)
+ ctx.scale(canvas.scale, canvas.scale);
+ ctx.rotate(canvas.rotate);
+ ctx.translate(-originX, -originY)
+
+ //! [0]
+ ctx.beginPath();
+ ctx.moveTo(75,40);
+ ctx.bezierCurveTo(75,37,70,25,50,25);
+ ctx.bezierCurveTo(20,25,20,62.5,20,62.5);
+ ctx.bezierCurveTo(20,80,40,102,75,120);
+ ctx.bezierCurveTo(110,102,130,80,130,62.5);
+ ctx.bezierCurveTo(130,62.5,130,25,100,25);
+ ctx.bezierCurveTo(85,25,75,37,75,40);
+ ctx.closePath();
+ //! [0]
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
}
}
- }
+ Column {
+ id: controls
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: lineWidthCtrl; min: 1; max: 10; init: 2; name: "Outline"}
+ Slider {id: scaleCtrl; min: 0.1; max: 10; init: 1; name: "Scale"}
+ Slider {id: rotateCtrl; min: 0; max: Math.PI*2; init: 0; name: "Rotate"}
+ }
}
diff --git a/examples/quick/canvas/canvas.qrc b/examples/quick/canvas/canvas.qrc
index 06d39f3624..cfdfc844b9 100644
--- a/examples/quick/canvas/canvas.qrc
+++ b/examples/quick/canvas/canvas.qrc
@@ -3,24 +3,7 @@
<file>canvas.qml</file>
<file>bezierCurve/bezierCurve.qml</file>
<file>clip/clip.qml</file>
- <file>contents/Button.qml</file>
<file>contents/qt-logo.png</file>
- <file>contents/ScrollBar.qml</file>
- <file>contents/Slider.qml</file>
- <file>contents/TitleBar.qml</file>
- <file>contents/ToolBar.qml</file>
- <file>contents/images/button-pressed.png</file>
- <file>contents/images/button.png</file>
- <file>contents/images/default.svg</file>
- <file>contents/images/gloss.png</file>
- <file>contents/images/lineedit.png</file>
- <file>contents/images/lineedit.sci</file>
- <file>contents/images/quit.png</file>
- <file>contents/images/stripes.png</file>
- <file>contents/images/titlebar.png</file>
- <file>contents/images/titlebar.sci</file>
- <file>contents/images/toolbutton.png</file>
- <file>contents/images/toolbutton.sci</file>
<file>quadraticCurveTo/quadraticCurveTo.qml</file>
<file>roundedrect/roundedrect.qml</file>
<file>smile/smile.qml</file>
diff --git a/examples/quick/canvas/clip/clip.qml b/examples/quick/canvas/clip/clip.qml
index 1e9728ff8d..71def05d20 100644
--- a/examples/quick/canvas/clip/clip.qml
+++ b/examples/quick/canvas/clip/clip.qml
@@ -40,111 +40,109 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
+ id:container
+ width: 320
+ height: 480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter}
- Canvas {
- id:canvas
- width:320
- height:280
- property string strokeStyle:"blue"
- property string fillStyle:"steelblue"
- property int lineWidth:2
- property int nSize:nCtrl.value
- property real radius:rCtrl.value
- property bool fill:true
- property bool stroke:false
- property real px:xCtrl.value
- property real py:yCtrl.value
- property real alpha:alphaCtrl.value
- property string imagefile:"../contents/qt-logo.png"
- antialiasing: true
- Component.onCompleted:loadImage(canvas.imagefile);
+ Column {
+ spacing:5
+ anchors.fill: parent
+ anchors.topMargin: 12
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Squircle with Clip"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
+ Canvas {
+ id: canvas
+ width: 320
+ height: 280
+ property color strokeStyle: Qt.darker(fillStyle, 1.2)
+ property color fillStyle:"#14aaff" // green
+ property int lineWidth:2
+ property int nSize:nCtrl.value
+ property real radius:rCtrl.value
+ property bool fill:true
+ property bool stroke:false
+ property real px: width/2
+ property real py: height/2 + 20
+ property real alpha: 1.0
+ property string imagefile:"../contents/qt-logo.png"
+ antialiasing: true
+ Component.onCompleted:loadImage(canvas.imagefile);
- onAlphaChanged:requestPaint();
- onRadiusChanged:requestPaint();
- onLineWidthChanged:requestPaint();
- onNSizeChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onPxChanged:requestPaint();
- onPyChanged:requestPaint();
-
- onImageLoaded : requestPaint();
+ onRadiusChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onNSizeChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onImageLoaded : requestPaint();
+ onPaint: squcirle();
- onPaint: squcirle();
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
- function squcirle() {
- var ctx = canvas.getContext("2d");
- var N = canvas.nSize;
- var R = canvas.radius;
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
- N=Math.abs(N);
- var M=N;
- if (N>100) M=100;
- if (N<0.00000000001) M=0.00000000001;
+ ctx.save();
+ ctx.globalAlpha = canvas.alpha;
+ ctx.fillStyle = "white";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
- ctx.save();
- ctx.globalAlpha =canvas.alpha;
- ctx.fillStyle = "gray";
- ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.fillStyle = canvas.fillStyle;
- ctx.lineWidth = canvas.lineWidth;
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
- ctx.beginPath();
- var i = 0, x, y;
- for (i=0; i<(2*R+1); i++){
- x = Math.round(i-R) + canvas.px;
- y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
- if (i == 0)
- ctx.moveTo(x, y);
- else
- ctx.lineTo(x, y);
- }
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
- for (i=(2*R); i<(4*R+1); i++){
- x =Math.round(3*R-i)+canvas.px;
- y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
- ctx.lineTo(x, y);
- }
- ctx.closePath();
- if (canvas.stroke) {
- ctx.stroke();
- }
+ if (canvas.fill) {
+ ctx.fill();
+ }
- if (canvas.fill) {
- ctx.fill();
- }
- //! [0]
- ctx.clip();
+ //! [0]
+ ctx.clip();
+ ctx.drawImage(canvas.imagefile, 0, 0);
+ //! [0]
- ctx.drawImage(canvas.imagefile, 0, 0);
- //! [0]
- ctx.restore();
- }
- }
-
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:nCtrl; width:300; height:20; min:1; max:10; init:4; name:"N"}
- Slider {id:rCtrl; width:300; height:20; min:30; max:180; init:100; name:"Radius"}
- Slider {id:xCtrl; width:300; height:20; min:50; max:300; init:180; name:"X"}
- Slider {id:yCtrl; width:300; height:20; min:30; max:300; init:220; name:"Y"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
+ ctx.restore();
+ }
}
}
- }
+ Column {
+ id: controls
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: nCtrl; min: 1; max: 10; init: 4; name:"N"}
+ Slider {id: rCtrl; min: 30; max: 180; init: 80; name:"Radius"}
+ }
}
diff --git a/examples/quick/canvas/contents/images/button-pressed.png b/examples/quick/canvas/contents/images/button-pressed.png
deleted file mode 100644
index e434d327f2..0000000000
--- a/examples/quick/canvas/contents/images/button-pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/button.png b/examples/quick/canvas/contents/images/button.png
deleted file mode 100644
index 56a63ce641..0000000000
--- a/examples/quick/canvas/contents/images/button.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/default.svg b/examples/quick/canvas/contents/images/default.svg
deleted file mode 100644
index 248199cc4e..0000000000
--- a/examples/quick/canvas/contents/images/default.svg
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="48px" id="svg1306">
- <defs id="defs1308">
- <linearGradient id="linearGradient4083">
- <stop id="stop4085" offset="0" stop-color="#ffffff" stop-opacity="0"/>
- <stop offset="0.75" id="stop4089" stop-color="#ffffff" stop-opacity="0"/>
- <stop id="stop4087" offset="1" stop-color="#ffffff" stop-opacity="1"/>
- </linearGradient>
- <linearGradient id="linearGradient4032">
- <stop id="stop4034" offset="0" stop-color="#fff7c2" stop-opacity="0.63829786"/>
- <stop offset="0.59394139" id="stop4036" stop-color="#fcaf3e" stop-opacity="0.18348624"/>
- <stop id="stop4038" offset="0.83850551" stop-color="#fcaf3e" stop-opacity="0.50458717"/>
- <stop id="stop4040" offset="1" stop-color="#fcaf3e" stop-opacity="1"/>
- </linearGradient>
- <linearGradient id="linearGradient4026">
- <stop id="stop4028" offset="0" stop-color="#fff9c6" stop-opacity="1"/>
- <stop offset="0.54166669" id="stop4042" stop-color="#fff28c" stop-opacity="1"/>
- <stop id="stop4030" offset="1" stop-color="#ffea85" stop-opacity="1"/>
- </linearGradient>
- <linearGradient xlink:href="#linearGradient4026" id="linearGradient3168" gradientUnits="userSpaceOnUse" x1="-28.968945" y1="-25.326815" x2="-37.19698" y2="-9.5590506"/>
- <radialGradient xlink:href="#linearGradient4032" id="radialGradient4020" cx="-33.519073" cy="-22.113297" fx="-33.519073" fy="-22.113297" r="9.5" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.487739,1.292402,-1.10267,0.497242,-41.77393,32.41492)"/>
- <radialGradient xlink:href="#linearGradient4083" id="radialGradient4081" cx="23.99999" cy="23.381506" fx="23.99999" fy="23.381506" r="19.141981" gradientTransform="matrix(1.006701,2.235326e-16,-2.23715e-16,1.007522,-0.160816,0.426981)" gradientUnits="userSpaceOnUse"/>
- </defs>
-
- <metadata id="metadata1311">
- <rdf:RDF>
- <cc:Work rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
- <dc:title>weather-clear</dc:title>
- <dc:date>January 2006</dc:date>
- <dc:creator>
- <cc:Agent>
- <dc:title>Ryan Collier (pseudo)</dc:title>
- </cc:Agent>
- </dc:creator>
- <dc:publisher>
- <cc:Agent>
- <dc:title>http://www.tango-project.org</dc:title>
- </cc:Agent>
- </dc:publisher>
- <dc:source>http://www.pseudocode.org</dc:source>
- <dc:subject>
- <rdf:Bag>
- <rdf:li>weather</rdf:li>
- <rdf:li>applet</rdf:li>
- <rdf:li>notification</rdf:li>
- </rdf:Bag>
- </dc:subject>
- <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
- <dc:contributor>
- <cc:Agent>
- <dc:title>Garrett LeSage</dc:title>
- </cc:Agent>
- </dc:contributor>
- </cc:Work>
- <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
- <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
- <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
- <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
- <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
- <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
- <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
- </cc:License>
- </rdf:RDF>
- </metadata>
- <g id="layer1">
- <g>
- <g opacity="0.7">
- <path d="M 24 2.5 L 21.625 9.1875 C 22.399034 9.0641318 23.191406 9 24 9 C 24.808594 9 25.600966 9.0641317 26.375 9.1875 L 24 2.5 z M 8.8125 8.78125 L 11.84375 15.21875 C 12.779034 13.928569 13.928569 12.779034 15.21875 11.84375 L 8.8125 8.78125 z M 39.21875 8.78125 L 32.78125 11.84375 C 34.071431 12.779034 35.220966 13.928569 36.15625 15.21875 L 39.21875 8.78125 z M 9.1875 21.59375 L 2.5 23.96875 L 9.1875 26.34375 C 9.0673373 25.57952 9 24.797813 9 24 C 9 23.180625 9.0608858 22.377571 9.1875 21.59375 z M 38.8125 21.625 C 38.935868 22.399034 39 23.191406 39 24 C 39 24.808594 38.935868 25.600966 38.8125 26.375 L 45.5 24 L 38.8125 21.625 z M 11.84375 32.78125 L 8.8125 39.1875 L 15.21875 36.15625 C 13.928569 35.220966 12.779034 34.071431 11.84375 32.78125 z M 36.15625 32.78125 C 35.229789 34.05926 34.087617 35.194799 32.8125 36.125 L 39.21875 39.1875 L 36.15625 32.78125 z M 21.625 38.8125 L 24 45.5 L 26.375 38.8125 C 25.600966 38.935868 24.808594 39 24 39 C 23.191406 39 22.399034 38.935868 21.625 38.8125 z " fill="#fce94f" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.73732895" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
- <path d="M 24 5.25 L 22.65625 9.0625 C 23.098888 9.0231486 23.547187 9 24 9 C 24.452813 9 24.901112 9.0231486 25.34375 9.0625 L 24 5.25 z M 10.78125 10.75 L 12.5 14.375 C 13.071538 13.694089 13.724004 13.038745 14.40625 12.46875 L 10.78125 10.75 z M 37.25 10.75 L 33.625 12.46875 C 34.304675 13.038189 34.961811 13.695325 35.53125 14.375 L 37.25 10.75 z M 9.0625 22.625 L 5.28125 23.96875 L 9.0625 25.3125 C 9.024981 24.880146 9 24.442031 9 24 C 9 23.536406 9.0212735 23.077908 9.0625 22.625 z M 38.9375 22.65625 C 38.976851 23.098888 39 23.547187 39 24 C 39 24.452813 38.976851 24.901112 38.9375 25.34375 L 42.71875 24 L 38.9375 22.65625 z M 35.53125 33.59375 C 34.958293 34.27954 34.309985 34.957363 33.625 35.53125 L 37.25 37.25 L 35.53125 33.59375 z M 12.5 33.625 L 10.78125 37.21875 L 14.375 35.5 C 13.702932 34.935884 13.064116 34.297068 12.5 33.625 z M 22.65625 38.9375 L 24 42.71875 L 25.34375 38.9375 C 24.901112 38.976851 24.452813 39 24 39 C 23.547187 39 23.098888 38.976851 22.65625 38.9375 z " fill="none" fill-opacity="1" stroke="url(#radialGradient4081)" stroke-width="0.84646249" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
- </g>
- <g>
- <g>
- <path transform="matrix(0.778062,-1.061285,1.061287,0.778062,67.47952,3.641324)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="#ffee54" fill-opacity="1" stroke="#fcaf3e" stroke-width="0.75991178" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
- <path transform="matrix(1.244257,-0.167707,0.216642,1.251844,67.61648,40.527)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="url(#radialGradient4020)" fill-opacity="1" stroke="none" stroke-width="1.01737845" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
- <path transform="matrix(0.715791,-0.976349,0.97635,0.715792,64.00044,5.269544)" d="M -22.5 -17.5 A 9.5 9.5 0 1 1 -41.5,-17.5 A 9.5 9.5 0 1 1 -22.5 -17.5 z" fill="none" fill-opacity="1" stroke="url(#linearGradient3168)" stroke-width="0.82601947" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="4" stroke-dasharray="none" stroke-opacity="1"/>
- </g>
- </g>
- </g>
- </g>
-</svg>
diff --git a/examples/quick/canvas/contents/images/gloss.png b/examples/quick/canvas/contents/images/gloss.png
deleted file mode 100755
index 5d370cd93d..0000000000
--- a/examples/quick/canvas/contents/images/gloss.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.png b/examples/quick/canvas/contents/images/lineedit.png
deleted file mode 100755
index 2cc38dc35b..0000000000
--- a/examples/quick/canvas/contents/images/lineedit.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/lineedit.sci b/examples/quick/canvas/contents/images/lineedit.sci
deleted file mode 100644
index 054bff78be..0000000000
--- a/examples/quick/canvas/contents/images/lineedit.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-border.left: 10
-border.top: 10
-border.bottom: 10
-border.right: 10
-source: lineedit.png
diff --git a/examples/quick/canvas/contents/images/quit.png b/examples/quick/canvas/contents/images/quit.png
deleted file mode 100755
index 5bda1b6e0d..0000000000
--- a/examples/quick/canvas/contents/images/quit.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/stripes.png b/examples/quick/canvas/contents/images/stripes.png
deleted file mode 100755
index 9f36727ea4..0000000000
--- a/examples/quick/canvas/contents/images/stripes.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/toolbutton.png b/examples/quick/canvas/contents/images/toolbutton.png
deleted file mode 100755
index 11310013ee..0000000000
--- a/examples/quick/canvas/contents/images/toolbutton.png
+++ /dev/null
Binary files differ
diff --git a/examples/quick/canvas/contents/images/toolbutton.sci b/examples/quick/canvas/contents/images/toolbutton.sci
deleted file mode 100644
index 9e4f965307..0000000000
--- a/examples/quick/canvas/contents/images/toolbutton.sci
+++ /dev/null
@@ -1,5 +0,0 @@
-border.left: 15
-border.top: 4
-border.bottom: 4
-border.right: 15
-source: toolbutton.png
diff --git a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
index 9e03c03b98..0756d339ff 100644
--- a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
+++ b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml
@@ -40,91 +40,97 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
+ id:container
+ width:320
+ height:480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter}
+ Column {
+ spacing:5
+ anchors.fill: parent
+ anchors.topMargin: 12
- Canvas {
- id:canvas
- width:320
- height:280
- property string strokeStyle:"steelblue"
- property string fillStyle:"yellow"
- property int lineWidth:lineWidthCtrl.value
- property bool fill:true
- property bool stroke:true
- property real alpha:alphaCtrl.value
- property real scaleX : scaleXCtrl.value
- property real scaleY : scaleYCtrl.value
- property real rotate : rotateCtrl.value
- antialiasing: true
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Quadratic Curve"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
- onLineWidthChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onAlphaChanged:requestPaint();
- onScaleXChanged:requestPaint();
- onScaleYChanged:requestPaint();
- onRotateChanged:requestPaint();
- Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
- Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
- Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ Canvas {
+ id: canvas
+ width: 320
+ height: 280
- onPaint: {
- var ctx = canvas.getContext('2d');
- ctx.save();
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.globalAlpha = canvas.alpha;
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.fillStyle = canvas.fillStyle;
- ctx.lineWidth = canvas.lineWidth;
- ctx.scale(canvas.scaleX, canvas.scaleY);
- ctx.rotate(canvas.rotate);
- // ![0]
- ctx.beginPath();
- ctx.moveTo(75,25);
- ctx.quadraticCurveTo(25,25,25,62.5);
- ctx.quadraticCurveTo(25,100,50,100);
- ctx.quadraticCurveTo(50,120,30,125);
- ctx.quadraticCurveTo(60,120,65,100);
- ctx.quadraticCurveTo(125,100,125,62.5);
- ctx.quadraticCurveTo(125,25,75,25);
- ctx.closePath();
- // ![0]
- if (canvas.fill)
- ctx.fill();
- if (canvas.stroke)
- ctx.stroke();
+ property color strokeStyle: Qt.darker(fillStyle, 1.3)
+ property color fillStyle: "#14aaff" // blue
+ property int lineWidth: lineWidthCtrl.value
+ property bool fill: true
+ property bool stroke: true
+ property real alpha: 1.0
+ property real scale : scaleCtrl.value
+ property real rotate : rotateCtrl.value
+ antialiasing: true
- // ![1]
- ctx.fillStyle="green";
- ctx.font = "Bold 15px";
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onScaleChanged:requestPaint();
+ onRotateChanged:requestPaint();
- ctx.fillText("QML酷毙了", 30, 60);
- // ![1]
- ctx.restore();
- }
- }
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ var originX = 75
+ var originY = 75
+
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.translate(originX, originX);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.translate(originX, originY)
+ ctx.rotate(canvas.rotate);
+ ctx.scale(canvas.scale, canvas.scale);
+ ctx.translate(-originX, -originY)
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:lineWidthCtrl; width:300; height:20; min:1; max:10; init:2; name:"Line width"}
- Slider {id:scaleXCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleX"}
- Slider {id:scaleYCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleY"}
- Slider {id:rotateCtrl; width:300; height:20; min:0; max:Math.PI*2; init:0; name:"Rotate"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
+ // ![0]
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+ ctx.closePath();
+ // ![0]
+
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+
+ ctx.restore();
+
+ // ![1]
+ ctx.fillStyle = "white";
+ ctx.font = "Bold 17px";
+ ctx.fillText("Qt Quick", 110, 140);
+ // ![1]
+ }
}
}
- }
+ Column {
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id:lineWidthCtrl; min:1; max:10; init:2; name:"Outline"}
+ Slider {id:scaleCtrl; min:0.1; max:10; init:1; name:"Scale"}
+ Slider {id:rotateCtrl; min:0; max:Math.PI*2; init:0; name:"Rotate"}
+ }
}
diff --git a/examples/quick/canvas/roundedrect/roundedrect.qml b/examples/quick/canvas/roundedrect/roundedrect.qml
index 42142cef19..5a0a77425a 100644
--- a/examples/quick/canvas/roundedrect/roundedrect.qml
+++ b/examples/quick/canvas/roundedrect/roundedrect.qml
@@ -40,84 +40,82 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
+ id:container
+ width: 320
+ height: 480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter}
- Canvas {
- id:canvas
- width:320
- height:280
- antialiasing: true
+ Column {
+ spacing: 6
+ anchors.fill: parent
+ anchors.topMargin: 12
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Rounded rectangle"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
+ Canvas {
+ id: canvas
+ width: 320
+ height: 280
+ antialiasing: true
- property int radius: rCtrl.value
- property int rectx: rxCtrl.value
- property int recty: ryCtrl.value
- property int rectWidth: width - 2*rectx
- property int rectHeight: height - 2*recty
- property string strokeStyle:"blue"
- property string fillStyle:"steelblue"
- property int lineWidth:lineWidthCtrl.value
- property bool fill:true
- property bool stroke:true
- property real alpha:alphaCtrl.value
+ property int radius: rCtrl.value
+ property int rectx: 60
+ property int recty: 60
+ property int rectWidth: width - 2*rectx
+ property int rectHeight: height - 2*recty
+ property color strokeStyle: Qt.darker(fillStyle, 1.4)
+ property color fillStyle: "#ae32a0" // purple
+ property int lineWidth: lineWidthCtrl.value
+ property bool fill: true
+ property bool stroke: true
+ property real alpha: 1.0
- onLineWidthChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onRadiusChanged:requestPaint();
- onRectxChanged:requestPaint();
- onRectyChanged:requestPaint();
- onAlphaChanged:requestPaint();
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onRadiusChanged:requestPaint();
- onPaint: {
- var ctx = getContext("2d");
- ctx.save();
- ctx.clearRect(0,0,canvas.width, canvas.height);
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.lineWidth = canvas.lineWidth
- ctx.fillStyle = canvas.fillStyle
- ctx.globalAlpha = canvas.alpha
- ctx.beginPath();
- ctx.moveTo(rectx+radius,recty); // top side
- ctx.lineTo(rectx+rectWidth-radius,recty);
- // draw top right corner
- ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius);
- ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side
- // draw bottom right corner
- ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius);
- ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side
- // draw bottom left corner
- ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius);
- ctx.lineTo(rectx,recty+radius); // left side
- // draw top left corner
- ctx.arcTo(rectx,recty,rectx+radius,recty,radius);
- ctx.closePath();
- if (canvas.fill)
- ctx.fill();
- if (canvas.stroke)
- ctx.stroke();
- ctx.restore();
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.save();
+ ctx.clearRect(0,0,canvas.width, canvas.height);
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.lineWidth = canvas.lineWidth
+ ctx.fillStyle = canvas.fillStyle
+ ctx.globalAlpha = canvas.alpha
+ ctx.beginPath();
+ ctx.moveTo(rectx+radius,recty); // top side
+ ctx.lineTo(rectx+rectWidth-radius,recty);
+ // draw top right corner
+ ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius);
+ ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side
+ // draw bottom right corner
+ ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius);
+ ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side
+ // draw bottom left corner
+ ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius);
+ ctx.lineTo(rectx,recty+radius); // left side
+ // draw top left corner
+ ctx.arcTo(rectx,recty,rectx+radius,recty,radius);
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
}
}
-
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:lineWidthCtrl; width:300; height:20; min:1; max:10; init:2; name:"Line width"}
- Slider {id:rxCtrl; width:300; height:20; min:5; max:30; init:10; name:"rectx"}
- Slider {id:ryCtrl; width:300; height:20; min:5; max:30; init:10; name:"recty"}
- Slider {id:rCtrl; width:300; height:20; min:10; max:100; init:40; name:"Radius"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
- }
+ Column {
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: lineWidthCtrl ; min: 1 ; max: 10; init: 2 ; name: "Outline"}
+ Slider {id: rCtrl ; min: 10 ; max: 80 ; init: 40 ; name: "Radius"}
}
- }
}
diff --git a/examples/quick/canvas/smile/smile.qml b/examples/quick/canvas/smile/smile.qml
index c8b01b305a..0251b1b101 100644
--- a/examples/quick/canvas/smile/smile.qml
+++ b/examples/quick/canvas/smile/smile.qml
@@ -40,87 +40,90 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
+ id: container
+ width: 320
+ height: 480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter}
+ Column {
+ spacing: 6
+ anchors.fill: parent
+ anchors.topMargin: 12
- Canvas {
- id:canvas
- width:320
- height:280
- antialiasing: true
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Smile with arcs"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
- property string strokeStyle:"green"
- property string fillStyle:"yellow"
- property int lineWidth:lineWidthCtrl.value
- property bool fill:true
- property bool stroke:true
- property real alpha:alphaCtrl.value
- property real scaleX : scaleXCtrl.value
- property real scaleY : scaleYCtrl.value
- property real rotate : rotateCtrl.value
+ Canvas {
+ id: canvas
+ width: 320
+ height: parent.height - controls.height
+ antialiasing: true
- onLineWidthChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onAlphaChanged:requestPaint();
- onScaleXChanged:requestPaint();
- onScaleYChanged:requestPaint();
- onRotateChanged:requestPaint();
+ property color strokeStyle: Qt.darker(fillStyle, 1.6)
+ property color fillStyle: "#e0c31e" // yellow
+ property int lineWidth: lineWidthCtrl.value
+ property bool fill: true
+ property bool stroke: true
+ property real scale : scaleCtrl.value
+ property real rotate : rotateCtrl.value
- Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } }
- Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
- Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} }
+ onLineWidthChanged:requestPaint();
+ onFillChanged:requestPaint();
+ onStrokeChanged:requestPaint();
+ onScaleChanged:requestPaint();
+ onRotateChanged:requestPaint();
- onPaint: {
- var ctx = canvas.getContext('2d');
- ctx.save();
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.globalAlpha = canvas.alpha;
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.fillStyle = canvas.fillStyle;
- ctx.lineWidth = canvas.lineWidth;
- ctx.scale(canvas.scaleX, canvas.scaleY);
- ctx.rotate(canvas.rotate);
- ctx.beginPath();
- ctx.moveTo(75 + 50 * Math.cos(0),
- 75 - 50 * Math.sin(Math.PI*2));
- ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
- ctx.moveTo(75,70);
- ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise)
- ctx.moveTo(60,65);
- ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
- ctx.moveTo(90 + 5 * Math.cos(0),
- 65 - 5 * Math.sin(Math.PI*2));
- ctx.moveTo(90,65);
- ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
- ctx.closePath();
- if (canvas.fill)
- ctx.fill();
- if (canvas.stroke)
- ctx.stroke();
- ctx.restore();
- }
- }
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ var originX = 85
+ var originY = 75
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.translate(originX, originX);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.translate(originX, originY)
+ ctx.scale(canvas.scale, canvas.scale);
+ ctx.rotate(canvas.rotate);
+ ctx.translate(-originX, -originY)
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:lineWidthCtrl; width:300; height:20; min:1; max:10; init:2; name:"Line width"}
- Slider {id:scaleXCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleX"}
- Slider {id:scaleYCtrl; width:300; height:20; min:0.1; max:10; init:1; name:"ScaleY"}
- Slider {id:rotateCtrl; width:300; height:20; min:0; max:Math.PI*2; init:0; name:"Rotate"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
+ ctx.beginPath();
+ ctx.moveTo(75 + 50 * Math.cos(0),
+ 75 - 50 * Math.sin(Math.PI*2));
+ ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle
+ ctx.moveTo(75,70);
+ ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise)
+ ctx.moveTo(60,65);
+ ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye
+ ctx.moveTo(90 + 5 * Math.cos(0),
+ 65 - 5 * Math.sin(Math.PI*2));
+ ctx.moveTo(90,65);
+ ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye
+ ctx.closePath();
+ if (canvas.fill)
+ ctx.fill();
+ if (canvas.stroke)
+ ctx.stroke();
+ ctx.restore();
+ }
}
}
- }
+ Column {
+ id: controls
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: lineWidthCtrl ; min: 1 ; max: 10 ; init: 2 ; name: "Outline"}
+ Slider {id: scaleCtrl ; min: 0.1 ; max: 10 ; init: 1 ; name: "Scale"}
+ Slider {id: rotateCtrl ; min: 0 ; max: Math.PI*2 ; init: 0 ; name: "Rotate"}
+ }
}
diff --git a/examples/quick/canvas/squircle/squircle.qml b/examples/quick/canvas/squircle/squircle.qml
index 3044816479..4e5c5a49fc 100644
--- a/examples/quick/canvas/squircle/squircle.qml
+++ b/examples/quick/canvas/squircle/squircle.qml
@@ -40,114 +40,111 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
+
Item {
- id:container
- width:320
- height:480
-
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter}
- Image {
- anchors.horizontalCenter:parent.horizontalCenter
- source:"squircle.png"
- width:250
- height:25
- }
- Canvas {
- id:canvas
- width:320
- height:250
- antialiasing: true
-
- property string strokeStyle:"blue"
- property string fillStyle:"steelblue"
- property int lineWidth:2
- property int nSize:nCtrl.value
- property real radius:rCtrl.value
- property bool fill:true
- property bool stroke:false
- property real px:xCtrl.value
- property real py:yCtrl.value
- property real alpha:alphaCtrl.value
-
- onAlphaChanged:requestPaint();
- onRadiusChanged:requestPaint();
- onLineWidthChanged:requestPaint();
- onNSizeChanged:requestPaint();
- onFillChanged:requestPaint();
- onStrokeChanged:requestPaint();
- onPxChanged:requestPaint();
- onPyChanged:requestPaint();
-
-
- onPaint: squcirle();
-
- function squcirle() {
- var ctx = canvas.getContext("2d");
- var N = canvas.nSize;
- var R = canvas.radius;
-
- N=Math.abs(N);
- var M=N;
- if (N>100) M=100;
- if (N<0.00000000001) M=0.00000000001;
-
- ctx.save();
- ctx.globalAlpha =canvas.alpha;
- ctx.fillStyle = "gray";
- ctx.fillRect(0, 0, canvas.width, canvas.height);
-
- ctx.strokeStyle = canvas.strokeStyle;
- ctx.fillStyle = canvas.fillStyle;
- ctx.lineWidth = canvas.lineWidth;
-
- ctx.beginPath();
- var i = 0, x, y;
- for (i=0; i<(2*R+1); i++){
- x = Math.round(i-R) + canvas.px;
- y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
-
- if (i == 0)
- ctx.moveTo(x, y);
- else
- ctx.lineTo(x, y);
- }
-
- for (i=(2*R); i<(4*R+1); i++){
- x =Math.round(3*R-i)+canvas.px;
- y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
- ctx.lineTo(x, y);
- }
- ctx.closePath();
- if (canvas.stroke) {
- ctx.stroke();
- }
-
- if (canvas.fill) {
- ctx.fill();
- }
-
- ctx.fillStyle = "yellow";
- ctx.font = "Helvetica 16px";
- ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py);
- ctx.restore();
+ id: container
+ width: 320
+ height: 480
+
+ Column {
+ spacing: 6
+ anchors.fill: parent
+ anchors.topMargin: 12
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Squircles"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
}
- }
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:nCtrl; width:300; height:20; min:1; max:10; init:4; name:"N"}
- Slider {id:rCtrl; width:300; height:20; min:30; max:180; init:100; name:"Radius"}
- Slider {id:xCtrl; width:300; height:20; min:50; max:300; init:180; name:"X"}
- Slider {id:yCtrl; width:300; height:20; min:30; max:300; init:220; name:"Y"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
+ Image {
+ anchors.horizontalCenter: parent.horizontalCenter
+ source: "squircle.png"
+ width: 250
+ height: 25
}
+
+ Canvas {
+ id: canvas
+ width: 320
+ height: 250
+ antialiasing: true
+
+ property color strokeStyle: Qt.darker(fillStyle, 1.2)
+ property color fillStyle: "#6400aa"
+
+ property int lineWidth: 2
+ property int nSize: nCtrl.value
+ property real radius: rCtrl.value
+ property bool fill: true
+ property bool stroke: false
+ property real px: width/2
+ property real py: height/2 + 10
+ property real alpha: 1.0
+
+ onRadiusChanged: requestPaint();
+ onLineWidthChanged: requestPaint();
+ onNSizeChanged: requestPaint();
+ onFillChanged: requestPaint();
+ onStrokeChanged: requestPaint();
+
+ onPaint: squcirle();
+
+ function squcirle() {
+ var ctx = canvas.getContext("2d");
+ var N = canvas.nSize;
+ var R = canvas.radius;
+
+ N=Math.abs(N);
+ var M=N;
+ if (N>100) M=100;
+ if (N<0.00000000001) M=0.00000000001;
+
+ ctx.save();
+ ctx.globalAlpha =canvas.alpha;
+ ctx.fillStyle = "white";
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ ctx.strokeStyle = canvas.strokeStyle;
+ ctx.fillStyle = canvas.fillStyle;
+ ctx.lineWidth = canvas.lineWidth;
+
+ ctx.beginPath();
+ var i = 0, x, y;
+ for (i=0; i<(2*R+1); i++){
+ x = Math.round(i-R) + canvas.px;
+ y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py;
+
+ if (i == 0)
+ ctx.moveTo(x, y);
+ else
+ ctx.lineTo(x, y);
+ }
+
+ for (i=(2*R); i<(4*R+1); i++){
+ x =Math.round(3*R-i)+canvas.px;
+ y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py;
+ ctx.lineTo(x, y);
+ }
+ ctx.closePath();
+ if (canvas.stroke) {
+ ctx.stroke();
+ }
+
+ if (canvas.fill) {
+ ctx.fill();
+ }
+ ctx.restore();
+ }
+ }
+
+ }
+ Column {
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: nCtrl ; min: 1 ; max: 10 ; init: 2 ; name: "N"}
+ Slider {id: rCtrl ; min: 30 ; max: 180 ; init: 60 ; name: "Radius"}
}
- }
}
diff --git a/examples/quick/canvas/tiger/tiger.qml b/examples/quick/canvas/tiger/tiger.qml
index 8b629eecf3..94a7d2dc3d 100644
--- a/examples/quick/canvas/tiger/tiger.qml
+++ b/examples/quick/canvas/tiger/tiger.qml
@@ -40,89 +40,95 @@
import QtQuick 2.0
import "../contents"
+import "../../shared"
import "tiger.js" as Tiger
+
Item {
- id:container
- width:320
- height:480
+ id: container
+ width: 320
+ height: 480
- Column {
- spacing:5
- anchors.fill:parent
- Text { font.pointSize:15; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter}
+ Column {
+ spacing: 6
+ anchors.fill: parent
+ anchors.topMargin: 12
- Canvas {
- id:canvas
- width:320
- height:280
- antialiasing: true
- property string strokeStyle:"steelblue"
- property string fillStyle:"yellow"
- property bool fill:true
- property bool stroke:true
- property real alpha:alphaCtrl.value
- property real scaleX : scaleXCtrl.value
- property real scaleY : scaleYCtrl.value
- property real rotate : rotateCtrl.value
- property int frame:0
+ Text {
+ font.pointSize: 24
+ font.bold: true
+ text: "Tiger with SVG path"
+ anchors.horizontalCenter: parent.horizontalCenter
+ color: "#777"
+ }
- onFillChanged: requestPaint();
- onStrokeChanged: requestPaint();
- onAlphaChanged: requestPaint();
- onScaleXChanged: requestPaint();
- onScaleYChanged: requestPaint();
- onRotateChanged: requestPaint();
+ Canvas {
+ id: canvas
+ width: 320
+ height: 280
+ antialiasing: true
- onPainted : {
- canvas.frame++;
- if (canvas.frame < Tiger.tiger.length)
- requestPaint();
- }
- onPaint: {
- var ctx = canvas.getContext('2d');
- ctx.save();
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.globalAlpha = canvas.alpha;
- ctx.scale(canvas.scaleX, canvas.scaleY);
- ctx.rotate(canvas.rotate);
- ctx.globalCompositeOperation = "source-over";
- ctx.translate(canvas.width/2, canvas.height/2);
- ctx.strokeStyle = Qt.rgba(.3, .3, .3,1);
- ctx.lineWidth = 1;
+ property string strokeStyle: "steelblue"
+ property string fillStyle: "yellow"
+ property bool fill: true
+ property bool stroke: true
+ property real alpha: alphaCtrl.value
+ property real scale: scaleCtrl.value
+ property real rotate: rotateCtrl.value
+ property int frame: 0
- //! [0]
- for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) {
- if (Tiger.tiger[i].width != undefined)
- ctx.lineWidth = Tiger.tiger[i].width;
+ onFillChanged: requestPaint();
+ onStrokeChanged: requestPaint();
+ onAlphaChanged: requestPaint();
+ onScaleChanged: requestPaint();
+ onRotateChanged: requestPaint();
- if (Tiger.tiger[i].path != undefined)
- ctx.path = Tiger.tiger[i].path;
+ onPaint: {
+ var ctx = canvas.getContext('2d');
+ var originX = canvas.width/2 + 30
+ var originY = canvas.height/2 + 60
- if (Tiger.tiger[i].fill != undefined) {
- ctx.fillStyle = Tiger.tiger[i].fill;
- ctx.fill();
- }
+ ctx.save();
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.globalAlpha = canvas.alpha;
+ ctx.globalCompositeOperation = "source-over";
+
+ ctx.translate(originX, originY)
+ ctx.scale(canvas.scale, canvas.scale);
+ ctx.rotate(canvas.rotate);
+ ctx.translate(-originX, -originY)
- if (Tiger.tiger[i].stroke != undefined) {
- ctx.strokeStyle = Tiger.tiger[i].stroke;
- ctx.stroke();
+ ctx.strokeStyle = Qt.rgba(.3, .3, .3,1);
+ ctx.lineWidth = 1;
+
+ //! [0]
+ for (var i = 0; i < Tiger.tiger.length; i++) {
+ if (Tiger.tiger[i].width != undefined)
+ ctx.lineWidth = Tiger.tiger[i].width;
+
+ if (Tiger.tiger[i].path != undefined)
+ ctx.path = Tiger.tiger[i].path;
+
+ if (Tiger.tiger[i].fill != undefined) {
+ ctx.fillStyle = Tiger.tiger[i].fill;
+ ctx.fill();
+ }
+
+ if (Tiger.tiger[i].stroke != undefined) {
+ ctx.strokeStyle = Tiger.tiger[i].stroke;
+ ctx.stroke();
+ }
}
+ //! [0]
+ ctx.restore();
}
- //! [0]
- ctx.restore();
}
}
- Rectangle {
- id:controls
- width:320
- height:150
- Column {
- spacing:3
- Slider {id:scaleXCtrl; width:300; height:20; min:0.1; max:10; init:0.5; name:"ScaleX"}
- Slider {id:scaleYCtrl; width:300; height:20; min:0.1; max:10; init:0.5; name:"ScaleY"}
- Slider {id:rotateCtrl; width:300; height:20; min:0; max:Math.PI*2; init:0; name:"Rotate"}
- Slider {id:alphaCtrl; width:300; height:20; min:0; max:1; init:1; name:"Alpha"}
- }
+ Column {
+ id: controls
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 12
+ Slider {id: scaleCtrl ; min: 0.1 ; max: 1 ; init: 0.3 ; name: "Scale"}
+ Slider {id: rotateCtrl ; min: 0 ; max: Math.PI*2 ; init: 0 ; name: "Rotate"}
+ Slider {id: alphaCtrl ; min: 0 ; max: 1 ; init: 1 ; name: "Alpha"}
}
- }
}
diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/FileDialogs.qml
new file mode 100644
index 0000000000..3a987ff86f
--- /dev/null
+++ b/examples/quick/dialogs/FileDialogs.qml
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Dialogs 1.0
+import "../shared"
+
+Rectangle {
+
+ width: 580
+ height: 360
+ color: "#444444"
+
+ Rectangle {
+ id: toolbar
+ width: parent.width
+ height: 40
+ border.color: "black"
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#444444" }
+ GradientStop { position: 0.3; color: "grey" }
+ GradientStop { position: 0.85; color: "grey" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+ Row {
+ spacing: 6
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 8
+ height: parent.height - 6
+ width: parent.width
+ ToolButton {
+ text: "Open"
+ anchors.verticalCenter: parent.verticalCenter
+ onClicked: fileDialog.open()
+ }
+ ToolButton {
+ text: "Close"
+ anchors.verticalCenter: parent.verticalCenter
+ onClicked: fileDialog.close()
+ }
+ ToolButton {
+ text: "/tmp"
+ anchors.verticalCenter: parent.verticalCenter
+ // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet.
+ onClicked: fileDialog.folder = "/tmp"
+ }
+ }
+ }
+
+ FileDialog {
+ id: fileDialog
+ visible: fileDialogVisible.checked
+ modality: fileDialogModal.checked ? Qt.WindowModal : Qt.NonModal
+ title: fileDialogSelectFolder.checked ? "Choose a folder" :
+ (fileDialogSelectMultiple.checked ? "Choose some files" : "Choose a file")
+ selectExisting: fileDialogSelectExisting.checked
+ selectMultiple: fileDialogSelectMultiple.checked
+ selectFolder: fileDialogSelectFolder.checked
+ nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ]
+ selectedNameFilter: "All files (*)"
+ onAccepted: { console.log("Accepted: " + fileUrls) }
+ onRejected: { console.log("Rejected") }
+ }
+
+ Column {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: toolbar.bottom
+ anchors.margins: 8
+ spacing: 8
+ Text {
+ color: "white"
+ font.bold: true
+ text: "File dialog properties:"
+ }
+ CheckBox {
+ id: fileDialogModal
+ text: "Modal"
+ checked: true
+ Binding on checked { value: fileDialog.modality != Qt.NonModal }
+ }
+ CheckBox {
+ id: fileDialogSelectFolder
+ text: "Select Folder"
+ Binding on checked { value: fileDialog.selectFolder }
+ }
+ CheckBox {
+ id: fileDialogSelectExisting
+ text: "Select Existing Files"
+ checked: true
+ Binding on checked { value: fileDialog.selectExisting }
+ }
+ CheckBox {
+ id: fileDialogSelectMultiple
+ text: "Select Multiple Files"
+ Binding on checked { value: fileDialog.selectMultiple }
+ }
+ CheckBox {
+ id: fileDialogVisible
+ text: "Visible"
+ Binding on checked { value: fileDialog.visible }
+ }
+ Text {
+ color: "#EEEEDD"
+ text: "<b>current view folder:</b> " + fileDialog.folder
+ }
+ Text {
+ color: "#EEEEDD"
+ text: "<b>name filters:</b> {" + fileDialog.nameFilters + "}; current filter: " + fileDialog.selectedNameFilter
+ width: parent.width
+ wrapMode: Text.Wrap
+ }
+ Text {
+ color: "#EEEEDD"
+ text: "<b>chosen files:</b> " + fileDialog.fileUrls
+ width: parent.width
+ wrapMode: Text.Wrap
+ }
+ Text {
+ color: "#EEEEDD"
+ text: "<b>chosen single path:</b> " + fileDialog.fileUrl
+ width: parent.width
+ wrapMode: Text.Wrap
+ }
+ }
+}
diff --git a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
index cc034e34ba..d99deb754f 100644
--- a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
+++ b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
@@ -27,11 +27,11 @@
/*!
\example quick/scenegraph/customgeometry
- \title Custom Geometry Example
+ \title Scene Graph - Custom Geometry
\ingroup qtquickexamples
\brief Shows how to implement a custom geometry in the Qt Quick Scene Graph.
- \brief The custom geometry example shows how to create a QQuickItem which
+ The custom geometry example shows how to create a QQuickItem which
uses the scene graph API to build a custom geometry for the scene
graph. It does this by creating a BezierCurve item which is made
part of the CustomGeometry module and makes use of this in a QML
diff --git a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc
index 5ded717e5f..49f1a825e1 100644
--- a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc
+++ b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc
@@ -27,7 +27,7 @@
/*!
\example quick/scenegraph/openglunderqml
- \title OpenGL Under QML
+ \title Scene Graph - OpenGL Under QML
\ingroup qtquickexamples
\brief Shows how to render OpenGL under a Qt Quick scene.
diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro
index 88b8d03dc3..3ddb216615 100644
--- a/examples/quick/scenegraph/scenegraph.pro
+++ b/examples/quick/scenegraph/scenegraph.pro
@@ -1,2 +1,7 @@
TEMPLATE = subdirs
-SUBDIRS += customgeometry simplematerial openglunderqml
+SUBDIRS += \
+ customgeometry \
+ openglunderqml \
+ simplematerial \
+ textureinsgnode \
+ textureinthread \
diff --git a/examples/quick/scenegraph/shared/logorenderer.cpp b/examples/quick/scenegraph/shared/logorenderer.cpp
new file mode 100644
index 0000000000..4c5927b543
--- /dev/null
+++ b/examples/quick/scenegraph/shared/logorenderer.cpp
@@ -0,0 +1,258 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "logorenderer.h"
+#include <QPainter>
+#include <QPaintEngine>
+#include <math.h>
+
+LogoRenderer::LogoRenderer()
+{
+}
+
+LogoRenderer::~LogoRenderer()
+{
+}
+
+
+void LogoRenderer::paintQtLogo()
+{
+ program1.enableAttributeArray(normalAttr1);
+ program1.enableAttributeArray(vertexAttr1);
+ program1.setAttributeArray(vertexAttr1, vertices.constData());
+ program1.setAttributeArray(normalAttr1, normals.constData());
+ glDrawArrays(GL_TRIANGLES, 0, vertices.size());
+ program1.disableAttributeArray(normalAttr1);
+ program1.disableAttributeArray(vertexAttr1);
+}
+
+
+void LogoRenderer::initialize()
+{
+ glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
+
+ QOpenGLShader *vshader1 = new QOpenGLShader(QOpenGLShader::Vertex, &program1);
+ const char *vsrc1 =
+ "attribute highp vec4 vertex;\n"
+ "attribute mediump vec3 normal;\n"
+ "uniform mediump mat4 matrix;\n"
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
+ " float angle = max(dot(normal, toLight), 0.0);\n"
+ " vec3 col = vec3(0.40, 1.0, 0.0);\n"
+ " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
+ " color = clamp(color, 0.0, 1.0);\n"
+ " gl_Position = matrix * vertex;\n"
+ "}\n";
+ vshader1->compileSourceCode(vsrc1);
+
+ QOpenGLShader *fshader1 = new QOpenGLShader(QOpenGLShader::Fragment, &program1);
+ const char *fsrc1 =
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_FragColor = color;\n"
+ "}\n";
+ fshader1->compileSourceCode(fsrc1);
+
+ program1.addShader(vshader1);
+ program1.addShader(fshader1);
+ program1.link();
+
+ vertexAttr1 = program1.attributeLocation("vertex");
+ normalAttr1 = program1.attributeLocation("normal");
+ matrixUniform1 = program1.uniformLocation("matrix");
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ m_fAngle = 0;
+ m_fScale = 1;
+ createGeometry();
+}
+
+void LogoRenderer::render()
+{
+ glDepthMask(true);
+
+ glClearColor(0.5f, 0.5f, 0.7f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+
+ glFrontFace(GL_CW);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+
+ QMatrix4x4 modelview;
+ modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
+ modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f);
+ modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f);
+ modelview.scale(m_fScale);
+ modelview.translate(0.0f, -0.2f, 0.0f);
+
+ program1.bind();
+ program1.setUniformValue(matrixUniform1, modelview);
+ paintQtLogo();
+ program1.release();
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+
+ m_fAngle += 1.0f;
+}
+
+void LogoRenderer::createGeometry()
+{
+ vertices.clear();
+ normals.clear();
+
+ qreal x1 = +0.06f;
+ qreal y1 = -0.14f;
+ qreal x2 = +0.14f;
+ qreal y2 = -0.06f;
+ qreal x3 = +0.08f;
+ qreal y3 = +0.00f;
+ qreal x4 = +0.30f;
+ qreal y4 = +0.22f;
+
+ quad(x1, y1, x2, y2, y2, x2, y1, x1);
+ quad(x3, y3, x4, y4, y4, x4, y3, x3);
+
+ extrude(x1, y1, x2, y2);
+ extrude(x2, y2, y2, x2);
+ extrude(y2, x2, y1, x1);
+ extrude(y1, x1, x1, y1);
+ extrude(x3, y3, x4, y4);
+ extrude(x4, y4, y4, x4);
+ extrude(y4, x4, y3, x3);
+
+ const qreal Pi = 3.14159f;
+ const int NumSectors = 100;
+
+ for (int i = 0; i < NumSectors; ++i) {
+ qreal angle1 = (i * 2 * Pi) / NumSectors;
+ qreal x5 = 0.30 * sin(angle1);
+ qreal y5 = 0.30 * cos(angle1);
+ qreal x6 = 0.20 * sin(angle1);
+ qreal y6 = 0.20 * cos(angle1);
+
+ qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors;
+ qreal x7 = 0.20 * sin(angle2);
+ qreal y7 = 0.20 * cos(angle2);
+ qreal x8 = 0.30 * sin(angle2);
+ qreal y8 = 0.30 * cos(angle2);
+
+ quad(x5, y5, x6, y6, x7, y7, x8, y8);
+
+ extrude(x6, y6, x7, y7);
+ extrude(x8, y8, x5, y5);
+ }
+
+ for (int i = 0;i < vertices.size();i++)
+ vertices[i] *= 2.0f;
+}
+
+void LogoRenderer::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
+{
+ vertices << QVector3D(x1, y1, -0.05f);
+ vertices << QVector3D(x2, y2, -0.05f);
+ vertices << QVector3D(x4, y4, -0.05f);
+
+ vertices << QVector3D(x3, y3, -0.05f);
+ vertices << QVector3D(x4, y4, -0.05f);
+ vertices << QVector3D(x2, y2, -0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ vertices << QVector3D(x4, y4, 0.05f);
+ vertices << QVector3D(x2, y2, 0.05f);
+ vertices << QVector3D(x1, y1, 0.05f);
+
+ vertices << QVector3D(x2, y2, 0.05f);
+ vertices << QVector3D(x4, y4, 0.05f);
+ vertices << QVector3D(x3, y3, 0.05f);
+
+ n = QVector3D::normal
+ (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+}
+
+void LogoRenderer::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
+{
+ vertices << QVector3D(x1, y1, +0.05f);
+ vertices << QVector3D(x2, y2, +0.05f);
+ vertices << QVector3D(x1, y1, -0.05f);
+
+ vertices << QVector3D(x2, y2, -0.05f);
+ vertices << QVector3D(x1, y1, -0.05f);
+ vertices << QVector3D(x2, y2, +0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+}
diff --git a/examples/quick/canvas/contents/Button.qml b/examples/quick/scenegraph/shared/logorenderer.h
index efdf4eae76..48fbf87203 100644
--- a/examples/quick/canvas/contents/Button.qml
+++ b/examples/quick/scenegraph/shared/logorenderer.h
@@ -38,50 +38,40 @@
**
****************************************************************************/
-import QtQuick 2.0
+#ifndef LOGORENDERER_H
+#define LOGORENDERER_H
-Item {
- id: container
+#include <QtGui/qvector3d.h>
+#include <QtGui/qmatrix4x4.h>
+#include <QtGui/qopenglshaderprogram.h>
- signal clicked
+#include <QTime>
+#include <QVector>
- property string text
- width: buttonText.width + 28
- height: buttonText.height + 14
+class LogoRenderer {
- BorderImage {
- id: buttonImage
- source: "images/toolbutton.sci"
- width: container.width - 10
- height: container.height
- }
- BorderImage {
- id: pressed
- opacity: 0
- source: "images/toolbutton.sci"
- width: container.width - 10
- height: container.height
- }
- MouseArea {
- id: mouseRegion
- anchors.fill: buttonImage
- onClicked: { container.clicked(); }
- }
- Text {
- id: buttonText
- color: "white"
- anchors.centerIn: buttonImage
- font.bold: true
- font.pointSize: 15
- text: container.text
- style: Text.Raised
- styleColor: "black"
- }
- states: [
- State {
- name: "Pressed"
- when: mouseRegion.pressed == true
- PropertyChanges { target: pressed; opacity: 1 }
- }
- ]
-}
+public:
+ LogoRenderer();
+ ~LogoRenderer();
+
+ void render();
+ void initialize();
+
+private:
+
+ qreal m_fAngle;
+ qreal m_fScale;
+
+ void paintQtLogo();
+ void createGeometry();
+ void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
+ void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
+
+ QVector<QVector3D> vertices;
+ QVector<QVector3D> normals;
+ QOpenGLShaderProgram program1;
+ int vertexAttr1;
+ int normalAttr1;
+ int matrixUniform1;
+};
+#endif
diff --git a/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc b/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc
index 20d244fe99..97cc4677d5 100644
--- a/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc
+++ b/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc
@@ -27,7 +27,7 @@
/*!
\example quick/scenegraph/simplematerial
- \title Simple Material Example
+ \title Scene Graph - Simple Material
\ingroup qtquickexamples
\brief Shows how to define a scene graph material to fill a shape.
diff --git a/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg b/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg
new file mode 100644
index 0000000000..306b8bab20
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg
Binary files differ
diff --git a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc b/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc
new file mode 100644
index 0000000000..b24b0bd97b
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example quick/scenegraph/textureinsgnode
+ \title Scene Graph - Rendering FBOs
+ \ingroup qtquickexamples
+
+ \brief Shows how to use FramebufferObjects with Qt Quick.
+
+ \image textureinsgnode-example.jpg
+ */
diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp
new file mode 100644
index 0000000000..67df392555
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "fboinsgrenderer.h"
+#include "logorenderer.h"
+
+#include <QtGui/QOpenGLFramebufferObject>
+
+#include <QtQuick/QQuickWindow>
+#include <qsgsimpletexturenode.h>
+
+
+
+
+class TextureNode : public QObject, public QSGSimpleTextureNode
+{
+ Q_OBJECT
+
+public:
+ TextureNode(QQuickWindow *window)
+ : m_fbo(0)
+ , m_texture(0)
+ , m_window(window)
+ , m_logoRenderer(0)
+ {
+ connect(m_window, SIGNAL(beforeRendering()), this, SLOT(renderFBO()));
+ }
+
+ ~TextureNode()
+ {
+ delete m_texture;
+ delete m_fbo;
+ delete m_logoRenderer;
+ }
+
+public slots:
+ void renderFBO()
+ {
+ QSize size = rect().size().toSize();
+
+ if (!m_fbo) {
+
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ m_fbo = new QOpenGLFramebufferObject(size, format);
+ m_texture = m_window->createTextureFromId(m_fbo->texture(), size);
+ m_logoRenderer = new LogoRenderer();
+ m_logoRenderer->initialize();
+ setTexture(m_texture);
+ }
+
+ m_fbo->bind();
+
+ glViewport(0, 0, size.width(), size.height());
+
+ m_logoRenderer->render();
+
+ m_fbo->bindDefault();
+
+ m_window->update();
+ }
+
+private:
+ QOpenGLFramebufferObject *m_fbo;
+ QSGTexture *m_texture;
+ QQuickWindow *m_window;
+
+ LogoRenderer *m_logoRenderer;
+};
+
+
+
+FboInSGRenderer::FboInSGRenderer()
+{
+ setFlag(ItemHasContents, true);
+}
+
+
+QSGNode *FboInSGRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ // Don't bother with resize and such, just recreate the node from scratch
+ // when geometry changes.
+ if (oldNode)
+ delete oldNode;
+
+ TextureNode *node = new TextureNode(window());
+ node->setRect(boundingRect());
+
+ return node;
+}
+
+#include "fboinsgrenderer.moc"
diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h
new file mode 100644
index 0000000000..42e10aef6d
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FBOINSGRENDERER_H
+#define FBOINSGRENDERER_H
+
+#include <QQuickItem>
+
+
+class FboInSGRenderer : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ FboInSGRenderer();
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+
+};
+
+#endif
diff --git a/examples/quick/canvas/contents/ToolBar.qml b/examples/quick/scenegraph/textureinsgnode/main.cpp
index 005a6b144e..8fa6f6814f 100644
--- a/examples/quick/canvas/contents/ToolBar.qml
+++ b/examples/quick/scenegraph/textureinsgnode/main.cpp
@@ -38,32 +38,22 @@
**
****************************************************************************/
-import QtQuick 2.0
+#include <QGuiApplication>
-Item {
- id: toolbar
+#include <QtQuick/QQuickView>
- property variant labels
- signal buttonClicked(int index)
+#include "fboinsgrenderer.h"
- BorderImage {
- source: "images/titlebar.sci"
- width: parent.width
- height: parent.height + 14
- y: -7
- }
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
- Row {
- y: 3
- anchors.horizontalCenter: parent.horizontalCenter
- Repeater {
- model: toolbar.labels
- delegate:
- Button {
- text: modelData
- onClicked: toolbar.buttonClicked(model.index)
- }
- }
- }
+ qmlRegisterType<FboInSGRenderer>("SceneGraphRendering", 1, 0, "Renderer");
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml"));
+ view.show();
+
+ return app.exec();
}
diff --git a/examples/quick/scenegraph/textureinsgnode/main.qml b/examples/quick/scenegraph/textureinsgnode/main.qml
new file mode 100644
index 0000000000..6f6d7d1c1a
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/main.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+import SceneGraphRendering 1.0
+
+Item {
+ width: 400
+ height: 400
+
+ // The checkers background
+ ShaderEffect {
+ id: tileBackground
+ anchors.fill: parent
+
+ property real tileSize: 16
+ property color color1: Qt.rgba(0.9, 0.9, 0.9, 1);
+ property color color2: Qt.rgba(0.85, 0.85, 0.85, 1);
+
+ property size pixelSize: Qt.size(width / tileSize, height / tileSize);
+
+ fragmentShader:
+ "
+ uniform lowp vec4 color1;
+ uniform lowp vec4 color2;
+ uniform highp vec2 pixelSize;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
+ if (tc.x != tc.y)
+ gl_FragColor = color1;
+ else
+ gl_FragColor = color2;
+ }
+ "
+ }
+
+ Renderer {
+ id: renderer
+ anchors.fill: parent
+ anchors.margins: 10
+
+ // The transform is just to show something interesting..
+ transform: [
+ Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; },
+ Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 },
+ Scale { id: scale; },
+ Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 }
+ ]
+ }
+
+ // Just to show something interesting
+ SequentialAnimation {
+ PauseAnimation { duration: 5000 }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: renderer; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { target: renderer; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ running: true
+ loops: Animation.Infinite
+ }
+
+ Rectangle {
+ id: labelFrame
+ anchors.margins: -10
+ radius: 5
+ color: "white"
+ border.color: "black"
+ opacity: 0.8
+ anchors.fill: label
+ }
+
+ Text {
+ id: label
+ anchors.bottom: renderer.bottom
+ anchors.left: renderer.left
+ anchors.right: renderer.right
+ anchors.margins: 20
+ wrapMode: Text.WordWrap
+ text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application on the scene graph rendering thread. It is displayed using a QSGSimpleTextureNode."
+ }
+
+
+}
diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro
new file mode 100644
index 0000000000..238e20a553
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro
@@ -0,0 +1,16 @@
+QT += qml quick
+
+HEADERS += fboinsgrenderer.h
+SOURCES += fboinsgrenderer.cpp main.cpp
+
+INCLUDEPATH += ../shared
+HEADERS += ../shared/logorenderer.h
+SOURCES += ../shared/logorenderer.cpp
+
+RESOURCES += textureinsgnode.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinsgnode
+INSTALLS += target
+
+OTHER_FILES += \
+ main.qml
diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc
new file mode 100644
index 0000000000..9ecf0ada1c
--- /dev/null
+++ b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/scenegraph/textureinsgnode">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/scenegraph/textureinthread/doc/images/textureinthread-example.jpg b/examples/quick/scenegraph/textureinthread/doc/images/textureinthread-example.jpg
new file mode 100644
index 0000000000..59134e07c4
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/doc/images/textureinthread-example.jpg
Binary files differ
diff --git a/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc b/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc
new file mode 100644
index 0000000000..476605b268
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example quick/scenegraph/textureinthread
+ \title Scene Graph - Rendering FBOs in a thread
+ \ingroup qtquickexamples
+
+ \brief Shows how to use FramebufferObjects in a thread together with Qt Quick.
+
+ \image textureinthread-example.jpg
+ */
diff --git a/examples/quick/canvas/contents/TitleBar.qml b/examples/quick/scenegraph/textureinthread/main.cpp
index 1698a2a98a..e415d254a1 100644
--- a/examples/quick/canvas/contents/TitleBar.qml
+++ b/examples/quick/scenegraph/textureinthread/main.cpp
@@ -38,33 +38,22 @@
**
****************************************************************************/
-import QtQuick 2.0
+#include <QGuiApplication>
-Item {
- id: titleBar
- property string title: ""
+#include <QtQuick/QQuickView>
- BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
+#include "threadrenderer.h"
- Image {
- id: quitButton
- anchors.left: parent.left//; anchors.leftMargin: 0
- anchors.verticalCenter: parent.verticalCenter
- source: "images/quit.png"
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.quit()
- }
- }
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
- Text {
- id: categoryText
- anchors {
- left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10
- verticalCenter: parent.verticalCenter
- }
- elide: Text.ElideLeft
- text: title
- font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black"
- }
+ qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer");
+
+ QQuickView view;
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml"));
+ view.show();
+
+ return app.exec();
}
diff --git a/examples/quick/scenegraph/textureinthread/main.qml b/examples/quick/scenegraph/textureinthread/main.qml
new file mode 100644
index 0000000000..4493ec46fd
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/main.qml
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+import SceneGraphRendering 1.0
+
+Item {
+ width: 400
+ height: 400
+
+ // The checkers background
+ ShaderEffect {
+ id: tileBackground
+ anchors.fill: parent
+
+ property real tileSize: 16
+ property color color1: Qt.rgba(0.9, 0.9, 0.9, 1);
+ property color color2: Qt.rgba(0.85, 0.85, 0.85, 1);
+
+ property size pixelSize: Qt.size(width / tileSize, height / tileSize);
+
+ fragmentShader:
+ "
+ uniform lowp vec4 color1;
+ uniform lowp vec4 color2;
+ uniform highp vec2 pixelSize;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
+ if (tc.x != tc.y)
+ gl_FragColor = color1;
+ else
+ gl_FragColor = color2;
+ }
+ "
+ }
+
+ Renderer {
+ id: renderer
+ anchors.fill: parent
+ anchors.margins: 10
+
+ // The transform is just to show something interesting..
+ transform: [
+ Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; },
+ Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 },
+ Scale { id: scale; },
+ Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 }
+ ]
+ }
+
+ // Just to show something interesting
+ SequentialAnimation {
+ PauseAnimation { duration: 5000 }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic }
+ NumberAnimation { target: renderer; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { target: renderer; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic }
+ ParallelAnimation {
+ NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack }
+ }
+ running: true
+ loops: Animation.Infinite
+ }
+
+ Rectangle {
+ id: labelFrame
+ anchors.margins: -10
+ radius: 5
+ color: "white"
+ border.color: "black"
+ opacity: 0.8
+ anchors.fill: label
+ }
+
+ Text {
+ id: label
+ anchors.bottom: renderer.bottom
+ anchors.left: renderer.left
+ anchors.right: renderer.right
+ anchors.margins: 20
+ wrapMode: Text.WordWrap
+ text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application in a dedicated background thread. The background thread juggles two FBOs, one that is being rendered to and one for displaying. The texture to display is posted to the scene graph and displayed using a QSGSimpleTextureNode."
+ }
+
+
+}
diff --git a/examples/quick/scenegraph/textureinthread/textureinthread.pro b/examples/quick/scenegraph/textureinthread/textureinthread.pro
new file mode 100644
index 0000000000..b48c2a1863
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/textureinthread.pro
@@ -0,0 +1,16 @@
+QT += quick
+
+HEADERS += threadrenderer.h
+SOURCES += threadrenderer.cpp main.cpp
+
+INCLUDEPATH += ../shared
+HEADERS += ../shared/logorenderer.h
+SOURCES += ../shared/logorenderer.cpp
+
+RESOURCES += textureinthread.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinthread
+INSTALLS += target
+
+OTHER_FILES += \
+ main.qml
diff --git a/examples/quick/scenegraph/textureinthread/textureinthread.qrc b/examples/quick/scenegraph/textureinthread/textureinthread.qrc
new file mode 100644
index 0000000000..9ecf0ada1c
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/textureinthread.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/scenegraph/textureinsgnode">
+ <file>main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp
new file mode 100644
index 0000000000..90b6b49880
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "threadrenderer.h"
+#include "logorenderer.h"
+
+#include <QtCore/QMutex>
+#include <QtCore/QThread>
+
+#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLFramebufferObject>
+
+#include <QtQuick/QQuickWindow>
+#include <qsgsimpletexturenode.h>
+
+
+/*
+ * The render thread shares a context with the scene graph and will
+ * render into two separate FBOs, one to use for display and one
+ * to use for rendering
+ */
+class RenderThread : public QThread
+{
+ Q_OBJECT
+public:
+ RenderThread(const QSize &size)
+ : m_renderFbo(0)
+ , m_displayFbo(0)
+ , m_logoRenderer(0)
+ , m_size(size)
+ {
+ // Since we're using queued connections, we need affinity to the rendering thread.
+ moveToThread(this);
+
+ // Set up the QOpenGLContext to use for rendering in this thread. It is sharing
+ // memory space with the GL context of the scene graph. This constructor is called
+ // during updatePaintNode, so we are currently on the scene graph thread with the
+ // scene graph's OpenGL context current.
+ QOpenGLContext *current = QOpenGLContext::currentContext();
+ m_context = new QOpenGLContext();
+ m_context->setShareContext(current);
+ m_context->setFormat(current->format());
+ m_context->create();
+ m_context->moveToThread(this);
+
+ // We need a non-visible surface to make current...
+ m_fakeSurface = new QWindow();
+ m_fakeSurface->setGeometry(0, 0, 64, 64);
+ m_fakeSurface->setSurfaceType(QWindow::OpenGLSurface);
+ m_fakeSurface->setFormat(current->format());
+ m_fakeSurface->create();
+ }
+
+public slots:
+ void renderNext()
+ {
+ m_context->makeCurrent(m_fakeSurface);
+
+ if (!m_renderFbo) {
+ // Initialize the buffers and renderer
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ m_renderFbo = new QOpenGLFramebufferObject(m_size, format);
+ m_displayFbo = new QOpenGLFramebufferObject(m_size, format);
+ m_logoRenderer = new LogoRenderer();
+ m_logoRenderer->initialize();
+ }
+
+ m_renderFbo->bind();
+ glViewport(0, 0, m_size.width(), m_size.height());
+
+ m_logoRenderer->render();
+
+ // We need to flush the contents to the FBO before posting
+ // the texture to the other thread, otherwise, we might
+ // get unexpected results.
+ glFlush();
+
+ m_renderFbo->bindDefault();
+ qSwap(m_renderFbo, m_displayFbo);
+
+ emit textureReady(m_displayFbo->texture(), m_size);
+ }
+
+signals:
+ void textureReady(int id, const QSize &size);
+
+private:
+ QOpenGLFramebufferObject *m_renderFbo;
+ QOpenGLFramebufferObject *m_displayFbo;
+
+ LogoRenderer *m_logoRenderer;
+
+ QWindow *m_fakeSurface;
+ QOpenGLContext *m_context;
+ QSize m_size;
+};
+
+
+
+class TextureNode : public QObject, public QSGSimpleTextureNode
+{
+ Q_OBJECT
+
+public:
+ TextureNode(QQuickWindow *window)
+ : m_id(0)
+ , m_size(0, 0)
+ , m_texture(0)
+ , m_window(window)
+ {
+ // Our texture node must have a texture, so use the default 0 texture.
+ m_texture = m_window->createTextureFromId(0, QSize(1, 1));
+ setTexture(m_texture);
+ setFiltering(QSGTexture::Linear);
+ }
+
+ ~TextureNode()
+ {
+ delete m_texture;
+ }
+
+signals:
+ void textureInUse();
+ void pendingNewTexture();
+
+public slots:
+
+ // This function gets called on the FBO rendering thread and will store the
+ // texture id and size and schedule an update on the window.
+ void newTexture(int id, const QSize &size) {
+ m_mutex.lock();
+ m_id = id;
+ m_size = size;
+ m_mutex.unlock();
+
+ // We cannot call QQuickWindow::update directly here, as this is only allowed
+ // from the rendering thread or GUI thread.
+ emit pendingNewTexture();
+ }
+
+
+ // Before the scene graph starts to render, we update to the pending texture
+ void prepareNode() {
+ m_mutex.lock();
+ int newId = m_id;
+ QSize size = m_size;
+ m_id = 0;
+ m_mutex.unlock();
+ if (newId) {
+ delete m_texture;
+ m_texture = m_window->createTextureFromId(newId, size);
+ setTexture(m_texture);
+
+ // This will notify the rendering thread that the texture is now being rendered
+ // and it can start rendering to the other one.
+ emit textureInUse();
+ }
+ }
+
+private:
+
+ int m_id;
+ QSize m_size;
+
+ QMutex m_mutex;
+
+ QSGTexture *m_texture;
+ QQuickWindow *m_window;
+};
+
+
+
+ThreadRenderer::ThreadRenderer()
+{
+ setFlag(ItemHasContents, true);
+}
+
+
+
+QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+{
+ TextureNode *node = static_cast<TextureNode *>(oldNode);
+
+ if (!node) {
+ node = new TextureNode(window());
+ m_renderThread = new RenderThread(QSize(512, 512));
+
+ /* Set up connections to get the production of FBO textures in sync with vsync on the
+ * rendering thread.
+ *
+ * When a new texture is ready on the rendering thread, we use a direct connection to
+ * the texture node to let it know a new texture can be used. The node will then
+ * emit pendingNewTexture which we bind to QQuickWindow::update to schedule a redraw.
+ *
+ * When the scene graph starts rendering the next frame, the prepareNode() function
+ * is used to update the node with the new texture. Once it completes, it emits
+ * textureInUse() which we connect to the FBO rendering thread's renderNext() to have
+ * it start producing content into its current "back buffer".
+ *
+ * This FBO rendering pipeline is throttled by vsync on the scene graph rendering thread.
+ */
+ connect(m_renderThread, SIGNAL(textureReady(int,QSize)), node, SLOT(newTexture(int,QSize)), Qt::DirectConnection);
+ connect(node, SIGNAL(pendingNewTexture()), window(), SLOT(update()), Qt::QueuedConnection);
+ connect(window(), SIGNAL(beforeRendering()), node, SLOT(prepareNode()), Qt::DirectConnection);
+ connect(node, SIGNAL(textureInUse()), m_renderThread, SLOT(renderNext()), Qt::QueuedConnection);
+
+ // Start the render thread and enter let it process events.
+ m_renderThread->start();
+
+ // Get the production of FBO textures started..
+ QMetaObject::invokeMethod(m_renderThread, "renderNext", Qt::QueuedConnection);
+ }
+
+ node->setRect(boundingRect());
+
+ return node;
+}
+
+#include "threadrenderer.moc"
diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.h b/examples/quick/scenegraph/textureinthread/threadrenderer.h
new file mode 100644
index 0000000000..f12e6404e5
--- /dev/null
+++ b/examples/quick/scenegraph/textureinthread/threadrenderer.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef THREADRENDERER_H
+#define THREADRENDERER_H
+
+#include <QQuickItem>
+
+class RenderThread;
+
+class ThreadRenderer : public QQuickItem
+{
+ Q_OBJECT
+
+public:
+ ThreadRenderer();
+
+protected:
+ QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+
+private:
+ RenderThread *m_renderThread;
+};
+
+#endif
diff --git a/examples/quick/shared/CheckBox.qml b/examples/quick/shared/CheckBox.qml
new file mode 100644
index 0000000000..1d29430934
--- /dev/null
+++ b/examples/quick/shared/CheckBox.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ height: label.height + 4
+ width: label.width + height + 4
+ property alias text: label.text
+ property bool checked
+ property alias pressed: mouseArea.pressed
+ Rectangle {
+ antialiasing: true
+ border.color: "white"
+ color: "transparent"
+ anchors.fill: gradientRect
+ anchors.rightMargin: 1
+ anchors.bottomMargin: 1
+ radius: 3
+ }
+ Rectangle {
+ border.color: "black"
+ anchors.fill: gradientRect
+ anchors.leftMargin: 1
+ anchors.topMargin: 1
+ radius: 3
+ }
+ Rectangle {
+ id: gradientRect
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: mouseArea.pressed ? "darkgrey" : "#CCCCCC" }
+ GradientStop { position: 0.6; color: "#887766" }
+ GradientStop { position: 1.0; color: mouseArea.pressed ? "white" : "#333333" }
+ }
+ anchors.verticalCenter: parent.verticalCenter
+ height: parent.height
+ width: height
+ anchors.margins: 1
+ radius: 3
+ }
+ Text {
+ id: theX
+ anchors.centerIn: gradientRect
+ text: checked ? "✓" : ""
+ }
+ Text {
+ anchors.centerIn: gradientRect
+ anchors.horizontalCenterOffset: 0.5
+ anchors.verticalCenterOffset: 0.5
+ color: "white"
+ text: theX.text
+ }
+ Text {
+ id: label
+ color: "#EEEEDD"
+ anchors.left: gradientRect.right
+ anchors.leftMargin: 6
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: parent.checked = !parent.checked
+ }
+}
diff --git a/examples/quick/canvas/contents/Slider.qml b/examples/quick/shared/Slider.qml
index e0fed95ee8..d310a25bd5 100644
--- a/examples/quick/canvas/contents/Slider.qml
+++ b/examples/quick/shared/Slider.qml
@@ -42,73 +42,75 @@
import QtQuick 2.0
Item {
- id:slider
- property real min:0
- property real max:1
- property real value: min + (max - min) * (bar.x / (foo.width - bar.width))
- property real init:min+(max-min)/2
- property string name:"Slider"
+ id: slider
+ height: 26
+ width: 320
+
+ property real min: 0
+ property real max: 1
+ property real value: min + (max - min) * mousearea.value
+ property real init: min+(max-min)/2
+ property string name: "Slider"
+ property color color: "#0066cc"
Component.onCompleted: setValue(init)
function setValue(v) {
if (min < max)
- bar.x = v/(max - min) * (foo.width - bar.width);
+ handle.x = Math.round( v / (max - min) *
+ (mousearea.drag.maximumX - mousearea.drag.minimumX)
+ + mousearea.drag.minimumX);
}
Rectangle {
id:sliderName
- anchors.left:parent.left
+ anchors.left: parent.left
+ anchors.leftMargin: 16
height: childrenRect.height
- width:childrenRect.width
- anchors.verticalCenter:parent.verticalCenter
+ width: Math.max(44, childrenRect.width)
+ anchors.verticalCenter: parent.verticalCenter
Text {
- text:slider.name
- font.pointSize:12
- }
+ text: slider.name + ":"
+ font.pointSize: 12
+ color: "#333"
+ }
}
- Item {
+
+ Rectangle{
id: foo
- height: 6
- width: parent.width - 4 - sliderName.width
- anchors.verticalCenter:parent.verticalCenter
- anchors.left:sliderName.right
- anchors.leftMargin:5
+ width: parent.width - 8 - sliderName.width
+ color: "#eee"
+ height: 7
+ radius: 3
+ antialiasing: true
+ border.color: Qt.darker(color, 1.2)
+ anchors.left: sliderName.right
+ anchors.right: parent.right
+ anchors.leftMargin: 10
+ anchors.rightMargin: 24
+ anchors.verticalCenter: parent.verticalCenter
+
Rectangle {
height: parent.height
anchors.left: parent.left
- anchors.right: bar.horizontalCenter
- color: "blue"
+ anchors.right: handle.horizontalCenter
+ color: slider.color
radius: 3
+ border.width: 1
+ border.color: Qt.darker(color, 1.3)
+ opacity: 0.8
}
- Rectangle {
- height: parent.height
- anchors.left: bar.horizontalCenter
- anchors.right: parent.right
- color: "gray"
- radius: 3
- }
- Rectangle {
- anchors.fill: parent
- color: "transparent"
- radius: 3
- border.width: 2
- border.color: "black"
- }
-
- Rectangle {
- id: bar
- y: -7
- width: 20
- height: 20
- radius: 15
- color: "white"
- border.width: 2
- border.color: "black"
+ Image {
+ id: handle
+ source: "images/slider_handle.png"
+ anchors.verticalCenter: parent.verticalCenter
MouseArea {
+ id: mousearea
anchors.fill: parent
+ anchors.margins: -4
drag.target: parent
drag.axis: Drag.XAxis
- drag.minimumX: 0
- drag.maximumX: foo.width - parent.width
+ drag.minimumX: Math.round(-handle.width / 2 + 3)
+ drag.maximumX: Math.round(foo.width - handle.width/2 - 3)
+ property real value: (handle.x - drag.minimumX) / (drag.maximumX - drag.minimumX)
}
}
}
diff --git a/examples/quick/canvas/contents/ScrollBar.qml b/examples/quick/shared/ToolButton.qml
index 2c51e0fc48..1af0d13dcf 100644
--- a/examples/quick/canvas/contents/ScrollBar.qml
+++ b/examples/quick/shared/ToolButton.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
@@ -41,34 +41,53 @@
import QtQuick 2.0
Item {
- id: scrollBar
- // The properties that define the scrollbar's state.
- // position and pageSize are in the range 0.0 - 1.0. They are relative to the
- // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
- // of the height of the view.
- // orientation can be either 'Vertical' or 'Horizontal'
- property real position
- property real pageSize
- property string orientation : "Vertical"
- property alias bgColor: background.color
- property alias fgColor: thumb.color
-
- // A light, semi-transparent background
+ height: parent.height - 4
+ width: height * 2
+ anchors.verticalCenter: parent.verticalCenter
+ property alias text: label.text
+ property string tooltip
+ signal clicked
Rectangle {
- id: background
- radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
- color: "white"; opacity: 0.3
+ antialiasing: true
+ border.color: "white"
+ color: "transparent"
anchors.fill: parent
+ anchors.rightMargin: 1
+ anchors.bottomMargin: 1
+ radius: 3
}
- // Size the bar to the required size, depending upon the orientation.
Rectangle {
- id: thumb
- opacity: 0.7
- color: "black"
- radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1)
- x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1)
- y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1
- width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2))
- height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2)
+ border.color: "black"
+ anchors.fill: parent
+ anchors.leftMargin: 1
+ anchors.topMargin: 1
+ radius: 3
+ }
+ Rectangle {
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: mouseArea.pressed ? "darkgrey" : "#CCCCCC" }
+ GradientStop { position: 0.6; color: "#887766" }
+ GradientStop { position: 1.0; color: mouseArea.pressed ? "white" : "#333333" }
+ }
+ anchors.fill: parent
+ anchors.margins: 1
+ radius: 3
+ }
+ Text {
+ id: label
+ anchors.centerIn: parent
+ }
+ Text {
+ anchors.centerIn: parent
+ anchors.horizontalCenterOffset: 0.5
+ anchors.verticalCenterOffset: 0.5
+ color: "white"
+ text: label.text
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: parent.clicked()
}
}
diff --git a/examples/quick/shared/images/slider_handle.png b/examples/quick/shared/images/slider_handle.png
new file mode 100644
index 0000000000..63c518be7d
--- /dev/null
+++ b/examples/quick/shared/images/slider_handle.png
Binary files differ
diff --git a/examples/quick/shared/qmldir b/examples/quick/shared/qmldir
index 2f1e56aefb..68bd573f85 100644
--- a/examples/quick/shared/qmldir
+++ b/examples/quick/shared/qmldir
@@ -1,3 +1,6 @@
Button 2.0 Button.qml
+CheckBox 2.1 CheckBox.qml
LauncherList 2.0 LauncherList.qml
SimpleLauncherDelegate 2.0 SimpleLauncherDelegate.qml
+Slider 2.0 Slider.qml
+ToolButton 2.1 ToolButton.qml
diff --git a/examples/quick/shared/quick_shared.qrc b/examples/quick/shared/quick_shared.qrc
index 74a964e5ef..aa6a761e0d 100644
--- a/examples/quick/shared/quick_shared.qrc
+++ b/examples/quick/shared/quick_shared.qrc
@@ -3,6 +3,8 @@
<file>LauncherList.qml</file>
<file>SimpleLauncherDelegate.qml</file>
<file>Button.qml</file>
+ <file>CheckBox.qml</file>
+ <file>ToolButton.qml</file>
<file>images/back.png</file>
<file>images/next.png</file>
</qresource>
diff --git a/examples/quick/shared/shared.qrc b/examples/quick/shared/shared.qrc
index 0c9f39e7b0..cbc782f2c7 100644
--- a/examples/quick/shared/shared.qrc
+++ b/examples/quick/shared/shared.qrc
@@ -3,6 +3,10 @@
<file>LauncherList.qml</file>
<file>SimpleLauncherDelegate.qml</file>
<file>Button.qml</file>
+ <file>Slider.qml</file>
+ <file>images/slider_handle.png</file>
+ <file>CheckBox.qml</file>
+ <file>ToolButton.qml</file>
<file>images/back.png</file>
<file>images/next.png</file>
</qresource>
diff --git a/src/imports/dialogs/DefaultFileDialog.qml b/src/imports/dialogs/DefaultFileDialog.qml
new file mode 100644
index 0000000000..80bf6b5cb1
--- /dev/null
+++ b/src/imports/dialogs/DefaultFileDialog.qml
@@ -0,0 +1,366 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Dialogs 1.0
+import Qt.labs.folderlistmodel 2.0
+import "qml"
+
+AbstractFileDialog {
+ id: root
+ onVisibleChanged: {
+ if (visible) {
+ selectedIndices = []
+ lastClickedIdx = -1
+ currentPathField.visible = false
+ }
+ }
+
+ property bool showFocusHighlight: false
+ property real textX: 28
+ property SystemPalette palette
+ property var selectedIndices: []
+ property int lastClickedIdx: -1
+ folder: urlToPath(view.model.folder)
+
+ function dirDown(path) {
+ view.model.folder = path
+ lastClickedIdx = -1
+ selectedIndices = []
+ }
+ function dirUp() {
+ view.model.folder = view.model.parentFolder
+ lastClickedIdx = -1
+ selectedIndices = []
+ }
+ function up(extend) {
+ if (view.currentIndex > 0)
+ --view.currentIndex
+ else
+ view.currentIndex = 0
+ if (extend) {
+ if (selectedIndices.indexOf(view.currentIndex) < 0) {
+ var selCopy = selectedIndices
+ selCopy.push(view.currentIndex)
+ selectedIndices = selCopy
+ }
+ } else
+ selectedIndices = [view.currentIndex]
+ }
+ function down(extend) {
+ if (view.currentIndex < view.model.count - 1)
+ ++view.currentIndex
+ else
+ view.currentIndex = view.model.count - 1
+ if (extend) {
+ if (selectedIndices.indexOf(view.currentIndex) < 0) {
+ var selCopy = selectedIndices
+ selCopy.push(view.currentIndex)
+ selectedIndices = selCopy
+ }
+ } else
+ selectedIndices = [view.currentIndex]
+ }
+ function acceptSelection() {
+ clearSelection()
+ if (selectFolder && selectedIndices.length == 0)
+ addSelection(folder)
+ else {
+ selectedIndices.map(function(idx) {
+ if (view.model.isFolder(idx)) {
+ if (selectFolder)
+ addSelection(view.model.get(idx, "filePath"))
+ } else {
+ if (!selectFolder)
+ addSelection(view.model.get(idx, "filePath"))
+ }
+ })
+ }
+ accept()
+ }
+
+ Rectangle {
+ width: 480 // TODO: QTBUG-29817 geometry from AbstractFileDialog
+ height: 320
+ id: window
+ color: palette.window
+ anchors.centerIn: Qt.application.supportsMultipleWindows ? null : parent
+
+ SystemPalette { id: palette }
+
+ Component {
+ id: folderDelegate
+ Rectangle {
+ id: wrapper
+ function launch() {
+ if (view.model.isFolder(index)) {
+ dirDown(filePath)
+ } else {
+ root.acceptSelection()
+ }
+ }
+ width: window.width
+ height: nameText.implicitHeight * 1.5
+ color: "transparent"
+ Rectangle {
+ id: itemHighlight
+ visible: root.selectedIndices.indexOf(index) >= 0
+ anchors.fill: parent
+ color: palette.highlight
+ }
+ Image {
+ id: icon
+ source: "images/folder.png"
+ height: wrapper.height - y * 2; width: height
+ x: (root.textX - width) / 2
+ y: 2
+ visible: view.model.isFolder(index)
+ }
+ Text {
+ id: nameText
+ anchors.fill: parent; verticalAlignment: Text.AlignVCenter
+ text: fileName
+ anchors.leftMargin: root.textX
+ color: itemHighlight.visible ? palette.highlightedText : palette.windowText
+ elide: Text.ElideRight
+ }
+ MouseArea {
+ id: mouseRegion
+ anchors.fill: parent
+ onDoubleClicked: {
+ selectedIndices = [index]
+ root.lastClickedIdx = index
+ launch()
+ }
+ onClicked: {
+ view.currentIndex = index
+ if (mouse.modifiers & Qt.ControlModifier && root.selectMultiple) {
+ // modifying the contents of selectedIndices doesn't notify,
+ // so we have to re-assign the variable
+ var selCopy = selectedIndices
+ var existingIdx = selCopy.indexOf(index)
+ if (existingIdx >= 0)
+ selCopy.splice(existingIdx, 1)
+ else
+ selCopy.push(index)
+ selectedIndices = selCopy
+ } else if (mouse.modifiers & Qt.ShiftModifier && root.selectMultiple) {
+ if (root.lastClickedIdx >= 0) {
+ var sel = []
+ if (index > lastClickedIdx) {
+ for (var i = root.lastClickedIdx; i <= index; i++)
+ sel.push(i)
+ } else {
+ for (var i = root.lastClickedIdx; i >= index; i--)
+ sel.push(i)
+ }
+ selectedIndices = sel
+ }
+ } else {
+ selectedIndices = [index]
+ root.lastClickedIdx = index
+ }
+ }
+ }
+ }
+ }
+
+ ListView {
+ id: view
+ anchors.top: titleBar.bottom
+ anchors.bottom: bottomBar.top
+ clip: true
+ x: 0
+ width: parent.width
+ model: FolderListModel { }
+ delegate: folderDelegate
+ highlight: Rectangle {
+ color: "transparent"
+ border.color: palette.midlight
+ }
+ highlightMoveDuration: 0
+ highlightMoveVelocity: -1
+ focus: !currentPathField.visible
+ Keys.onPressed: {
+ event.accepted = true
+ switch (event.key) {
+ case Qt.Key_Up:
+ root.up(event.modifiers & Qt.ShiftModifier && root.selectMultiple)
+ break
+ case Qt.Key_Down:
+ root.down(event.modifiers & Qt.ShiftModifier && root.selectMultiple)
+ break
+ case Qt.Key_Left:
+ root.dirUp()
+ break
+ case Qt.Key_Return:
+ case Qt.Key_Select:
+ case Qt.Key_Right:
+ if (view.currentItem)
+ view.currentItem.launch()
+ else
+ root.acceptSelection()
+ break
+ default:
+ // do nothing
+ event.accepted = false
+ break
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: view
+ enabled: currentPathField.visible
+ onClicked: currentPathField.visible = false
+ }
+
+
+ Item {
+ id: titleBar
+ width: parent.width
+ height: currentPathField.height * 1.5
+ BorderImage {
+ source: "images/titlebar.sci"
+ anchors.fill: parent
+ anchors.topMargin: -7
+ anchors.bottomMargin: -7
+ }
+ Rectangle {
+ id: upButton
+ width: root.textX
+ height: titleBar.height
+ color: "transparent"
+
+ Image {
+ id: upButtonImage
+ anchors.centerIn: parent; source: "images/up.png"
+ }
+ MouseArea { id: upRegion; anchors.centerIn: parent
+ width: 56
+ height: parent.height
+ onClicked: if (view.model.parentFolder != "") dirUp()
+ }
+ states: [
+ State {
+ name: "pressed"
+ when: upRegion.pressed
+ PropertyChanges { target: upButton; color: palette.highlight }
+ }
+ ]
+ }
+ Text {
+ id: currentPathText
+ anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter
+ anchors.leftMargin: textX; anchors.rightMargin: 4
+ text: root.urlToPath(view.model.folder)
+ color: "white"
+ elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
+ MouseArea {
+ anchors.fill: parent
+ onClicked: currentPathField.visible = true
+ }
+ }
+ TextField {
+ id: currentPathField
+ anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter
+ anchors.leftMargin: textX; anchors.rightMargin: 4
+ visible: false
+ focus: visible
+ text: root.urlToPath(view.model.folder)
+ onAccepted: {
+ root.clearSelection()
+ if (root.addSelection(text))
+ root.accept()
+ else
+ view.model.folder = root.pathFolder(text)
+ }
+ onDownPressed: currentPathField.visible = false
+ }
+ }
+ Rectangle {
+ id: bottomBar
+ width: parent.width
+ height: buttonRow.height + buttonRow.spacing * 2
+ anchors.bottom: parent.bottom
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: palette.dark }
+ GradientStop { position: 0.3; color: palette.mid }
+ GradientStop { position: 0.85; color: palette.mid }
+ GradientStop { position: 1.0; color: palette.light }
+ }
+
+ Row {
+ id: buttonRow
+ anchors.right: parent.right
+ anchors.rightMargin: spacing
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: 4
+ TextField {
+ id: filterField
+ text: root.selectedNameFilter
+ visible: !selectFolder
+ width: bottomBar.width - cancelButton.width - okButton.width - parent.spacing * 5
+ anchors.verticalCenter: parent.verticalCenter
+ onAccepted: {
+ root.selectNameFilter(text)
+ view.model.nameFilters = text
+ }
+ }
+ Button {
+ id: cancelButton
+ text: "Cancel"
+ onClicked: root.reject()
+ }
+ Button {
+ id: okButton
+ text: "OK"
+ onClicked: {
+ if (view.model.isFolder(view.currentIndex) && !selectFolder)
+ dirDown(view.model.get(view.currentIndex, "filePath"))
+ else
+ root.acceptSelection()
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/imports/dialogs/WidgetFileDialog.qml b/src/imports/dialogs/WidgetFileDialog.qml
new file mode 100644
index 0000000000..837c7f8a57
--- /dev/null
+++ b/src/imports/dialogs/WidgetFileDialog.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.PrivateWidgets 1.0
+
+QtFileDialog { }
diff --git a/src/imports/dialogs/dialogs.pro b/src/imports/dialogs/dialogs.pro
new file mode 100644
index 0000000000..1a8ec05b85
--- /dev/null
+++ b/src/imports/dialogs/dialogs.pro
@@ -0,0 +1,30 @@
+CXX_MODULE = qml
+TARGET = dialogplugin
+TARGETPATH = QtQuick/Dialogs
+IMPORT_VERSION = 1.0
+
+SOURCES += \
+ plugin.cpp \
+ qquickabstractfiledialog.cpp \
+ qquickplatformfiledialog.cpp \
+ qquickfiledialog.cpp
+
+HEADERS += \
+ qquickabstractfiledialog_p.h \
+ qquickplatformfiledialog_p.h \
+ qquickfiledialog_p.h
+
+QML_FILES += \
+ DefaultFileDialog.qml \
+ WidgetFileDialog.qml \
+ qml/Button.qml \
+ qml/TextField.qml \
+ qml/qmldir \
+ images/folder.png \
+ images/titlebar.png \
+ images/titlebar.sci \
+ images/up.png
+
+QT += quick-private gui-private core-private
+
+load(qml_plugin)
diff --git a/src/imports/dialogs/images/folder.png b/src/imports/dialogs/images/folder.png
new file mode 100644
index 0000000000..e53e2ad464
--- /dev/null
+++ b/src/imports/dialogs/images/folder.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.png b/src/imports/dialogs/images/titlebar.png
index 51c90082d0..51c90082d0 100755..100644
--- a/examples/quick/canvas/contents/images/titlebar.png
+++ b/src/imports/dialogs/images/titlebar.png
Binary files differ
diff --git a/examples/quick/canvas/contents/images/titlebar.sci b/src/imports/dialogs/images/titlebar.sci
index 0418d94cd6..0418d94cd6 100644
--- a/examples/quick/canvas/contents/images/titlebar.sci
+++ b/src/imports/dialogs/images/titlebar.sci
diff --git a/src/imports/dialogs/images/up.png b/src/imports/dialogs/images/up.png
new file mode 100644
index 0000000000..b05f8025d0
--- /dev/null
+++ b/src/imports/dialogs/images/up.png
Binary files differ
diff --git a/src/imports/dialogs/plugin.cpp b/src/imports/dialogs/plugin.cpp
new file mode 100644
index 0000000000..46bd0dcb9d
--- /dev/null
+++ b/src/imports/dialogs/plugin.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlextensionplugin.h>
+#include "qquickfiledialog_p.h"
+#include "qquickabstractfiledialog_p.h"
+#include "qquickplatformfiledialog_p.h"
+#include <private/qguiapplication_p.h>
+
+//#define PURE_QML_ONLY
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlmodule QtQuick.Dialogs 1
+ \title Qt Quick Dialog QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for standard file, color picker and message dialogs
+
+ This QML module contains types for creating and interacting with system dialogs.
+
+ To use the types in this module, import the module with the following line:
+
+ \code
+ import QtQuick.Dialogs 1.0
+ \endcode
+*/
+
+class QtQuick2DialogsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ QtQuick2DialogsPlugin() : QQmlExtensionPlugin() { }
+
+ virtual void initializeEngine(QQmlEngine *, const char *uri) {
+ bool needQml = false;
+ QDir qmlDir(baseUrl().toLocalFile());
+ // If there is no support for native dialogs on the platform, we need to
+ // either re-use QFileDialog, or register a QML implementation instead.
+#ifdef PURE_QML_ONLY
+ needQml = true;
+#else
+ if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog)) {
+ needQml = true;
+ // If there is not a QApplication, there's no point in trying to load
+ // widget-based dialogs, because a runtime error will occur.
+ if (QCoreApplication::instance()->metaObject()->className() == QLatin1String("QApplication")) {
+ // Test whether PrivateWidgets can load. It's not currently possible
+ // to use the given engine for that, so we need to create a temporary one.
+ // That doesn't work in registerTypes either, which is why it's done here.
+ QString dialogQmlPath(qmlDir.filePath("WidgetFileDialog.qml"));
+ QQmlEngine tempEngine;
+ QQmlComponent widgetDialogComponent(&tempEngine);
+ QFile widgetDialogQmlFile(dialogQmlPath);
+ widgetDialogQmlFile.open(QIODevice::ReadOnly);
+ widgetDialogComponent.setData(widgetDialogQmlFile.readAll(), QUrl());
+
+ switch (widgetDialogComponent.status()) {
+ case QQmlComponent::Ready:
+ needQml = (qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, 1, 0, "FileDialog") < 0);
+ // returns -1 unless we omit the module from qmldir, because otherwise
+ // QtQuick.Dialogs is already a protected namespace
+ // after the qmldir having been parsed. (QQmlImportDatabase::importPlugin)
+ // But omitting the module from qmldir results in this warning:
+ // "Module 'QtQuick.Dialogs' does not contain a module identifier directive -
+ // it cannot be protected from external registrations."
+ // TODO register all types in registerTypes, to avoid the warning
+ // But, in that case we cannot check for existence by trying to instantiate the component.
+ // So it will have to just look for a file (qmldir?) and assume
+ // that whatever modules are installed are also in working order.
+ break;
+ default:
+ break;
+ }
+ }
+ }
+#endif
+ if (needQml) {
+ QString dialogQmlPath = qmlDir.filePath("DefaultFileDialog.qml");
+ qmlRegisterType<QQuickFileDialog>(uri, 1, 0, "AbstractFileDialog"); // implementation wrapper
+ // qDebug() << "registering FileDialog as " << dialogQmlPath << "success?" <<
+ qmlRegisterType(QUrl::fromLocalFile(dialogQmlPath), uri, 1, 0, "FileDialog");
+ }
+ }
+
+ virtual void registerTypes(const char *uri) {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs"));
+
+#ifndef PURE_QML_ONLY
+ // Prefer the QPA file dialog helper if the platform supports it
+ if (QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
+ qmlRegisterType<QQuickPlatformFileDialog>(uri, 1, 0, "FileDialog");
+#endif
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
diff --git a/src/imports/dialogs/plugins.qmltypes b/src/imports/dialogs/plugins.qmltypes
new file mode 100644
index 0000000000..faf68de909
--- /dev/null
+++ b/src/imports/dialogs/plugins.qmltypes
@@ -0,0 +1,72 @@
+import QtQuick.tooling 1.1
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated with the command 'qmlplugindump QtQuick.Dialogs 1.0'.
+
+Module {
+ Component {
+ name: "QQuickAbstractFileDialog"
+ prototype: "QObject"
+ Property { name: "visible"; type: "bool" }
+ Property { name: "modality"; type: "Qt::WindowModality" }
+ Property { name: "title"; type: "string" }
+ Property { name: "selectExisting"; type: "bool" }
+ Property { name: "selectMultiple"; type: "bool" }
+ Property { name: "selectFolder"; type: "bool" }
+ Property { name: "folder"; type: "string" }
+ Property { name: "nameFilters"; type: "QStringList" }
+ Property { name: "selectedNameFilter"; type: "string" }
+ Property { name: "filePath"; type: "string"; isReadonly: true }
+ Property { name: "filePaths"; type: "QStringList"; isReadonly: true }
+ Signal { name: "visibilityChanged" }
+ Signal { name: "filterSelected" }
+ Signal { name: "fileModeChanged" }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Method { name: "open" }
+ Method { name: "close" }
+ Method {
+ name: "setVisible"
+ Parameter { name: "v"; type: "bool" }
+ }
+ Method {
+ name: "setModality"
+ Parameter { name: "m"; type: "Qt::WindowModality" }
+ }
+ Method {
+ name: "setTitle"
+ Parameter { name: "t"; type: "string" }
+ }
+ Method {
+ name: "setSelectExisting"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setSelectMultiple"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setSelectFolder"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setFolder"
+ Parameter { name: "f"; type: "string" }
+ }
+ Method {
+ name: "setNameFilters"
+ Parameter { name: "f"; type: "QStringList" }
+ }
+ Method {
+ name: "selectNameFilter"
+ Parameter { name: "f"; type: "string" }
+ }
+ }
+ Component {
+ name: "QQuickQFileDialog"
+ prototype: "QQuickAbstractFileDialog"
+ exports: ["QtQuick.PrivateWidgets/QtFileDialog 1.0"]
+ }
+}
diff --git a/src/imports/dialogs/qml/Button.qml b/src/imports/dialogs/qml/Button.qml
new file mode 100644
index 0000000000..42ee9f79e8
--- /dev/null
+++ b/src/imports/dialogs/qml/Button.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ height: label.implicitHeight * 2
+ width: Math.max(label.implicitWidth * 1.2, height * 2.5);
+ anchors.verticalCenter: parent.verticalCenter
+ property alias text: label.text
+ property string tooltip
+ signal clicked
+ SystemPalette { id: palette }
+ Rectangle {
+ antialiasing: true
+ border.color: mouseArea.pressed ? palette.highlight : palette.light
+ color: "transparent"
+ anchors.fill: parent
+ anchors.rightMargin: 1
+ anchors.bottomMargin: 1
+ radius: 3
+ }
+ Rectangle {
+ border.color: palette.dark
+ anchors.fill: parent
+ anchors.leftMargin: 1
+ anchors.topMargin: 1
+ radius: 3
+ }
+ Rectangle {
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: mouseArea.pressed ? palette.dark : palette.light }
+ GradientStop { position: 0.2; color: palette.button }
+ GradientStop { position: 0.8; color: palette.button }
+ GradientStop { position: 1.0; color: mouseArea.pressed ? palette.light : palette.dark }
+ }
+ anchors.fill: parent
+ anchors.margins: 1
+ radius: 3
+ }
+ Text {
+ id: label
+ anchors.centerIn: parent
+ color: palette.buttonText
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+}
diff --git a/src/imports/dialogs/qml/TextField.qml b/src/imports/dialogs/qml/TextField.qml
new file mode 100644
index 0000000000..204eef71b9
--- /dev/null
+++ b/src/imports/dialogs/qml/TextField.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+
+Item {
+ id: root
+
+ property alias textInput: textInput
+ property alias text: textInput.text
+ signal accepted
+ signal downPressed
+
+ SystemPalette { id: palette }
+ height: textInput.implicitHeight + 4
+ Rectangle {
+ id: rect
+ anchors.fill: parent
+ anchors.leftMargin: -radius
+ border.color: palette.light
+ radius: height / 4
+ antialiasing: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: palette.dark }
+ GradientStop { position: 0.2; color: palette.button }
+ GradientStop { position: 0.8; color: palette.button }
+ GradientStop { position: 1.0; color: palette.light }
+ }
+ }
+
+ TextInput {
+ id: textInput
+ color: palette.text
+ anchors.fill: parent
+ verticalAlignment: Text.AlignVCenter
+ onAccepted: root.accepted()
+ Keys.onDownPressed: root.downPressed()
+ }
+}
diff --git a/src/imports/dialogs/qml/qmldir b/src/imports/dialogs/qml/qmldir
new file mode 100644
index 0000000000..85575c738a
--- /dev/null
+++ b/src/imports/dialogs/qml/qmldir
@@ -0,0 +1,2 @@
+Button 1.0 Button.qml
+TextField 1.0 TextField.qml
diff --git a/src/imports/dialogs/qmldir b/src/imports/dialogs/qmldir
new file mode 100644
index 0000000000..50867d7361
--- /dev/null
+++ b/src/imports/dialogs/qmldir
@@ -0,0 +1,2 @@
+plugin dialogplugin
+typeinfo plugins.qmltypes
diff --git a/src/imports/dialogs/qquickabstractfiledialog.cpp b/src/imports/dialogs/qquickabstractfiledialog.cpp
new file mode 100644
index 0000000000..905cb5d030
--- /dev/null
+++ b/src/imports/dialogs/qquickabstractfiledialog.cpp
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickabstractfiledialog_p.h"
+#include "qquickitem.h"
+
+#include <private/qguiapplication_p.h>
+#include <QWindow>
+#include <QQuickWindow>
+
+QT_BEGIN_NAMESPACE
+
+QQuickAbstractFileDialog::QQuickAbstractFileDialog(QObject *parent)
+ : QObject(parent)
+ , m_dlgHelper(0)
+ , m_parentWindow(0)
+ , m_options(QSharedPointer<QFileDialogOptions>(new QFileDialogOptions()))
+ , m_visible(false)
+ , m_modality(Qt::WindowModal)
+ , m_selectExisting(true)
+ , m_selectMultiple(false)
+ , m_selectFolder(false)
+{
+}
+
+QQuickAbstractFileDialog::~QQuickAbstractFileDialog()
+{
+}
+
+void QQuickAbstractFileDialog::setVisible(bool v)
+{
+ if (m_visible == v) return;
+ m_visible = v;
+ if (helper()) {
+ if (v) {
+ helper()->setOptions(m_options);
+ helper()->setFilter();
+ m_visible = helper()->show(Qt::Dialog, m_modality, parentWindow());
+ emit filterSelected();
+ } else {
+ helper()->hide();
+ }
+ }
+
+ emit visibilityChanged();
+}
+
+void QQuickAbstractFileDialog::setModality(Qt::WindowModality m)
+{
+ if (m_modality == m) return;
+ m_modality = m;
+ emit modalityChanged();
+}
+
+void QQuickAbstractFileDialog::setTitle(QString t)
+{
+ if (m_options->windowTitle() == t) return;
+ m_options->setWindowTitle(t);
+ emit titleChanged();
+}
+
+void QQuickAbstractFileDialog::setSelectExisting(bool selectExisting)
+{
+ if (selectExisting == m_selectExisting) return;
+ m_selectExisting = selectExisting;
+ updateModes();
+}
+
+void QQuickAbstractFileDialog::setSelectMultiple(bool selectMultiple)
+{
+ if (selectMultiple == m_selectMultiple) return;
+ m_selectMultiple = selectMultiple;
+ updateModes();
+}
+
+void QQuickAbstractFileDialog::setSelectFolder(bool selectFolder)
+{
+ if (selectFolder == m_selectFolder) return;
+ m_selectFolder = selectFolder;
+ updateModes();
+}
+
+QString QQuickAbstractFileDialog::folder()
+{
+ if (m_dlgHelper && !m_dlgHelper->directory().isEmpty())
+ return m_dlgHelper->directory();
+ return m_options->initialDirectory();
+}
+
+void QQuickAbstractFileDialog::setFolder(QString f)
+{
+ if (m_dlgHelper)
+ m_dlgHelper->setDirectory(f);
+ m_options->setInitialDirectory(f);
+ emit folderChanged();
+}
+
+void QQuickAbstractFileDialog::setNameFilters(const QStringList &f)
+{
+ m_options->setNameFilters(f);
+ if (f.isEmpty())
+ selectNameFilter(QString());
+ else if (!f.contains(selectedNameFilter()))
+ selectNameFilter(f.first());
+ emit nameFiltersChanged();
+}
+
+QString QQuickAbstractFileDialog::selectedNameFilter()
+{
+ QString ret;
+ if (m_dlgHelper)
+ ret = m_dlgHelper->selectedNameFilter();
+ if (ret.isEmpty())
+ return m_options->initiallySelectedNameFilter();
+ return ret;
+}
+
+void QQuickAbstractFileDialog::selectNameFilter(QString f)
+{
+ // This should work whether the dialog is currently being shown already, or ahead of time.
+ m_options->setInitiallySelectedNameFilter(f);
+ if (m_dlgHelper)
+ m_dlgHelper->selectNameFilter(f);
+ emit filterSelected();
+}
+
+QUrl QQuickAbstractFileDialog::fileUrl()
+{
+ QList<QUrl> urls = fileUrls();
+ return (urls.count() == 1) ? urls[0] : QUrl();
+}
+
+QList<QUrl> QQuickAbstractFileDialog::fileUrls()
+{
+ QList<QUrl> ret;
+ if (m_dlgHelper)
+ foreach (QString path, m_dlgHelper->selectedFiles())
+ ret << QUrl::fromLocalFile(path);
+ return ret;
+}
+
+void QQuickAbstractFileDialog::accept()
+{
+ setVisible(false);
+ emit accepted();
+}
+
+void QQuickAbstractFileDialog::reject()
+{
+ setVisible(false);
+ emit rejected();
+}
+
+void QQuickAbstractFileDialog::visibleChanged(bool v)
+{
+ m_visible = v;
+ emit visibilityChanged();
+}
+
+void QQuickAbstractFileDialog::updateModes()
+{
+ // The 4 possible modes are AnyFile, ExistingFile, Directory, ExistingFiles
+ // Assume AnyFile until we find a reason to the contrary
+ QFileDialogOptions::FileMode mode = QFileDialogOptions::AnyFile;
+
+ if (m_selectFolder) {
+ mode = QFileDialogOptions::Directory;
+ m_options->setOption(QFileDialogOptions::ShowDirsOnly);
+ m_selectMultiple = false;
+ m_selectExisting = true;
+ setNameFilters(QStringList());
+ } else if (m_selectExisting) {
+ mode = m_selectMultiple ?
+ QFileDialogOptions::ExistingFiles : QFileDialogOptions::ExistingFile;
+ m_options->setOption(QFileDialogOptions::ShowDirsOnly, false);
+ } else if (m_selectMultiple) {
+ m_selectExisting = true;
+ }
+ if (!m_selectExisting)
+ m_selectMultiple = false;
+ m_options->setFileMode(mode);
+ m_options->setAcceptMode(m_selectExisting ?
+ QFileDialogOptions::AcceptOpen : QFileDialogOptions::AcceptSave);
+ emit fileModeChanged();
+}
+
+QQuickWindow *QQuickAbstractFileDialog::parentWindow()
+{
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ if (parentItem)
+ m_parentWindow = parentItem->window();
+ return m_parentWindow;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickabstractfiledialog_p.h b/src/imports/dialogs/qquickabstractfiledialog_p.h
new file mode 100644
index 0000000000..e9565108d6
--- /dev/null
+++ b/src/imports/dialogs/qquickabstractfiledialog_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKABSTRACTFILEDIALOG_P_H
+#define QQUICKABSTRACTFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQml>
+#include <QQuickView>
+#include <QtGui/qpa/qplatformdialoghelper.h>
+#include <qpa/qplatformtheme.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickAbstractFileDialog : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged)
+ Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
+ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
+ Q_PROPERTY(bool selectExisting READ selectExisting WRITE setSelectExisting NOTIFY fileModeChanged)
+ Q_PROPERTY(bool selectMultiple READ selectMultiple WRITE setSelectMultiple NOTIFY fileModeChanged)
+ Q_PROPERTY(bool selectFolder READ selectFolder WRITE setSelectFolder NOTIFY fileModeChanged)
+ Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged)
+ Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged)
+ Q_PROPERTY(QString selectedNameFilter READ selectedNameFilter WRITE selectNameFilter NOTIFY filterSelected)
+ Q_PROPERTY(QUrl fileUrl READ fileUrl NOTIFY accepted)
+ Q_PROPERTY(QList<QUrl> fileUrls READ fileUrls NOTIFY accepted)
+ // TODO: QTBUG-29817: provide x y width and height (after QPlatformDialogHelper provides it)
+
+public:
+ QQuickAbstractFileDialog(QObject *parent = 0);
+ virtual ~QQuickAbstractFileDialog();
+
+ bool isVisible() const { return m_visible; }
+ Qt::WindowModality modality() const { return m_modality; }
+ QString title() const { return m_options->windowTitle(); }
+ bool selectExisting() const { return m_selectExisting; }
+ bool selectMultiple() const { return m_selectMultiple; }
+ bool selectFolder() const { return m_selectFolder; }
+ QString folder();
+ QStringList nameFilters() const { return m_options->nameFilters(); }
+ QString selectedNameFilter();
+ QUrl fileUrl();
+ virtual QList<QUrl> fileUrls();
+
+public Q_SLOTS:
+ void open() { setVisible(true); }
+ void close() { setVisible(false); }
+ virtual void setVisible(bool v);
+ void setModality(Qt::WindowModality m);
+ void setTitle(QString t);
+ void setSelectExisting(bool s);
+ void setSelectMultiple(bool s);
+ void setSelectFolder(bool s);
+ void setFolder(QString f);
+ void setNameFilters(const QStringList &f);
+ void selectNameFilter(QString f);
+
+Q_SIGNALS:
+ void visibilityChanged();
+ void modalityChanged();
+ void titleChanged();
+ void folderChanged();
+ void nameFiltersChanged();
+ void filterSelected();
+ void fileModeChanged();
+ void accepted();
+ void rejected();
+
+protected Q_SLOTS:
+ void accept();
+ void reject();
+ void visibleChanged(bool v);
+
+protected:
+ virtual QPlatformFileDialogHelper *helper() = 0;
+ void updateModes();
+ QQuickWindow *parentWindow();
+
+protected:
+ QPlatformFileDialogHelper *m_dlgHelper;
+ QQuickWindow *m_parentWindow;
+ QSharedPointer<QFileDialogOptions> m_options;
+ bool m_visible;
+ Qt::WindowModality m_modality;
+ bool m_selectExisting;
+ bool m_selectMultiple;
+ bool m_selectFolder;
+
+ Q_DISABLE_COPY(QQuickAbstractFileDialog)
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKABSTRACTFILEDIALOG_P_H
diff --git a/src/imports/dialogs/qquickfiledialog.cpp b/src/imports/dialogs/qquickfiledialog.cpp
new file mode 100644
index 0000000000..89b8b4cc5b
--- /dev/null
+++ b/src/imports/dialogs/qquickfiledialog.cpp
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickfiledialog_p.h"
+#include <QQuickItem>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype AbstractFileDialog
+ \instantiates QQuickFileDialog
+ \inqmlmodule QtQuick.Dialogs 1
+ \ingroup qtquick-visual
+ \brief API wrapper for QML file dialog implementations
+ \since 5.1
+ \internal
+
+ AbstractFileDialog provides only the API for implementing a file dialog.
+ The implementation (e.g. a Window or Item) can be provided as \l implementation,
+ which is the default property (the only allowed child element).
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::AbstractFileDialog::accepted
+
+ The \a accepted signal is emitted by \l accept().
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::AbstractFileDialog::rejected
+
+ The \a accepted signal is emitted by \l reject().
+*/
+
+/*!
+ \class QQuickFileDialog
+ \inmodule QtQuick.Dialogs
+ \internal
+
+ The QQuickFileDialog class is a concrete subclass of \l
+ QQuickAbstractFileDialog, but it is abstract from the QML perspective
+ because it needs to enclose a graphical implementation. It exists in order
+ to provide accessors and helper functions which the QML implementation will
+ need.
+
+ \since 5.1
+*/
+
+/*!
+ Constructs a file dialog wrapper with parent window \a parent.
+*/
+QQuickFileDialog::QQuickFileDialog(QObject *parent)
+ : QQuickAbstractFileDialog(parent)
+ , m_implementation(0)
+ , m_dialogWindow(0)
+{
+}
+
+
+/*!
+ Destroys the file dialog wrapper.
+*/
+QQuickFileDialog::~QQuickFileDialog()
+{
+}
+
+QList<QUrl> QQuickFileDialog::fileUrls()
+{
+ QList<QUrl> ret;
+ foreach (QString path, m_selections)
+ ret << QUrl::fromLocalFile(path);
+ return ret;
+}
+
+/*!
+ \qmlproperty bool AbstractFileDialog::visible
+
+ This property holds whether the dialog is visible. By default this is false.
+*/
+void QQuickFileDialog::setVisible(bool v)
+{
+ if (m_visible == v) return;
+ m_visible = v;
+ // For a pure QML implementation, there is no helper.
+ // But m_implementation is probably either an Item or a Window at this point.
+ if (!m_dialogWindow) {
+ m_dialogWindow = qobject_cast<QWindow *>(m_implementation);
+ if (!m_dialogWindow) {
+ QQuickItem *dlgItem = qobject_cast<QQuickItem *>(m_implementation);
+ if (dlgItem) {
+ m_dialogWindow = dlgItem->window();
+ // An Item-based dialog implementation doesn't come with a window, so
+ // we have to instantiate one iff the platform allows it.
+ if (!m_dialogWindow && QGuiApplicationPrivate::platformIntegration()->
+ hasCapability(QPlatformIntegration::MultipleWindows)) {
+ QQuickWindow *win = new QQuickWindow;
+ m_dialogWindow = win;
+ dlgItem->setParentItem(win->contentItem());
+ m_dialogWindow->setMinimumSize(QSize(dlgItem->width(), dlgItem->height()));
+ }
+
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ // qDebug() << "item implementation" << dlgItem << "has window" << m_dialogWindow << "and parent" << parentItem;
+
+ // If the platform does not support multiple windows, but the dialog is
+ // implemented as an Item, then just reparent it and make it visible.
+ // TODO QTBUG-29818: put it into a fake Item-based window, when we have a reusable self-decorated one.
+ if (parentItem && !m_dialogWindow)
+ dlgItem->setParentItem(parentItem);
+ }
+ }
+ if (m_dialogWindow)
+ connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool)));
+ }
+ if (m_dialogWindow) {
+ if (v) {
+ m_dialogWindow->setTransientParent(parentWindow());
+ m_dialogWindow->setTitle(title());
+ m_dialogWindow->setModality(m_modality);
+ }
+ m_dialogWindow->setVisible(v);
+ }
+ emit visibilityChanged();
+}
+
+/*!
+ \qmlproperty bool AbstractFileDialog::filePaths
+
+ A list of files to be populated as the user chooses.
+*/
+
+/*!
+ \brief Clears \l filePaths
+*/
+void QQuickFileDialog::clearSelection()
+{
+ m_selections.clear();
+}
+
+/*!
+ \brief Adds one file to \l filePaths
+
+ \l path should be given as an absolute file system path. If it is given as a
+ file:// URL, it will be converted to a path. Returns true on success,
+ false if the given path is not valid given the current setting properties.
+*/
+bool QQuickFileDialog::addSelection(QString path)
+{
+ if (path.startsWith("file:"))
+ path = QUrl(path).toLocalFile();
+ QFileInfo info(path);
+ if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) {
+ if (m_selectFolder)
+ m_selections.append(pathFolder(path).toLocalFile());
+ else
+ m_selections.append(path);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \brief get a file's directory as a URL
+
+ If \a path points to a directory, just convert it to a URL.
+ If \a path points to a file, convert the file's directory to a URL.
+*/
+QUrl QQuickFileDialog::pathFolder(const QString &path)
+{
+ QFileInfo info(path);
+ if (info.exists() && info.isDir())
+ return QUrl::fromLocalFile(path);
+ return QUrl::fromLocalFile(QFileInfo(path).absolutePath());
+}
+
+/*!
+ \qmlproperty QObject AbstractFileDialog::implementation
+
+ The QML object which implements the actual file dialog. Should be either a
+ \l Window or an \l Item.
+*/
+void QQuickFileDialog::setImplementation(QObject *obj)
+{
+ m_implementation = obj;
+ if (m_dialogWindow)
+ disconnect(this, SLOT(visibleChanged(bool)));
+ m_dialogWindow = 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickfiledialog_p.h b/src/imports/dialogs/qquickfiledialog_p.h
new file mode 100644
index 0000000000..0a660b316b
--- /dev/null
+++ b/src/imports/dialogs/qquickfiledialog_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKFILEDIALOG_P_H
+#define QQUICKFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickabstractfiledialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickFileDialog : public QQuickAbstractFileDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* implementation READ implementation WRITE setImplementation DESIGNABLE false)
+ Q_CLASSINFO("DefaultProperty", "implementation") // AbstractFileDialog in QML can have only one child
+
+public:
+ explicit QQuickFileDialog(QObject *parent = 0);
+ ~QQuickFileDialog();
+ QObject* implementation() { return m_implementation; }
+ virtual QList<QUrl> fileUrls();
+
+signals:
+
+public Q_SLOTS:
+ void setImplementation(QObject* obj);
+ virtual void setVisible(bool v);
+
+ void clearSelection();
+ bool addSelection(QString path);
+
+protected:
+ virtual QPlatformFileDialogHelper *helper() { return 0; }
+ Q_INVOKABLE QString urlToPath(const QUrl &url) { return url.toLocalFile(); }
+ Q_INVOKABLE QUrl pathToUrl(const QString &path) { return QUrl::fromLocalFile(path); }
+ Q_INVOKABLE QUrl pathFolder(const QString &path);
+
+private:
+ QObject *m_implementation;
+ QWindow *m_dialogWindow;
+ QStringList m_selections;
+
+ Q_DISABLE_COPY(QQuickFileDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickFileDialog *)
+
+#endif // QQUICKFILEDIALOG_P_H
diff --git a/src/imports/dialogs/qquickplatformfiledialog.cpp b/src/imports/dialogs/qquickplatformfiledialog.cpp
new file mode 100644
index 0000000000..f2bd279d7b
--- /dev/null
+++ b/src/imports/dialogs/qquickplatformfiledialog.cpp
@@ -0,0 +1,314 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickplatformfiledialog_p.h"
+#include "qquickitem.h"
+
+#include <private/qguiapplication_p.h>
+#include <QWindow>
+#include <QQuickView>
+#include <QQuickWindow>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmltype FileDialog
+ \instantiates QQuickPlatformFileDialog
+ \inqmlmodule QtQuick.Dialogs 1
+ \ingroup qtquick-visual
+ \brief Dialog component for choosing files from a local filesystem.
+ \since 5.1
+
+ FileDialog provides a basic file chooser: it allows the user to select
+ existing files and/or directories, or create new filenames. The dialog is
+ initially invisible. You need to set the properties as desired first, then
+ set \l visible to true or call \l open().
+
+ Here is a minimal example to open a file dialog and exit after the user
+ chooses a file:
+
+ \qml
+ import QtQuick 2.0
+ import QtQuick.Dialogs 1.0
+
+ FileDialog {
+ id: fileDialog
+ title: "Please choose a file"
+ onAccepted: {
+ console.log("You chose: " + fileDialog.filePaths)
+ Qt.quit()
+ }
+ onRejected: {
+ console.log("Cancelled")
+ Qt.quit()
+ }
+ Component.onCompleted: visible = true
+ }
+ \endqml
+
+ A FileDialog window is automatically transient for its parent window. So
+ whether you declare the dialog inside an \l Item or inside a \l Window, the
+ dialog will appear centered over the window containing the item, or over
+ the Window that you declared.
+
+ The implementation of FileDialog will be a platform file dialog if
+ possible. If that isn't possible, then it will try to instantiate a
+ \l QFileDialog. If that also isn't possible, then it will fall back to a QML
+ implementation, DefaultFileDialog.qml. In that case you can customize the
+ appearance by editing this file. DefaultFileDialog.qml contains a Rectangle
+ to hold the dialog's contents, because certain embedded systems do not
+ support multiple top-level windows. When the dialog becomes visible, it
+ will automatically be wrapped in a Window if possible, or simply reparented
+ on top of the main window if there can only be one window.
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FileDialog::accepted
+
+ The \a accepted signal is emitted when the user has finished using the
+ dialog. You can then inspect the \a filePath or \a filePaths properties to
+ get the selection.
+
+ Example:
+
+ \qml
+ FileDialog {
+ onAccepted: { console.log("Selected file: " + filePath) }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FileDialog::rejected
+
+ The \a rejected signal is emitted when the user has dismissed the dialog,
+ either by closing the dialog window or by pressing the Cancel button.
+*/
+
+/*!
+ \class QQuickPlatformFileDialog
+ \inmodule QtQuick.Dialogs
+ \internal
+
+ \brief The QQuickPlatformFileDialog class provides a file dialog
+
+ The dialog is implemented via the QPlatformFileDialogHelper when possible;
+ otherwise it falls back to a QFileDialog or a QML implementation.
+
+ \since 5.1
+*/
+
+/*!
+ Constructs a file dialog with parent window \a parent.
+*/
+QQuickPlatformFileDialog::QQuickPlatformFileDialog(QObject *parent) :
+ QQuickAbstractFileDialog(parent)
+{
+}
+
+/*!
+ Destroys the file dialog.
+*/
+QQuickPlatformFileDialog::~QQuickPlatformFileDialog()
+{
+ if (m_dlgHelper)
+ m_dlgHelper->hide();
+ delete m_dlgHelper;
+}
+
+QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
+{
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ if (parentItem)
+ m_parentWindow = parentItem->window();
+
+ if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()->
+ usePlatformNativeDialog(QPlatformTheme::FileDialog) ) {
+ m_dlgHelper = static_cast<QPlatformFileDialogHelper *>(QGuiApplicationPrivate::platformTheme()
+ ->createPlatformDialogHelper(QPlatformTheme::FileDialog));
+ if (!m_dlgHelper)
+ return m_dlgHelper;
+ connect(m_dlgHelper, SIGNAL(directoryEntered(QString)), this, SIGNAL(folderChanged()));
+ connect(m_dlgHelper, SIGNAL(filterSelected(QString)), this, SIGNAL(filterSelected()));
+ connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
+ connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
+ }
+
+ return m_dlgHelper;
+}
+
+/*!
+ \qmlproperty bool FileDialog::visible
+
+ This property holds whether the dialog is visible. By default this is
+ false.
+
+ \sa modality
+*/
+
+/*!
+ \qmlproperty Qt::WindowModality FileDialog::modality
+
+ Whether the dialog should be shown modal with respect to the window
+ containing the dialog's parent Item, modal with respect to the whole
+ application, or non-modal.
+
+ By default it is \l WindowModal.
+
+ Modality does not mean that there are any blocking calls to wait for the
+ dialog to be accepted or rejected; it's only that the user will be
+ prevented from interacting with the parent window and/or the application
+ windows at the same time. You probably need to write an onAccepted handler
+ to actually load or save the chosen file.
+*/
+
+/*!
+ \qmlmethod void FileDialog::open()
+
+ Shows the dialog to the user. It is equivalent to setting \l visible to
+ true.
+*/
+
+/*!
+ \qmlmethod void FileDialog::close()
+
+ Closes the dialog.
+*/
+
+/*!
+ \qmlproperty string FileDialog::title
+
+ The title of the dialog window.
+*/
+
+/*!
+ \qmlproperty bool FileDialog::selectExisting
+
+ Whether only existing files or directories can be selected.
+
+ By default, this property is true. This property must be set to the desired
+ value before opening the dialog. Setting this property to false implies
+ that the dialog is for naming a file to which to save something, or naming
+ a folder to be created; therefore \l selectMultiple must be false.
+*/
+
+/*!
+ \qmlproperty bool FileDialog::selectMultiple
+
+ Whether more than one filename can be selected.
+
+ By default, this property is false. This property must be set to the
+ desired value before opening the dialog. Setting this property to true
+ implies that \l selectExisting must be true.
+*/
+
+/*!
+ \qmlproperty bool FileDialog::selectFolder
+
+ Whether the selected item should be a folder.
+
+ By default, this property is false. This property must be set to the
+ desired value before opening the dialog. Setting this property to true
+ implies that \l selectMultiple must be false and \l selectExisting must be
+ true.
+*/
+
+/*!
+ \qmlproperty string FileDialog::folder
+
+ The path to the currently selected folder. Setting this property before
+ invoking open() will cause the file browser to be initially positioned on
+ the specified folder.
+
+ The value of this property is also updated after the dialog is closed.
+
+ By default, this property is false.
+*/
+
+/*!
+ \qmlproperty list<string> FileDialog::nameFilters
+
+ A list of strings to be used as file name filters. Each string can be a
+ space-separated list of filters; filters may include the ? and * wildcards.
+ The list of filters can also be enclosed in parentheses and a textual
+ description of the filter can be provided.
+
+ For example:
+
+ \qml
+ FileDialog {
+ nameFilters: [ "Image files (*.jpg *.png)", "All files (*)" ]
+ }
+ \endqml
+
+ \note Directories are not excluded by filters.
+ \sa selectedNameFilter
+*/
+
+/*!
+ \qmlproperty string FileDialog::selectedNameFilter
+
+ Which of the \l nameFilters is currently selected.
+
+ This property can be set before the dialog is visible, to set the default
+ name filter, and can also be set while the dialog is visible to set the
+ current name filter. It is also updated when the user selects a different
+ filter.
+*/
+
+/*!
+ \qmlproperty string FileDialog::filePath
+
+ The path of the file which was selected by the user.
+
+ \note This property is set only if exactly one file was selected. In all
+ other cases, it will return an empty string.
+
+ \sa filePaths
+*/
+
+/*!
+ \qmlproperty list<string> FileDialog::filePaths
+
+ The list of file paths which were selected by the user.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/imports/dialogs/qquickplatformfiledialog_p.h b/src/imports/dialogs/qquickplatformfiledialog_p.h
new file mode 100644
index 0000000000..3559543319
--- /dev/null
+++ b/src/imports/dialogs/qquickplatformfiledialog_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKPLATFORMFILEDIALOG_P_H
+#define QQUICKPLATFORMFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qquickabstractfiledialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPlatformFileDialog : public QQuickAbstractFileDialog
+{
+ Q_OBJECT
+
+public:
+ QQuickPlatformFileDialog(QObject *parent = 0);
+ virtual ~QQuickPlatformFileDialog();
+
+protected:
+ QPlatformFileDialogHelper *helper();
+
+ Q_DISABLE_COPY(QQuickPlatformFileDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickPlatformFileDialog *)
+
+#endif // QQUICKPLATFORMFILEDIALOG_P_H
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 72888b2c71..e411a4f097 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -9,7 +9,10 @@ qtHaveModule(quick) {
qtquick2 \
particles \
window \
+ dialogs \
testlib
}
qtHaveModule(xmlpatterns) : SUBDIRS += xmllistmodel
+
+qtHaveModule(widgets) : SUBDIRS += widgets
diff --git a/src/imports/widgets/plugins.qmltypes b/src/imports/widgets/plugins.qmltypes
new file mode 100644
index 0000000000..f9fe1f722c
--- /dev/null
+++ b/src/imports/widgets/plugins.qmltypes
@@ -0,0 +1,72 @@
+import QtQuick.tooling 1.1
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated with the command 'qmlplugindump QtQuick.PrivateWidgets 1.0'.
+
+Module {
+ Component {
+ name: "QQuickAbstractFileDialog"
+ prototype: "QObject"
+ Property { name: "visible"; type: "bool" }
+ Property { name: "modality"; type: "Qt::WindowModality" }
+ Property { name: "title"; type: "string" }
+ Property { name: "selectExisting"; type: "bool" }
+ Property { name: "selectMultiple"; type: "bool" }
+ Property { name: "selectFolder"; type: "bool" }
+ Property { name: "folder"; type: "string" }
+ Property { name: "nameFilters"; type: "QStringList" }
+ Property { name: "selectedNameFilter"; type: "string" }
+ Property { name: "filePath"; type: "string"; isReadonly: true }
+ Property { name: "filePaths"; type: "QStringList"; isReadonly: true }
+ Signal { name: "visibilityChanged" }
+ Signal { name: "filterSelected" }
+ Signal { name: "fileModeChanged" }
+ Signal { name: "accepted" }
+ Signal { name: "rejected" }
+ Method { name: "open" }
+ Method { name: "close" }
+ Method {
+ name: "setVisible"
+ Parameter { name: "v"; type: "bool" }
+ }
+ Method {
+ name: "setModality"
+ Parameter { name: "m"; type: "Qt::WindowModality" }
+ }
+ Method {
+ name: "setTitle"
+ Parameter { name: "t"; type: "string" }
+ }
+ Method {
+ name: "setSelectExisting"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setSelectMultiple"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setSelectFolder"
+ Parameter { name: "s"; type: "bool" }
+ }
+ Method {
+ name: "setFolder"
+ Parameter { name: "f"; type: "string" }
+ }
+ Method {
+ name: "setNameFilters"
+ Parameter { name: "f"; type: "QStringList" }
+ }
+ Method {
+ name: "selectNameFilter"
+ Parameter { name: "f"; type: "string" }
+ }
+ }
+ Component {
+ name: "QQuickQFileDialog"
+ prototype: "QQuickAbstractFileDialog"
+ exports: ["QtFileDialog 1.0"]
+ }
+}
diff --git a/src/imports/widgets/qmldir b/src/imports/widgets/qmldir
new file mode 100644
index 0000000000..16c84424f2
--- /dev/null
+++ b/src/imports/widgets/qmldir
@@ -0,0 +1,3 @@
+module QtQuick.PrivateWidgets
+plugin widgetsplugin
+typeinfo plugins.qmltypes
diff --git a/src/imports/widgets/qquickqfiledialog.cpp b/src/imports/widgets/qquickqfiledialog.cpp
new file mode 100644
index 0000000000..672c6d1bf4
--- /dev/null
+++ b/src/imports/widgets/qquickqfiledialog.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickqfiledialog_p.h"
+#include "qquickitem.h"
+
+#include <private/qguiapplication_p.h>
+#include <private/qqmlcontext_p.h>
+#include <QWindow>
+#include <QQuickWindow>
+#include <QFileDialog>
+
+QT_BEGIN_NAMESPACE
+
+class QFileDialogHelper : public QPlatformFileDialogHelper
+{
+public:
+ QFileDialogHelper() :
+ QPlatformFileDialogHelper()
+ {
+ connect(&m_dialog, SIGNAL(currentChanged(const QString&)), this, SIGNAL(currentChanged(const QString&)));
+ connect(&m_dialog, SIGNAL(directoryEntered(const QString&)), this, SIGNAL(directoryEntered(const QString&)));
+ connect(&m_dialog, SIGNAL(fileSelected(const QString&)), this, SIGNAL(fileSelected(const QString&)));
+ connect(&m_dialog, SIGNAL(filesSelected(const QStringList&)), this, SIGNAL(filesSelected(const QStringList&)));
+ connect(&m_dialog, SIGNAL(filterSelected(const QString&)), this, SIGNAL(filterSelected(const QString&)));
+ connect(&m_dialog, SIGNAL(accepted()), this, SIGNAL(accept()));
+ connect(&m_dialog, SIGNAL(rejected()), this, SIGNAL(reject()));
+ }
+
+ virtual bool defaultNameFilterDisables() const { return true; }
+ virtual void setDirectory(const QString &dir) { m_dialog.setDirectory(dir); }
+ virtual QString directory() const { return m_dialog.directory().absolutePath(); }
+ virtual void selectFile(const QString &f) { m_dialog.selectFile(f); }
+ virtual QStringList selectedFiles() const { return m_dialog.selectedFiles(); }
+
+ virtual void setFilter() {
+ m_dialog.setWindowTitle(QPlatformFileDialogHelper::options()->windowTitle());
+ if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::LookIn))
+ m_dialog.setLabelText(m_dialog.LookIn, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::LookIn));
+ if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::FileName))
+ m_dialog.setLabelText(m_dialog.FileName, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::FileName));
+ if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::FileType))
+ m_dialog.setLabelText(m_dialog.FileType, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::FileType));
+ if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::Accept))
+ m_dialog.setLabelText(m_dialog.Accept, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::Accept));
+ if (QPlatformFileDialogHelper::options()->isLabelExplicitlySet(QFileDialogOptions::Reject))
+ m_dialog.setLabelText(m_dialog.Reject, QPlatformFileDialogHelper::options()->labelText(QFileDialogOptions::Reject));
+ m_dialog.setFilter(QPlatformFileDialogHelper::options()->filter());
+ m_dialog.setNameFilters(QPlatformFileDialogHelper::options()->nameFilters());
+ m_dialog.selectNameFilter(QPlatformFileDialogHelper::options()->initiallySelectedNameFilter());
+ m_dialog.setFileMode(QFileDialog::FileMode(QPlatformFileDialogHelper::options()->fileMode()));
+ m_dialog.setOptions((QFileDialog::Options)((int)(QPlatformFileDialogHelper::options()->options())));
+ m_dialog.setAcceptMode(QFileDialog::AcceptMode(QPlatformFileDialogHelper::options()->acceptMode()));
+ }
+
+ virtual void selectNameFilter(const QString &f) { m_dialog.selectNameFilter(f); }
+ virtual QString selectedNameFilter() const { return m_dialog.selectedNameFilter(); }
+ virtual void exec() { m_dialog.exec(); }
+
+ virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
+ m_dialog.windowHandle()->setTransientParent(parent);
+ m_dialog.windowHandle()->setFlags(f);
+ m_dialog.setWindowModality(m);
+ m_dialog.show();
+ return m_dialog.isVisible();
+ }
+
+ virtual void hide() { m_dialog.hide(); }
+
+private:
+ QFileDialog m_dialog;
+};
+
+/*!
+ \qmltype QtFileDialog
+ \instantiates QQuickQFileDialog
+ \inqmlmodule QtQuick.PrivateWidgets 1
+ \ingroup qtquick-visual
+ \brief Dialog component for choosing files from a local filesystem.
+ \since 5.1
+ \internal
+
+ QtFileDialog provides a means to instantiate and manage a QFileDialog.
+ It is not recommended to be used directly; it is an implementation
+ detail of \l FileDialog in the \l QtQuick.Dialogs module.
+
+ To use this type, you will need to import the module with the following line:
+ \code
+ import QtQuick.PrivateWidgets 1.0
+ \endcode
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FileDialog::accepted
+
+ The \a accepted signal is emitted when the user has finished using the
+ dialog. You can then inspect the \a filePath or \a filePaths properties to
+ get the selection.
+
+ Example:
+
+ \qml
+ FileDialog {
+ onAccepted: { console.log("Selected file: " + filePath) }
+ }
+ \endqml
+*/
+
+/*!
+ \qmlsignal QtQuick::Dialogs::FileDialog::rejected
+
+ The \a rejected signal is emitted when the user has dismissed the dialog,
+ either by closing the dialog window or by pressing the Cancel button.
+*/
+
+/*!
+ \class QQuickQFileDialog
+ \inmodule QtQuick.PrivateWidgets
+ \internal
+
+ \brief The QQuickQFileDialog class is a wrapper for a QFileDialog.
+
+ \since 5.1
+*/
+
+/*!
+ Constructs a file dialog with parent window \a parent.
+*/
+QQuickQFileDialog::QQuickQFileDialog(QObject *parent)
+ : QQuickAbstractFileDialog(parent)
+{
+}
+
+/*!
+ Destroys the file dialog.
+*/
+QQuickQFileDialog::~QQuickQFileDialog()
+{
+ if (m_dlgHelper)
+ m_dlgHelper->hide();
+ delete m_dlgHelper;
+}
+
+QPlatformFileDialogHelper *QQuickQFileDialog::helper()
+{
+ QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
+ if (parentItem)
+ m_parentWindow = parentItem->window();
+
+ if (!m_dlgHelper) {
+ m_dlgHelper = new QFileDialogHelper();
+ connect(m_dlgHelper, SIGNAL(directoryEntered(QString)), this, SIGNAL(folderChanged()));
+ connect(m_dlgHelper, SIGNAL(filterSelected(QString)), this, SIGNAL(filterSelected()));
+ connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
+ connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
+ }
+
+ return m_dlgHelper;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/widgets/qquickqfiledialog_p.h b/src/imports/widgets/qquickqfiledialog_p.h
new file mode 100644
index 0000000000..73067f796c
--- /dev/null
+++ b/src/imports/widgets/qquickqfiledialog_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKQFILEDIALOG_P_H
+#define QQUICKQFILEDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "../dialogs/qquickabstractfiledialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickQFileDialog : public QQuickAbstractFileDialog
+{
+ Q_OBJECT
+
+public:
+ QQuickQFileDialog(QObject *parent = 0);
+ virtual ~QQuickQFileDialog();
+
+protected:
+ QPlatformFileDialogHelper *helper();
+
+ Q_DISABLE_COPY(QQuickQFileDialog)
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickQFileDialog *)
+
+#endif // QQUICKQFILEDIALOG_P_H
diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro
new file mode 100644
index 0000000000..57281178a0
--- /dev/null
+++ b/src/imports/widgets/widgets.pro
@@ -0,0 +1,17 @@
+CXX_MODULE = qml
+TARGET = widgetsplugin
+TARGETPATH = QtQuick/PrivateWidgets
+IMPORT_VERSION = 1.0
+
+SOURCES += \
+ widgetsplugin.cpp \
+ qquickqfiledialog.cpp \
+ ../dialogs/qquickabstractfiledialog.cpp
+
+HEADERS += \
+ qquickqfiledialog_p.h \
+ ../dialogs/qquickabstractfiledialog_p.h
+
+QT += quick-private gui-private core-private qml-private v8-private widgets
+
+load(qml_plugin)
diff --git a/src/imports/widgets/widgetsplugin.cpp b/src/imports/widgets/widgetsplugin.cpp
new file mode 100644
index 0000000000..6d3a56ca27
--- /dev/null
+++ b/src/imports/widgets/widgetsplugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include "qquickqfiledialog_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlmodule QtQuick.PrivateWidgets 1
+ \title QWidget QML Types
+ \ingroup qmlmodules
+ \brief Provides QML types for certain QWidgets
+ \internal
+
+ This QML module contains types which should not be depended upon in QtQuick
+ applications, but are available if the Widgets module is linked. It is
+ recommended to load components from this module conditionally, if at all,
+ and to provide fallback implementations in case they fail to load.
+
+ \code
+ import QtQuick.PrivateWidgets 1.0
+ \endcode
+
+ \since 5.1
+*/
+
+class QtQuick2PrivateWidgetsPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.PrivateWidgets"));
+
+ qmlRegisterType<QQuickQFileDialog>(uri, 1, 0, "QtFileDialog");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "widgetsplugin.moc"
diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp
index 5d4b2a567b..379a168110 100644
--- a/src/qml/qml/qqmlglobal.cpp
+++ b/src/qml/qml/qqmlglobal.cpp
@@ -54,6 +54,7 @@ QQmlValueTypeProvider::QQmlValueTypeProvider()
QQmlValueTypeProvider::~QQmlValueTypeProvider()
{
+ QQml_removeValueTypeProvider(this);
}
QQmlValueType *QQmlValueTypeProvider::createValueType(int type)
@@ -266,13 +267,13 @@ bool QQmlValueTypeProvider::store(int, const void *, void *, size_t) { return fa
bool QQmlValueTypeProvider::read(int, const void *, size_t, int, void *) { return false; }
bool QQmlValueTypeProvider::write(int, const void *, void *, size_t) { return false; }
+Q_GLOBAL_STATIC(QQmlValueTypeProvider, nullValueTypeProvider)
static QQmlValueTypeProvider *valueTypeProvider = 0;
static QQmlValueTypeProvider **getValueTypeProvider(void)
{
if (valueTypeProvider == 0) {
- static QQmlValueTypeProvider nullValueTypeProvider;
- valueTypeProvider = &nullValueTypeProvider;
+ valueTypeProvider = nullValueTypeProvider;
}
return &valueTypeProvider;
@@ -285,6 +286,34 @@ Q_QML_PRIVATE_EXPORT void QQml_addValueTypeProvider(QQmlValueTypeProvider *newPr
*providerPtr = newProvider;
}
+Q_QML_PRIVATE_EXPORT void QQml_removeValueTypeProvider(QQmlValueTypeProvider *oldProvider)
+{
+ if (oldProvider == nullValueTypeProvider) {
+ // don't remove the null provider
+ // we get here when the QtQml library is being unloaded
+ return;
+ }
+
+ // the only entry with next = 0 is the null provider
+ Q_ASSERT(oldProvider->next);
+
+ QQmlValueTypeProvider *prev = valueTypeProvider;
+ if (prev == oldProvider) {
+ valueTypeProvider = oldProvider->next;
+ return;
+ }
+
+ // singly-linked list removal
+ for ( ; prev; prev = prev->next) {
+ if (prev->next != oldProvider)
+ continue; // this is not the provider you're looking for
+ prev->next = oldProvider->next;
+ return;
+ }
+
+ qWarning("QQml_removeValueTypeProvider: was asked to remove provider %p but it was not found", oldProvider);
+}
+
Q_AUTOTEST_EXPORT QQmlValueTypeProvider *QQml_valueTypeProvider(void)
{
static QQmlValueTypeProvider **providerPtr = getValueTypeProvider();
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 0ce026a558..f6b2c81536 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -271,6 +271,7 @@ private:
virtual bool write(int, const void *, void *, size_t);
friend Q_QML_PRIVATE_EXPORT void QQml_addValueTypeProvider(QQmlValueTypeProvider *);
+ friend Q_QML_PRIVATE_EXPORT void QQml_removeValueTypeProvider(QQmlValueTypeProvider *);
QQmlValueTypeProvider *next;
};
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index 099c7eb443..40d77c3d9b 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -106,7 +106,7 @@ during the updatePaintNode() call. The rule of thumb is to only
use classes with the "QSG" prefix inside the
QQuickItem::updatePaintNode() function.
-For more details, see the \l {Custom Geometry Example}.
+For more details, see the \l {Scene Graph - Custom Geometry}.
\section3 Preprocessing
@@ -140,7 +140,7 @@ type.
Below is a complete list of material classes:
\annotatedlist{qtquick-scenegraph-materials}
-For more details, see the \l {Simple Material Example}
+For more details, see the \l {Scene Graph - Simple Material}
\section2 Convenience Nodes
@@ -280,21 +280,19 @@ needed to perform the rendering. The downside is that Qt Quick decides
when to call the signals and this is the only time the OpenGL
application is allowed to draw.
-The \l {OpenGL Under QML} example gives an example on how to use use
-these signals.
-
+The \l {Scene Graph - OpenGL Under QML} example gives an example on
+how to use use these signals.
The other alternative is to create a FramebufferObject, render into it
and use the result as a textured node in the scene graph, for instance
-using a QSGSimpleTextureNode. A simple way of doing the same is to use
-a QQuickPaintedItem with QQuickPaintedItem::FramebufferObject as
-render target and by calling QPainter::beginNativePainting() before
-the OpenGL rendering and QPainter::endNativePainting() after. When
-OpenGL content is integrated with a texture and FramebufferObject, the
-application has more control over when the content is rendered. For
-instance, the application can create a second QOpenGLContext on the
-GUI thread which shares memory with the scene graph's OpenGL context
-and drive the rendering manually.
+using a QSGSimpleTextureNode. The \l {Scene Graph - Rendering FBOs}
+and \l {Scene Graph - Rendering FBOs in a thread} examples show how
+this can be done in an optimal manner.
+
+A simple way of doing the same is to use a QQuickPaintedItem with
+QQuickPaintedItem::FramebufferObject as render target and by calling
+QPainter::beginNativePainting() before the OpenGL rendering and
+QPainter::endNativePainting() after.
\warning When mixing OpenGL content with scene graph rendering, it is
important the application does not leave the OpenGL context in a state
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 7c91193623..9d9ddd6ef0 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -190,9 +190,10 @@ QQuickCanvasItemPrivate::QQuickCanvasItemPrivate()
, hasCanvasWindow(false)
, available(false)
, contextInitialized(false)
- , renderTarget(QQuickCanvasItem::FramebufferObject)
+ , renderTarget(QQuickCanvasItem::Image)
, renderStrategy(QQuickCanvasItem::Cooperative)
{
+ antialiasing = true;
}
QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate()
@@ -245,7 +246,7 @@ QQuickCanvasItemPrivate::~QQuickCanvasItemPrivate()
results in faster rendering.
The default render target is Canvas.Image and the default renderStrategy is
- Canvas.Threaded.
+ Canvas.Cooperative.
\section1 Tiled Canvas
The Canvas item supports tiled rendering by setting \l canvasSize, \l tileSize
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 3ab93e6d0f..33a831acad 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -54,20 +54,29 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickScreenAttached
\inqmlmodule QtQuick.Window 2
\ingroup qtquick-visual-utility
- \brief The Screen attached object provides information about the Screen an Item is displayed on.
+ \brief The Screen attached object provides information about the Screen an Item or Window is displayed on.
- The Screen attached object is only valid inside Item or Item derived types, after component completion.
- Inside these items it refers to the screen that the item is currently being displayed on.
+ The Screen attached object is valid inside Item or Item derived types,
+ after component completion. Inside these items it refers to the screen that
+ the item is currently being displayed on.
+
+ The attached object is also valid inside Window or Window derived types,
+ after component completion. In that case it refers to the screen where the
+ Window was created. It is generally better to access the Screen from the
+ relevant Item instead, because on a multi-screen desktop computer, the user
+ can drag a Window into a position where it spans across multiple screens.
+ In that case some Items will be on one screen, and others on a different
+ screen.
To use this type, you will need to import the module with the following line:
\code
import QtQuick.Window 2.0
\endcode
+ It is a separate import in order to allow you to have a QML environment
+ without access to window system features.
- Note that the Screen type is not valid at Component.onCompleted, because the Item has not been displayed on
- a screen by this time.
-
- Restricting this import will allow you to have a QML environment without access to window system features.
+ Note that the Screen type is not valid at Component.onCompleted, because
+ the Item or Window has not been displayed on a screen by this time.
*/
/*!
@@ -86,13 +95,32 @@ QT_BEGIN_NAMESPACE
\qmlattachedproperty Qt::ScreenOrientation QtQuick.Window2::Screen::primaryOrientation
\readonly
- This contains the primary orientation of the screen.
+ This contains the primary orientation of the screen. If the
+ screen's height is greater than its width, then the orientation is
+ Qt.PortraitOrientation; otherwise it is Qt.LandscapeOrientation.
+
+ If you are designing an application which changes its layout depending on
+ device orientation, you probably want to use primaryOrientation to
+ determine the layout. That is because on a desktop computer, you can expect
+ primaryOrientation to change when the user rotates the screen via the
+ operating system's control panel, even if the computer does not contain an
+ accelerometer. Likewise on most handheld computers which do have
+ accelerometers, the operating system will rotate the whole screen
+ automatically, so again you will see the primaryOrientation change.
*/
/*!
\qmlattachedproperty Qt::ScreenOrientation QtQuick.Window2::Screen::orientation
\readonly
- This contains the current orientation of the screen.
+ This contains the current orientation of the screen, from the accelerometer
+ (if any). On a desktop computer, this value typically does not change.
+
+ If primaryOrientation == orientation, it means that the screen
+ automatically rotates all content which is displayed, depending on how you
+ hold it. But if orientation changes while primaryOrientation does NOT
+ change, then probably you are using a device which does not rotate its own
+ display. In that case you may need to use \l Item.rotation or
+ \l Item.transform to rotate your content.
*/
/*!
\qmlattachedmethod int QtQuick.Window2::Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b)
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index e051b5202c..015f52cc46 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -635,6 +635,13 @@ void QQuickTextEditPrivate::mirrorChange()
}
}
+#ifndef QT_NO_IM
+Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints() const
+{
+ return inputMethodHints | Qt::ImhMultiLine;
+}
+#endif
+
QQuickTextEdit::VAlignment QQuickTextEdit::vAlign() const
{
Q_D(const QQuickTextEdit);
@@ -1632,7 +1639,7 @@ QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const
v = (bool)(flags() & ItemAcceptsInputMethod);
break;
case Qt::ImHints:
- v = (int)inputMethodHints();
+ v = (int)d->effectiveInputMethodHints();
break;
default:
v = d->control->inputMethodQuery(property);
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index e4819e4d2d..5306c979cf 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -106,6 +106,10 @@ public:
void setNativeCursorEnabled(bool enabled) { control->setCursorWidth(enabled ? 1 : 0); }
+#ifndef QT_NO_IM
+ Qt::InputMethodHints effectiveInputMethodHints() const;
+#endif
+
QColor color;
QColor selectionColor;
QColor selectedTextColor;
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index f9de3d25e7..1c65c37516 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1910,7 +1910,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
else
return QVariant(d->selectionStart());
default:
- return QVariant();
+ return QQuickItem::inputMethodQuery(property);
}
}
#endif // QT_NO_IM
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 9acd24cae3..2e8f58b849 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -77,8 +77,11 @@ void QQuickWindowPrivate::updateFocusItemTransform()
Q_Q(QQuickWindow);
#ifndef QT_NO_IM
QQuickItem *focus = q->activeFocusItem();
- if (focus && qApp->focusObject() == focus)
- qApp->inputMethod()->setInputItemTransform(QQuickItemPrivate::get(focus)->itemToWindowTransform());
+ if (focus && qApp->focusObject() == focus) {
+ QQuickItemPrivate *focusPrivate = QQuickItemPrivate::get(focus);
+ qApp->inputMethod()->setInputItemTransform(focusPrivate->itemToWindowTransform());
+ qApp->inputMethod()->setInputItemRectangle(QRectF(0, 0, focusPrivate->width, focusPrivate->height));
+ }
#endif
}
@@ -690,6 +693,7 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, F
}
afi = afi->parentItem();
}
+ updateFocusItemTransform();
QFocusEvent event(QEvent::FocusIn, Qt::OtherFocusReason);
q->sendEvent(newActiveFocusItem, &event);
@@ -771,6 +775,7 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item,
if (newActiveFocusItem) {
Q_ASSERT(newActiveFocusItem == scope);
activeFocusItem = scope;
+ updateFocusItemTransform();
QFocusEvent event(QEvent::FocusIn, Qt::OtherFocusReason);
q->sendEvent(newActiveFocusItem, &event);
@@ -909,7 +914,7 @@ void QQuickWindowPrivate::cleanup(QSGNode *n)
scene graph and its OpenGL context being deleted. The
sceneGraphInvalidated() signal will be emitted when this happens.
- \sa {OpenGL Under QML}
+ \sa {Scene Graph - OpenGL Under QML}
*/
@@ -1189,7 +1194,7 @@ void QQuickWindow::keyPressEvent(QKeyEvent *e)
#ifndef QT_NO_SHORTCUT
// Try looking for a Shortcut before sending key events
- if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(this, e))
+ if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(this->activeFocusItem(), e))
return;
#endif
diff --git a/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h b/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
index ae759c0b24..6fba0d18bc 100644
--- a/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgdefaultrenderer_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QMLRENDERER_H
-#define QMLRENDERER_H
+#ifndef QSGDEFAULTRENDERER_P_H
+#define QSGDEFAULTRENDERER_P_H
#include "qsgrenderer_p.h"
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index 27d4ed413a..818b9b26aa 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -284,7 +284,7 @@ const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()
setIndexDataPattern() functions. Whether this hint is respected or
not is implementation specific.
- \sa QSGGeometryNode, {Custom Geometry Example}
+ \sa QSGGeometryNode, {Scene Graph - Custom Geometry}
*/
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 5effdbfda6..50e9c77d4e 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef MATERIAL_H
-#define MATERIAL_H
+#ifndef QSGMATERIAL_H
+#define QSGMATERIAL_H
#include <QtQuick/qtquickglobal.h>
#include <qopenglshaderprogram.h>
diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h
index 522546d8e8..3fa2f7fc04 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.h
+++ b/src/quick/scenegraph/coreapi/qsgnode.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef NODE_H
-#define NODE_H
+#ifndef QSGNODE_H
+#define QSGNODE_H
#include <QtQuick/qsggeometry.h>
#include <QtGui/QMatrix4x4>
@@ -333,4 +333,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QSGNode::Flags)
QT_END_NAMESPACE
-#endif // NODE_H
+#endif // QSGNODE_H
diff --git a/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h b/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
index 7e57bf5bbf..eb612ff877 100644
--- a/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
+++ b/src/quick/scenegraph/coreapi/qsgnodeupdater_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef NODEUPDATER_P_H
-#define NODEUPDATER_P_H
+#ifndef QSGNODEUPDATER_P_H
+#define QSGNODEUPDATER_P_H
#include <private/qtquickglobal_p.h>
#include <QtGui/private/qdatabuffer_p.h>
@@ -94,4 +94,4 @@ protected:
QT_END_NAMESPACE
-#endif // NODEUPDATER_P_H
+#endif
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 5dd53547d1..844e8b1d8c 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef RENDERER_H
-#define RENDERER_H
+#ifndef QSGRENDERER_P_H
+#define QSGRENDERER_P_H
#include <qset.h>
#include <qhash.h>
@@ -239,4 +239,4 @@ private:
QT_END_NAMESPACE
-#endif // RENDERER_H
+#endif
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 85c1d2e6ff..cc22bfa61f 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef ADAPTATIONINTERFACES_H
-#define ADAPTATIONINTERFACES_H
+#ifndef QSGADAPTATIONLAYER_P_H
+#define QSGADAPTATIONLAYER_P_H
#include <QtQuick/qsgnode.h>
#include <QtQuick/qsgtexture.h>
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
index a1cd381968..a3d5d7c3ae 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef DEFAULT_GLYPHNODE_H
-#define DEFAULT_GLYPHNODE_H
+#ifndef QSGDEFAULTGLYPHNODE_P_H
+#define QSGDEFAULTGLYPHNODE_P_H
#include <private/qsgadaptationlayer_p.h>
#include <QtQuick/qsgnode.h>
@@ -78,4 +78,4 @@ private:
QT_END_NAMESPACE
-#endif // DEFAULT_GLYPHNODE_H
+#endif
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
index efa96a1805..263523221e 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef TEXTMASKMATERIAL_H
-#define TEXTMASKMATERIAL_H
+#ifndef QSGDEFAULTGLYPHNODE_P_P_H
+#define QSGDEFAULTGLYPHNODE_P_P_H
#include <qcolor.h>
#include <QtQuick/qsgmaterial.h>
@@ -93,4 +93,4 @@ private:
QT_END_NAMESPACE
-#endif // TEXTMASKMATERIAL_H
+#endif
diff --git a/src/quick/scenegraph/qsgdefaultimagenode_p.h b/src/quick/scenegraph/qsgdefaultimagenode_p.h
index d2b3baae79..7d299faee3 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultimagenode_p.h
@@ -40,8 +40,8 @@
****************************************************************************/
-#ifndef DEFAULT_PIXMAPNODE_H
-#define DEFAULT_PIXMAPNODE_H
+#ifndef QSGDEFAULTIMAGENODE_P_H
+#define QSGDEFAULTIMAGENODE_P_H
#include <private/qsgadaptationlayer_p.h>
#include <QtQuick/qsgtexturematerial.h>
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
index e4560784fd..24bdbb3d34 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
@@ -40,8 +40,8 @@
****************************************************************************/
-#ifndef DEFAULT_RECTANGLENODE_H
-#define DEFAULT_RECTANGLENODE_H
+#ifndef QSGDEFAULTRECTANGLENODE_P_H
+#define QSGDEFAULTRECTANGLENODE_P_H
#include <private/qsgadaptationlayer_p.h>
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
index b75a123d34..4f03ab52e2 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef DISTANCEFIELD_GLYPHNODE_H
-#define DISTANCEFIELD_GLYPHNODE_H
+#ifndef QSGDISTANCEFIELDGLYPHNODE_P_H
+#define QSGDISTANCEFIELDGLYPHNODE_P_H
#include <private/qsgadaptationlayer_p.h>
#include <QtQuick/qsgtexture.h>
@@ -112,4 +112,4 @@ private:
QT_END_NAMESPACE
-#endif // DISTANCEFIELD_GLYPHNODE_H
+#endif
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
index fe66776896..d6aa38affa 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef DISTANCEFIELDTEXTMATERIAL_H
-#define DISTANCEFIELDTEXTMATERIAL_H
+#ifndef QSGDISTANCEFIELDGLYPHNODE_P_P_H
+#define QSGDISTANCEFIELDGLYPHNODE_P_P_H
#include <QtQuick/qsgmaterial.h>
#include "qsgdistancefieldglyphnode_p.h"
@@ -141,4 +141,4 @@ public:
QT_END_NAMESPACE
-#endif // DISTANCEFIELDTEXTMATERIAL_H
+#endif
diff --git a/src/quick/scenegraph/util/qsgareaallocator_p.h b/src/quick/scenegraph/util/qsgareaallocator_p.h
index 4ec628288b..1255001d0c 100644
--- a/src/quick/scenegraph/util/qsgareaallocator_p.h
+++ b/src/quick/scenegraph/util/qsgareaallocator_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef AREAALLOCATOR_H
-#define AREAALLOCATOR_H
+#ifndef QSGAREAALLOCATOR_P_H
+#define QSGAREAALLOCATOR_P_H
#include <private/qtquickglobal_p.h>
#include <QtCore/qsize.h>
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.h b/src/quick/scenegraph/util/qsgflatcolormaterial.h
index 27cf256603..f0a3a3741d 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef FLATCOLORMATERIAL_H
-#define FLATCOLORMATERIAL_H
+#ifndef QSGFLATCOLORMATERIAL_H
+#define QSGFLATCOLORMATERIAL_H
#include <QtQuick/qsgmaterial.h>
#include <qcolor.h>
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.cpp b/src/quick/scenegraph/util/qsgsimplematerial.cpp
index bed1b710ca..ee7a272fbe 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.cpp
+++ b/src/quick/scenegraph/util/qsgsimplematerial.cpp
@@ -142,7 +142,7 @@
the unique QSGSimpleMaterialShader implementation must be
instantiated with a unique C++ type.
- \sa {Simple Material Example}
+ \sa {Scene Graph - Simple Material}
*/
/*!
diff --git a/src/quick/scenegraph/util/qsgsimplerectnode.h b/src/quick/scenegraph/util/qsgsimplerectnode.h
index 856e6793bc..bed2d98078 100644
--- a/src/quick/scenegraph/util/qsgsimplerectnode.h
+++ b/src/quick/scenegraph/util/qsgsimplerectnode.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef SOLIDRECTNODE_H
-#define SOLIDRECTNODE_H
+#ifndef QSGSIMPLERECTNODE_H
+#define QSGSIMPLERECTNODE_H
#include <QtQuick/qsgnode.h>
#include <QtQuick/qsgflatcolormaterial.h>
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index 48927ce5e1..1a8c69a474 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -232,6 +232,8 @@ static void qt_debug_remove_texture(QSGTexture* texture)
If the texture is used in such a way that atlas is not preferable,
the function removedFromAtlas() can be used to extract a
non-atlassed copy.
+
+ \sa {Scene Graph - Rendering FBOs}, {Scene Graph - Rendering FBOs in a thread}
*/
/*!
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.h b/src/quick/scenegraph/util/qsgtexturematerial.h
index 83d941b084..b842779716 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.h
+++ b/src/quick/scenegraph/util/qsgtexturematerial.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef TEXTUREMATERIAL_H
-#define TEXTUREMATERIAL_H
+#ifndef QSGTEXTUREMATERIAL_H
+#define QSGTEXTUREMATERIAL_H
#include <QtQuick/qsgmaterial.h>
#include <QtQuick/qsgtexture.h>
@@ -92,4 +92,4 @@ public:
QT_END_NAMESPACE
-#endif // TEXTUREMATERIAL_H
+#endif
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.h b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
index a3ffa48c31..81da0650f1 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.h
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef VERTEXCOLORMATERIAL_H
-#define VERTEXCOLORMATERIAL_H
+#ifndef QSGVERTEXCOLORMATERIAL_H
+#define QSGVERTEXCOLORMATERIAL_H
#include <QtQuick/qsgmaterial.h>
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 7a9bea3aa0..0033be82be 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -78,6 +78,11 @@
QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_DEBUG
+static bool qsg_leak_check = !qgetenv("QML_LEAK_CHECK").isEmpty();
+#endif
+
// The cache limit describes the maximum "junk" in the cache.
static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded in qpixmapcache.cpp
@@ -741,7 +746,9 @@ QQuickPixmapStore::~QQuickPixmapStore()
{
m_destroying = true;
+#ifndef QT_NO_DEBUG
int leakedPixmaps = 0;
+#endif
QList<QQuickPixmapData*> cachedData = m_cache.values();
// Prevent unreferencePixmap() from assuming it needs to kick
@@ -753,7 +760,9 @@ QQuickPixmapStore::~QQuickPixmapStore()
foreach (QQuickPixmapData* pixmap, cachedData) {
int currRefCount = pixmap->refCount;
if (currRefCount) {
+#ifndef QT_NO_DEBUG
leakedPixmaps++;
+#endif
while (currRefCount > 0) {
pixmap->release();
currRefCount--;
@@ -766,8 +775,10 @@ QQuickPixmapStore::~QQuickPixmapStore()
shrinkCache(20);
}
- if (leakedPixmaps)
+#ifndef QT_NO_DEBUG
+ if (leakedPixmaps && qsg_leak_check)
qDebug("Number of leaked pixmaps: %i", leakedPixmaps);
+#endif
}
void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
diff --git a/tests/auto/quick/dialogs/data/RectWithFileDialog.qml b/tests/auto/quick/dialogs/data/RectWithFileDialog.qml
new file mode 100644
index 0000000000..ca7ecc948a
--- /dev/null
+++ b/tests/auto/quick/dialogs/data/RectWithFileDialog.qml
@@ -0,0 +1,33 @@
+import QtQuick 2.0
+import QtQuick.Dialogs 1.0
+
+Rectangle {
+ width: 1024
+ height: 320
+ property alias fileDialog: fileDialog
+ property alias label: label
+ property alias mouseArea: mouseArea
+
+ FileDialog {
+ id: fileDialog
+ title: "Choose some files"
+ selectMultiple: true
+ nameFilters: [ "QML files (*.qml)", "All files (*)" ]
+ selectedNameFilter: "QML files (*.qml)"
+ onAccepted: label.text = fileDialog.filePaths
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: fileDialog.visible = !fileDialog.visible
+ }
+
+ Text {
+ id: label
+ text: "Click to open a file dialog"
+ wrapMode: Text.Wrap
+ anchors.fill: parent
+ anchors.margins: 10
+ }
+}
diff --git a/tests/auto/quick/dialogs/dialogs.pro b/tests/auto/quick/dialogs/dialogs.pro
new file mode 100644
index 0000000000..d28c623a1f
--- /dev/null
+++ b/tests/auto/quick/dialogs/dialogs.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_dialogs
+SOURCES += tst_dialogs.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private v8-private testlib
+
+TESTDATA = data/*
+
+OTHER_FILES += \
+ data/FileDialog.qml \
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
new file mode 100644
index 0000000000..9f0dc8ec18
--- /dev/null
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include "../../shared/util.h"
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+#include <QSignalSpy>
+
+class tst_dialogs : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void initTestCase()
+ {
+ QQmlDataTest::initTestCase();
+ }
+
+ // FileDialog
+ void fileDialogDefaultModality();
+ void fileDialogNonModal();
+ void fileDialogNameFilters();
+
+private:
+};
+
+void tst_dialogs::fileDialogDefaultModality()
+{
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickWindow> cleanup(window);
+
+ window->setSource(testFileUrl("RectWithFileDialog.qml"));
+ window->setGeometry(240,240,1024,320);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ // Click to show
+ QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog"));
+ QSignalSpy spyVisibilityChanged(dlg, SIGNAL(visibilityChanged()));
+ QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // show
+ QTRY_VERIFY(spyVisibilityChanged.count() > 0);
+ int visibilityChangedCount = spyVisibilityChanged.count();
+ // Can't hide by clicking the main window, because dialog is modal.
+ QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100));
+#ifdef Q_OS_MAC
+ /*
+ On the Mac, if you send an event directly to a window, the modal dialog
+ doesn't block the event, so the window will process it normally. This
+ is a different code path compared to having a user click the mouse and
+ generate a native event; in that case the OS does the filtering itself,
+ and Qt will not even see the event. But simulating real events in the
+ test framework is generally unstable. So there isn't a good way to test
+ modality on the mac.
+ */
+ QSKIP("Modality test doesn't work on Mac OS");
+#endif
+ // So we expect no change in visibility.
+ QCOMPARE(spyVisibilityChanged.count(), visibilityChangedCount);
+
+ QCOMPARE(dlg->property("visible").toBool(), true);
+ QMetaObject::invokeMethod(dlg, "close");
+ QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount);
+ visibilityChangedCount = spyVisibilityChanged.count();
+ QCOMPARE(dlg->property("visible").toBool(), false);
+ QMetaObject::invokeMethod(dlg, "open");
+ QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount);
+ QCOMPARE(dlg->property("visible").toBool(), true);
+ QCOMPARE(dlg->property("modality").toInt(), (int)Qt::WindowModal);
+}
+
+void tst_dialogs::fileDialogNonModal()
+{
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickWindow> cleanup(window);
+
+ window->setSource(testFileUrl("RectWithFileDialog.qml"));
+ window->setGeometry(240,240,1024,320);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ // Click to toggle visibility
+ QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog"));
+ dlg->setProperty("modality", QVariant((int)Qt::NonModal));
+ QSignalSpy spyVisibilityChanged(dlg, SIGNAL(visibilityChanged()));
+ QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // show
+ int visibilityChangedCount = spyVisibilityChanged.count();
+ QTRY_VERIFY(visibilityChangedCount > 0);
+ QCOMPARE(dlg->property("visible").toBool(), true);
+ QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide
+ QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount);
+ QCOMPARE(dlg->property("visible").toBool(), false);
+ QCOMPARE(dlg->property("modality").toInt(), (int)Qt::NonModal);
+}
+
+void tst_dialogs::fileDialogNameFilters()
+{
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickWindow> cleanup(window);
+
+ window->setSource(testFileUrl("RectWithFileDialog.qml"));
+ window->setGeometry(240,240,1024,320);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QObject *dlg = qvariant_cast<QObject *>(window->rootObject()->property("fileDialog"));
+ QStringList filters;
+ filters << "QML files (*.qml)";
+ filters << "Image files (*.jpg, *.png, *.gif)";
+ filters << "All files (*)";
+ dlg->setProperty("nameFilters", QVariant(filters));
+ QCOMPARE(dlg->property("selectedNameFilter").toString(), filters.first());
+}
+
+QTEST_MAIN(tst_dialogs)
+
+#include "tst_dialogs.moc"
diff --git a/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml b/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml
index b9e8d75f5a..000888a36f 100644
--- a/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/CanvasComponent.qml
@@ -5,6 +5,7 @@ Component {
id:canvas
Canvas {
id:c
+ antialiasing: false;
width:100;height:100
onPaint :{} //this line is needed for some tests (make sure onPaint handler always called
property alias paintCount:spyPaint.count
@@ -27,4 +28,4 @@ Component {
SignalSpy {id: spyImageLoaded;target:c;signalName: "imageLoaded"}
SignalSpy {id: spyAvailableChanged;target:c;signalName: "availableChanged"}
}
-} \ No newline at end of file
+}
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index b2e07e4c13..2d3c8f7ca7 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -366,6 +366,7 @@ void tst_qquickwindow::constantUpdatesOnWindow_data()
void tst_qquickwindow::constantUpdatesOnWindow()
{
+ QSKIP("This test fails frequently on the present overworked CI mac machines");
QFETCH(bool, blockedGui);
QFETCH(QByteArray, signal);
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index aa1e1ec701..81d4fd3348 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -69,6 +69,7 @@ QUICKTESTS = \
qquickcanvasitem \
qquickscreen \
touchmouse \
+ dialogs \
SUBDIRS += $$PUBLICTESTS