From 3dbbcc09e98d768a5b7b6c0a498f8aefd9e25b9e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 1 Apr 2013 13:45:21 -0700 Subject: Embed some default particles. Most prototype level particle effects, at least in our example code, uses basic and generic particles. Embedding these images into the particles plugin will facilitate prototyping with the particles API. Currently finding an image and copying it between projects is a relatively large development cost for quick particle system prototypes. Change-Id: I077104915353ab298e2aabd36e2a0a2070030914 Reviewed-by: Gunnar Sletta --- examples/quick/particles/affectors/content/attractor.qml | 6 +++--- examples/quick/particles/affectors/content/groupgoal.qml | 4 ++-- examples/quick/particles/affectors/content/move.qml | 6 +++--- .../quick/particles/affectors/content/spritegoal.qml | 4 ++-- .../quick/particles/affectors/content/turbulence.qml | 4 ++-- .../particles/customparticle/content/imagecolors.qml | 2 +- .../quick/particles/emitters/content/burstandpulse.qml | 2 +- .../quick/particles/emitters/content/customemitter.qml | 2 +- examples/quick/particles/emitters/content/emitmask.qml | 2 +- .../quick/particles/emitters/content/maximumemitted.qml | 2 +- .../particles/emitters/content/shapeanddirection.qml | 2 +- .../quick/particles/emitters/content/trailemitter.qml | 4 ++-- .../particles/emitters/content/velocityfrommotion.qml | 8 ++++---- .../quick/particles/imageparticle/content/colored.qml | 4 ++-- .../quick/particles/imageparticle/content/colortable.qml | 2 +- examples/quick/particles/images.qrc | 3 --- examples/quick/particles/images/particle.png | Bin 861 -> 0 bytes examples/quick/particles/images/particle4.png | Bin 1799 -> 0 bytes examples/quick/particles/images/star.png | Bin 1550 -> 0 bytes .../quick/particles/system/content/dynamiccomparison.qml | 4 ++-- .../quick/particles/system/content/dynamicemitters.qml | 2 +- .../quick/particles/system/content/multiplepainters.qml | 2 +- examples/quick/particles/system/content/startstop.qml | 2 +- .../quick/particles/system/content/timedgroupchanges.qml | 2 +- 24 files changed, 33 insertions(+), 36 deletions(-) delete mode 100644 examples/quick/particles/images/particle.png delete mode 100644 examples/quick/particles/images/particle4.png delete mode 100644 examples/quick/particles/images/star.png (limited to 'examples') diff --git a/examples/quick/particles/affectors/content/attractor.qml b/examples/quick/particles/affectors/content/attractor.qml index fd7fd65b9c..349132e61a 100644 --- a/examples/quick/particles/affectors/content/attractor.qml +++ b/examples/quick/particles/affectors/content/attractor.qml @@ -77,7 +77,7 @@ Rectangle { ImageParticle { id: stars groups: ["stars"] - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color: "white" colorVariation: 0.1 alpha: 0 @@ -96,7 +96,7 @@ Rectangle { ImageParticle { id: shot groups: ["shot"] - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color: "#0FF06600" colorVariation: 0.3 @@ -104,7 +104,7 @@ Rectangle { ImageParticle { id: engine groups: ["engine"] - source: "../../images/particle4.png" + source: "qrc:///particleresources/fuzzydot.png" color: "orange" SequentialAnimation on color { diff --git a/examples/quick/particles/affectors/content/groupgoal.qml b/examples/quick/particles/affectors/content/groupgoal.qml index 19fa041288..cf4361eb94 100644 --- a/examples/quick/particles/affectors/content/groupgoal.qml +++ b/examples/quick/particles/affectors/content/groupgoal.qml @@ -124,7 +124,7 @@ Rectangle { id: smoke anchors.fill: parent groups: ["smoke"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorVariation: 0 color: "#00111111" } @@ -132,7 +132,7 @@ Rectangle { id: pilot anchors.fill: parent groups: ["pilot"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" redVariation: 0.01 blueVariation: 0.4 color: "#0010004f" diff --git a/examples/quick/particles/affectors/content/move.qml b/examples/quick/particles/affectors/content/move.qml index b4d83318b0..e90f8c685c 100644 --- a/examples/quick/particles/affectors/content/move.qml +++ b/examples/quick/particles/affectors/content/move.qml @@ -50,7 +50,7 @@ Rectangle { ImageParticle { groups: ["A"] anchors.fill: parent - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color:"#FF1010" redVariation: 0.8 } @@ -80,7 +80,7 @@ Rectangle { ImageParticle { groups: ["B"] anchors.fill: parent - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color:"#10FF10" greenVariation: 0.8 } @@ -112,7 +112,7 @@ Rectangle { ImageParticle { groups: ["C"] anchors.fill: parent - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color:"#1010FF" blueVariation: 0.8 } diff --git a/examples/quick/particles/affectors/content/spritegoal.qml b/examples/quick/particles/affectors/content/spritegoal.qml index 78b161f25b..ab108bb065 100644 --- a/examples/quick/particles/affectors/content/spritegoal.qml +++ b/examples/quick/particles/affectors/content/spritegoal.qml @@ -66,7 +66,7 @@ Item { ImageParticle { system: sys groups: ["starfield"] - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" colorVariation: 0.3 color: "white" } @@ -170,7 +170,7 @@ Item { z:0 system: sys groups: ["exhaust"] - source: "../../images/particle4.png" + source: "qrc:///particleresources/fuzzydot.png" color: "orange" SequentialAnimation on color { diff --git a/examples/quick/particles/affectors/content/turbulence.qml b/examples/quick/particles/affectors/content/turbulence.qml index d7a86039b4..eacedbe153 100644 --- a/examples/quick/particles/affectors/content/turbulence.qml +++ b/examples/quick/particles/affectors/content/turbulence.qml @@ -75,13 +75,13 @@ Rectangle { ImageParticle { groups: ["smoke"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" color: "#11111111" colorVariation: 0 } ImageParticle { groups: ["flame"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" color: "#11ff400f" colorVariation: 0.1 } diff --git a/examples/quick/particles/customparticle/content/imagecolors.qml b/examples/quick/particles/customparticle/content/imagecolors.qml index 130518a6f9..3fb4c9f378 100644 --- a/examples/quick/particles/customparticle/content/imagecolors.qml +++ b/examples/quick/particles/customparticle/content/imagecolors.qml @@ -71,7 +71,7 @@ Rectangle { } Image { id: particle - source: "../../images/particle4.png" + source: "qrc:///particleresources/fuzzydot.png" } //! [vertex] vertexShader:" diff --git a/examples/quick/particles/emitters/content/burstandpulse.qml b/examples/quick/particles/emitters/content/burstandpulse.qml index 18d1c43933..28c56b326d 100644 --- a/examples/quick/particles/emitters/content/burstandpulse.qml +++ b/examples/quick/particles/emitters/content/burstandpulse.qml @@ -67,7 +67,7 @@ Rectangle { id: particles anchors.fill: parent ImageParticle { - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" alpha: 0 colorVariation: 0.6 } diff --git a/examples/quick/particles/emitters/content/customemitter.qml b/examples/quick/particles/emitters/content/customemitter.qml index 966c78e70f..9ad504ebc8 100644 --- a/examples/quick/particles/emitters/content/customemitter.qml +++ b/examples/quick/particles/emitters/content/customemitter.qml @@ -90,7 +90,7 @@ ParticleSystem { } ImageParticle { - source: "../../images/particle4.png" + source: "qrc:///particleresources/fuzzydot.png" alpha: 0.0 } } diff --git a/examples/quick/particles/emitters/content/emitmask.qml b/examples/quick/particles/emitters/content/emitmask.qml index 08c04f6e5f..1c2e7b458f 100644 --- a/examples/quick/particles/emitters/content/emitmask.qml +++ b/examples/quick/particles/emitters/content/emitmask.qml @@ -51,7 +51,7 @@ Rectangle { anchors.centerIn: parent ImageParticle { - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" z: 2 anchors.fill: parent color: "#336666CC" diff --git a/examples/quick/particles/emitters/content/maximumemitted.qml b/examples/quick/particles/emitters/content/maximumemitted.qml index df92f05f4b..4bd9079770 100644 --- a/examples/quick/particles/emitters/content/maximumemitted.qml +++ b/examples/quick/particles/emitters/content/maximumemitted.qml @@ -53,7 +53,7 @@ Rectangle { ImageParticle { system: sys id: cp - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorVariation: 0.4 color: "#000000FF" } diff --git a/examples/quick/particles/emitters/content/shapeanddirection.qml b/examples/quick/particles/emitters/content/shapeanddirection.qml index 1dec5b2fa7..0ca433cfba 100644 --- a/examples/quick/particles/emitters/content/shapeanddirection.qml +++ b/examples/quick/particles/emitters/content/shapeanddirection.qml @@ -58,7 +58,7 @@ Rectangle { ImageParticle { groups: ["center","edge"] anchors.fill: parent - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorVariation: 0.1 color: "#009999FF" } diff --git a/examples/quick/particles/emitters/content/trailemitter.qml b/examples/quick/particles/emitters/content/trailemitter.qml index a4972b7b73..3186b511ef 100644 --- a/examples/quick/particles/emitters/content/trailemitter.qml +++ b/examples/quick/particles/emitters/content/trailemitter.qml @@ -56,7 +56,7 @@ Rectangle { system: particles anchors.fill: parent groups: ["A", "B"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorVariation: 0 color: "#00111111" } @@ -65,7 +65,7 @@ Rectangle { anchors.fill: parent system: particles groups: ["C", "D"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorVariation: 0.1 color: "#00ff400f" } diff --git a/examples/quick/particles/emitters/content/velocityfrommotion.qml b/examples/quick/particles/emitters/content/velocityfrommotion.qml index 1f1d6607d0..d325f9b7e1 100644 --- a/examples/quick/particles/emitters/content/velocityfrommotion.qml +++ b/examples/quick/particles/emitters/content/velocityfrommotion.qml @@ -61,7 +61,7 @@ Rectangle { ParticleSystem { id: sys1 } ImageParticle { system: sys1 - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" color: "cyan" alpha: 0 SequentialAnimation on color { @@ -127,7 +127,7 @@ Rectangle { } } colorVariation: 0.5 - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" } Emitter { id: trailsStars @@ -149,7 +149,7 @@ Rectangle { } ParticleSystem { id: sys3; } ImageParticle { - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" system: sys3 color: "orange" alpha: 0 @@ -191,7 +191,7 @@ Rectangle { ParticleSystem { id: sys4; } ImageParticle { system: sys4 - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" color: "green" alpha: 0 SequentialAnimation on color { diff --git a/examples/quick/particles/imageparticle/content/colored.qml b/examples/quick/particles/imageparticle/content/colored.qml index 939ec7e437..236cc0f372 100644 --- a/examples/quick/particles/imageparticle/content/colored.qml +++ b/examples/quick/particles/imageparticle/content/colored.qml @@ -50,7 +50,7 @@ Rectangle { ImageParticle { groups: ["stars"] anchors.fill: parent - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" } Emitter { group: "stars" @@ -64,7 +64,7 @@ Rectangle { // ![0] ImageParticle { anchors.fill: parent - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" alpha: 0 alphaVariation: 0.2 colorVariation: 1.0 diff --git a/examples/quick/particles/imageparticle/content/colortable.qml b/examples/quick/particles/imageparticle/content/colortable.qml index 4090163872..87b5ae2678 100644 --- a/examples/quick/particles/imageparticle/content/colortable.qml +++ b/examples/quick/particles/imageparticle/content/colortable.qml @@ -55,7 +55,7 @@ Rectangle { alpha: 0 //! [0] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" colorTable: "../../images/colortable.png" sizeTable: "../../images/colortable.png" //! [0] diff --git a/examples/quick/particles/images.qrc b/examples/quick/particles/images.qrc index 9f284a087d..1f754838a8 100644 --- a/examples/quick/particles/images.qrc +++ b/examples/quick/particles/images.qrc @@ -12,10 +12,8 @@ images/meteor.png images/meteors.png images/nullRock.png - images/particle.png images/particle2.png images/particle3.png - images/particle4.png images/particleA.png images/portal_bg.png images/realLeaf1.png @@ -27,7 +25,6 @@ images/sizeInOut.png images/snowflake.png images/sparkleSize.png - images/star.png images/starfish_0.png images/starfish_1.png images/starfish_2.png diff --git a/examples/quick/particles/images/particle.png b/examples/quick/particles/images/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/quick/particles/images/particle.png and /dev/null differ diff --git a/examples/quick/particles/images/particle4.png b/examples/quick/particles/images/particle4.png deleted file mode 100644 index bc95b703c1..0000000000 Binary files a/examples/quick/particles/images/particle4.png and /dev/null differ diff --git a/examples/quick/particles/images/star.png b/examples/quick/particles/images/star.png deleted file mode 100644 index 0d592cfa87..0000000000 Binary files a/examples/quick/particles/images/star.png and /dev/null differ diff --git a/examples/quick/particles/system/content/dynamiccomparison.qml b/examples/quick/particles/system/content/dynamiccomparison.qml index 247a25a17d..9db7c0a1ec 100644 --- a/examples/quick/particles/system/content/dynamiccomparison.qml +++ b/examples/quick/particles/system/content/dynamiccomparison.qml @@ -52,7 +52,7 @@ Rectangle { ImageParticle { system: sys - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" color: "white" colorVariation: 1.0 alpha: 0.1 @@ -90,7 +90,7 @@ Rectangle { property int lifeSpan: 10000 width: 32 height: 32 - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" y: 0 PropertyAnimation on y {from: -16; to: root.height-16; duration: container.lifeSpan; running: true} SequentialAnimation on opacity { diff --git a/examples/quick/particles/system/content/dynamicemitters.qml b/examples/quick/particles/system/content/dynamicemitters.qml index 10ac33bd76..72ec1ffc23 100644 --- a/examples/quick/particles/system/content/dynamicemitters.qml +++ b/examples/quick/particles/system/content/dynamicemitters.qml @@ -51,7 +51,7 @@ Rectangle { } ImageParticle { system: sys - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" color: "white" colorVariation: 1.0 alpha: 0.1 diff --git a/examples/quick/particles/system/content/multiplepainters.qml b/examples/quick/particles/system/content/multiplepainters.qml index 8a38874533..e0a1288588 100644 --- a/examples/quick/particles/system/content/multiplepainters.qml +++ b/examples/quick/particles/system/content/multiplepainters.qml @@ -91,6 +91,6 @@ Rectangle { height: 240 width: root.width z: 1 - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" } } diff --git a/examples/quick/particles/system/content/startstop.qml b/examples/quick/particles/system/content/startstop.qml index 5ce8729a43..e787919b05 100644 --- a/examples/quick/particles/system/content/startstop.qml +++ b/examples/quick/particles/system/content/startstop.qml @@ -69,7 +69,7 @@ Rectangle { ImageParticle { anchors.fill: parent system: particles - source: "../../images/star.png" + source: "qrc:///particleresources/star.png" sizeTable: "../../images/sparkleSize.png" alpha: 0 colorVariation: 0.6 diff --git a/examples/quick/particles/system/content/timedgroupchanges.qml b/examples/quick/particles/system/content/timedgroupchanges.qml index 6443878a36..7131633769 100644 --- a/examples/quick/particles/system/content/timedgroupchanges.qml +++ b/examples/quick/particles/system/content/timedgroupchanges.qml @@ -119,7 +119,7 @@ Rectangle { ImageParticle { groups: ["works", "fire", "splode"] - source: "../../images/particle.png" + source: "qrc:///particleresources/glowdot.png" entryEffect: ImageParticle.Scale } } -- cgit v1.2.3 From 21e162d410a9b5bbb2c3a3e07e004a1a586a1d4f Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 17 Apr 2013 23:03:16 +0800 Subject: Doc: Qt QML: Fix module name format Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation QtQml -> Qt QML Change-Id: I45ca4496a02214feab48707b026c6bec085df138 Reviewed-by: Jerome Pasion --- examples/HACKING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/HACKING b/examples/HACKING index 9539d2d129..7d2a61a481 100644 --- a/examples/HACKING +++ b/examples/HACKING @@ -1,4 +1,4 @@ -Some guidelines for QtQml examples +Some guidelines for Qt QML examples Snippets --- -- cgit v1.2.3 From 21aa22ba3fe2f6424742ba0a8fbf39937b81ad13 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 7 Mar 2013 10:20:19 +0100 Subject: Create BG context and fake surface on GUI thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the example more messy and also makes it very hard to avoid the initial black frame, but it is not compliant with the limitations we experience on Windows. Task-number: QTBUG-30077 Change-Id: If5a6da16f8fc1269cd20d2aa1190588025203d4f Reviewed-by: Friedemann Kleint Reviewed-by: Samuel Rødal --- examples/quick/scenegraph/textureinthread/main.cpp | 32 ++++++++-- .../scenegraph/textureinthread/threadrenderer.cpp | 69 ++++++++++++++++------ .../scenegraph/textureinthread/threadrenderer.h | 6 ++ 3 files changed, 85 insertions(+), 22 deletions(-) (limited to 'examples') diff --git a/examples/quick/scenegraph/textureinthread/main.cpp b/examples/quick/scenegraph/textureinthread/main.cpp index e415d254a1..3286055496 100644 --- a/examples/quick/scenegraph/textureinthread/main.cpp +++ b/examples/quick/scenegraph/textureinthread/main.cpp @@ -38,6 +38,8 @@ ** ****************************************************************************/ +#include + #include #include @@ -49,11 +51,31 @@ int main(int argc, char **argv) QGuiApplication app(argc, argv); qmlRegisterType("SceneGraphRendering", 1, 0, "Renderer"); + int execReturn = 0; + + { + QQuickView view; + + // Rendering in a thread introduces a slightly more complicated cleanup + // so we ensure that no cleanup of graphics resources happen until the + // application is shutting down. + view.setPersistentOpenGLContext(true); + view.setPersistentSceneGraph(true); + + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); + view.show(); + + execReturn = app.exec(); + } - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); - view.show(); + // As the render threads make use of our QGuiApplication object + // to clean up gracefully, wait for them to finish before + // QGuiApp is taken off the heap. + foreach (QThread *t, ThreadRenderer::threads) { + t->wait(); + delete t; + } - return app.exec(); + return execReturn; } diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp index 90b6b49880..7de1d294ba 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp @@ -46,10 +46,13 @@ #include #include +#include +#include #include #include +QList ThreadRenderer::threads; /* * The render thread shares a context with the scene graph and will @@ -60,37 +63,39 @@ class RenderThread : public QThread { Q_OBJECT public: - RenderThread(const QSize &size) + RenderThread(const QSize &size, QOpenGLContext *context) : m_renderFbo(0) , m_displayFbo(0) , m_logoRenderer(0) + , m_fakeSurface(0) , m_size(size) { - // Since we're using queued connections, we need affinity to the rendering thread. - moveToThread(this); + ThreadRenderer::threads << 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->setShareContext(context); + m_context->setFormat(context->format()); 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()); + // We need a non-visible surface to make current in the other thread + // and QWindows must be created and managed on the GUI thread. + m_fakeSurface = new QOffscreenSurface(); + m_fakeSurface->setFormat(context->format()); m_fakeSurface->create(); } + void setSurface(QOffscreenSurface *surface) { m_fakeSurface = surface; } + public slots: void renderNext() { + if (!m_context->isValid()) + m_context->create(); + m_context->makeCurrent(m_fakeSurface); if (!m_renderFbo) { @@ -119,6 +124,23 @@ public slots: emit textureReady(m_displayFbo->texture(), m_size); } + void shutDown() + { + m_context->makeCurrent(m_fakeSurface); + delete m_renderFbo; + delete m_displayFbo; + delete m_logoRenderer; + m_context->doneCurrent(); + delete m_context; + + // schedule this to be deleted only after we're done cleaning up + m_fakeSurface->deleteLater(); + + // Stop event processing, move the thread to GUI and make sure it is deleted. + exit(); + moveToThread(QGuiApplication::instance()->thread()); + } + signals: void textureReady(int id, const QSize &size); @@ -128,7 +150,7 @@ private: LogoRenderer *m_logoRenderer; - QWindow *m_fakeSurface; + QOffscreenSurface *m_fakeSurface; QOpenGLContext *m_context; QSize m_size; }; @@ -209,19 +231,35 @@ private: ThreadRenderer::ThreadRenderer() + : m_renderThread(0) { setFlag(ItemHasContents, true); + polish(); } +void ThreadRenderer::updatePolish() +{ + if (!window() || !window()->openglContext()) + return; + m_renderThread = new RenderThread(QSize(512, 512), window()->openglContext()); + m_renderThread->moveToThread(m_renderThread); + m_renderThread->start(); + connect(window(), SIGNAL(sceneGraphInvalidated()), m_renderThread, SLOT(shutDown()), Qt::QueuedConnection); +} QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { + if (!m_renderThread) { + polish(); + update(); + return 0; + } + TextureNode *node = static_cast(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. @@ -242,9 +280,6 @@ QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * 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); } diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.h b/examples/quick/scenegraph/textureinthread/threadrenderer.h index f12e6404e5..8c68e27d92 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.h +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.h @@ -52,9 +52,15 @@ class ThreadRenderer : public QQuickItem public: ThreadRenderer(); + static QList threads; + +public slots: + void updatePolish(); + protected: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + private: RenderThread *m_renderThread; }; -- cgit v1.2.3 From 59f075df52f5e78b95b360fb0533c2249924e7a7 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 17 Apr 2013 23:03:16 +0800 Subject: Doc: Qt Quick: Fix module name format (Pt 1/2) Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation Attempt to differentiate between the whole module ("Qt Quick") and the QML import ("QtQuick") by encoding the latter with monospace font. There are places in the text where both representations are valid. Change-Id: Id6e157a4191aaa4e23a9cd5c76abfe902fe43d33 Reviewed-by: Jerome Pasion --- examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc | 4 ++-- examples/quick/particles/system/doc/src/system.qdoc | 2 +- examples/quick/shadereffects/doc/src/shadereffects.qdoc | 2 +- examples/quick/views/doc/src/views.qdoc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples') diff --git a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc index d4aabc01d8..9450c19259 100644 --- a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc +++ b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc @@ -43,12 +43,12 @@ The example consists of an item class, a plugin class and a QML file to use this plugin. The \c TextBalloon class represents the individual text balloons extending QQuickPaintedItem, the \c TextBalloonPlugin class - represents the skeleton code for a QtQuick plugin and the + represents the skeleton code for a \l {Qt Quick} plugin and the \c textballoons.qml file is used to load the plugin and display the text balloons. We will focus on the \c TextBalloon class first and continue with the - \c textballoons.qml file. For an example on how to implement a QtQuick + \c textballoons.qml file. For an example on how to implement a \l {Qt Quick} plugin please look at \l{declarative/tutorials/extending/chapter6-plugins} {Writing an Extension Plugin} diff --git a/examples/quick/particles/system/doc/src/system.qdoc b/examples/quick/particles/system/doc/src/system.qdoc index 04dc1727d2..2bef4c6947 100644 --- a/examples/quick/particles/system/doc/src/system.qdoc +++ b/examples/quick/particles/system/doc/src/system.qdoc @@ -53,6 +53,6 @@ \snippet quick/particles/system/content/dynamicemitters.qml 0 Note that this effect, a flurry of flying rainbow spears, would be better served with TrailEmitter. It is only done with dynamic emitters in this example to show the concept more simply. - Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, ImageParticle objects follow the normal Z-ordering rules for QtQuick items. This example allow you to paint the inside of the particles above the black borders using a pair of ImageParticles each painting different parts of the same logical particle. + Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, ImageParticle objects follow the normal Z-ordering rules for \l {Qt Quick} items. This example allow you to paint the inside of the particles above the black borders using a pair of ImageParticles each painting different parts of the same logical particle. */ diff --git a/examples/quick/shadereffects/doc/src/shadereffects.qdoc b/examples/quick/shadereffects/doc/src/shadereffects.qdoc index 5d1547a1fe..6f6311a5ae 100644 --- a/examples/quick/shadereffects/doc/src/shadereffects.qdoc +++ b/examples/quick/shadereffects/doc/src/shadereffects.qdoc @@ -32,7 +32,7 @@ \ingroup qtquickexamples This example demonstrates a couple of visual effects that you can perform - with shaders in QtQuick 2.0 + with shaders in \l {Qt Quick}. ShaderEffects typically operate on other types, using a ShaderEffectSource \snippet quick/shadereffects/shadereffects.qml source diff --git a/examples/quick/views/doc/src/views.qdoc b/examples/quick/views/doc/src/views.qdoc index cc8112f4dd..21a2d2e5e0 100644 --- a/examples/quick/views/doc/src/views.qdoc +++ b/examples/quick/views/doc/src/views.qdoc @@ -32,7 +32,7 @@ \image qml-modelviews-example.png \ingroup qtquickexamples - This is a collection of small QML examples relating to model and view functionality. They demonstrate how to show data from a model using the QtQuick view types. + This is a collection of small QML examples relating to model and view functionality. They demonstrate how to show data from a model using the \l {Qt Quick} view types. \section2 GridView and PathView demonstrate usage of these types to display views. \snippet quick/views/gridview/gridview-example.qml 0 -- cgit v1.2.3 From 9272193f5dc4cd1b418912cc5b9d8f2585a90f96 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 25 Apr 2013 13:26:04 +0200 Subject: Quote scenegraph example code from the right place. Change-Id: I0eced5b0062aa36dc67b575615ed4c82d3ea6d3d Reviewed-by: Jerome Pasion Reviewed-by: Shawn Rutledge --- .../customgeometry/doc/src/customgeometry.qdoc | 32 +++++++++++----------- .../openglunderqml/doc/src/openglunderqml.qdoc | 26 +++++++++--------- .../simplematerial/doc/src/simplematerial.qdoc | 26 +++++++++--------- 3 files changed, 42 insertions(+), 42 deletions(-) (limited to 'examples') diff --git a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc index d98407b6c1..e3cef52bf7 100644 --- a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc +++ b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc @@ -41,7 +41,7 @@ \section1 BezierCurve Declaration - \snippet quick/scenegraph/customgeometry/beziercurve.h 1 + \snippet scenegraph/customgeometry/beziercurve.h 1 The item declaration subclasses the QQuickItem class and adds five properties. One for each of the four control points in the bezier @@ -52,7 +52,7 @@ signals for each of them so changes will be picked up the QML engine and used accordingly. - \snippet quick/scenegraph/customgeometry/beziercurve.h 2 + \snippet scenegraph/customgeometry/beziercurve.h 2 The synchronization point between the QML scene and the rendering scene graph is the virtual function \l @@ -67,7 +67,7 @@ \section1 BezierCurve Implementation - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 1 + \snippet scenegraph/customgeometry/beziercurve.cpp 1 The BezierCurve constructor sets up default values for the control points and the number of segments. The bezier curve @@ -80,7 +80,7 @@ QQuickItem::updatePaintNode() when it is time for the QML scene to be synchronized with the rendering scene graph. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 2 + \snippet scenegraph/customgeometry/beziercurve.cpp 2 The BezierCurve class has no data members that need to be cleaned up so the destructor does nothing. It is worth mentioning that the @@ -89,7 +89,7 @@ QSGNode references in the QQuickItem class nor try to clean them up explicitly. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 3 + \snippet scenegraph/customgeometry/beziercurve.cpp 3 The setter function for the p1 property checks if the value is unchanged and exits early if this is the case. Then it updates the @@ -103,7 +103,7 @@ The other property setters are equivalent, and are omitted from this example. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 4 + \snippet scenegraph/customgeometry/beziercurve.cpp 4 The updatePaintNode() function is the primary integration point for synchronizing the state of the QML scene with the rendering @@ -113,7 +113,7 @@ our QSGGeometryNode which we will fill with geometry and a material. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 5 + \snippet scenegraph/customgeometry/beziercurve.cpp 5 We then create the geometry and add it to the node. The first argument to the QSGGeometry constructor is a definition of the @@ -135,7 +135,7 @@ geometry a member of a QSGGeometryNode subclass, in which case, we would not have set the QSGGeometryNode::OwnsGeometry flag. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 6 + \snippet scenegraph/customgeometry/beziercurve.cpp 6 The scene graph API provides a few commonly used used material implementations. In this example we use the QSGFlatColorMaterial @@ -143,7 +143,7 @@ color. Again we pass the ownership of the material to the node, so it can be cleaned up by the scene graph. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 7 + \snippet scenegraph/customgeometry/beziercurve.cpp 7 In the case where the QML item has changed and we only want to modify the existing node's geometry, we cast the \c oldNode to a @@ -151,7 +151,7 @@ segment count has changed, we call QSGGeometry::allocate() to make sure it has the right number of vertices. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 8 + \snippet scenegraph/customgeometry/beziercurve.cpp 8 To fill the geometry, we first extract the vertex array from it. Since we are using one of the default attribute sets, we can @@ -159,14 +159,14 @@ Then we go through each segment and calculate its position and write that value to the vertex. - \snippet quick/scenegraph/customgeometry/beziercurve.cpp 9 + \snippet scenegraph/customgeometry/beziercurve.cpp 9 In the end of the function, we return the node so the scene graph can render it. \section1 Application Entry-Point - \snippet quick/scenegraph/customgeometry/main.cpp 1 + \snippet scenegraph/customgeometry/main.cpp 1 The application is a straightforward QML application, with a QGuiApplication and a QQuickView that we pass a .qml file. To make @@ -183,24 +183,24 @@ \section1 Using the Item - \snippet quick/scenegraph/customgeometry/main.qml 1 + \snippet scenegraph/customgeometry/main.qml 1 Our .qml file imports the \c {QtQuick 2.0} module to get the standard types and also our own \c {CustomGeometry 1.0} module which contains our newly created BezierCurve objects. - \snippet quick/scenegraph/customgeometry/main.qml 2 + \snippet scenegraph/customgeometry/main.qml 2 Then we create the our root item and an instance of the BezierCurve which we anchor to fill the root. - \snippet quick/scenegraph/customgeometry/main.qml 3 + \snippet scenegraph/customgeometry/main.qml 3 To make the example a bit more interesting we add an animation to change the two control points in the curve. The end points stay unchanged. - \snippet quick/scenegraph/customgeometry/main.qml 4 + \snippet scenegraph/customgeometry/main.qml 4 Finally we overlay a short text outlining what the example shows. diff --git a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc index 4bf5444d79..d9f49c942b 100644 --- a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc +++ b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc @@ -50,7 +50,7 @@ in the QML file and this value is used by the OpenGL shader program that draws the squircles. - \snippet quick/scenegraph/openglunderqml/squircle.h 1 + \snippet scenegraph/openglunderqml/squircle.h 1 First of all, we need a QObject with a slot to connect the signals to. We subclass QQuickItem in order to use the \l @@ -73,13 +73,13 @@ Lets move on to the implementation. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 7 + \snippet scenegraph/openglunderqml/squircle.cpp 7 The constructor of the \c Squircle class simply initializes the values. The shader program will be initialized during rendering later. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 8 + \snippet scenegraph/openglunderqml/squircle.cpp 8 The property setter checks that the value has indeed changed before updating its internal variable. It then calls \l @@ -88,8 +88,8 @@ initialization, before the object has been entered into the scene and before it has a window. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 1 - \snippet quick/scenegraph/openglunderqml/squircle.cpp 2 + \snippet scenegraph/openglunderqml/squircle.cpp 1 + \snippet scenegraph/openglunderqml/squircle.cpp 2 For our paint function to be called, we need to connect to the window's signals. When Squircle object is populated into the @@ -106,14 +106,14 @@ slots are invoked on the wrong thread with no OpenGL context present. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 3 + \snippet scenegraph/openglunderqml/squircle.cpp 3 The default behavior of the scene graph is to clear the framebuffer before rendering. Since we render before the scene graph, we need to turn this clearing off. This means that we need to clear ourselves in the \c paint() function. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 4 + \snippet scenegraph/openglunderqml/squircle.cpp 4 The first thing we do in the \c paint() function is to initialize the shader program. By initializing the shader program @@ -126,18 +126,18 @@ all rendering related operations must happen on the rendering thread. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 5 + \snippet scenegraph/openglunderqml/squircle.cpp 5 We use the shader program to draw the squircle. At the end of the \c paint function we release the program and disable the attributes we used so that the OpenGL context is in a "clean" state for the scene graph to pick it up. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 6 + \snippet scenegraph/openglunderqml/squircle.cpp 6 In the \c cleanup() function we delete the program. - \snippet quick/scenegraph/openglunderqml/squircle.cpp 9 + \snippet scenegraph/openglunderqml/squircle.cpp 9 We use the \c sync() function to copy the state of the object in the GUI thread into the rendering thread. @@ -146,20 +146,20 @@ thread is blocked, so it is safe to simply copy the value without any additional protection. - \snippet quick/scenegraph/openglunderqml/main.cpp 1 + \snippet scenegraph/openglunderqml/main.cpp 1 The application's \c main() function instantiates a QQuickView and launches the \c main.qml file. The only thing worth noting is that we export the \c Squircle class to QML using the \l qmlRegisterType() macro. - \snippet quick/scenegraph/openglunderqml/main.qml 1 + \snippet scenegraph/openglunderqml/main.qml 1 We import the Squircle QML type with the name we registered in the \c main() function. We then instantiate it and create a running NumberAnimation on the its \c t property. - \snippet quick/scenegraph/openglunderqml/main.qml 2 + \snippet scenegraph/openglunderqml/main.qml 2 Then we overlay a short descriptive text, so that it is clearly visible that we are in fact rendering OpenGL under our Qt Quick diff --git a/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc b/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc index 1529649798..5d83b9fa5f 100644 --- a/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc +++ b/examples/quick/scenegraph/simplematerial/doc/src/simplematerial.qdoc @@ -47,7 +47,7 @@ material state is what we assign to each individual node, in this case to give them different colors. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 1 + \snippet scenegraph/simplematerial/simplematerial.cpp 1 The first thing we do when creating custom materials with the simplified scheme is to create a state class. In this case the @@ -55,7 +55,7 @@ compare function which the scene graph can use to reorder the node rendering. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 2 + \snippet scenegraph/simplematerial/simplematerial.cpp 2 Next we define the material shader, by subclassing a template instantiation of \l QSGSimpleMaterialShader with our \c State. @@ -74,21 +74,21 @@ classes. Using the same \c State class in multiple shaders will will lead to undefined behavior. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 3 + \snippet scenegraph/simplematerial/simplematerial.cpp 3 Next comes the declaration of the shader source code, where we define a vertex and fragment shader. The simple material assumes the presence of \c qt_Matrix in the vertex shader and \c qt_Opacity in the fragment shader. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 4 + \snippet scenegraph/simplematerial/simplematerial.cpp 4 We reimplement the \c attributes function to return the name of the \c aVertex and \c aTexCoord attribute names. These attributes will be mapped to attribute indices 0 and 1 in the node's geometry. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 6 + \snippet scenegraph/simplematerial/simplematerial.cpp 6 Uniforms can be accessed either by name or by index, where index is faster than name, so we reimplement the \c resolveUniforms() @@ -96,7 +96,7 @@ to worry about resolving \c qt_Opacity or \c qt_Matrix as these are handled by the baseclass. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 5 + \snippet scenegraph/simplematerial/simplematerial.cpp 5 The \c updateState() function is called once for every unique state and we use it to update the shader program with the current @@ -105,7 +105,7 @@ usecase, where all the colors are different, the updateState will be called once for every node. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 7 + \snippet scenegraph/simplematerial/simplematerial.cpp 7 The \c ColorNode class is supposed to draw something, so it needs to be a subclass of \l QSGGeometryNode. @@ -129,12 +129,12 @@ Finally, we tell the node to take ownership of the material, so we do not have to explicitly memorymanage it. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 8 + \snippet scenegraph/simplematerial/simplematerial.cpp 8 Since the Item is providing its own graphics to the scene graph, we set the flag \l QQuickItem::ItemHasContents. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 9 + \snippet scenegraph/simplematerial/simplematerial.cpp 9 Whenever the Item has changed graphically, the \l QQuickItem::updatePaintNode() function is called. @@ -157,23 +157,23 @@ state. Finally, we notify the scene graph that the node has undergone changes to its geometry and material. - \snippet quick/scenegraph/simplematerial/simplematerial.cpp 11 + \snippet scenegraph/simplematerial/simplematerial.cpp 11 The \c main() function of the application adds the custom QML type using \l qmlRegisterType() and opens up a \l QQuickView with our QML file. - \snippet quick/scenegraph/simplematerial/main.qml 1 + \snippet scenegraph/simplematerial/main.qml 1 In the QML file, we import our custom type so we can instantiate it. - \snippet quick/scenegraph/simplematerial/main.qml 2 + \snippet scenegraph/simplematerial/main.qml 2 Then we create a column of three instances of our custom item, each with a different color. - \snippet quick/scenegraph/simplematerial/main.qml 3 + \snippet scenegraph/simplematerial/main.qml 3 And finally we overlay a short descriptive text. -- cgit v1.2.3 From d5e612fb3e9753c762b741d135fabd2b1f8ae1a6 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 25 Apr 2013 11:16:40 +0200 Subject: Re-implemented itemChange must always call QQuickItem::itemChange Documentation for that fact, and the windowChanged signal. Fix existing QQuickItem subclasses which didn't call QQuickItem::itemChange. Examples should rather connect to the windowChanged() signal. Change-Id: Ieddcdbe69f849ddb120b64be9c5e0a21393b0ed9 Reviewed-by: Gunnar Sletta --- .../scenegraph/openglunderqml/doc/src/openglunderqml.qdoc | 6 +++--- examples/quick/scenegraph/openglunderqml/squircle.cpp | 11 +++-------- examples/quick/scenegraph/openglunderqml/squircle.h | 6 +++--- 3 files changed, 9 insertions(+), 14 deletions(-) (limited to 'examples') diff --git a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc index d9f49c942b..1f87412aa4 100644 --- a/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc +++ b/examples/quick/scenegraph/openglunderqml/doc/src/openglunderqml.qdoc @@ -93,8 +93,8 @@ For our paint function to be called, we need to connect to the window's signals. When Squircle object is populated into the - scene, the itemChange function is called with the change type \c - ItemSceneChange. We connect \l QQuickWindow::beforeRendering() to + scene, the windowChanged signal is emitted. In our handler, + we connect \l QQuickWindow::beforeRendering() to \c paint() to do the rendering, and \l QQuickWindow::beforeSynchronizing() to \c sync() to copy the state of the \c t property for the upcoming frame. @@ -157,7 +157,7 @@ We import the Squircle QML type with the name we registered in the \c main() function. We then instantiate it and create a running - NumberAnimation on the its \c t property. + NumberAnimation on its \c t property. \snippet scenegraph/openglunderqml/main.qml 2 diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp index 84509fb615..8ceb9c5f9e 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.cpp +++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp @@ -51,6 +51,7 @@ Squircle::Squircle() , m_t(0) , m_thread_t(0) { + connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*))); } //! [7] @@ -66,17 +67,11 @@ void Squircle::setT(qreal t) } //! [8] - //! [1] -void Squircle::itemChange(ItemChange change, const ItemChangeData &) +void Squircle::handleWindowChanged(QQuickWindow *win) { - // The ItemSceneChange event is sent when we are first attached to a window. - if (change == ItemSceneChange) { - QQuickWindow *win = window(); - if (!win) - return; + if (win) { //! [1] - // Connect the beforeRendering signal to our paint function. // Since this call is executed on the rendering thread it must be // a Qt::DirectConnection diff --git a/examples/quick/scenegraph/openglunderqml/squircle.h b/examples/quick/scenegraph/openglunderqml/squircle.h index e292ca325f..449e02bbf1 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.h +++ b/examples/quick/scenegraph/openglunderqml/squircle.h @@ -61,14 +61,14 @@ public: signals: void tChanged(); -protected: - void itemChange(ItemChange change, const ItemChangeData &); - public slots: void paint(); void cleanup(); void sync(); +private slots: + void handleWindowChanged(QQuickWindow *win); + private: QOpenGLShaderProgram *m_program; -- cgit v1.2.3 From d9ac1486bf94acd19367ea8b543cd88508ff3124 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 28 Apr 2013 10:59:06 +0800 Subject: Doc: Remove "qmldemos" group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The group is a remnant of Qt Quick 1, and currently only contains 1 member. Move it to the "qtquickexamples" group. Change-Id: I211b9b769274e139321760f4b52220449e03a6ad Reviewed-by: Topi Reiniö Reviewed-by: Jerome Pasion --- examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc index 60a9725e53..d812da4982 100644 --- a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc +++ b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc @@ -30,7 +30,7 @@ \example demos/calqlatr \brief This is an example calculator written in QML. \image qml-calqlatr-demo-small.png - \ingroup qmldemos + \ingroup qtquickexamples This demo implements a simple calculator app, designed for portrait devices. -- cgit v1.2.3 From cc17df90b40930d0e978c8268343a2d6ab400e64 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 29 Apr 2013 12:51:14 +0200 Subject: Doc: Fix example path for Qt Quick scenegraph examples Base path (examples/quick) is now defined in qdocconf file, example docs need to adjust their paths for \example command. Change-Id: I18412c4adf73691903ee58c9a056b6a4998d4d6a Reviewed-by: Jerome Pasion --- examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc | 2 +- examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc b/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc index b24b0bd97b..0917604a35 100644 --- a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc +++ b/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example quick/scenegraph/textureinsgnode + \example scenegraph/textureinsgnode \title Scene Graph - Rendering FBOs \ingroup qtquickexamples diff --git a/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc b/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc index 476605b268..6f4a2514f0 100644 --- a/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc +++ b/examples/quick/scenegraph/textureinthread/doc/src/textureinthread.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example quick/scenegraph/textureinthread + \example scenegraph/textureinthread \title Scene Graph - Rendering FBOs in a thread \ingroup qtquickexamples -- cgit v1.2.3 From 83acf00567af0c028e095b89e356c2927f5e4b2f Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 30 Apr 2013 13:24:38 +0200 Subject: Fix MaskedMouseArea example Task-number: QTBUG-30916 Change-Id: Icc73118f8d129b6c1ef285fd7a35f7a9a8e04391 Reviewed-by: Gabriel de Dietrich --- examples/quick/customitems/maskedmousearea/maskedmousearea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp b/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp index be37a5936d..4f0818ac71 100644 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp +++ b/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp @@ -42,7 +42,7 @@ #include #include - +#include MaskedMouseArea::MaskedMouseArea(QQuickItem *parent) : QQuickItem(parent), @@ -74,7 +74,7 @@ void MaskedMouseArea::setMaskSource(const QUrl &source) { if (m_maskSource != source) { m_maskSource = source; - m_maskImage = QImage(source.toLocalFile()); + m_maskImage = QImage(QQmlFile::urlToLocalFileOrQrc(source)); emit maskSourceChanged(); } } -- cgit v1.2.3 From 98023c7eba3205b85b2ad0c107ce72072a2b0bba Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 30 Apr 2013 15:06:40 +0200 Subject: Canvas: Do not apply transform to text twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The path already has the transform, no need to apply it a second time manually. Task-number: QTBUG-30501 Change-Id: Iedcb2e2f85a1f9eeac8e6264e00536c43bf16ddb Reviewed-by: Samuel Rødal --- examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml index 0756d339ff..69e703cca7 100644 --- a/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml +++ b/examples/quick/canvas/quadraticCurveTo/quadraticCurveTo.qml @@ -116,13 +116,12 @@ Item { if (canvas.stroke) ctx.stroke(); - ctx.restore(); - // ![1] ctx.fillStyle = "white"; ctx.font = "Bold 17px"; - ctx.fillText("Qt Quick", 110, 140); + ctx.fillText("Qt Quick", 40, 70); // ![1] + ctx.restore(); } } } -- cgit v1.2.3 From ddfa42c85b732972f819a2525293a90539d42d38 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Apr 2013 13:06:44 -0500 Subject: Better handle GL errors in EtcTexture::bind(). The scenegraph as a whole does not typically do GL error checking. That means GL errors occurring elsewhere could cause the etcprovider to unload textures that loaded correctly. Change-Id: Ic8e0caa62dab50b391e226cf0a493bc7e357dc46 Reviewed-by: Gunnar Sletta --- examples/quick/textureprovider/etcprovider.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'examples') diff --git a/examples/quick/textureprovider/etcprovider.cpp b/examples/quick/textureprovider/etcprovider.cpp index 52c2c17cfe..04545fe830 100644 --- a/examples/quick/textureprovider/etcprovider.cpp +++ b/examples/quick/textureprovider/etcprovider.cpp @@ -121,6 +121,10 @@ void EtcTexture::bind() "paddedWidth: " << m_paddedSize.width() << "paddedHeight: " << m_paddedSize.height(); #endif +#ifndef QT_NO_DEBUG + while (glGetError() != GL_NO_ERROR) { } +#endif + QOpenGLContext *ctx = QOpenGLContext::currentContext(); Q_ASSERT(ctx != 0); ctx->functions()->glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, @@ -128,6 +132,7 @@ void EtcTexture::bind() (m_paddedSize.width() * m_paddedSize.height()) >> 1, m_data.data() + 16); +#ifndef QT_NO_DEBUG // Gracefully fail in case of an error... GLuint error = glGetError(); if (error != GL_NO_ERROR) { @@ -137,6 +142,7 @@ void EtcTexture::bind() m_texture_id = 0; return; } +#endif m_uploaded = true; updateBindOptions(true); -- cgit v1.2.3 From ad5ae0d751e42a9ca6def5d98b2db740f195c16f Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 29 Apr 2013 15:01:32 +0200 Subject: Doc: Move example docs related to QtQml under the correct module This change moves 'Extending QML' qdoc file and the tutorials from examples/quick to examples/qml, which is the correct location for them. Change-Id: I24bd9dfa75baaab7bc8efe08489f09a7b65d98a6 Reviewed-by: Jerome Pasion Reviewed-by: Sze Howe Koh Reviewed-by: Alan Alpert --- examples/qml/doc/src/qml-extending.qdoc | 322 +++++++++++++++++++++ .../tutorials/extending/chapter1-basics/app.qml | 60 ++++ .../extending/chapter1-basics/chapter1-basics.pro | 5 + .../tutorials/extending/chapter1-basics/main.cpp | 57 ++++ .../extending/chapter1-basics/piechart.cpp | 79 +++++ .../tutorials/extending/chapter1-basics/piechart.h | 71 +++++ .../tutorials/extending/chapter2-methods/app.qml | 66 +++++ .../chapter2-methods/chapter2-methods.pro | 5 + .../tutorials/extending/chapter2-methods/main.cpp | 57 ++++ .../extending/chapter2-methods/piechart.cpp | 84 ++++++ .../extending/chapter2-methods/piechart.h | 84 ++++++ .../tutorials/extending/chapter3-bindings/app.qml | 74 +++++ .../chapter3-bindings/chapter3-bindings.pro | 5 + .../tutorials/extending/chapter3-bindings/main.cpp | 57 ++++ .../extending/chapter3-bindings/piechart.cpp | 86 ++++++ .../extending/chapter3-bindings/piechart.h | 84 ++++++ .../extending/chapter4-customPropertyTypes/app.qml | 60 ++++ .../chapter4-customPropertyTypes.pro | 7 + .../chapter4-customPropertyTypes/main.cpp | 66 +++++ .../chapter4-customPropertyTypes/piechart.cpp | 70 +++++ .../chapter4-customPropertyTypes/piechart.h | 78 +++++ .../chapter4-customPropertyTypes/pieslice.cpp | 66 +++++ .../chapter4-customPropertyTypes/pieslice.h | 66 +++++ .../extending/chapter5-listproperties/app.qml | 70 +++++ .../chapter5-listproperties.pro | 7 + .../extending/chapter5-listproperties/main.cpp | 58 ++++ .../extending/chapter5-listproperties/piechart.cpp | 72 +++++ .../extending/chapter5-listproperties/piechart.h | 75 +++++ .../extending/chapter5-listproperties/pieslice.cpp | 86 ++++++ .../extending/chapter5-listproperties/pieslice.h | 76 +++++ .../extending/chapter6-plugins/Charts/qmldir | 2 + .../tutorials/extending/chapter6-plugins/app.qml | 69 +++++ .../chapter6-plugins/chapter6-plugins.pro | 18 ++ .../extending/chapter6-plugins/chartsplugin.cpp | 53 ++++ .../extending/chapter6-plugins/chartsplugin.h | 57 ++++ .../extending/chapter6-plugins/piechart.cpp | 70 +++++ .../extending/chapter6-plugins/piechart.h | 69 +++++ .../extending/chapter6-plugins/pieslice.cpp | 86 ++++++ .../extending/chapter6-plugins/pieslice.h | 74 +++++ examples/qml/tutorials/extending/extending.pro | 10 + examples/quick/doc/src/qml-extending.qdoc | 322 --------------------- .../tutorials/extending/chapter1-basics/app.qml | 60 ---- .../extending/chapter1-basics/chapter1-basics.pro | 5 - .../tutorials/extending/chapter1-basics/main.cpp | 57 ---- .../extending/chapter1-basics/piechart.cpp | 79 ----- .../tutorials/extending/chapter1-basics/piechart.h | 71 ----- .../tutorials/extending/chapter2-methods/app.qml | 66 ----- .../chapter2-methods/chapter2-methods.pro | 5 - .../tutorials/extending/chapter2-methods/main.cpp | 57 ---- .../extending/chapter2-methods/piechart.cpp | 84 ------ .../extending/chapter2-methods/piechart.h | 84 ------ .../tutorials/extending/chapter3-bindings/app.qml | 74 ----- .../chapter3-bindings/chapter3-bindings.pro | 5 - .../tutorials/extending/chapter3-bindings/main.cpp | 57 ---- .../extending/chapter3-bindings/piechart.cpp | 86 ------ .../extending/chapter3-bindings/piechart.h | 84 ------ .../extending/chapter4-customPropertyTypes/app.qml | 60 ---- .../chapter4-customPropertyTypes.pro | 7 - .../chapter4-customPropertyTypes/main.cpp | 66 ----- .../chapter4-customPropertyTypes/piechart.cpp | 70 ----- .../chapter4-customPropertyTypes/piechart.h | 78 ----- .../chapter4-customPropertyTypes/pieslice.cpp | 66 ----- .../chapter4-customPropertyTypes/pieslice.h | 66 ----- .../extending/chapter5-listproperties/app.qml | 70 ----- .../chapter5-listproperties.pro | 7 - .../extending/chapter5-listproperties/main.cpp | 58 ---- .../extending/chapter5-listproperties/piechart.cpp | 72 ----- .../extending/chapter5-listproperties/piechart.h | 75 ----- .../extending/chapter5-listproperties/pieslice.cpp | 86 ------ .../extending/chapter5-listproperties/pieslice.h | 76 ----- .../extending/chapter6-plugins/Charts/qmldir | 2 - .../tutorials/extending/chapter6-plugins/app.qml | 69 ----- .../chapter6-plugins/chapter6-plugins.pro | 18 -- .../extending/chapter6-plugins/chartsplugin.cpp | 53 ---- .../extending/chapter6-plugins/chartsplugin.h | 57 ---- .../extending/chapter6-plugins/piechart.cpp | 70 ----- .../extending/chapter6-plugins/piechart.h | 69 ----- .../extending/chapter6-plugins/pieslice.cpp | 86 ------ .../extending/chapter6-plugins/pieslice.h | 74 ----- examples/quick/tutorials/extending/extending.pro | 10 - 80 files changed, 2561 insertions(+), 2561 deletions(-) create mode 100644 examples/qml/doc/src/qml-extending.qdoc create mode 100644 examples/qml/tutorials/extending/chapter1-basics/app.qml create mode 100644 examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro create mode 100644 examples/qml/tutorials/extending/chapter1-basics/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter1-basics/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter1-basics/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter2-methods/app.qml create mode 100644 examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro create mode 100644 examples/qml/tutorials/extending/chapter2-methods/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter2-methods/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter2-methods/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/app.qml create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/app.qml create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/app.qml create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/pieslice.h create mode 100644 examples/qml/tutorials/extending/extending.pro delete mode 100644 examples/quick/doc/src/qml-extending.qdoc delete mode 100644 examples/quick/tutorials/extending/chapter1-basics/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro delete mode 100644 examples/quick/tutorials/extending/chapter1-basics/main.cpp delete mode 100644 examples/quick/tutorials/extending/chapter1-basics/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter1-basics/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter2-methods/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro delete mode 100644 examples/quick/tutorials/extending/chapter2-methods/main.cpp delete mode 100644 examples/quick/tutorials/extending/chapter2-methods/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter2-methods/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter3-bindings/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro delete mode 100644 examples/quick/tutorials/extending/chapter3-bindings/main.cpp delete mode 100644 examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter3-bindings/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp delete mode 100644 examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/main.cpp delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp delete mode 100644 examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/app.qml delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/piechart.h delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp delete mode 100644 examples/quick/tutorials/extending/chapter6-plugins/pieslice.h delete mode 100644 examples/quick/tutorials/extending/extending.pro (limited to 'examples') diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc new file mode 100644 index 0000000000..9823a29b65 --- /dev/null +++ b/examples/qml/doc/src/qml-extending.qdoc @@ -0,0 +1,322 @@ +/**************************************************************************** +** +** 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 referenceexamples/adding +\title Extending QML - Adding Types Example +\brief Exporting C++ Classes +\ingroup qmlextendingexamples + +The Adding Types Example shows how to add a new object type, \c Person, to QML. +The \c Person type can be used from QML like this: + +\snippet referenceexamples/adding/example.qml 0 + +\section1 Declare the Person class + +All QML types map to C++ types. Here we declare a basic C++ Person class +with the two properties we want accessible on the QML type - name and shoeSize. +Although in this example we use the same name for the C++ class as the QML +type, the C++ class can be named differently, or appear in a namespace. + +\snippet referenceexamples/adding/person.h 0 + +\section1 Define the Person class + +\snippet referenceexamples/adding/person.cpp 0 + +The Person class implementation is quite basic. The property accessors simply +return members of the object instance. + +The \c main.cpp file also calls the \c qmlRegisterType() function to +register the \c Person type with QML as a type in the People library version 1.0, +and defines the mapping between the C++ and QML class names. + +\section1 Running the example + +The main.cpp file in the example includes a simple shell application that +loads and runs the QML snippet shown at the beginning of this page. +*/ + +/*! +\example referenceexamples/properties +\title Extending QML - Object and List Property Types Example +\brief Exporting C++ Properties +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Adding Types Example} +\endlist + +The Object and List Property Types example shows how to add object and list +properties in QML. This example adds a BirthdayParty type that specifies +a birthday party, consisting of a celebrant and a list of guests. People are +specified using the People QML type built in the previous example. + +\snippet referenceexamples/properties/example.qml 0 + +\section1 Declare the BirthdayParty + +The BirthdayParty class is declared like this: + +\snippet referenceexamples/properties/birthdayparty.h 0 +\snippet referenceexamples/properties/birthdayparty.h 1 +\snippet referenceexamples/properties/birthdayparty.h 2 +\snippet referenceexamples/properties/birthdayparty.h 3 + +The class contains a member to store the celebrant object, and also a +QList member. + +In QML, the type of a list properties - and the guests property is a list of +people - are all of type QDeclarativeListProperty. QDeclarativeListProperty is simple value +type that contains a set of function pointers. QML calls these function +pointers whenever it needs to read from, write to or otherwise interact with +the list. In addition to concrete lists like the people list used in this +example, the use of QDeclarativeListProperty allows for "virtual lists" and other advanced +scenarios. + +\section2 Define the BirthdayParty + +The implementation of BirthdayParty property accessors is straight forward. + +\snippet referenceexamples/properties/birthdayparty.cpp 0 + +\section1 Running the example + +The main.cpp file in the example includes a simple shell application that +loads and runs the QML snippet shown at the beginning of this page. +*/ + +/*! +\example referenceexamples/coercion +\title Extending QML - Inheritance and Coercion Example +\brief C++ Inheritance and Coercion +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +The Inheritance and Coercion Example shows how to use base classes to assign +types of more than one type to a property. It specializes the Person type +developed in the previous examples into two types - a \c Boy and a \c Girl. + +\snippet referenceexamples/coercion/example.qml 0 + +\section1 Declare Boy and Girl + +\snippet referenceexamples/coercion/person.h 0 + +The Person class remains unaltered in this example and the Boy and Girl C++ +classes are trivial extensions of it. As an example, the inheritance used here +is a little contrived, but in real applications it is likely that the two +extensions would add additional properties or modify the Person classes +behavior. + +\section2 Define People as a base class + +The implementation of the People class itself has not changed since the +previous example. However, as we have repurposed the People class as a common +base for Boy and Girl, we want to prevent it from being instantiated from QML +directly - an explicit Boy or Girl should be instantiated instead. + +\snippet referenceexamples/coercion/main.cpp 0 + +While we want to disallow instantiating Person from within QML, it still needs +to be registered with the QML engine, so that it can be used as a property type +and other types can be coerced to it. + +\section2 Define Boy and Girl + +The implementation of Boy and Girl are trivial. + +\snippet referenceexamples/coercion/person.cpp 1 + +All that is necessary is to implement the constructor, and to register the types +and their QML name with the QML engine. + +\section1 Running the example + +The BirthdayParty type has not changed since the previous example. The +celebrant and guests property still use the People type. + +\snippet referenceexamples/coercion/birthdayparty.h 0 + +However, as all three types, Person, Boy and Girl, have been registered with the +QML system, on assignment QML automatically (and type-safely) converts the Boy +and Girl objects into a Person. + +The main.cpp file in the example includes a simple shell application that +loads and runs the QML snippet shown at the beginning of this page. +*/ + +/*! +\example referenceexamples/default +\title Extending QML - Default Property Example +\brief Default Property +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +The Default Property Example is a minor modification of the +\l {Extending QML - Inheritance and Coercion Example} that simplifies the +specification of a BirthdayParty through the use of a default property. + +\snippet referenceexamples/default/example.qml 0 + +\section1 Declaring the BirthdayParty class + +The only difference between this example and the last, is the addition of the +\c DefaultProperty class info annotation. + +\snippet referenceexamples/default/birthdayparty.h 0 + +The default property specifies the property to assign to whenever an explicit +property is not specified, in the case of the BirthdayParty type the guest +property. It is purely a syntactic simplification, the behavior is identical +to specifying the property by name, but it can add a more natural feel in many +situations. The default property must be either an object or list property. + +\section1 Running the example + +The main.cpp file in the example includes a simple shell application that +loads and runs the QML snippet shown at the beginning of this page. +*/ + +/*! +\example referenceexamples/grouped +\title Extending QML - Grouped Properties Example +\brief Grouped Properties +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ + +/*! +\example referenceexamples/attached +\title Extending QML - Attached Properties Example +\brief Attached Properties +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Grouped Properties Example} +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ + +/*! +\example referenceexamples/signal +\title Extending QML - Signal Support Example +\brief Signal Support +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Attached Properties Example} +\li \l {Extending QML - Grouped Properties Example} +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ + +/*! +\example referenceexamples/methods +\title Extending QML - Methods Example +\brief Methods Support +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ + +/*! +\example referenceexamples/valuesource +\title Extending QML - Property Value Source Example +\brief Property Value Source +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Signal Support Example} +\li \l {Extending QML - Attached Properties Example} +\li \l {Extending QML - Grouped Properties Example} +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ + +/*! +\example referenceexamples/binding +\title Extending QML - Binding Example +\brief Binding +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Property Value Source Example} +\li \l {Extending QML - Signal Support Example} +\li \l {Extending QML - Attached Properties Example} +\li \l {Extending QML - Grouped Properties Example} +\li \l {Extending QML - Default Property Example} +\li \l {Extending QML - Inheritance and Coercion Example} +\li \l {Extending QML - Object and List Property Types Example} +\li \l {Extending QML - Adding Types Example} +\endlist + +*/ diff --git a/examples/qml/tutorials/extending/chapter1-basics/app.qml b/examples/qml/tutorials/extending/chapter1-basics/app.qml new file mode 100644 index 0000000000..d2f03daf83 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + name: "A simple pie chart" + color: "red" + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: aPieChart.name + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter1-basics/main.cpp b/examples/qml/tutorials/extending/chapter1-basics/main.cpp new file mode 100644 index 0000000000..d30628fd5a --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp new file mode 100644 index 0000000000..fa005781d8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include + +//![0] +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} +//![0] + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +//![1] +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); +} +//![1] + diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.h b/examples/qml/tutorials/extending/chapter1-basics/piechart.h new file mode 100644 index 0000000000..a6272453ce --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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: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 PIECHART_H +#define PIECHART_H + +//![0] +#include +#include + +class PieChart : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QString m_name; + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter2-methods/app.qml b/examples/qml/tutorials/extending/chapter2-methods/app.qml new file mode 100644 index 0000000000..06ecb3a09d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/app.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + color: "red" + + onChartCleared: console.log("The chart has been cleared") + } + + MouseArea { + anchors.fill: parent + onClicked: aPieChart.clearChart() + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to clear the chart" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter2-methods/main.cpp b/examples/qml/tutorials/extending/chapter2-methods/main.cpp new file mode 100644 index 0000000000..d30628fd5a --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp new file mode 100644 index 0000000000..ddcb1b3efd --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); +} + +//![0] +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); + + emit chartCleared(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.h b/examples/qml/tutorials/extending/chapter2-methods/piechart.h new file mode 100644 index 0000000000..86750197d2 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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: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 PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +//![2] + Q_INVOKABLE void clearChart(); + +signals: + void chartCleared(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter3-bindings/app.qml b/examples/qml/tutorials/extending/chapter3-bindings/app.qml new file mode 100644 index 0000000000..afb9e25c51 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/app.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + Row { + anchors.centerIn: parent + spacing: 20 + + PieChart { + id: chartA + width: 100; height: 100 + color: "red" + } + + PieChart { + id: chartB + width: 100; height: 100 + color: chartA.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: { chartA.color = "blue" } + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to change the chart color" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp new file mode 100644 index 0000000000..d30628fd5a --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: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$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp new file mode 100644 index 0000000000..a63035033f --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +//![0] +void PieChart::setColor(const QColor &color) +{ + if (color != m_color) { + m_color = color; + update(); // repaint with the new color + emit colorChanged(); + } +} +//![0] + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); +} + +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); +} diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h new file mode 100644 index 0000000000..25e82d66cc --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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: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 PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + + Q_INVOKABLE void clearChart(); + +//![2] +signals: + void colorChanged(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml new file mode 100644 index 0000000000..441b7f9b82 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } + } + + Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp new file mode 100644 index 0000000000..5b6e1cf451 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include "pieslice.h" + +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ +//![0] + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + +//![1] + qmlRegisterType("Charts", 1, 0, "PieSlice"); +//![1] + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); + +//![2] +} +//![2] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp new file mode 100644 index 0000000000..c1e2996e83 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +PieSlice *PieChart::pieSlice() const +{ + return m_pieSlice; +} + +//![0] +void PieChart::setPieSlice(PieSlice *pieSlice) +{ + m_pieSlice = pieSlice; + pieSlice->setParentItem(this); +} +//![0] + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h new file mode 100644 index 0000000000..9f0ea47eb9 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.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 documentation 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 PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + PieSlice *pieSlice() const; + void setPieSlice(PieSlice *pieSlice); +//![2] + +private: + QString m_name; + PieSlice *m_pieSlice; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp new file mode 100644 index 0000000000..2afe82048f --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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: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 "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h new file mode 100644 index 0000000000..4eef9bb6d1 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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: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 PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml new file mode 100644 index 0000000000..a57d1b833f --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp new file mode 100644 index 0000000000..f8826f6c31 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include "pieslice.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp new file mode 100644 index 0000000000..9fb61d9cd8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +//![0] +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice, 0, 0, 0); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h new file mode 100644 index 0000000000..55488f4900 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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: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 PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; +//![2] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp new file mode 100644 index 0000000000..52b409aa22 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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: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 "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h new file mode 100644 index 0000000000..f324179481 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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: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 PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) +//![0] + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir b/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir new file mode 100644 index 0000000000..d9e8471b3c --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/Charts/qmldir @@ -0,0 +1,2 @@ +module Charts +plugin chartsplugin diff --git a/examples/qml/tutorials/extending/chapter6-plugins/app.qml b/examples/qml/tutorials/extending/chapter6-plugins/app.qml new file mode 100644 index 0000000000..417fc6651a --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/app.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 Charts 1.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro new file mode 100644 index 0000000000..6bf44b4d15 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += plugin +QT += qml quick + +DESTDIR = Charts +TARGET = chartsplugin + +OBJECTS_DIR = tmp +MOC_DIR = tmp + +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h + +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..fea4c1aa85 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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: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 "chartsplugin.h" +//![0] +#include "piechart.h" +#include "pieslice.h" +#include + +void ChartsPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 1, 0, "PieChart"); + qmlRegisterType(uri, 1, 0, "PieSlice"); +} + +//![0] + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h new file mode 100644 index 0000000000..d768306967 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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: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 CHARTSPLUGIN_H +#define CHARTSPLUGIN_H + +//![0] +#include + +class ChartsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp new file mode 100644 index 0000000000..295bb8961d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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: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 "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice, 0, 0, 0); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.h b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h new file mode 100644 index 0000000000..b37bcdd411 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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: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 PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp new file mode 100644 index 0000000000..52b409aa22 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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: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 "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::Antialiasing, true); + painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h new file mode 100644 index 0000000000..0b488b4835 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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: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 PIESLICE_H +#define PIESLICE_H + +#include +#include + +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/extending.pro b/examples/qml/tutorials/extending/extending.pro new file mode 100644 index 0000000000..967473fda0 --- /dev/null +++ b/examples/qml/tutorials/extending/extending.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-listproperties \ + chapter6-plugins + diff --git a/examples/quick/doc/src/qml-extending.qdoc b/examples/quick/doc/src/qml-extending.qdoc deleted file mode 100644 index ee2dd06623..0000000000 --- a/examples/quick/doc/src/qml-extending.qdoc +++ /dev/null @@ -1,322 +0,0 @@ -/**************************************************************************** -** -** 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 referenceexamples/adding -\title Extending QML - Adding Types Example -\brief Exporting C++ Classes -\ingroup qmlextendingexamples - -The Adding Types Example shows how to add a new object type, \c Person, to QML. -The \c Person type can be used from QML like this: - -\snippet qml/referenceexamples/adding/example.qml 0 - -\section1 Declare the Person class - -All QML types map to C++ types. Here we declare a basic C++ Person class -with the two properties we want accessible on the QML type - name and shoeSize. -Although in this example we use the same name for the C++ class as the QML -type, the C++ class can be named differently, or appear in a namespace. - -\snippet qml/referenceexamples/adding/person.h 0 - -\section1 Define the Person class - -\snippet qml/referenceexamples/adding/person.cpp 0 - -The Person class implementation is quite basic. The property accessors simply -return members of the object instance. - -The \c main.cpp file also calls the \c qmlRegisterType() function to -register the \c Person type with QML as a type in the People library version 1.0, -and defines the mapping between the C++ and QML class names. - -\section1 Running the example - -The main.cpp file in the example includes a simple shell application that -loads and runs the QML snippet shown at the beginning of this page. -*/ - -/*! -\example referenceexamples/properties -\title Extending QML - Object and List Property Types Example -\brief Exporting C++ Properties -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Adding Types Example} -\endlist - -The Object and List Property Types example shows how to add object and list -properties in QML. This example adds a BirthdayParty type that specifies -a birthday party, consisting of a celebrant and a list of guests. People are -specified using the People QML type built in the previous example. - -\snippet qml/referenceexamples/properties/example.qml 0 - -\section1 Declare the BirthdayParty - -The BirthdayParty class is declared like this: - -\snippet qml/referenceexamples/properties/birthdayparty.h 0 -\snippet qml/referenceexamples/properties/birthdayparty.h 1 -\snippet qml/referenceexamples/properties/birthdayparty.h 2 -\snippet qml/referenceexamples/properties/birthdayparty.h 3 - -The class contains a member to store the celebrant object, and also a -QList member. - -In QML, the type of a list properties - and the guests property is a list of -people - are all of type QDeclarativeListProperty. QDeclarativeListProperty is simple value -type that contains a set of function pointers. QML calls these function -pointers whenever it needs to read from, write to or otherwise interact with -the list. In addition to concrete lists like the people list used in this -example, the use of QDeclarativeListProperty allows for "virtual lists" and other advanced -scenarios. - -\section2 Define the BirthdayParty - -The implementation of BirthdayParty property accessors is straight forward. - -\snippet qml/referenceexamples/properties/birthdayparty.cpp 0 - -\section1 Running the example - -The main.cpp file in the example includes a simple shell application that -loads and runs the QML snippet shown at the beginning of this page. -*/ - -/*! -\example referenceexamples/coercion -\title Extending QML - Inheritance and Coercion Example -\brief C++ Inheritance and Coercion -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -The Inheritance and Coercion Example shows how to use base classes to assign -types of more than one type to a property. It specializes the Person type -developed in the previous examples into two types - a \c Boy and a \c Girl. - -\snippet qml/referenceexamples/coercion/example.qml 0 - -\section1 Declare Boy and Girl - -\snippet qml/referenceexamples/coercion/person.h 0 - -The Person class remains unaltered in this example and the Boy and Girl C++ -classes are trivial extensions of it. As an example, the inheritance used here -is a little contrived, but in real applications it is likely that the two -extensions would add additional properties or modify the Person classes -behavior. - -\section2 Define People as a base class - -The implementation of the People class itself has not changed since the -previous example. However, as we have repurposed the People class as a common -base for Boy and Girl, we want to prevent it from being instantiated from QML -directly - an explicit Boy or Girl should be instantiated instead. - -\snippet qml/referenceexamples/coercion/main.cpp 0 - -While we want to disallow instantiating Person from within QML, it still needs -to be registered with the QML engine, so that it can be used as a property type -and other types can be coerced to it. - -\section2 Define Boy and Girl - -The implementation of Boy and Girl are trivial. - -\snippet qml/referenceexamples/coercion/person.cpp 1 - -All that is necessary is to implement the constructor, and to register the types -and their QML name with the QML engine. - -\section1 Running the example - -The BirthdayParty type has not changed since the previous example. The -celebrant and guests property still use the People type. - -\snippet qml/referenceexamples/coercion/birthdayparty.h 0 - -However, as all three types, Person, Boy and Girl, have been registered with the -QML system, on assignment QML automatically (and type-safely) converts the Boy -and Girl objects into a Person. - -The main.cpp file in the example includes a simple shell application that -loads and runs the QML snippet shown at the beginning of this page. -*/ - -/*! -\example referenceexamples/default -\title Extending QML - Default Property Example -\brief Default Property -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -The Default Property Example is a minor modification of the -\l {Extending QML - Inheritance and Coercion Example} that simplifies the -specification of a BirthdayParty through the use of a default property. - -\snippet qml/referenceexamples/default/example.qml 0 - -\section1 Declaring the BirthdayParty class - -The only difference between this example and the last, is the addition of the -\c DefaultProperty class info annotation. - -\snippet qml/referenceexamples/default/birthdayparty.h 0 - -The default property specifies the property to assign to whenever an explicit -property is not specified, in the case of the BirthdayParty type the guest -property. It is purely a syntactic simplification, the behavior is identical -to specifying the property by name, but it can add a more natural feel in many -situations. The default property must be either an object or list property. - -\section1 Running the example - -The main.cpp file in the example includes a simple shell application that -loads and runs the QML snippet shown at the beginning of this page. -*/ - -/*! -\example referenceexamples/grouped -\title Extending QML - Grouped Properties Example -\brief Grouped Properties -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ - -/*! -\example referenceexamples/attached -\title Extending QML - Attached Properties Example -\brief Attached Properties -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Grouped Properties Example} -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ - -/*! -\example referenceexamples/signal -\title Extending QML - Signal Support Example -\brief Signal Support -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Attached Properties Example} -\li \l {Extending QML - Grouped Properties Example} -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ - -/*! -\example referenceexamples/methods -\title Extending QML - Methods Example -\brief Methods Support -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ - -/*! -\example referenceexamples/valuesource -\title Extending QML - Property Value Source Example -\brief Property Value Source -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Signal Support Example} -\li \l {Extending QML - Attached Properties Example} -\li \l {Extending QML - Grouped Properties Example} -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ - -/*! -\example referenceexamples/binding -\title Extending QML - Binding Example -\brief Binding -\ingroup qmlextendingexamples - -This example builds on: -\list -\li \l {Extending QML - Property Value Source Example} -\li \l {Extending QML - Signal Support Example} -\li \l {Extending QML - Attached Properties Example} -\li \l {Extending QML - Grouped Properties Example} -\li \l {Extending QML - Default Property Example} -\li \l {Extending QML - Inheritance and Coercion Example} -\li \l {Extending QML - Object and List Property Types Example} -\li \l {Extending QML - Adding Types Example} -\endlist - -*/ diff --git a/examples/quick/tutorials/extending/chapter1-basics/app.qml b/examples/quick/tutorials/extending/chapter1-basics/app.qml deleted file mode 100644 index d2f03daf83..0000000000 --- a/examples/quick/tutorials/extending/chapter1-basics/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - name: "A simple pie chart" - color: "red" - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: aPieChart.name - } -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro deleted file mode 100644 index 8ed66f8b66..0000000000 --- a/examples/quick/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += qml quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/quick/tutorials/extending/chapter1-basics/main.cpp b/examples/quick/tutorials/extending/chapter1-basics/main.cpp deleted file mode 100644 index d30628fd5a..0000000000 --- a/examples/quick/tutorials/extending/chapter1-basics/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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: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$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp b/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp deleted file mode 100644 index fa005781d8..0000000000 --- a/examples/quick/tutorials/extending/chapter1-basics/piechart.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include - -//![0] -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} -//![0] - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -//![1] -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); -} -//![1] - diff --git a/examples/quick/tutorials/extending/chapter1-basics/piechart.h b/examples/quick/tutorials/extending/chapter1-basics/piechart.h deleted file mode 100644 index a6272453ce..0000000000 --- a/examples/quick/tutorials/extending/chapter1-basics/piechart.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -//![0] -#include -#include - -class PieChart : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QString m_name; - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter2-methods/app.qml b/examples/quick/tutorials/extending/chapter2-methods/app.qml deleted file mode 100644 index 06ecb3a09d..0000000000 --- a/examples/quick/tutorials/extending/chapter2-methods/app.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - color: "red" - - onChartCleared: console.log("The chart has been cleared") - } - - MouseArea { - anchors.fill: parent - onClicked: aPieChart.clearChart() - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to clear the chart" - } -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro deleted file mode 100644 index 8ed66f8b66..0000000000 --- a/examples/quick/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += qml quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/quick/tutorials/extending/chapter2-methods/main.cpp b/examples/quick/tutorials/extending/chapter2-methods/main.cpp deleted file mode 100644 index d30628fd5a..0000000000 --- a/examples/quick/tutorials/extending/chapter2-methods/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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: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$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp b/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp deleted file mode 100644 index ddcb1b3efd..0000000000 --- a/examples/quick/tutorials/extending/chapter2-methods/piechart.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); -} - -//![0] -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); - - emit chartCleared(); -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter2-methods/piechart.h b/examples/quick/tutorials/extending/chapter2-methods/piechart.h deleted file mode 100644 index 86750197d2..0000000000 --- a/examples/quick/tutorials/extending/chapter2-methods/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -//![2] - Q_INVOKABLE void clearChart(); - -signals: - void chartCleared(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter3-bindings/app.qml b/examples/quick/tutorials/extending/chapter3-bindings/app.qml deleted file mode 100644 index afb9e25c51..0000000000 --- a/examples/quick/tutorials/extending/chapter3-bindings/app.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - Row { - anchors.centerIn: parent - spacing: 20 - - PieChart { - id: chartA - width: 100; height: 100 - color: "red" - } - - PieChart { - id: chartB - width: 100; height: 100 - color: chartA.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: { chartA.color = "blue" } - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to change the chart color" - } -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro deleted file mode 100644 index 8ed66f8b66..0000000000 --- a/examples/quick/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += qml quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/quick/tutorials/extending/chapter3-bindings/main.cpp b/examples/quick/tutorials/extending/chapter3-bindings/main.cpp deleted file mode 100644 index d30628fd5a..0000000000 --- a/examples/quick/tutorials/extending/chapter3-bindings/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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: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$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp deleted file mode 100644 index a63035033f..0000000000 --- a/examples/quick/tutorials/extending/chapter3-bindings/piechart.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -//![0] -void PieChart::setColor(const QColor &color) -{ - if (color != m_color) { - m_color = color; - update(); // repaint with the new color - emit colorChanged(); - } -} -//![0] - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); -} - -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); -} diff --git a/examples/quick/tutorials/extending/chapter3-bindings/piechart.h b/examples/quick/tutorials/extending/chapter3-bindings/piechart.h deleted file mode 100644 index 25e82d66cc..0000000000 --- a/examples/quick/tutorials/extending/chapter3-bindings/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - - Q_INVOKABLE void clearChart(); - -//![2] -signals: - void colorChanged(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml deleted file mode 100644 index 441b7f9b82..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: chart - anchors.centerIn: parent - width: 100; height: 100 - - pieSlice: PieSlice { - anchors.fill: parent - color: "red" - } - } - - Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro deleted file mode 100644 index 23eb222ea3..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += qml quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp deleted file mode 100644 index 5b6e1cf451..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include "pieslice.h" - -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ -//![0] - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - -//![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); -//![1] - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); - -//![2] -} -//![2] diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp deleted file mode 100644 index c1e2996e83..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -PieSlice *PieChart::pieSlice() const -{ - return m_pieSlice; -} - -//![0] -void PieChart::setPieSlice(PieSlice *pieSlice) -{ - m_pieSlice = pieSlice; - pieSlice->setParentItem(this); -} -//![0] - diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h deleted file mode 100644 index 9f0ea47eb9..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/piechart.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - PieSlice *pieSlice() const; - void setPieSlice(PieSlice *pieSlice); -//![2] - -private: - QString m_name; - PieSlice *m_pieSlice; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp deleted file mode 100644 index 2afe82048f..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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: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 "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 90 * 16, 290 * 16); -} - diff --git a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h deleted file mode 100644 index 4eef9bb6d1..0000000000 --- a/examples/quick/tutorials/extending/chapter4-customPropertyTypes/pieslice.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/app.qml b/examples/quick/tutorials/extending/chapter5-listproperties/app.qml deleted file mode 100644 index a57d1b833f..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/app.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro deleted file mode 100644 index 23eb222ea3..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += qml quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp deleted file mode 100644 index f8826f6c31..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include "pieslice.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp deleted file mode 100644 index 9fb61d9cd8..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -//![0] -QQmlListProperty PieChart::slices() -{ - return QQmlListProperty(this, 0, &PieChart::append_slice, 0, 0, 0); -} - -void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} -//![0] diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h b/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h deleted file mode 100644 index 55488f4900..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/piechart.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty slices READ slices) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - QQmlListProperty slices(); - -private: - static void append_slice(QQmlListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; -//![2] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp deleted file mode 100644 index 52b409aa22..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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: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 "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h deleted file mode 100644 index f324179481..0000000000 --- a/examples/quick/tutorials/extending/chapter5-listproperties/pieslice.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) -//![0] - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir b/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir deleted file mode 100644 index d9e8471b3c..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module Charts -plugin chartsplugin diff --git a/examples/quick/tutorials/extending/chapter6-plugins/app.qml b/examples/quick/tutorials/extending/chapter6-plugins/app.qml deleted file mode 100644 index 417fc6651a..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/app.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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 Charts 1.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro deleted file mode 100644 index 6bf44b4d15..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -QT += qml quick - -DESTDIR = Charts -TARGET = chartsplugin - -OBJECTS_DIR = tmp -MOC_DIR = tmp - -HEADERS += piechart.h \ - pieslice.h \ - chartsplugin.h - -SOURCES += piechart.cpp \ - pieslice.cpp \ - chartsplugin.cpp - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp deleted file mode 100644 index fea4c1aa85..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** 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: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 "chartsplugin.h" -//![0] -#include "piechart.h" -#include "pieslice.h" -#include - -void ChartsPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); -} - -//![0] - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h deleted file mode 100644 index d768306967..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/chartsplugin.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** 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: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 CHARTSPLUGIN_H -#define CHARTSPLUGIN_H - -//![0] -#include - -class ChartsPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp deleted file mode 100644 index 295bb8961d..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/piechart.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** 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: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 "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QQmlListProperty PieChart::slices() -{ - return QQmlListProperty(this, 0, &PieChart::append_slice, 0, 0, 0); -} - -void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} diff --git a/examples/quick/tutorials/extending/chapter6-plugins/piechart.h b/examples/quick/tutorials/extending/chapter6-plugins/piechart.h deleted file mode 100644 index b37bcdd411..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/piechart.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty slices READ slices) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QQmlListProperty slices(); - -private: - static void append_slice(QQmlListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; - -#endif - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp deleted file mode 100644 index 52b409aa22..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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: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 "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h b/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h deleted file mode 100644 index 0b488b4835..0000000000 --- a/examples/quick/tutorials/extending/chapter6-plugins/pieslice.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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: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 PIESLICE_H -#define PIESLICE_H - -#include -#include - -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/quick/tutorials/extending/extending.pro b/examples/quick/tutorials/extending/extending.pro deleted file mode 100644 index 967473fda0..0000000000 --- a/examples/quick/tutorials/extending/extending.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - chapter1-basics \ - chapter2-methods \ - chapter3-bindings \ - chapter4-customPropertyTypes \ - chapter5-listproperties \ - chapter6-plugins - -- cgit v1.2.3 From 1d594c4e10caa9258f00bb7bcf61c307d027633b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 21 Feb 2013 09:16:56 +0100 Subject: Add new Item.Screen properties to screenInfo example Also removed the rotation animation which doesn't seem useful. (On most platforms the content will auto-rotate anyway.) Change-Id: Ia6ca1046fc2162a13be5c26cbf5d2b698ffa2367 Reviewed-by: Richard Moe Gustavsen --- examples/quick/window/screen/screenInfo.qml | 69 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'examples') diff --git a/examples/quick/window/screen/screenInfo.qml b/examples/quick/window/screen/screenInfo.qml index 8f60d83933..33fbc5d88e 100644 --- a/examples/quick/window/screen/screenInfo.qml +++ b/examples/quick/window/screen/screenInfo.qml @@ -38,53 +38,54 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window +import QtQuick 2.1 +import QtQuick.Window 2.1 Item { id: root width: 400 height: 200 - Item { - id: main - state: "orientation " + Window.Screen.orientation - property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation - property real baseWidth: landscapeWindow ? root.height : root.width - property real baseHeight: landscapeWindow ? root.width : root.height - property real rotationDelta: landscapeWindow ? -90 : 0 + function orientationToString(o) { + switch (o) { + case Qt.PrimaryOrientation: + return "primary"; + case Qt.PortraitOrientation: + return "portrait"; + case Qt.LandscapeOrientation: + return "landscape"; + case Qt.InvertedPortraitOrientation: + return "inverted portrait"; + case Qt.InvertedLandscapeOrientation: + return "inverted landscape"; + } + return "unknown"; + } - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight + Grid { anchors.centerIn: parent + columns: 2 + spacing: 8 Text { - text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation - anchors.centerIn:parent + text: "Screen \"" + Screen.name + "\":" + font.bold: true } + Item { width: 1; height: 1 } // spacer + Text { text: "dimensions" } + Text { text: Screen.width + "x" + Screen.height } - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] + Text { text: "logical pixel density" } + Text { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm" } - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } + Text { text: "available virtual desktop" } + Text { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight } + + Text { text: "orientation" } + Text { text: orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" } + + Text { text: "primary orientation" } + Text { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" } } } -- cgit v1.2.3 From f314fd4327167dd6af88f9b7050b34144d75241d Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Tue, 30 Apr 2013 23:38:07 +0800 Subject: Doc: Move full apps from "qtquickexamples" to "qtquickdemos" "qtquickexamples" is for illustrating code usage; "qtquickdemos" is for showcasing fully-functional apps. Renamed titles and screenshots to match the other demos. Also, attempt to make the descriptions sound more interesting. Change-Id: I2fb43c5d32f24159cd39564576d4ebd76b2cbeaa Reviewed-by: Alan Alpert Reviewed-by: Jerome Pasion --- .../calqlatr/doc/images/qml-calqlatr-demo-small.png | Bin 37120 -> 0 bytes .../demos/calqlatr/doc/images/qtquick-demo-calqlatr.png | Bin 0 -> 37120 bytes examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc | 10 ++++------ .../doc/images/qml-photosurface-example-small.png | Bin 47271 -> 0 bytes .../doc/images/qtquick-demo-photosurface-small.png | Bin 0 -> 47271 bytes .../quick/demos/photosurface/doc/src/photosurface.qdoc | 8 ++++---- 6 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png create mode 100644 examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png delete mode 100644 examples/quick/demos/photosurface/doc/images/qml-photosurface-example-small.png create mode 100644 examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png (limited to 'examples') diff --git a/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png b/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png deleted file mode 100644 index af67f63dd1..0000000000 Binary files a/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png and /dev/null differ diff --git a/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png b/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png new file mode 100644 index 0000000000..af67f63dd1 Binary files /dev/null and b/examples/quick/demos/calqlatr/doc/images/qtquick-demo-calqlatr.png differ diff --git a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc index d812da4982..7217c7d806 100644 --- a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc +++ b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc @@ -26,13 +26,11 @@ ****************************************************************************/ /*! - \title QML Demo - Calqlatr + \title Qt Quick Demo - Calqlatr + \ingroup qtquickdemos \example demos/calqlatr - \brief This is an example calculator written in QML. - \image qml-calqlatr-demo-small.png - \ingroup qtquickexamples - - This demo implements a simple calculator app, designed for portrait devices. + \brief A simple calculator app, designed for portrait devices. + \image qtquick-demo-calqlatr.png This app has the logic implemented in Javascipt and the appearance implemented in QML. */ diff --git a/examples/quick/demos/photosurface/doc/images/qml-photosurface-example-small.png b/examples/quick/demos/photosurface/doc/images/qml-photosurface-example-small.png deleted file mode 100644 index a0cd823999..0000000000 Binary files a/examples/quick/demos/photosurface/doc/images/qml-photosurface-example-small.png and /dev/null differ diff --git a/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png b/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png new file mode 100644 index 0000000000..a0cd823999 Binary files /dev/null and b/examples/quick/demos/photosurface/doc/images/qtquick-demo-photosurface-small.png differ diff --git a/examples/quick/demos/photosurface/doc/src/photosurface.qdoc b/examples/quick/demos/photosurface/doc/src/photosurface.qdoc index 343acce14a..48f8e8a14b 100644 --- a/examples/quick/demos/photosurface/doc/src/photosurface.qdoc +++ b/examples/quick/demos/photosurface/doc/src/photosurface.qdoc @@ -26,11 +26,11 @@ ****************************************************************************/ /*! - \title QML Demo - Photo Surface + \title Qt Quick Demo - Photo Surface + \ingroup qtquickdemos \example demos/photosurface - \brief This is the typical touch photo-shuffling example written in QML. - \image qml-photosurface-example-small.png - \ingroup qtquickexamples + \brief A touch-based app for shuffling photos around a virtual surface. + \image qtquick-demo-photosurface-small.png This example demonstrates how to handle dragging, rotation and pinch zooming within the same item using a PinchArea containing a MouseArea. -- cgit v1.2.3 From 2f97b8ccde72628c29664c4a10c75336e3fead7b Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 5 May 2013 00:31:03 +0800 Subject: Doc: Make the titles of example pages consistent Most of the example titles have either a "Qt Quick Examples -" prefix or a "Scene Graph -" prefix. Also fixed a typo ("Scenegraph" -> "Scene Graph") Change-Id: Ibeb25d88d1888be3fb004a9ad95dc7ccbfeed7e3 Reviewed-by: Jerome Pasion --- examples/quick/imageelements/doc/src/imageelements.qdoc | 2 +- examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc | 4 ++-- examples/quick/shadereffects/doc/src/shadereffects.qdoc | 2 +- examples/quick/text/doc/src/text.qdoc | 2 +- .../quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/quick/imageelements/doc/src/imageelements.qdoc b/examples/quick/imageelements/doc/src/imageelements.qdoc index 5abcece4fc..c9c2259cfe 100644 --- a/examples/quick/imageelements/doc/src/imageelements.qdoc +++ b/examples/quick/imageelements/doc/src/imageelements.qdoc @@ -25,7 +25,7 @@ ** ****************************************************************************/ /*! - \title QML Examples - Image Elements + \title Qt Quick Examples - Image Elements \example imageelements \brief This is a collection of QML examples relating to image types. \image qml-imageelements-example.png diff --git a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc index 9450c19259..11fd073a54 100644 --- a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc +++ b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc @@ -27,7 +27,7 @@ /*! - \title Scenegraph Painted Item Example + \title Scene Graph - Painted Item \brief Shows how to implement QPainter-based custom scenegraph items. \example customitems/painteditem \ingroup qtquickexamples @@ -72,7 +72,7 @@ \snippet quick/customitems/painteditem/textballoon.cpp 0 Then we implement the \c paint() function which is automatically called by - the Scenegraph framework to paint the contents of the item. The function + the Scene Graph framework to paint the contents of the item. The function paints the item in local coordinates. \snippet quick/customitems/painteditem/textballoon.cpp 1 diff --git a/examples/quick/shadereffects/doc/src/shadereffects.qdoc b/examples/quick/shadereffects/doc/src/shadereffects.qdoc index 6f6311a5ae..e0f03cbc2b 100644 --- a/examples/quick/shadereffects/doc/src/shadereffects.qdoc +++ b/examples/quick/shadereffects/doc/src/shadereffects.qdoc @@ -25,7 +25,7 @@ ** ****************************************************************************/ /*! - \title QML Examples - Shader Effects + \title Qt Quick Examples - Shader Effects \example shadereffects \image qml-shadereffects-example.png \brief This is a shader effects example diff --git a/examples/quick/text/doc/src/text.qdoc b/examples/quick/text/doc/src/text.qdoc index 1f173ac843..c4ea3137d6 100644 --- a/examples/quick/text/doc/src/text.qdoc +++ b/examples/quick/text/doc/src/text.qdoc @@ -25,7 +25,7 @@ ** ****************************************************************************/ /*! - \title QML Examples - Text + \title Qt Quick Examples - Text \example text \brief This is a collection of QML examples relating to text \image qml-text-example.png diff --git a/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc b/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc index 1ebe7eb9f5..05597b7e2c 100644 --- a/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc +++ b/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc @@ -28,7 +28,7 @@ /*! \page qmlexampletoggleswitch.html tutorial -\title QML Example - Toggle Switch +\title Qt Quick Examples - Toggle Switch \brief A reusable switch component made in QML \ingroup qtquickexamples -- cgit v1.2.3 From 0d4512c8bdfd7e1131c8633e8ad0d37c2dbc4ab3 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sun, 5 May 2013 08:08:41 +0800 Subject: Doc: Fix some broken snippet paths Change-Id: Ib79bfbea402b86e26a503de47383522317ca906b Reviewed-by: Jerome Pasion --- .../quick/accessibility/doc/src/accessibility.qdoc | 4 +-- examples/quick/animation/doc/src/animation.qdoc | 20 ++++++------- examples/quick/canvas/doc/src/canvas.qdoc | 10 +++---- .../quick/draganddrop/doc/src/draganddrop.qdoc | 10 +++---- .../quick/imageelements/doc/src/imageelements.qdoc | 8 ++--- examples/quick/mousearea/doc/src/mousearea.qdoc | 4 +-- .../textballoons/doc/src/textballoons.qdoc | 10 +++---- .../particles/affectors/doc/src/affectors.qdoc | 34 +++++++++++----------- .../customparticle/doc/src/customparticle.qdoc | 10 +++---- .../quick/particles/emitters/doc/src/emitters.qdoc | 12 ++++---- .../imageparticle/doc/src/imageparticle.qdoc | 14 ++++----- .../quick/particles/system/doc/src/system.qdoc | 10 +++---- .../quick/positioners/doc/src/positioners.qdoc | 8 ++--- .../quick/shadereffects/doc/src/shadereffects.qdoc | 8 ++--- examples/quick/text/doc/src/text.qdoc | 16 +++++----- examples/quick/threading/doc/src/threading.qdoc | 10 +++---- .../touchinteraction/doc/src/touchinteraction.qdoc | 10 +++---- .../slideswitch/doc/src/example-slideswitch.qdoc | 18 ++++++------ examples/quick/views/doc/src/views.qdoc | 30 +++++++++---------- 19 files changed, 123 insertions(+), 123 deletions(-) (limited to 'examples') diff --git a/examples/quick/accessibility/doc/src/accessibility.qdoc b/examples/quick/accessibility/doc/src/accessibility.qdoc index a637383324..0281ffff4e 100644 --- a/examples/quick/accessibility/doc/src/accessibility.qdoc +++ b/examples/quick/accessibility/doc/src/accessibility.qdoc @@ -33,8 +33,8 @@ Types in this example are augmented with meta-data for accessiblity systems. For example, the button identifies itself and its functionality to the accessibility system: - \snippet quick/accessibility/content/Button.qml button + \snippet accessibility/content/Button.qml button As do Text types inside the example: - \snippet quick/accessibility/accessibility.qml text + \snippet accessibility/accessibility.qml text */ diff --git a/examples/quick/animation/doc/src/animation.qdoc b/examples/quick/animation/doc/src/animation.qdoc index 064717835d..734b1af118 100644 --- a/examples/quick/animation/doc/src/animation.qdoc +++ b/examples/quick/animation/doc/src/animation.qdoc @@ -36,37 +36,37 @@ a small QML file emphasizing a particular type or feature. ColorAnimation demonstrates using a color animation to fade a sky from day to night. - \snippet quick/animation/basics/color-animation.qml 0 + \snippet animation/basics/color-animation.qml 0 PropertyAnimation demonstrates using a number animation to bounce a circle up and down. - \snippet quick/animation/basics/property-animation.qml 0 + \snippet animation/basics/property-animation.qml 0 Behaviors demonstrates using behaviors to animate moving a rectangle to whereever you click. - \snippet quick/animation/behaviors/behavior-example.qml 0 + \snippet animation/behaviors/behavior-example.qml 0 Wiggly Text demonstrates using more complex behaviors to animate and wiggle some text around as you drag it. It does this by assigning a complex binding to each letter: - \snippet quick/animation/behaviors/wigglytext.qml 0 + \snippet animation/behaviors/wigglytext.qml 0 Then, it uses behaviors to animate the movement on each letter: - \snippet quick/animation/behaviors/wigglytext.qml 1 + \snippet animation/behaviors/wigglytext.qml 1 Tv Tennis demonstrates using more complex behaviors to get paddles following a ball for an infinite game. Again a binding which depends on other values is applied to the position and a behavior provided the animation. - \snippet quick/animation/behaviors/tvtennis.qml 0 + \snippet animation/behaviors/tvtennis.qml 0 Easing Curves shows off all the easing curves available in Qt Quick animations. States demonstrates how the properties of an item can vary between states. It defines several states: - \snippet quick/animation/states/states.qml 0 + \snippet animation/states/states.qml 0 Note that there is also the implicit 'base state' from properties set directly on objects. Transitions takes the States example and animates the property changes by setting transitions: - \snippet quick/animation/states/transitions.qml 0 + \snippet animation/states/transitions.qml 0 PathAnimation animates an image along a beizer curve using a PathAnimation. - \snippet quick/animation/pathanimation/pathanimation.qml 0 + \snippet animation/pathanimation/pathanimation.qml 0 PathInterpolator animates an image along the same beizer curve, using a PathInterpolator instead. - \snippet quick/animation/pathinterpolator/pathinterpolator.qml 0 + \snippet animation/pathinterpolator/pathinterpolator.qml 0 */ diff --git a/examples/quick/canvas/doc/src/canvas.qdoc b/examples/quick/canvas/doc/src/canvas.qdoc index 638d25d83f..f3eb78e1d1 100644 --- a/examples/quick/canvas/doc/src/canvas.qdoc +++ b/examples/quick/canvas/doc/src/canvas.qdoc @@ -36,12 +36,12 @@ a small QML file emphasizing a particular type or feature. Red heart demonstrates using a bezierCurve API to stroke and fill a red heart. - \snippet quick/canvas/bezierCurve/bezierCurve.qml 0 + \snippet canvas/bezierCurve/bezierCurve.qml 0 Talk bubble demonstrates using a quadraticCurveTo API to stroke and fill a customized talk bubble: - \snippet quick/canvas/quadraticCurveTo/quadraticCurveTo.qml 0 + \snippet canvas/quadraticCurveTo/quadraticCurveTo.qml 0 This example also demonstrates the fillText API: - \snippet quick/canvas/quadraticCurveTo/quadraticCurveTo.qml 1 + \snippet canvas/quadraticCurveTo/quadraticCurveTo.qml 1 Squircle demonstrates using a collection of simple moveTo/lineTo path APIs to draw a smooth squircle. @@ -50,9 +50,9 @@ Smile face demonstrates using several complex path APIs to draw an fill a smile face. Clip demonstrates using clip API to clip a given image. - \snippet quick/canvas/clip/clip.qml 0 + \snippet canvas/clip/clip.qml 0 Tiger demonstrates using SVG path API to draw a tiger with a collection of SVG path strings. - \snippet quick/canvas/tiger/tiger.qml 0 + \snippet canvas/tiger/tiger.qml 0 */ diff --git a/examples/quick/draganddrop/doc/src/draganddrop.qdoc b/examples/quick/draganddrop/doc/src/draganddrop.qdoc index 381fdd1299..2c62e271e6 100644 --- a/examples/quick/draganddrop/doc/src/draganddrop.qdoc +++ b/examples/quick/draganddrop/doc/src/draganddrop.qdoc @@ -37,12 +37,12 @@ It has a DragTile component which uses a MouseArea to move an item when dragged: - \snippet quick/draganddrop/tiles/DragTile.qml 0 - \snippet quick/draganddrop/tiles/DragTile.qml 1 + \snippet draganddrop/tiles/DragTile.qml 0 + \snippet draganddrop/tiles/DragTile.qml 1 And a DropTile component which the dragged tiles can be dropped onto: - \snippet quick/draganddrop/tiles/DropTile.qml 0 + \snippet draganddrop/tiles/DropTile.qml 0 The keys property of the DropArea will only allow an item with matching key in it's Drag.keys property to be dropped on it. @@ -52,7 +52,7 @@ It uses a DelegateModel to move a delegate item to the position of another item it is dragged over. - \snippet quick/draganddrop/views/gridview.qml 0 - \snippet quick/draganddrop/views/gridview.qml 1 + \snippet draganddrop/views/gridview.qml 0 + \snippet draganddrop/views/gridview.qml 1 */ diff --git a/examples/quick/imageelements/doc/src/imageelements.qdoc b/examples/quick/imageelements/doc/src/imageelements.qdoc index c9c2259cfe..d88201faf9 100644 --- a/examples/quick/imageelements/doc/src/imageelements.qdoc +++ b/examples/quick/imageelements/doc/src/imageelements.qdoc @@ -40,20 +40,20 @@ 'Shadows' shows how to create a drop shadow effect for a rectangular item using a BorderImage: - \snippet quick/imageelements/content/ShadowRectangle.qml shadow + \snippet imageelements/content/ShadowRectangle.qml shadow 'AnimatedSprite' shows how to display a simple animation using an AnimatedSprite object: - \snippet quick/imageelements/animatedsprite.qml sprite + \snippet imageelements/animatedsprite.qml sprite The sprite animation will loop 3 times. 'SpriteSequence' demonstrates using a sprite sequence to draw an animated and interactive bear. The SpriteSequence defines 5 different sprites. The bear is initially in a 'still' state: - \snippet quick/imageelements/spritesequence.qml still + \snippet imageelements/spritesequence.qml still When the scene is clicked, an animation sets the sprite sequence to the 'falling' states and animates the bear's y property. - \snippet quick/imageelements/spritesequence.qml animation + \snippet imageelements/spritesequence.qml animation At the end of the animation the bear is set back to its initial state. */ diff --git a/examples/quick/mousearea/doc/src/mousearea.qdoc b/examples/quick/mousearea/doc/src/mousearea.qdoc index b0d9abce8f..091be69e5d 100644 --- a/examples/quick/mousearea/doc/src/mousearea.qdoc +++ b/examples/quick/mousearea/doc/src/mousearea.qdoc @@ -37,10 +37,10 @@ of that click which are available to QML. Signals are emitted by the MouseArea when clicks or other discrete operations occur within it - \snippet quick/mousearea/mousearea.qml clicks + \snippet mousearea/mousearea.qml clicks The MouseArea can also be used to drag items around. By setting the parameters of the drag property, the target item will be dragged around if the user starts to drag within the MouseArea. - \snippet quick/mousearea/mousearea.qml drag + \snippet mousearea/mousearea.qml drag */ diff --git a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc index 11fd073a54..7869383ca2 100644 --- a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc +++ b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc @@ -58,7 +58,7 @@ is the base class for all QPainter based items in the QML Scene Graph framework. - \snippet quick/customitems/painteditem/textballoon.h 0 + \snippet customitems/painteditem/textballoon.h 0 To implement a QQuickPaintedItem you must implement QQuickPaintedIem's pure virtual function \l {QQuickPaintedItem::}{paint()} which implements the @@ -69,13 +69,13 @@ We have to be sure to initialize the rightAligned property for a TextBalloon item. - \snippet quick/customitems/painteditem/textballoon.cpp 0 + \snippet customitems/painteditem/textballoon.cpp 0 Then we implement the \c paint() function which is automatically called by the Scene Graph framework to paint the contents of the item. The function paints the item in local coordinates. - \snippet quick/customitems/painteditem/textballoon.cpp 1 + \snippet customitems/painteditem/textballoon.cpp 1 We start with setting the pen and brush on the item to define the look of the item. After that we start drawing. Note that the \l {QQuickPaintedItem::}{boundingRect()} @@ -90,7 +90,7 @@ \section2 BalloonView - \snippet quick/customitems/painteditem/textballoons.qml 0 + \snippet customitems/painteditem/textballoons.qml 0 The balloonModel contains two types at application start which will be displayed by the balloonView. The balloonView alernates the TextBalloon @@ -98,7 +98,7 @@ \section2 Controls - \snippet quick/customitems/painteditem/textballoons.qml 1 + \snippet customitems/painteditem/textballoons.qml 1 The controls part of the UI contains a rectangle with a MouseArea which changes color when the mouse hovers over it. This control 'button' adds diff --git a/examples/quick/particles/affectors/doc/src/affectors.qdoc b/examples/quick/particles/affectors/doc/src/affectors.qdoc index 58661d5b70..a1407abda2 100644 --- a/examples/quick/particles/affectors/doc/src/affectors.qdoc +++ b/examples/quick/particles/affectors/doc/src/affectors.qdoc @@ -35,7 +35,7 @@ Each example is a small QML file emphasizing a particular type or feature. Age demonstrates using an Age affector to prematurely end the lives of particles. - \snippet quick/particles/affectors/content/age.qml 0 + \snippet particles/affectors/content/age.qml 0 As you move the affector around the screen, the particles inside it (which haven't already been affected) jump to a period near the end @@ -44,7 +44,7 @@ the end of their life instantly. Attractor demonstrates using an Attractor affector to simulate a black hole - \snippet quick/particles/affectors/content/attractor.qml 0 + \snippet particles/affectors/content/attractor.qml 0 All particles in the scene, including the rocket ship's exhaust and pellets, are pulled towards the black hole. This effect is stronger closer to the black hole, so the @@ -55,58 +55,58 @@ Custom Affector manipulates the properties of the particles directly in javascript. One Affector is used to make the leaves rock back and forth as they fall, looking more leaf-like than just spinning in circles: - \snippet quick/particles/affectors/content/customaffector.qml 0 + \snippet particles/affectors/content/customaffector.qml 0 Another is used to provide a slightly varying friction to the leaves as they 'land', to look more natural: - \snippet quick/particles/affectors/content/customaffector.qml 1 + \snippet particles/affectors/content/customaffector.qml 1 Friction is similar to the falling leaves in the custom affector, except that it uses a flat friction the whole way down instead of custom affectors. - \snippet quick/particles/affectors/content/friction.qml 0 + \snippet particles/affectors/content/friction.qml 0 Gravity is a convenience affector for applying a constant acceleration to particles inside it - \snippet quick/particles/affectors/content/gravity.qml 0 + \snippet particles/affectors/content/gravity.qml 0 GroupGoal sets up two particle groups for flaming and non-flaming balls, and gives you various ways to transition between them. - \snippet quick/particles/affectors/content/groupgoal.qml unlit + \snippet particles/affectors/content/groupgoal.qml unlit The non-flaming balls have a one in a hundred chance of lighting on their own each second, but they also have a GroupGoal set on the whole group. This affector affects all particles of the unlit group, when colliding with particles in the lit group, and cause them to move to the lighting group. - \snippet quick/particles/affectors/content/groupgoal.qml lighting + \snippet particles/affectors/content/groupgoal.qml lighting lighting is an intermediate group so that the glow builds up and the transition is less jarring. So it automatically moves into the lit group after 100ms. - \snippet quick/particles/affectors/content/groupgoal.qml lit + \snippet particles/affectors/content/groupgoal.qml lit The lit group also has TrailEmitters on it for additional fire and smoke, but does not transition anywhere. There are two more GroupGoal objects that allow particles in the unlit group to transition to the lighting group (and then to the lit group). - \snippet quick/particles/affectors/content/groupgoal.qml groupgoal-pilot + \snippet particles/affectors/content/groupgoal.qml groupgoal-pilot The first is just an area bound to the location of an image of a pilot flame. When unlit balls pass through the flame, they go straight to lit because the pilot flame is so hot. - \snippet quick/particles/affectors/content/groupgoal.qml groupgoal-ma + \snippet particles/affectors/content/groupgoal.qml groupgoal-ma The second is bound to the location of the last pointer interaction, so that touching or clicking on unlit balls (which is hard due to their constant movement) causes them to move to the lighting group. Move shows some simple effects you can get by altering trajectory midway. The red particles have an affector that affects their position, jumping them forwards by 120px. - \snippet quick/particles/affectors/content/move.qml A + \snippet particles/affectors/content/move.qml A The green particles have an affector that affects their velocity, but with some angle variation. By adding some random direction velocity to their existing forwards velocity, they begin to spray off in a cone. - \snippet quick/particles/affectors/content/move.qml B + \snippet particles/affectors/content/move.qml B The blue particles have an affector that affects their acceleration, and because it sets relative to false this resets the acceleration instead of adding to it. Once the blue particles reach the affector, their horizontal velocity stops increasing as their vertical velocity decreases. - \snippet quick/particles/affectors/content/move.qml C + \snippet particles/affectors/content/move.qml C SpriteGoal has an affector which interacts with the sprite engine of particles, if they are being drawn as sprites by ImageParticle. - \snippet quick/particles/affectors/content/spritegoal.qml 0 + \snippet particles/affectors/content/spritegoal.qml 0 The SpriteGoal follows the image of the rocket ship on screen, and when it interacts with particles drawn by ImageParticle as sprites, it instructs them to move immediately to the "explode" state, which in this case is the animation of the asteroid breaking into many pieces. Turbulence has a flame with smoke, and both sets of particles being affected by a Turbulence affector. This gives a faint wind effect. - \snippet quick/particles/affectors/content/turbulence.qml 0 + \snippet particles/affectors/content/turbulence.qml 0 To make the wind change direction, subsitute a black and white noise image in the noiseSource parameter (it currently uses a default noise source). Wander uses a Wander affector to add some horizontal drift to snowflakes as they fall down. - \snippet quick/particles/affectors/content/wander.qml 0 + \snippet particles/affectors/content/wander.qml 0 There are different movements given by applying the Wander to different attributes of the trajectory, so the example makes it easy to play around and see the difference. */ diff --git a/examples/quick/particles/customparticle/doc/src/customparticle.qdoc b/examples/quick/particles/customparticle/doc/src/customparticle.qdoc index ccef82c922..fb53a67831 100644 --- a/examples/quick/particles/customparticle/doc/src/customparticle.qdoc +++ b/examples/quick/particles/customparticle/doc/src/customparticle.qdoc @@ -36,19 +36,19 @@ Blur Particles adds a blur effect to the particles, which increases over the particle's life time. It uses a custom vertex shader: - \snippet quick/particles/customparticle/content/blurparticles.qml vertex + \snippet particles/customparticle/content/blurparticles.qml vertex to propagate life time simulation to a custom fragement shader: - \snippet quick/particles/customparticle/content/blurparticles.qml fragment + \snippet particles/customparticle/content/blurparticles.qml fragment which has access to both the normal image sampler and a blurred sampler, the image plus a ShaderEffect. Fragment Shader just uses the particle system as a vertex delivery system. - \snippet quick/particles/customparticle/content/fragmentshader.qml 0 + \snippet particles/customparticle/content/fragmentshader.qml 0 Image Colors uses CustomParticle to assign colors to particles based on their location in a picture. The vertex shader, - \snippet quick/particles/customparticle/content/imagecolors.qml vertex + \snippet particles/customparticle/content/imagecolors.qml vertex passes along the starting position for each vertex to the fragment shader, - \snippet quick/particles/customparticle/content/imagecolors.qml fragment + \snippet particles/customparticle/content/imagecolors.qml fragment which uses it to determine the color for that particle. */ diff --git a/examples/quick/particles/emitters/doc/src/emitters.qdoc b/examples/quick/particles/emitters/doc/src/emitters.qdoc index 8eb7919000..acf8ce41c4 100644 --- a/examples/quick/particles/emitters/doc/src/emitters.qdoc +++ b/examples/quick/particles/emitters/doc/src/emitters.qdoc @@ -34,27 +34,27 @@ Each example is a small QML file emphasizing a particular type or feature. Velocity from motion gives the effect of strong particle motion through primarily moving the emitters: - \snippet quick/particles/emitters/content/velocityfrommotion.qml 0 + \snippet particles/emitters/content/velocityfrommotion.qml 0 Burst and pulse calls the burst and pulse methods on two idential emitters. - \snippet quick/particles/emitters/content/burstandpulse.qml 0 + \snippet particles/emitters/content/burstandpulse.qml 0 Note how burst takes an argument of number of particles to emit, and pulse takes an argument of number of milliseconds to emit for. This gives a slightly different behaviour, which is easy to see in this example. Custom Emitter connects to the emitParticles signal to set arbitrary values on particle data as they're emitted; - \snippet quick/particles/emitters/content/customemitter.qml 0 + \snippet particles/emitters/content/customemitter.qml 0 This is used to emit curving particles in six rotating spokes. Emit mask sets an image mask on the Emitter, to emit out of an arbitrary shape. - \snippet quick/particles/emitters/content/emitmask.qml 0 + \snippet particles/emitters/content/emitmask.qml 0 Maximum emitted emits no more than a certain number of particles at a time. This example makes it easy to see what happens when the limit is reached. Shape and Direction emits particles out of an unfilled Ellipse shape, using a TargetDirection - \snippet quick/particles/emitters/content/shapeanddirection.qml 0 + \snippet particles/emitters/content/shapeanddirection.qml 0 This sends the particles towards the center of the ellipse with proportional speed, keeping the ellipse outline as they move to the center. TrailEmitter uses that type to add smoke particles to trail the fire particles in the scene. - \snippet quick/particles/emitters/content/customemitter.qml 0 + \snippet particles/emitters/content/customemitter.qml 0 */ diff --git a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc index c8f2dc988b..4fda13746a 100644 --- a/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc +++ b/examples/quick/particles/imageparticle/doc/src/imageparticle.qdoc @@ -35,25 +35,25 @@ Each example is a small QML file emphasizing a particular type or feature. All at once shows off several of the features of ImageParticle at the same time. - \snippet quick/particles/imageparticle/content/allatonce.qml 0 + \snippet particles/imageparticle/content/allatonce.qml 0 Colored shows a simple ImageParticle with some color variation. - \snippet quick/particles/imageparticle/content/colored.qml 0 + \snippet particles/imageparticle/content/colored.qml 0 Color Table sets the color over life on the particles to provide a fixed rainbow effect. - \snippet quick/particles/imageparticle/content/colortable.qml 0 + \snippet particles/imageparticle/content/colortable.qml 0 Deformation spins and squishes a starfish particle. - \snippet quick/particles/imageparticle/content/deformation.qml spin - \snippet quick/particles/imageparticle/content/deformation.qml deform + \snippet particles/imageparticle/content/deformation.qml spin + \snippet particles/imageparticle/content/deformation.qml deform Rotation demonstrates the autoRotate property, so that particles rotate in the direction that they travel. Sharing demonstrates what happens when multiple ImageParticles try to render the same particle. The following ImageParticle renders the particles inside the ListView: - \snippet quick/particles/imageparticle/content/sharing.qml 0 + \snippet particles/imageparticle/content/sharing.qml 0 The following ImageParticle is placed inside the list highlight, and renders the particles above the other ImageParticle. - \snippet quick/particles/imageparticle/content/sharing.qml 1 + \snippet particles/imageparticle/content/sharing.qml 1 Note that because it sets the color and alpha in this ImageParticle, it renders the particles in a different color. Since it doesn't specify anything about the rotation, it shares the rotation with the other ImageParticle so that the flowers are rotated the same way in both. Note that you can undo rotation in another ImageParticle, you just need to explicity set rotationVariation to 0. diff --git a/examples/quick/particles/system/doc/src/system.qdoc b/examples/quick/particles/system/doc/src/system.qdoc index 2bef4c6947..99be23d9d1 100644 --- a/examples/quick/particles/system/doc/src/system.qdoc +++ b/examples/quick/particles/system/doc/src/system.qdoc @@ -35,7 +35,7 @@ Each example is a small QML file emphasizing a particular type or feature. Dynamic comparison compares using the particle system to getting a similar effect with the following code that dynamically instantiates Image types. - \snippet quick/particles/system/content/dynamiccomparison.qml fake + \snippet particles/system/content/dynamiccomparison.qml fake Note how the Image objects are not able to be randomly colorized. Start and Stop simply sets the running and paused states of a ParticleSystem. While the system does not perform any simulation when stopped or paused, a restart restarts the simulation from the beginning, while unpausing resumes the simulation from where it was. @@ -43,14 +43,14 @@ Timed group changes is an example that highlights the ParticleGroup type. While normally referring to groups with a string name is sufficient, additional effects can be done by setting properties on groups. The first group has a variable duration on it, but always transitions to the second group. - \snippet quick/particles/system/content/timedgroupchanges.qml 0 + \snippet particles/system/content/timedgroupchanges.qml 0 The second group has a TrailEmitter on it, and a fixed duration for emitting into the third group. By placing the TrailEmitter as a direct child of the ParticleGroup, it automatically selects that group to follow. - \snippet quick/particles/system/content/timedgroupchanges.qml 1 + \snippet particles/system/content/timedgroupchanges.qml 1 The third group has an Affector as a direct child, which makes the affector automatically target this group. The affector means that as soon as particles enter this group, a burst function can be called on another emitter, using the x,y positions of this particle. - \snippet quick/particles/system/content/timedgroupchanges.qml 2 + \snippet particles/system/content/timedgroupchanges.qml 2 If TrailEmitter does not suit your needs for multiple emitters, you can also dynamically create Emitters while still using the same ParticleSystem and image particle - \snippet quick/particles/system/content/dynamicemitters.qml 0 + \snippet particles/system/content/dynamicemitters.qml 0 Note that this effect, a flurry of flying rainbow spears, would be better served with TrailEmitter. It is only done with dynamic emitters in this example to show the concept more simply. Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, ImageParticle objects follow the normal Z-ordering rules for \l {Qt Quick} items. This example allow you to paint the inside of the particles above the black borders using a pair of ImageParticles each painting different parts of the same logical particle. diff --git a/examples/quick/positioners/doc/src/positioners.qdoc b/examples/quick/positioners/doc/src/positioners.qdoc index 3a20b145ef..794b3b25f9 100644 --- a/examples/quick/positioners/doc/src/positioners.qdoc +++ b/examples/quick/positioners/doc/src/positioners.qdoc @@ -38,15 +38,15 @@ It consists of a scene populated with items in a variety of positioners: Column, Row, Grid and Flow. Each positioner has animations described as Transitions. - \snippet quick/positioners/positioners-transitions.qml move + \snippet positioners/positioners-transitions.qml move The move transition specifies how items inside a positioner will animate when they are displaced by the appearance or disappearance of other items. - \snippet quick/positioners/positioners-transitions.qml add + \snippet positioners/positioners-transitions.qml add The add transition specifies how items will appear when they are added to a positioner. - \snippet quick/positioners/positioners-transitions.qml populate + \snippet positioners/positioners-transitions.qml populate The populate transition specifies how items will appear when their parent positioner is first created. Attached Properties shows how the Positioner attached property can be used to determine where an item is within a positioner. - \snippet quick/positioners/positioners-attachedproperties.qml 0 + \snippet positioners/positioners-attachedproperties.qml 0 */ diff --git a/examples/quick/shadereffects/doc/src/shadereffects.qdoc b/examples/quick/shadereffects/doc/src/shadereffects.qdoc index e0f03cbc2b..3d5f42eacc 100644 --- a/examples/quick/shadereffects/doc/src/shadereffects.qdoc +++ b/examples/quick/shadereffects/doc/src/shadereffects.qdoc @@ -35,17 +35,17 @@ with shaders in \l {Qt Quick}. ShaderEffects typically operate on other types, using a ShaderEffectSource - \snippet quick/shadereffects/shadereffects.qml source + \snippet shadereffects/shadereffects.qml source In the above snippet, theItem is the id of a complex QML object in the file. ShaderEffects can use this ShaderEffectSource as a texture in their fragment shader. - \snippet quick/shadereffects/shadereffects.qml fragment + \snippet shadereffects/shadereffects.qml fragment You can use any custom property on the ShaderEffect in your shader. This makes animated shader code very easy. - \snippet quick/shadereffects/shadereffects.qml properties + \snippet shadereffects/shadereffects.qml properties ShaderEffects can also have a custom vertext shader. Setting the mesh property on ShaderEffect provides more vertices for you to manipulate, enabling many effects. - \snippet quick/shadereffects/shadereffects.qml vertex + \snippet shadereffects/shadereffects.qml vertex */ diff --git a/examples/quick/text/doc/src/text.qdoc b/examples/quick/text/doc/src/text.qdoc index c4ea3137d6..c93d2db8aa 100644 --- a/examples/quick/text/doc/src/text.qdoc +++ b/examples/quick/text/doc/src/text.qdoc @@ -38,24 +38,24 @@ 'Hello' shows how to change and animate the letter spacing of a Text type. It uses a sequential animation to first animate the font.letterSpacing property from 0 to 50 over 3 seconds and then move the text to a random position on screen: - \snippet quick/text/fonts/hello.qml letterspacing + \snippet text/fonts/hello.qml letterspacing 'Fonts' shows different ways of using fonts with the Text type. Simply by name, using the font.family property directly: - \snippet quick/text/fonts/fonts.qml name + \snippet text/fonts/fonts.qml name or using a FontLoader type: - \snippet quick/text/fonts/fonts.qml fontloader + \snippet text/fonts/fonts.qml fontloader or using a FontLoader and specifying a local font file: - \snippet quick/text/fonts/fonts.qml fontloaderlocal + \snippet text/fonts/fonts.qml fontloaderlocal or finally using a FontLoader and specifying a remote font file: - \snippet quick/text/fonts/fonts.qml fontloaderremote + \snippet text/fonts/fonts.qml fontloaderremote 'Available Fonts' shows how to use the QML global Qt object and a list view to display all the fonts available on the system. The ListView type uses the list of fonts available as its model: - \snippet quick/text/fonts/availableFonts.qml model + \snippet text/fonts/availableFonts.qml model Inside the delegate, the font family is set with the modelData: - \snippet quick/text/fonts/availableFonts.qml delegate + \snippet text/fonts/availableFonts.qml delegate 'Banner' is a simple example showing how to create a banner using a row of text types and a NumberAnimation. @@ -66,5 +66,5 @@ 'Text Layout' shows how to create a more complex layout for a text item. This example lays out the text in two columns using the onLineLaidOut handler that allows you to position and resize each line: - \snippet quick/text/styledtext-layout.qml layout + \snippet text/styledtext-layout.qml layout */ diff --git a/examples/quick/threading/doc/src/threading.qdoc b/examples/quick/threading/doc/src/threading.qdoc index 71fcdf820b..1cced3b9d3 100644 --- a/examples/quick/threading/doc/src/threading.qdoc +++ b/examples/quick/threading/doc/src/threading.qdoc @@ -33,17 +33,17 @@ Threaded ListModel contains a ListView and a ListModel. The ListModel is updated asynchronusly in another thread, and the results propagate back to the main thread. A timer requests updates from the worker thread periodically: - \snippet quick/threading/threadedlistmodel/timedisplay.qml 0 + \snippet threading/threadedlistmodel/timedisplay.qml 0 Inside the worker thread, the ListModel is synchronized once the data is finished loading: - \snippet quick/threading/threadedlistmodel/dataloader.js 0 + \snippet threading/threadedlistmodel/dataloader.js 0 WorkerScript contains an example of using a WorkerScript to offload expensive calculations into another thread. This keeps the UI from being blocked. This example calculates numbers in Pascal's Triangle, and not in a very optimal way, so it will often take several seconds to complete the calculation. By doing this in a WorkerScript in another thread, the UI is not blocked during this time. When the UI needs another value, a request is sent to the WorkerScript: - \snippet quick/threading/workerscript/workerscript.qml 0 + \snippet threading/workerscript/workerscript.qml 0 The workerscript then is free to take a really long time to calculate it: - \snippet quick/threading/workerscript/workerscript.js 0 + \snippet threading/workerscript/workerscript.js 0 When it's done, the result returns to the main scene via the WorkerScript type: - \snippet quick/threading/workerscript/workerscript.qml 1 + \snippet threading/workerscript/workerscript.qml 1 */ diff --git a/examples/quick/touchinteraction/doc/src/touchinteraction.qdoc b/examples/quick/touchinteraction/doc/src/touchinteraction.qdoc index 164409076c..09a5f51105 100644 --- a/examples/quick/touchinteraction/doc/src/touchinteraction.qdoc +++ b/examples/quick/touchinteraction/doc/src/touchinteraction.qdoc @@ -34,21 +34,21 @@ Multipoint Flames demonstrates distinguishing different fingers in a MultiPointTouchArea, by assigning a different colored flame to each touch point. The MultipointTouchArea sets up multiple touch points: - \snippet quick/touchinteraction/multipointtouch/multiflame.qml 0 + \snippet touchinteraction/multipointtouch/multiflame.qml 0 The flames are then simply bound to the coordiates of the touch point, and whether it is currently pressed, like so: - \snippet quick/touchinteraction/multipointtouch/multiflame.qml 1 + \snippet touchinteraction/multipointtouch/multiflame.qml 1 Bear-Whack demonstrates using a MultiPointTouchArea to add multiple finger support to a simple game. The interaction with the game is done through a SpriteGoal that follows the TouchPoint. The TouchPoints added to the MultiPointTouchArea are a component with all this logic embedded into it: - \snippet quick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml 0 + \snippet touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml 0 Flick Resize uses a PinchArea to allow Pinch-to-Resize behavior. This is easily achieved just by listening to the PinchArea signals and responding to user input. - \snippet quick/touchinteraction/pincharea/flickresize.qml 0 + \snippet touchinteraction/pincharea/flickresize.qml 0 Flickable is a simple example demonstrating the Flickable type. The object inside the flickable is very big, but the flickable itself is very small: - \snippet quick/touchinteraction/flickable/basic-flickable.qml 0 + \snippet touchinteraction/flickable/basic-flickable.qml 0 Corkboards shows a more complex Flickable usecase, with types on the flickable that respond to mouse and keyboard interaction. This doesn't require special code, the Qt Quick types automatically cooperate with Flickable for accepting the touch events. diff --git a/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc b/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc index 05597b7e2c..3a14dd465a 100644 --- a/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc +++ b/examples/quick/ui-components/slideswitch/doc/src/example-slideswitch.qdoc @@ -48,12 +48,12 @@ The objects that compose the switch are: \endlist \section1 Switch.qml -\snippet quick/ui-components/slideswitch/content/Switch.qml 0 +\snippet ui-components/slideswitch/content/Switch.qml 0 \section1 Walkthrough \section2 Interface -\snippet quick/ui-components/slideswitch/content/Switch.qml 1 +\snippet ui-components/slideswitch/content/Switch.qml 1 This property is the interface of the switch. By default, the switch is off and this property is \c false. It can be used to activate/disactivate the switch or to query its current state. @@ -76,14 +76,14 @@ Item { the text will only be visible when the switch is on. \section2 Images and user interaction -\snippet quick/ui-components/slideswitch/content/Switch.qml 4 +\snippet ui-components/slideswitch/content/Switch.qml 4 First, we create the background image of the switch. In order for the switch to toggle when the user clicks on the background, we add a \l{MouseArea} as a child item of the image. A \c MouseArea has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a \c toggle() function. We will see what this function does in a moment. -\snippet quick/ui-components/slideswitch/content/Switch.qml 5 +\snippet ui-components/slideswitch/content/Switch.qml 5 Then, we place the image of the knob on top of the background. The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag @@ -91,7 +91,7 @@ property of the \c MouseArea is for. We also want to toggle the switch if the kn in the \c dorelease() function that is called in the \c onReleased property. \section2 States -\snippet quick/ui-components/slideswitch/content/Switch.qml 6 +\snippet ui-components/slideswitch/content/Switch.qml 6 We define the two states of the switch: \list @@ -105,13 +105,13 @@ For more information on states see \l{Qt Quick States}. We add two JavaScript functions to our switch: -\snippet quick/ui-components/slideswitch/content/Switch.qml 2 +\snippet ui-components/slideswitch/content/Switch.qml 2 This first function is called when the background image or the knob are clicked. We simply want the switch to toggle between the two states (\e on and \e off). -\snippet quick/ui-components/slideswitch/content/Switch.qml 3 +\snippet ui-components/slideswitch/content/Switch.qml 3 This second function is called when the knob is released and we want to make sure that the knob does not end up between states (neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. @@ -119,7 +119,7 @@ This second function is called when the knob is released and we want to make sur For more information on scripts see \l{Using JavaScript Expressions in QML}. \section2 Transition -\snippet quick/ui-components/slideswitch/content/Switch.qml 7 +\snippet ui-components/slideswitch/content/Switch.qml 7 At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. In order for the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. @@ -128,5 +128,5 @@ For more information on transitions see \l{Animation and Transitions in Qt Quick \section1 Usage The switch can be used in a QML file, like this: -\snippet quick/ui-components/slideswitch/slideswitch.qml 0 +\snippet ui-components/slideswitch/slideswitch.qml 0 */ diff --git a/examples/quick/views/doc/src/views.qdoc b/examples/quick/views/doc/src/views.qdoc index 21a2d2e5e0..2d664c9bd9 100644 --- a/examples/quick/views/doc/src/views.qdoc +++ b/examples/quick/views/doc/src/views.qdoc @@ -35,48 +35,48 @@ This is a collection of small QML examples relating to model and view functionality. They demonstrate how to show data from a model using the \l {Qt Quick} view types. \section2 GridView and PathView demonstrate usage of these types to display views. - \snippet quick/views/gridview/gridview-example.qml 0 + \snippet views/gridview/gridview-example.qml 0 \section2 Dynamic List demonstrates animation of runtime additions and removals to a ListView. The ListView.onAdd signal handler runs an animation when new items are added to the view, and the ListView.onRemove another when they are removed. - \snippet quick/views/listview/dynamiclist.qml 0 - \snippet quick/views/listview/dynamiclist.qml 1 + \snippet views/listview/dynamiclist.qml 0 + \snippet views/listview/dynamiclist.qml 1 \section2 Expanding Delegates demonstrates delegates that expand when activated. It has a complex delegate the size and appearance of which can change, displacing other items in the view. - \snippet quick/views/listview/expandingdelegates.qml 0 - \snippet quick/views/listview/expandingdelegates.qml 1 - \snippet quick/views/listview/expandingdelegates.qml 2 - \snippet quick/views/listview/expandingdelegates.qml 3 + \snippet views/listview/expandingdelegates.qml 0 + \snippet views/listview/expandingdelegates.qml 1 + \snippet views/listview/expandingdelegates.qml 2 + \snippet views/listview/expandingdelegates.qml 3 \section2 Highlight demonstrates adding a custom highlight to a ListView. - \snippet quick/views/listview/highlight.qml 0 + \snippet views/listview/highlight.qml 0 \section2 Highlight Ranges shows the three different highlight range modes of ListView. - \snippet quick/views/listview/highlightranges.qml 0 - \snippet quick/views/listview/highlightranges.qml 1 - \snippet quick/views/listview/highlightranges.qml 2 + \snippet views/listview/highlightranges.qml 0 + \snippet views/listview/highlightranges.qml 1 + \snippet views/listview/highlightranges.qml 2 \section2 Sections demonstrates the various section headers and footers available to ListView. - \snippet quick/views/listview/sections.qml 0 + \snippet views/listview/sections.qml 0 \section2 Packages demonstrates using Packages to transition delegates between two views. It has a Package which defines delegate items for each view and an item that can be transferred between delegates. - \snippet quick/views/package/Delegate.qml 0 + \snippet views/package/Delegate.qml 0 A DelegateModel allows the individual views to access their specific items from the shared package delegate. - \snippet quick/views/package/view.qml 0 + \snippet views/package/view.qml 0 \section2 ObjectModel uses an ObjectModel for the model instead of a ListModel. - \snippet quick/views/visualitemmodel/visualitemmodel.qml 0 + \snippet views/objectmodel/objectmodel.qml 0 */ -- cgit v1.2.3 From 40d90b50c555a968f1ae540527199042fbcf1a32 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Tue, 30 Apr 2013 23:35:41 +0800 Subject: Doc: Make Qt Quick demos accessible from Qt documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add screenshots and brief descriptions. Integrate source code into documentation. Create new group, "qtquickdemos". Change-Id: I92715b2cdd861b1ff2bdd28a640e63d2a220499e Reviewed-by: Topi Reiniö Reviewed-by: Jerome Pasion --- .../doc/images/qtquick-demo-clocks-small.png | Bin 0 -> 26067 bytes examples/quick/demos/clocks/doc/src/clocks.qdoc | 35 ++++++++++++++++++++ .../doc/images/qtquick-demo-maroon-med-1.png | Bin 0 -> 73390 bytes .../doc/images/qtquick-demo-maroon-med-2.png | Bin 0 -> 61303 bytes examples/quick/demos/maroon/doc/src/maroon.qdoc | 36 +++++++++++++++++++++ .../doc/images/qtquick-demo-photoviewer-small.png | Bin 0 -> 73662 bytes .../demos/photoviewer/doc/src/photoviewer.qdoc | 35 ++++++++++++++++++++ .../doc/images/qtquick-demo-rssnews-small.png | Bin 0 -> 43372 bytes examples/quick/demos/rssnews/doc/src/rssnews.qdoc | 35 ++++++++++++++++++++ .../doc/images/qtquick-demo-samegame-med-1.png | Bin 0 -> 100713 bytes .../doc/images/qtquick-demo-samegame-med-2.png | Bin 0 -> 134892 bytes .../quick/demos/samegame/doc/src/samegame.qdoc | 36 +++++++++++++++++++++ .../stocqt/doc/images/qtquick-demo-stocqt.png | Bin 0 -> 24592 bytes examples/quick/demos/stocqt/doc/src/stocqt.qdoc | 35 ++++++++++++++++++++ .../doc/images/qtquick-demo-tweetsearch-med-1.png | Bin 0 -> 18531 bytes .../doc/images/qtquick-demo-tweetsearch-med-2.png | Bin 0 -> 90622 bytes .../demos/tweetsearch/doc/src/tweetsearch.qdoc | 36 +++++++++++++++++++++ 17 files changed, 248 insertions(+) create mode 100644 examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png create mode 100644 examples/quick/demos/clocks/doc/src/clocks.qdoc create mode 100644 examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png create mode 100644 examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png create mode 100644 examples/quick/demos/maroon/doc/src/maroon.qdoc create mode 100644 examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png create mode 100644 examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc create mode 100644 examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png create mode 100644 examples/quick/demos/rssnews/doc/src/rssnews.qdoc create mode 100644 examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png create mode 100644 examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png create mode 100644 examples/quick/demos/samegame/doc/src/samegame.qdoc create mode 100644 examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png create mode 100644 examples/quick/demos/stocqt/doc/src/stocqt.qdoc create mode 100644 examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png create mode 100644 examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png create mode 100644 examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc (limited to 'examples') diff --git a/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png b/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png new file mode 100644 index 0000000000..94b641d891 Binary files /dev/null and b/examples/quick/demos/clocks/doc/images/qtquick-demo-clocks-small.png differ diff --git a/examples/quick/demos/clocks/doc/src/clocks.qdoc b/examples/quick/demos/clocks/doc/src/clocks.qdoc new file mode 100644 index 0000000000..b34f844cc6 --- /dev/null +++ b/examples/quick/demos/clocks/doc/src/clocks.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - Clocks + \ingroup qtquickdemos + \example demos/clocks + \brief An app that shows the current time in different cities. + \image qtquick-demo-clocks-small.png +*/ + diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png new file mode 100644 index 0000000000..6d41179c23 Binary files /dev/null and b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-1.png differ diff --git a/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png new file mode 100644 index 0000000000..c8f37486f6 Binary files /dev/null and b/examples/quick/demos/maroon/doc/images/qtquick-demo-maroon-med-2.png differ diff --git a/examples/quick/demos/maroon/doc/src/maroon.qdoc b/examples/quick/demos/maroon/doc/src/maroon.qdoc new file mode 100644 index 0000000000..c18b6bc874 --- /dev/null +++ b/examples/quick/demos/maroon/doc/src/maroon.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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - Maroon in Trouble + \ingroup qtquickdemos + \example demos/maroon + \brief A cute game designed for touchscreens. + \image qtquick-demo-maroon-med-1.png + \image qtquick-demo-maroon-med-2.png +*/ + diff --git a/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png b/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png new file mode 100644 index 0000000000..d872310a3e Binary files /dev/null and b/examples/quick/demos/photoviewer/doc/images/qtquick-demo-photoviewer-small.png differ diff --git a/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc b/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc new file mode 100644 index 0000000000..b0f1368a1c --- /dev/null +++ b/examples/quick/demos/photoviewer/doc/src/photoviewer.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - Photo Viewer + \ingroup qtquickdemos + \example demos/photoviewer + \brief An online photo viewer that displays Flickr feeds. + \image qtquick-demo-photoviewer-small.png +*/ + diff --git a/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png b/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png new file mode 100644 index 0000000000..0ad6c02251 Binary files /dev/null and b/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png differ diff --git a/examples/quick/demos/rssnews/doc/src/rssnews.qdoc b/examples/quick/demos/rssnews/doc/src/rssnews.qdoc new file mode 100644 index 0000000000..019b54d609 --- /dev/null +++ b/examples/quick/demos/rssnews/doc/src/rssnews.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - RSS News + \ingroup qtquickdemos + \example demos/rssnews + \brief An RSS news reader. + \image qtquick-demo-rssnews-small.png +*/ + diff --git a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png new file mode 100644 index 0000000000..cce9f11017 Binary files /dev/null and b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-1.png differ diff --git a/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png new file mode 100644 index 0000000000..ca9e8368b1 Binary files /dev/null and b/examples/quick/demos/samegame/doc/images/qtquick-demo-samegame-med-2.png differ diff --git a/examples/quick/demos/samegame/doc/src/samegame.qdoc b/examples/quick/demos/samegame/doc/src/samegame.qdoc new file mode 100644 index 0000000000..70042d73f0 --- /dev/null +++ b/examples/quick/demos/samegame/doc/src/samegame.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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - Same Game + \ingroup qtquickdemos + \example demos/samegame + \brief A QML implementation of the popular puzzle game by Kuniaki Moribe. + \image qtquick-demo-samegame-med-1.png + \image qtquick-demo-samegame-med-2.png +*/ + diff --git a/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png b/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png new file mode 100644 index 0000000000..1783881e1f Binary files /dev/null and b/examples/quick/demos/stocqt/doc/images/qtquick-demo-stocqt.png differ diff --git a/examples/quick/demos/stocqt/doc/src/stocqt.qdoc b/examples/quick/demos/stocqt/doc/src/stocqt.qdoc new file mode 100644 index 0000000000..7001bfb395 --- /dev/null +++ b/examples/quick/demos/stocqt/doc/src/stocqt.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - StocQt + \ingroup qtquickdemos + \example demos/stocqt + \brief A configurable stock chart for the NASDAQ-100. + \image qtquick-demo-stocqt.png +*/ + diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png new file mode 100644 index 0000000000..930ee39929 Binary files /dev/null and b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png differ diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png new file mode 100644 index 0000000000..9eff191a47 Binary files /dev/null and b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png differ diff --git a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc new file mode 100644 index 0000000000..9ba252fcb5 --- /dev/null +++ b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.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$ +** +****************************************************************************/ + +/*! + \title Qt Quick Demo - Tweet Search + \ingroup qtquickdemos + \example demos/tweetsearch + \brief A Twitter search client with 3D effects. + \image qtquick-demo-tweetsearch-med-1.png + \image qtquick-demo-tweetsearch-med-2.png +*/ + -- cgit v1.2.3 From 56da72fb219356d2948e9adae3f3a17553fc7add Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 May 2013 15:30:17 +0200 Subject: Fix warnings in stocqt-example. Task-number: QTBUG-31083 Change-Id: I97d429c1a30664373478636c6b066dbdcd2a46ee Reviewed-by: Shawn Rutledge --- examples/quick/demos/stocqt/content/CheckBox.qml | 21 ++++++++++----------- .../quick/demos/stocqt/content/StockSettings.qml | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/quick/demos/stocqt/content/CheckBox.qml b/examples/quick/demos/stocqt/content/CheckBox.qml index 9c429d65dc..1e7dcf7c74 100644 --- a/examples/quick/demos/stocqt/content/CheckBox.qml +++ b/examples/quick/demos/stocqt/content/CheckBox.qml @@ -40,13 +40,12 @@ import QtQuick 2.0 -Row { +Item { id: button property alias text: txt.text property bool buttonEnabled: true width: 140 height: 25 - spacing: 5 x: 5 MouseArea { id: mouse @@ -75,14 +74,14 @@ Row { radius: 1 color: mouse.pressed || buttonEnabled ? "#76644A" : "transparent" } - Text { - id: txt - anchors.left: checkbox.right - anchors.leftMargin: 4 - anchors.verticalCenter: parent.verticalCenter - text: "Close " - color: "#ecc089" - font.pixelSize: 18 - } + } + Text { + id: txt + anchors.left: checkbox.right + anchors.leftMargin: 4 + anchors.verticalCenter: parent.verticalCenter + text: "Close " + color: "#ecc089" + font.pixelSize: 18 } } diff --git a/examples/quick/demos/stocqt/content/StockSettings.qml b/examples/quick/demos/stocqt/content/StockSettings.qml index 5978a3b6a0..07152410fa 100644 --- a/examples/quick/demos/stocqt/content/StockSettings.qml +++ b/examples/quick/demos/stocqt/content/StockSettings.qml @@ -88,7 +88,6 @@ Rectangle { anchors.leftMargin: 30 anchors.top: startDateText.bottom anchors.topMargin: 8 - date: new Date(1995, 3, 25) } Text { @@ -212,4 +211,6 @@ Rectangle { onClicked: root.chartType = "all" } } + + Component.onCompleted: startDatePicker.date = new Date(1995, 3, 25) } -- cgit v1.2.3 From 648351e6658172f2044b00ab592b48583bd27a4a Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 15 May 2013 00:03:18 +0800 Subject: Doc: Update references to QDeclarative* classes Change-Id: Ifbde8c1ccfc0c759da6f2204320b9170a04179eb Reviewed-by: Alan Alpert --- examples/qml/doc/src/qml-extending.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc index 9823a29b65..7dbd147cc1 100644 --- a/examples/qml/doc/src/qml-extending.qdoc +++ b/examples/qml/doc/src/qml-extending.qdoc @@ -93,11 +93,11 @@ The class contains a member to store the celebrant object, and also a QList member. In QML, the type of a list properties - and the guests property is a list of -people - are all of type QDeclarativeListProperty. QDeclarativeListProperty is simple value +people - are all of type QQmlListProperty. QQmlListProperty is simple value type that contains a set of function pointers. QML calls these function pointers whenever it needs to read from, write to or otherwise interact with the list. In addition to concrete lists like the people list used in this -example, the use of QDeclarativeListProperty allows for "virtual lists" and other advanced +example, the use of QQmlListProperty allows for "virtual lists" and other advanced scenarios. \section2 Define the BirthdayParty -- cgit v1.2.3 From cc36ce673545131047595c79ded1f465ec601780 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 22 May 2013 10:35:27 +0200 Subject: Disable textureinthread example when threaded gl is not available. Task-number: QTBUG-30077 Change-Id: I8b6e4b8a33819fe84c843e85d863b582cfd69439 Reviewed-by: Friedemann Kleint --- .../quick/scenegraph/textureinthread/error.qml | 49 ++++++++++++++++++++++ examples/quick/scenegraph/textureinthread/main.cpp | 12 +++++- .../scenegraph/textureinthread/textureinthread.pro | 6 ++- .../scenegraph/textureinthread/textureinthread.qrc | 3 +- 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 examples/quick/scenegraph/textureinthread/error.qml (limited to 'examples') diff --git a/examples/quick/scenegraph/textureinthread/error.qml b/examples/quick/scenegraph/textureinthread/error.qml new file mode 100644 index 0000000000..1dbd576ef7 --- /dev/null +++ b/examples/quick/scenegraph/textureinthread/error.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** 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 + +Text { + width: 400 + height: 100 + text: 'Platform does not support threaded OpenGL needed by this example.' + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter +} diff --git a/examples/quick/scenegraph/textureinthread/main.cpp b/examples/quick/scenegraph/textureinthread/main.cpp index 3286055496..801f1891b9 100644 --- a/examples/quick/scenegraph/textureinthread/main.cpp +++ b/examples/quick/scenegraph/textureinthread/main.cpp @@ -42,6 +42,9 @@ #include +#include +#include + #include #include "threadrenderer.h" @@ -50,6 +53,13 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); + if (!QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) { + QQuickView view; + view.setSource(QUrl("qrc:///scenegraph/textureinthread/error.qml")); + view.show(); + return app.exec(); + } + qmlRegisterType("SceneGraphRendering", 1, 0, "Renderer"); int execReturn = 0; @@ -63,7 +73,7 @@ int main(int argc, char **argv) view.setPersistentSceneGraph(true); view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); + view.setSource(QUrl("qrc:///scenegraph/textureinthread/main.qml")); view.show(); execReturn = app.exec(); diff --git a/examples/quick/scenegraph/textureinthread/textureinthread.pro b/examples/quick/scenegraph/textureinthread/textureinthread.pro index b48c2a1863..7f5fbb76e9 100644 --- a/examples/quick/scenegraph/textureinthread/textureinthread.pro +++ b/examples/quick/scenegraph/textureinthread/textureinthread.pro @@ -1,5 +1,8 @@ QT += quick +# To make threaded gl check... +QT += core-private gui-private + HEADERS += threadrenderer.h SOURCES += threadrenderer.cpp main.cpp @@ -13,4 +16,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinthread INSTALLS += target OTHER_FILES += \ - main.qml + main.qml \ + error.qml diff --git a/examples/quick/scenegraph/textureinthread/textureinthread.qrc b/examples/quick/scenegraph/textureinthread/textureinthread.qrc index 9ecf0ada1c..66eb53b736 100644 --- a/examples/quick/scenegraph/textureinthread/textureinthread.qrc +++ b/examples/quick/scenegraph/textureinthread/textureinthread.qrc @@ -1,5 +1,6 @@ - + main.qml + error.qml -- cgit v1.2.3 From 1ef4e4b156be8653af64dbccb47abcccc234246a Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 8 Mar 2013 16:44:52 +0100 Subject: window and Screen example: new properties; splash screen Demonstrates the new properties, how to make a splash screen, and how to make a standalone app with an icon. Combined the Screen info into this example too. Change-Id: I5b731539b39c55327f4e5b93860a880a35835896 Reviewed-by: Richard Moe Gustavsen --- examples/quick/shared/images/qt-logo.png | Bin 0 -> 13923 bytes examples/quick/shared/shared.qrc | 2 + examples/quick/window/ScreenInfo.qml | 95 ++++++++++ examples/quick/window/Splash.qml | 74 ++++++++ .../quick/window/doc/images/qml-window-example.png | Bin 0 -> 9863 bytes examples/quick/window/doc/src/window.qdoc | 71 +++++++ examples/quick/window/main.cpp | 58 ++++++ examples/quick/window/resources/icon.icns | Bin 0 -> 59662 bytes examples/quick/window/resources/icon.ico | Bin 0 -> 11825 bytes examples/quick/window/resources/icon.svg | 208 +++++++++++++++++++++ examples/quick/window/resources/icon64.png | Bin 0 -> 3004 bytes examples/quick/window/resources/window.rc | 32 ++++ examples/quick/window/screen/screenInfo.qml | 91 --------- examples/quick/window/window.pro | 18 +- examples/quick/window/window.qml | 180 ++++++++++++++++++ examples/quick/window/window.qrc | 7 + examples/quick/window/window/Window.qml | 58 ------ examples/quick/window/window/nogui.qml | 50 ----- examples/quick/window/window/standalone.qml | 128 ------------- examples/quick/window/window/twowindows.qml | 89 --------- examples/quick/window/window/window.cpp | 58 ------ examples/quick/window/window/window.pro | 13 -- examples/quick/window/window/window.qrc | 5 - 23 files changed, 741 insertions(+), 496 deletions(-) create mode 100644 examples/quick/shared/images/qt-logo.png create mode 100644 examples/quick/window/ScreenInfo.qml create mode 100644 examples/quick/window/Splash.qml create mode 100644 examples/quick/window/doc/images/qml-window-example.png create mode 100644 examples/quick/window/doc/src/window.qdoc create mode 100644 examples/quick/window/main.cpp create mode 100644 examples/quick/window/resources/icon.icns create mode 100644 examples/quick/window/resources/icon.ico create mode 100644 examples/quick/window/resources/icon.svg create mode 100644 examples/quick/window/resources/icon64.png create mode 100644 examples/quick/window/resources/window.rc delete mode 100644 examples/quick/window/screen/screenInfo.qml create mode 100644 examples/quick/window/window.qml create mode 100644 examples/quick/window/window.qrc delete mode 100644 examples/quick/window/window/Window.qml delete mode 100644 examples/quick/window/window/nogui.qml delete mode 100644 examples/quick/window/window/standalone.qml delete mode 100644 examples/quick/window/window/twowindows.qml delete mode 100644 examples/quick/window/window/window.cpp delete mode 100644 examples/quick/window/window/window.pro delete mode 100644 examples/quick/window/window/window.qrc (limited to 'examples') diff --git a/examples/quick/shared/images/qt-logo.png b/examples/quick/shared/images/qt-logo.png new file mode 100644 index 0000000000..7d3e97eb36 Binary files /dev/null and b/examples/quick/shared/images/qt-logo.png differ diff --git a/examples/quick/shared/shared.qrc b/examples/quick/shared/shared.qrc index 0b574ac879..8912c17831 100644 --- a/examples/quick/shared/shared.qrc +++ b/examples/quick/shared/shared.qrc @@ -8,5 +8,7 @@ CheckBox.qml images/back.png images/next.png + images/qt-logo.png + images/checkmark.png diff --git a/examples/quick/window/ScreenInfo.qml b/examples/quick/window/ScreenInfo.qml new file mode 100644 index 0000000000..e4abc8d69d --- /dev/null +++ b/examples/quick/window/ScreenInfo.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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.1 +import QtQuick.Window 2.1 + +Item { + id: root + width: 400 + height: propertyGrid.implicitHeight + 16 + + function orientationToString(o) { + switch (o) { + case Qt.PrimaryOrientation: + return "primary"; + case Qt.PortraitOrientation: + return "portrait"; + case Qt.LandscapeOrientation: + return "landscape"; + case Qt.InvertedPortraitOrientation: + return "inverted portrait"; + case Qt.InvertedLandscapeOrientation: + return "inverted landscape"; + } + return "unknown"; + } + + Grid { + id: propertyGrid + columns: 2 + spacing: 8 + x: spacing + y: spacing + + //! [screen] + Text { + text: "Screen \"" + Screen.name + "\":" + font.bold: true + } + Item { width: 1; height: 1 } // spacer + + Text { text: "dimensions" } + Text { text: Screen.width + "x" + Screen.height } + + Text { text: "logical pixel density" } + Text { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm" } + + Text { text: "available virtual desktop" } + Text { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight } + + Text { text: "orientation" } + Text { text: orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" } + + Text { text: "primary orientation" } + Text { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" } + //! [screen] + } +} diff --git a/examples/quick/window/Splash.qml b/examples/quick/window/Splash.qml new file mode 100644 index 0000000000..092e6e6fc2 --- /dev/null +++ b/examples/quick/window/Splash.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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.Window 2.1 + +//! [splash-properties] +Window { + visible: true + width: splashImage.width + height: splashImage.height + color: "transparent" + title: "Splash Window" + modality: Qt.ApplicationModal + flags: Qt.SplashScreen + property int timeout: 2000 +//! [splash-properties] +//! [screen-properties] + x: (Screen.width - splashImage.width) / 2 + y: (Screen.height - splashImage.height) / 2 +//! [screen-properties] + + Image { + id: splashImage + source: "../../shared/images/qt-logo.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + //! [timer] + Timer { + interval: timeout; running: true; repeat: false + onTriggered: visible = false + } + //! [timer] +} diff --git a/examples/quick/window/doc/images/qml-window-example.png b/examples/quick/window/doc/images/qml-window-example.png new file mode 100644 index 0000000000..72487b4d93 Binary files /dev/null and b/examples/quick/window/doc/images/qml-window-example.png differ diff --git a/examples/quick/window/doc/src/window.qdoc b/examples/quick/window/doc/src/window.qdoc new file mode 100644 index 0000000000..07d2f115c1 --- /dev/null +++ b/examples/quick/window/doc/src/window.qdoc @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +/*! + \title Qt Quick Examples - Window and Screen + \example window + \brief This example demonstrates the Window and Screen types in QML + \image qml-window-example.png + \ingroup qtquickexamples + + This example shows you how to create a Window in QML, how to control its + \l {QQuickWindow::visibility} {visibility}, how to present a splash screen + during application startup, and how to access the properties of the + \l Screen. It also demonstrates how to package QML into + \l {The Qt Resource System} {resources} and provide an + \l {Setting the Application Icon} {icon} to create a standalone QML desktop application. + + A splash screen can be created with the \l {Qt::SplashScreen} {Qt.SplashScreen} flag, + and should be \l {Qt::ApplicationModal} {ApplicationModal} to prevent interaction + with the main window. If the splash window is also transparent, and showing a + partially transparent image, then it will look like a shaped window. + \snippet window/Splash.qml splash-properties + + In this example a \l Timer will automatically dismiss the splash screen, + but in a real application you might want to connect to a signal from the + application logic to hide the splash when initialization is complete. + \snippet window/Splash.qml timer + + The main window in this example is the control window, with some buttons + and checkboxes to control and provide feedback on the state of a secondary + window. Each checkbox has a binding to the property whose state it is + displaying, and also an onClicked handler to change the state. This is the + typical pattern to create a two-way binding while avoiding binding loops. + \snippet window/window.qml windowedCheckbox + + The \l Screen has several properties which are generally useful to applications + which need to rotate some content when the screen orientation changes, to position + windows on the screen or to convert real units to logical pixel units. ScreenInfo.qml + (which is displayed inline in window.qml, or can be run by itself with qmlscene) + simply displays the property values, while the splash screen uses them to + center the window on the screen. + \snippet window/Splash.qml screen-properties + + If a Window is nested inside an \l Item or another Window, the inner window + becomes "transient for" the outer one (see \l Window for more explanation). + But if you want to create multiple top-level windows as unrelated peers, you + can create them inside a non-visual \l QtObject root item, as this example does. +*/ diff --git a/examples/quick/window/main.cpp b/examples/quick/window/main.cpp new file mode 100644 index 0000000000..2223c607b4 --- /dev/null +++ b/examples/quick/window/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(QUrl("qrc:///window/window.qml")); + if ( component.isReady() ) + component.create(); + else + qWarning() << component.errorString(); + return app.exec(); +} diff --git a/examples/quick/window/resources/icon.icns b/examples/quick/window/resources/icon.icns new file mode 100644 index 0000000000..88b4b24449 Binary files /dev/null and b/examples/quick/window/resources/icon.icns differ diff --git a/examples/quick/window/resources/icon.ico b/examples/quick/window/resources/icon.ico new file mode 100644 index 0000000000..52af30a6ca Binary files /dev/null and b/examples/quick/window/resources/icon.ico differ diff --git a/examples/quick/window/resources/icon.svg b/examples/quick/window/resources/icon.svg new file mode 100644 index 0000000000..0b6153206d --- /dev/null +++ b/examples/quick/window/resources/icon.svg @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/quick/window/resources/icon64.png b/examples/quick/window/resources/icon64.png new file mode 100644 index 0000000000..0fa324401f Binary files /dev/null and b/examples/quick/window/resources/icon64.png differ diff --git a/examples/quick/window/resources/window.rc b/examples/quick/window/resources/window.rc new file mode 100644 index 0000000000..4de84d297e --- /dev/null +++ b/examples/quick/window/resources/window.rc @@ -0,0 +1,32 @@ +#include "winver.h" + +IDI_ICON1 ICON DISCARDABLE "icon.ico" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,0 + PRODUCTVERSION 1,0,0,0 + FILEFLAGS 0x0L + FILEFLAGSMASK 0x3fL + FILEOS 0x00040004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "CompanyName", "Digia Plc and/or its subsidiary(-ies)" + VALUE "FileDescription", "QtQuick Window Example" + VALUE "FileVersion", "1.0.0.0" + VALUE "LegalCopyright", "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies)." + VALUE "InternalName", "window" + VALUE "OriginalFilename", "window.exe" + VALUE "ProductName", "QtQuick Window Example" + VALUE "ProductVersion", "1.0.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/examples/quick/window/screen/screenInfo.qml b/examples/quick/window/screen/screenInfo.qml deleted file mode 100644 index 33fbc5d88e..0000000000 --- a/examples/quick/window/screen/screenInfo.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** 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.1 -import QtQuick.Window 2.1 - -Item { - id: root - width: 400 - height: 200 - - function orientationToString(o) { - switch (o) { - case Qt.PrimaryOrientation: - return "primary"; - case Qt.PortraitOrientation: - return "portrait"; - case Qt.LandscapeOrientation: - return "landscape"; - case Qt.InvertedPortraitOrientation: - return "inverted portrait"; - case Qt.InvertedLandscapeOrientation: - return "inverted landscape"; - } - return "unknown"; - } - - Grid { - anchors.centerIn: parent - columns: 2 - spacing: 8 - - Text { - text: "Screen \"" + Screen.name + "\":" - font.bold: true - } - Item { width: 1; height: 1 } // spacer - - Text { text: "dimensions" } - Text { text: Screen.width + "x" + Screen.height } - - Text { text: "logical pixel density" } - Text { text: Screen.logicalPixelDensity.toFixed(2) + " dots/mm" } - - Text { text: "available virtual desktop" } - Text { text: Screen.desktopAvailableWidth + "x" + Screen.desktopAvailableHeight } - - Text { text: "orientation" } - Text { text: orientationToString(Screen.orientation) + " (" + Screen.orientation + ")" } - - Text { text: "primary orientation" } - Text { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" } - } -} diff --git a/examples/quick/window/window.pro b/examples/quick/window/window.pro index 93e43fcd65..be35b24325 100644 --- a/examples/quick/window/window.pro +++ b/examples/quick/window/window.pro @@ -1,6 +1,16 @@ -TEMPLATE = subdirs -SUBDIRS += \ - window +TEMPLATE = app +QT += quick qml +SOURCES += main.cpp +RESOURCES += \ + window.qrc \ + ../shared/shared.qrc EXAMPLE_FILES = \ - screen + window.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/window +INSTALLS += target + +ICON = resources/icon64.png +macx: ICON = resources/icon.icns +win32: RC_FILE = resources/window.rc diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml new file mode 100644 index 0000000000..1d7282f7a1 --- /dev/null +++ b/examples/quick/window/window.qml @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** 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.Window 2.1 +import "../shared" as Shared + +QtObject { + property real defaultSpacing: 10 + property SystemPalette palette: SystemPalette { } + + property var splashWindow: Splash { } + + property var controlWindow: Window { + width: 400 + height: col.implicitHeight + defaultSpacing * 2 + color: palette.window + title: "Control Window" + visible: true + Column { + id: col + anchors.fill: parent + anchors.margins: defaultSpacing + spacing: defaultSpacing + property real cellWidth: col.width / 3 - spacing + Text { text: "Control the second window:" } + Grid { + id: grid + columns: 3 + spacing: defaultSpacing + width: parent.width + Shared.Button { + id: showButton + width: col.cellWidth + text: testWindow.visible ? "Hide" : "Show" + onClicked: testWindow.visible = !testWindow.visible + } + //! [windowedCheckbox] + Shared.CheckBox { + text: "Windowed" + height: showButton.height + width: col.cellWidth + Binding on checked { value: testWindow.visibility === Window.Windowed } + onClicked: testWindow.visibility = Window.Windowed + } + //! [windowedCheckbox] + Shared.CheckBox { + height: showButton.height + width: col.cellWidth + text: "Full Screen" + Binding on checked { value: testWindow.visibility === Window.FullScreen } + onClicked: testWindow.visibility = Window.FullScreen + } + Shared.Button { + id: autoButton + width: col.cellWidth + text: "Automatic" + onClicked: testWindow.visibility = Window.AutomaticVisibility + } + Shared.CheckBox { + height: autoButton.height + text: "Minimized" + Binding on checked { value: testWindow.visibility === Window.Minimized } + onClicked: testWindow.visibility = Window.Minimized + } + Shared.CheckBox { + height: autoButton.height + text: "Maximized" + Binding on checked { value: testWindow.visibility === Window.Maximized } + onClicked: testWindow.visibility = Window.Maximized + } + } + function visibilityToString(v) { + switch (v) { + case Window.Windowed: + return "windowed"; + case Window.Minimized: + return "minimized"; + case Window.Maximized: + return "maximized"; + case Window.FullScreen: + return "fullscreen"; + case Window.AutomaticVisibility: + return "automatic"; + case Window.Hidden: + return "hidden"; + } + return "unknown"; + } + Text { + text: "second window is " + (testWindow.visible ? "visible" : "invisible") + + " and has visibility " + parent.visibilityToString(testWindow.visibility) + } + Rectangle { + id: horizontalRule + color: "black" + width: parent.width + height: 1 + } + ScreenInfo { } + } + } + + property var testWindow: Window { + width: 320 + height: 240 + color: "#215400" + title: "Test Window with color " + color + Rectangle { + anchors.fill: parent + anchors.margins: defaultSpacing + Text { + anchors.centerIn: parent + text: "Second Window" + } + MouseArea { + anchors.fill: parent + onClicked: testWindow.color = "#e0c31e" + } + Shared.Button { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: defaultSpacing + text: testWindow.visibility === Window.FullScreen ? "exit fullscreen" : "go fullscreen" + width: 150 + onClicked: { + if (testWindow.visibility === Window.FullScreen) + testWindow.visibility = Window.AutomaticVisibility + else + testWindow.visibility = Window.FullScreen + } + } + Shared.Button { + anchors.left: parent.left + anchors.top: parent.top + anchors.margins: defaultSpacing + text: "X" + width: 30 + onClicked: testWindow.visible = false + } + } + } +} diff --git a/examples/quick/window/window.qrc b/examples/quick/window/window.qrc new file mode 100644 index 0000000000..dc211bdaaf --- /dev/null +++ b/examples/quick/window/window.qrc @@ -0,0 +1,7 @@ + + + window.qml + Splash.qml + ScreenInfo.qml + + diff --git a/examples/quick/window/window/Window.qml b/examples/quick/window/window/Window.qml deleted file mode 100644 index 07900930d3..0000000000 --- a/examples/quick/window/window/Window.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** 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.Window 2.0 - -Window { - width: 640 - height: 480 - visible: true //It's false by default - property Component self - Component.onCompleted: self = Qt.createComponent("Window.qml") - Text{ - text: "Hello World!" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: self.createObject(); - } -} diff --git a/examples/quick/window/window/nogui.qml b/examples/quick/window/window/nogui.qml deleted file mode 100644 index 2a5734c773..0000000000 --- a/examples/quick/window/window/nogui.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** 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 QtQml 2.0 - -/* - This object's only functionality is to exist as a root object and - display nothing, proving that qmlscene can run without windows. - (A QtObject can't even have Component.onCompleted) -*/ -QtObject { - property string philosophy: "hello bleak windowless world" -} diff --git a/examples/quick/window/window/standalone.qml b/examples/quick/window/window/standalone.qml deleted file mode 100644 index db73bf66eb..0000000000 --- a/examples/quick/window/window/standalone.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** 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.Window 2.0 - -Item { - width: 320 - height: 240 - // It's not possible to set an Item's windowTitle. If you want to modify - // window properties, you need to explicitly create a Window. - Text { - id: text1 - anchors.centerIn: parent - text: "First Window\n" + (Qt.application.supportsMultipleWindows ? - "click the button to open a second window" : "only one window is allowed") - } - Rectangle { - border.color: "black" - radius: 4 - anchors.top: text1.bottom - anchors.horizontalCenter: text1.horizontalCenter - width: 100 - height: 30 - TextInput { - id: ti1 - focus: true // but the modal popup will prevent input while it is open - anchors.centerIn: parent - } - } - Rectangle { - border.color: "black" - color: childWindow.visible ? "goldenrod" : "beige" - radius: height / 4 - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.margins: 10 - width: text.implicitWidth + 20 - height: text.implicitHeight + 20 - visible: Qt.application.supportsMultipleWindows - Text { - id: text - text: "Pop up window" - anchors.centerIn: parent - } - MouseArea { - anchors.fill: parent - onClicked: childWindow.visible = !childWindow.visible - } - } - - Window { - id: childWindow - width: 320 - height: 240 - x: 220 - y: 120 - color: "beige" - title: "Second Window" - modality: Qt.ApplicationModal - flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint - Text { - id: text2 - anchors.centerIn: parent - text: "Modal Frameless Stay-on-Top Window" - } - Text { - anchors.top: parent.top - anchors.right: parent.right - anchors.margins: 10 - text: "X" - MouseArea{ - anchors.fill: parent - onClicked: childWindow.visible = false - } - } - Rectangle { - border.color: "black" - radius: 4 - anchors.top: text2.bottom - anchors.horizontalCenter: text2.horizontalCenter - width: 100 - height: 30 - TextInput { - id: ti2 - focus: true - anchors.centerIn: parent - } - } - } -} diff --git a/examples/quick/window/window/twowindows.qml b/examples/quick/window/window/twowindows.qml deleted file mode 100644 index 4a8d2f4f1b..0000000000 --- a/examples/quick/window/window/twowindows.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** 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.Window 2.0 - -QtObject { - property var win1: Window { - width: 320 - height: 240 - x: 0 - y: 0 - visible: true - color: "#ccffff" - title: "First Window" - Text { - anchors.centerIn: parent - text: "First Window" - Text { - id: statusText - anchors.top: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - anchors.fill: parent - onClicked: win2.visible = !win2.visible - } - } - property var win2: Window { - width: 320 - height: 240 - x: 220 - y: 120 - visible: true - color: "green" - title: "Second Window: " + color - Rectangle { - anchors.fill: parent - anchors.margins: 10 - Text { - anchors.centerIn: parent - text: "Second Window" - } - MouseArea { - anchors.fill: parent - onClicked: win2.color = "#ffffcc" - } - } - onVisibleChanged: statusText.text = "second window is " + (visible ? "visible" : "invisible") - } -} diff --git a/examples/quick/window/window/window.cpp b/examples/quick/window/window/window.cpp deleted file mode 100644 index 277effc20c..0000000000 --- a/examples/quick/window/window/window.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include -#include -#include - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(QUrl("qrc:///window/window/Window.qml")); - if ( component.isReady() ) - component.create(); - else - qWarning() << component.errorString(); - return app.exec(); -} diff --git a/examples/quick/window/window/window.pro b/examples/quick/window/window/window.pro deleted file mode 100644 index 3525a893fa..0000000000 --- a/examples/quick/window/window/window.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -QT += qml - -SOURCES += window.cpp -RESOURCES += window.qrc - -EXAMPLE_FILES = \ - nogui.qml \ - standalone.qml \ - twowindows.qml - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/window/window -INSTALLS = target diff --git a/examples/quick/window/window/window.qrc b/examples/quick/window/window/window.qrc deleted file mode 100644 index c203c140fc..0000000000 --- a/examples/quick/window/window/window.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - Window.qml - - -- cgit v1.2.3 From 43484528552cb2ba3dc1dabfcce22ed40bf4f8db Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 27 May 2013 18:44:34 +0200 Subject: Package dialogs examples into a single executable Introduced tabs and added the C++ boilerplate launcher. Change-Id: Ibb49a182e3928aba5dced097d5307eb7d1f4b42d Reviewed-by: Richard Moe Gustavsen --- examples/quick/dialogs/ColorDialogs.qml | 38 +++++++++++- examples/quick/dialogs/FileDialogs.qml | 77 ++++++++++++------------ examples/quick/dialogs/dialogs.pro | 17 ++++++ examples/quick/dialogs/dialogs.qml | 59 +++++++++++++++++++ examples/quick/dialogs/dialogs.qrc | 7 +++ examples/quick/dialogs/main.cpp | 41 +++++++++++++ examples/quick/quick.pro | 1 + examples/quick/shared/TabSet.qml | 101 ++++++++++++++++++++++++++++++++ examples/quick/shared/images/tab.png | Bin 0 -> 507 bytes examples/quick/shared/qmldir | 1 + examples/quick/shared/shared.h | 2 +- examples/quick/shared/shared.qrc | 2 + 12 files changed, 305 insertions(+), 41 deletions(-) create mode 100644 examples/quick/dialogs/dialogs.pro create mode 100644 examples/quick/dialogs/dialogs.qml create mode 100644 examples/quick/dialogs/dialogs.qrc create mode 100644 examples/quick/dialogs/main.cpp create mode 100644 examples/quick/shared/TabSet.qml create mode 100644 examples/quick/shared/images/tab.png (limited to 'examples') diff --git a/examples/quick/dialogs/ColorDialogs.qml b/examples/quick/dialogs/ColorDialogs.qml index 7817c8edf8..f3d253aa8c 100644 --- a/examples/quick/dialogs/ColorDialogs.qml +++ b/examples/quick/dialogs/ColorDialogs.qml @@ -46,8 +46,8 @@ Rectangle { width: 320 height: 200 color: palette.window - SystemPalette { id: palette } + clip: true ColorDialog { id: colorDialog @@ -62,7 +62,7 @@ Rectangle { Column { anchors.fill: parent - anchors.margins: 8 + anchors.margins: 12 spacing: 8 Text { font.bold: true @@ -106,4 +106,38 @@ Rectangle { } } } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.close() + } + Button { + text: "set to green" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.color = "green" + } + } + } } diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/FileDialogs.qml index a6df29bb37..8ed64b0b3c 100644 --- a/examples/quick/dialogs/FileDialogs.qml +++ b/examples/quick/dialogs/FileDialogs.qml @@ -43,43 +43,11 @@ import QtQuick.Dialogs 1.0 import "../shared" Rectangle { - width: 580 - height: 360 + height: 400 color: palette.window SystemPalette { id: palette } - - Rectangle { - id: toolbar - width: parent.width - height: 40 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 8 - height: parent.height - 6 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.close() - } - Button { - 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" - } - } - } + clip: true FileDialog { id: fileDialog @@ -97,10 +65,8 @@ Rectangle { } Column { - anchors.left: parent.left - anchors.right: parent.right - anchors.top: toolbar.bottom - anchors.margins: 8 + anchors.fill: parent + anchors.margins: 12 spacing: 8 Text { color: palette.windowText @@ -163,4 +129,39 @@ Rectangle { wrapMode: Text.Wrap } } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.close() + } + Button { + text: "go to /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" + } + } + } } diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro new file mode 100644 index 0000000000..b76f396e9d --- /dev/null +++ b/examples/quick/dialogs/dialogs.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp +RESOURCES += dialogs.qrc ../shared/shared.qrc + +OTHER_FILES += \ + dialogs.qml \ + FileDialogs.qml \ + ColorDialogs.qml + +EXAMPLE_FILES = \ + FileDialogs.qml \ + ColorDialogs.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs +INSTALLS += target diff --git a/examples/quick/dialogs/dialogs.qml b/examples/quick/dialogs/dialogs.qml new file mode 100644 index 0000000000..b5f9841a3f --- /dev/null +++ b/examples/quick/dialogs/dialogs.qml @@ -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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +TabSet { + width: 580 + height: 440 + + FileDialogs { + property string title: "File Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } + + ColorDialogs { + property string title: "Color Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } +} diff --git a/examples/quick/dialogs/dialogs.qrc b/examples/quick/dialogs/dialogs.qrc new file mode 100644 index 0000000000..efebfe4845 --- /dev/null +++ b/examples/quick/dialogs/dialogs.qrc @@ -0,0 +1,7 @@ + + + dialogs.qml + FileDialogs.qml + ColorDialogs.qml + + diff --git a/examples/quick/dialogs/main.cpp b/examples/quick/dialogs/main.cpp new file mode 100644 index 0000000000..bbf0c48104 --- /dev/null +++ b/examples/quick/dialogs/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** 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 "../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index 2d8acb3345..311e264af1 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -20,6 +20,7 @@ SUBDIRS = accessibility \ customitems \ imageprovider \ window \ + dialogs \ particles \ demos diff --git a/examples/quick/shared/TabSet.qml b/examples/quick/shared/TabSet.qml new file mode 100644 index 0000000000..10263a70ac --- /dev/null +++ b/examples/quick/shared/TabSet.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** 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 { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setZOrders() + Component.onCompleted: setZOrders() + + function setZOrders() { + for (var i = 0; i < stack.children.length; ++i) + stack.children[i].z = (i == current ? 1 : 0) + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "images/tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/quick/shared/images/tab.png b/examples/quick/shared/images/tab.png new file mode 100644 index 0000000000..ad8021605f Binary files /dev/null and b/examples/quick/shared/images/tab.png differ diff --git a/examples/quick/shared/qmldir b/examples/quick/shared/qmldir index cc4eb3c793..4f7c50540d 100644 --- a/examples/quick/shared/qmldir +++ b/examples/quick/shared/qmldir @@ -3,3 +3,4 @@ CheckBox 2.1 CheckBox.qml LauncherList 2.0 LauncherList.qml SimpleLauncherDelegate 2.0 SimpleLauncherDelegate.qml Slider 2.0 Slider.qml +TabSet 2.1 TabSet.qml diff --git a/examples/quick/shared/shared.h b/examples/quick/shared/shared.h index eab15f3e0a..c59e858d47 100644 --- a/examples/quick/shared/shared.h +++ b/examples/quick/shared/shared.h @@ -47,9 +47,9 @@ QQuickView view;\ view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\ view.setSource(QUrl("qrc:///" #NAME ".qml")); \ + view.setResizeMode(QQuickView::SizeRootObjectToView);\ if (QGuiApplication::platformName() == QLatin1String("qnx") || \ QGuiApplication::platformName() == QLatin1String("eglfs")) {\ - view.setResizeMode(QQuickView::SizeRootObjectToView);\ view.showFullScreen();\ } else {\ view.show();\ diff --git a/examples/quick/shared/shared.qrc b/examples/quick/shared/shared.qrc index 8912c17831..6aaeca5211 100644 --- a/examples/quick/shared/shared.qrc +++ b/examples/quick/shared/shared.qrc @@ -6,9 +6,11 @@ Slider.qml images/slider_handle.png CheckBox.qml + TabSet.qml images/back.png images/next.png images/qt-logo.png images/checkmark.png + images/tab.png -- cgit v1.2.3 From 56c1111d392ac6bfb33559f1ca4e09e4e258a777 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 28 May 2013 09:00:58 +0200 Subject: Dialogs: Create directory structure for documentation Change-Id: I5245a6931606673733130b1f168fddafe8def695 Reviewed-by: Jerome Pasion --- examples/quick/dialogs/ColorDialogs.qml | 143 ----------------- examples/quick/dialogs/FileDialogs.qml | 167 -------------------- .../dialogs/colorandfiledialogs/ColorDialogs.qml | 145 ++++++++++++++++++ .../dialogs/colorandfiledialogs/FileDialogs.qml | 169 +++++++++++++++++++++ .../colorandfiledialogs/colorandfiledialogs.pro | 17 +++ .../colorandfiledialogs/colorandfiledialogs.qrc | 7 + .../quick/dialogs/colorandfiledialogs/dialogs.qml | 59 +++++++ .../doc/images/qml-colorandfiledialogs-example.jpg | Bin 0 -> 47413 bytes .../doc/src/colorandfiledialogs.qdoc | 44 ++++++ .../quick/dialogs/colorandfiledialogs/main.cpp | 41 +++++ examples/quick/dialogs/dialogs.pro | 19 +-- examples/quick/dialogs/dialogs.qml | 59 ------- examples/quick/dialogs/dialogs.qrc | 7 - examples/quick/dialogs/main.cpp | 41 ----- 14 files changed, 485 insertions(+), 433 deletions(-) delete mode 100644 examples/quick/dialogs/ColorDialogs.qml delete mode 100644 examples/quick/dialogs/FileDialogs.qml create mode 100644 examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml create mode 100644 examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml create mode 100644 examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro create mode 100644 examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc create mode 100644 examples/quick/dialogs/colorandfiledialogs/dialogs.qml create mode 100644 examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg create mode 100644 examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc create mode 100644 examples/quick/dialogs/colorandfiledialogs/main.cpp delete mode 100644 examples/quick/dialogs/dialogs.qml delete mode 100644 examples/quick/dialogs/dialogs.qrc delete mode 100644 examples/quick/dialogs/main.cpp (limited to 'examples') diff --git a/examples/quick/dialogs/ColorDialogs.qml b/examples/quick/dialogs/ColorDialogs.qml deleted file mode 100644 index f3d253aa8c..0000000000 --- a/examples/quick/dialogs/ColorDialogs.qml +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** 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: 320 - height: 200 - color: palette.window - SystemPalette { id: palette } - clip: true - - ColorDialog { - id: colorDialog - visible: colorDialogVisible.checked - modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal - title: "Choose a color" - color: "green" - showAlphaChannel: colorDialogAlpha.checked - onAccepted: { console.log("Accepted: " + color) } - onRejected: { console.log("Rejected") } - } - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - font.bold: true - text: "Color dialog properties:" - } - CheckBox { - id: colorDialogModal - text: "Modal" - checked: true - Binding on checked { value: colorDialog.modality != Qt.NonModal } - } - CheckBox { - id: colorDialogAlpha - text: "Show alpha channel" - Binding on checked { value: colorDialog.showAlphaChannel } - } - CheckBox { - id: colorDialogVisible - text: "Visible" - Binding on checked { value: colorDialog.visible } - } - Row { - id: colorRow - spacing: parent.spacing - height: colorLabel.implicitHeight * 2.0 - Rectangle { - color: colorDialog.color - height: parent.height - width: height * 2 - border.color: "black" - MouseArea { - anchors.fill: parent - onClicked: colorDialog.open() - } - } - Text { - id: colorLabel - color: palette.windowText - text: "current color: " + colorDialog.color - anchors.verticalCenter: parent.verticalCenter - } - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 50 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: parent.height - 6 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.close() - } - Button { - text: "set to green" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.color = "green" - } - } - } -} diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/FileDialogs.qml deleted file mode 100644 index 8ed64b0b3c..0000000000 --- a/examples/quick/dialogs/FileDialogs.qml +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** 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: 400 - color: palette.window - SystemPalette { id: palette } - clip: true - - 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.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - 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: palette.windowText - text: "current view folder: " + fileDialog.folder - } - Text { - color: palette.windowText - text: "name filters: {" + fileDialog.nameFilters + "}" - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "current filter:" + fileDialog.selectedNameFilter - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "chosen files: " + fileDialog.fileUrls - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "chosen single path: " + fileDialog.fileUrl - width: parent.width - wrapMode: Text.Wrap - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 50 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: parent.height - 6 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.close() - } - Button { - text: "go to /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" - } - } - } -} diff --git a/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml new file mode 100644 index 0000000000..6a0af7f730 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** 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: 320 + height: 200 + color: palette.window + SystemPalette { id: palette } + clip: true + + //! [colordialog] + ColorDialog { + id: colorDialog + visible: colorDialogVisible.checked + modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal + title: "Choose a color" + color: "green" + showAlphaChannel: colorDialogAlpha.checked + onAccepted: { console.log("Accepted: " + color) } + onRejected: { console.log("Rejected") } + } + //! [colordialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + font.bold: true + text: "Color dialog properties:" + } + CheckBox { + id: colorDialogModal + text: "Modal" + checked: true + Binding on checked { value: colorDialog.modality != Qt.NonModal } + } + CheckBox { + id: colorDialogAlpha + text: "Show alpha channel" + Binding on checked { value: colorDialog.showAlphaChannel } + } + CheckBox { + id: colorDialogVisible + text: "Visible" + Binding on checked { value: colorDialog.visible } + } + Row { + id: colorRow + spacing: parent.spacing + height: colorLabel.implicitHeight * 2.0 + Rectangle { + color: colorDialog.color + height: parent.height + width: height * 2 + border.color: "black" + MouseArea { + anchors.fill: parent + onClicked: colorDialog.open() + } + } + Text { + id: colorLabel + color: palette.windowText + text: "current color: " + colorDialog.color + anchors.verticalCenter: parent.verticalCenter + } + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.close() + } + Button { + text: "set to green" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.color = "green" + } + } + } +} diff --git a/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml new file mode 100644 index 0000000000..d1278609f9 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** 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: 400 + color: palette.window + SystemPalette { id: palette } + clip: true + + //! [filedialog] + 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") } + } + //! [filedialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + color: palette.windowText + 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: palette.windowText + text: "current view folder: " + fileDialog.folder + } + Text { + color: palette.windowText + text: "name filters: {" + fileDialog.nameFilters + "}" + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "current filter:" + fileDialog.selectedNameFilter + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "chosen files: " + fileDialog.fileUrls + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "chosen single path: " + fileDialog.fileUrl + width: parent.width + wrapMode: Text.Wrap + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.close() + } + Button { + text: "go to /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" + } + } + } +} diff --git a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro new file mode 100644 index 0000000000..3a7b25c91a --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro @@ -0,0 +1,17 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp +RESOURCES += colorandfiledialogs.qrc ../../shared/shared.qrc + +OTHER_FILES += \ + dialogs.qml \ + FileDialogs.qml \ + ColorDialogs.qml + +EXAMPLE_FILES = \ + FileDialogs.qml \ + ColorDialogs.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs +INSTALLS += target diff --git a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc new file mode 100644 index 0000000000..efebfe4845 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc @@ -0,0 +1,7 @@ + + + dialogs.qml + FileDialogs.qml + ColorDialogs.qml + + diff --git a/examples/quick/dialogs/colorandfiledialogs/dialogs.qml b/examples/quick/dialogs/colorandfiledialogs/dialogs.qml new file mode 100644 index 0000000000..b5f9841a3f --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/dialogs.qml @@ -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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +TabSet { + width: 580 + height: 440 + + FileDialogs { + property string title: "File Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } + + ColorDialogs { + property string title: "Color Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } +} diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg b/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg new file mode 100644 index 0000000000..4517a39308 Binary files /dev/null and b/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg differ diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc new file mode 100644 index 0000000000..e3d021dba8 --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +/*! + \title Qt Quick ColorDialog and FileDialog Examples + \example colorandfiledialogs + \brief This example demonstrates the color and file dialog types in QML + \image qml-colorandfiledialogs-example.jpg + \ingroup qtquickdialog_examples + + This example demonstrates the color and file system dialogs in the \l{Qt Quick Dialogs} + module. The appearance and behavior is platform-dependent. + + A \l FileDialog is used to choose a single file, multiple files or a + single directory, depending on how it is configured. + \snippet dialogs/colorandfiledialogs/FileDialogs.qml filedialog + + A \l ColorDialog is used to choose a color, with or without alpha (transparency) + depending on how it is configured. + \snippet dialogs/colorandfiledialogs/ColorDialogs.qml colordialog +*/ diff --git a/examples/quick/dialogs/colorandfiledialogs/main.cpp b/examples/quick/dialogs/colorandfiledialogs/main.cpp new file mode 100644 index 0000000000..e8c2ae6aaa --- /dev/null +++ b/examples/quick/dialogs/colorandfiledialogs/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** 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 "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro index b76f396e9d..275e36470f 100644 --- a/examples/quick/dialogs/dialogs.pro +++ b/examples/quick/dialogs/dialogs.pro @@ -1,17 +1,4 @@ -TEMPLATE = app +TEMPLATE = subdirs -QT += quick qml -SOURCES += main.cpp -RESOURCES += dialogs.qrc ../shared/shared.qrc - -OTHER_FILES += \ - dialogs.qml \ - FileDialogs.qml \ - ColorDialogs.qml - -EXAMPLE_FILES = \ - FileDialogs.qml \ - ColorDialogs.qml - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs -INSTALLS += target +SUBDIRS = \ + colorandfiledialogs diff --git a/examples/quick/dialogs/dialogs.qml b/examples/quick/dialogs/dialogs.qml deleted file mode 100644 index b5f9841a3f..0000000000 --- a/examples/quick/dialogs/dialogs.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** 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 "../shared" - -TabSet { - width: 580 - height: 440 - - FileDialogs { - property string title: "File Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png - } - - ColorDialogs { - property string title: "Color Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png - } -} diff --git a/examples/quick/dialogs/dialogs.qrc b/examples/quick/dialogs/dialogs.qrc deleted file mode 100644 index efebfe4845..0000000000 --- a/examples/quick/dialogs/dialogs.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - dialogs.qml - FileDialogs.qml - ColorDialogs.qml - - diff --git a/examples/quick/dialogs/main.cpp b/examples/quick/dialogs/main.cpp deleted file mode 100644 index bbf0c48104..0000000000 --- a/examples/quick/dialogs/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** 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 "../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) -- cgit v1.2.3 From c7915779e113e270a1fd862eda375aa8ffcbbf4a Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 29 May 2013 11:01:22 +0200 Subject: Doc: Fix various problems in Qt Quick Dialogs documentation This change fixes the following things in .qdocconf: - CamelCase for project name (required for generating valid tags in example manifest file). - Proper selector for QML Types topic - Fix exampledirs to not pull in all the Qt Quick examples - Add examplesinstallpath to make Qt Creator see the examples Also fixes the paths in example docs according to changed exampledirs. Change-Id: If18f7b5a3160d85814d508e1cbfb7bdb1a002c54 Reviewed-by: Caroline Chao Reviewed-by: Jerome Pasion Reviewed-by: Shawn Rutledge --- .../dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc index e3d021dba8..68804649a9 100644 --- a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc +++ b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc @@ -36,9 +36,9 @@ A \l FileDialog is used to choose a single file, multiple files or a single directory, depending on how it is configured. - \snippet dialogs/colorandfiledialogs/FileDialogs.qml filedialog + \snippet colorandfiledialogs/FileDialogs.qml filedialog A \l ColorDialog is used to choose a color, with or without alpha (transparency) depending on how it is configured. - \snippet dialogs/colorandfiledialogs/ColorDialogs.qml colordialog + \snippet colorandfiledialogs/ColorDialogs.qml colordialog */ -- cgit v1.2.3 From 251a267fb5a48790b1446b5eda3ee553cd4abfab Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 29 May 2013 10:58:38 +0200 Subject: window example: show only the splash screen until the timeout The window takes time to resize itself; we can avoid letting the user see that by delaying visibility of the main window. Change-Id: I81d656102b384a66b5539cbd879aadb85261ba33 Reviewed-by: Gabriel de Dietrich --- examples/quick/window/Splash.qml | 11 ++++++++--- examples/quick/window/window.qml | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/quick/window/Splash.qml b/examples/quick/window/Splash.qml index 092e6e6fc2..c981bd2585 100644 --- a/examples/quick/window/Splash.qml +++ b/examples/quick/window/Splash.qml @@ -43,6 +43,7 @@ import QtQuick.Window 2.1 //! [splash-properties] Window { + id: splash visible: true width: splashImage.width height: splashImage.height @@ -50,7 +51,8 @@ Window { title: "Splash Window" modality: Qt.ApplicationModal flags: Qt.SplashScreen - property int timeout: 2000 + property int timeoutInterval: 2000 + signal timeout //! [splash-properties] //! [screen-properties] x: (Screen.width - splashImage.width) / 2 @@ -67,8 +69,11 @@ Window { } //! [timer] Timer { - interval: timeout; running: true; repeat: false - onTriggered: visible = false + interval: timeoutInterval; running: true; repeat: false + onTriggered: { + visible = false + splash.timeout() + } } //! [timer] } diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml index 1d7282f7a1..67e2ba40ff 100644 --- a/examples/quick/window/window.qml +++ b/examples/quick/window/window.qml @@ -46,14 +46,11 @@ QtObject { property real defaultSpacing: 10 property SystemPalette palette: SystemPalette { } - property var splashWindow: Splash { } - property var controlWindow: Window { width: 400 height: col.implicitHeight + defaultSpacing * 2 color: palette.window title: "Control Window" - visible: true Column { id: col anchors.fill: parent @@ -177,4 +174,8 @@ QtObject { } } } + + property var splashWindow: Splash { + onTimeout: controlWindow.visible = true + } } -- cgit v1.2.3 From 5e3d81ecfe0a14be2e1028a15df80df16d301db2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 29 May 2013 15:22:32 +0200 Subject: Fix various bugs in calqlatr It's still not a great example but at least it's somewhat usable now. - added files to .pro so you see them all in Creator - keypad is fixed size and the "tape" takes up the rest, so you can resize the window to be able to see long numbers - you can flick the ListView (MouseArea not on top of the whole thing!) - ListView scrolls to the bottom when you add numbers past the point that scrolling is necessary to see them - Clear, sqrt and +/- keys are functional Task-number: QTBUG-26556 Change-Id: I485e4123ad6c24ca64bad3efc3acfc14587268d8 Reviewed-by: Friedemann Kleint Reviewed-by: Alan Alpert --- examples/quick/demos/calqlatr/calqlatr.pro | 19 +++++++++++++++++++ examples/quick/demos/calqlatr/calqlatr.qml | 11 ++++++++--- examples/quick/demos/calqlatr/content/Display.qml | 20 ++++++++++++++++++-- examples/quick/demos/calqlatr/content/NumberPad.qml | 2 +- examples/quick/demos/calqlatr/content/calculator.js | 8 ++++---- 5 files changed, 50 insertions(+), 10 deletions(-) (limited to 'examples') diff --git a/examples/quick/demos/calqlatr/calqlatr.pro b/examples/quick/demos/calqlatr/calqlatr.pro index 1b002a5f27..91d52a293e 100644 --- a/examples/quick/demos/calqlatr/calqlatr.pro +++ b/examples/quick/demos/calqlatr/calqlatr.pro @@ -6,5 +6,24 @@ SOURCES += main.cpp RESOURCES += calqlatr.qrc \ ../../shared/shared.qrc +OTHER_FILES = calqlatr.qml \ + content/Button.qml \ + content/Display.qml \ + content/NumberPad.qml \ + content/StyleLabel.qml \ + content/audio/touch.wav \ + content/calculator.js \ + content/images/icon-back.png \ + content/images/icon-close.png \ + content/images/icon-settings.png \ + content/images/logo.png \ + content/images/paper-edge-left.png \ + content/images/paper-edge-right.png \ + content/images/paper-grip.png \ + content/images/settings-selected-a.png \ + content/images/settings-selected-b.png \ + content/images/touch-green.png \ + content/images/touch-white.png + target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/calqlatr INSTALLS += target diff --git a/examples/quick/demos/calqlatr/calqlatr.qml b/examples/quick/demos/calqlatr/calqlatr.qml index 16b2e19724..0a092c25da 100644 --- a/examples/quick/demos/calqlatr/calqlatr.qml +++ b/examples/quick/demos/calqlatr/calqlatr.qml @@ -57,7 +57,7 @@ Rectangle { Item { id: pad - width: window.width * 0.58 + width: 180 NumberPad { y: 10; anchors.horizontalCenter: parent.horizontalCenter } } @@ -77,7 +77,7 @@ Rectangle { Display { id: display x: -16 - width: window.width * 0.42 + width: window.width - pad.width height: parent.height MouseArea { @@ -85,7 +85,12 @@ Rectangle { property real oldP: 0 property bool rewind: false - anchors.fill: parent + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + } + height: 50 onPositionChanged: { var reverse = startX > window.width / 2 var mx = mapToItem(window, mouse.x).x diff --git a/examples/quick/demos/calqlatr/content/Display.qml b/examples/quick/demos/calqlatr/content/Display.qml index 4a78a3ebcd..ec8edfea66 100644 --- a/examples/quick/demos/calqlatr/content/Display.qml +++ b/examples/quick/demos/calqlatr/content/Display.qml @@ -42,23 +42,38 @@ import QtQuick 2.0 Item { id: display + property bool enteringDigits: false function displayOperator(operator) { listView.model.append({ "operator": operator, "operand": "" }) + enteringDigits = true } function newLine(operator, operand) { listView.model.append({ "operator": operator, "operand": operand }) + enteringDigits = false + listView.positionViewAtEnd() } function appendDigit(digit) { - if (!listView.model.count) + if (!enteringDigits) listView.model.append({ "operator": "", "operand": "" }) var i = listView.model.count - 1; listView.model.get(i).operand = listView.model.get(i).operand + digit; + enteringDigits = true + } + + function clear() + { + if (enteringDigits) { + var i = listView.model.count - 1 + if (i >= 0) + listView.model.remove(i) + enteringDigits = false + } } Item { @@ -87,6 +102,7 @@ Item { } Image { + id: grip source: "images/paper-grip.png" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom @@ -97,7 +113,7 @@ Item { id: listView x: 16; y: 30 width: display.width - height: display.height + height: display.height - 50 - y delegate: Item { height: 20 width: parent.width diff --git a/examples/quick/demos/calqlatr/content/NumberPad.qml b/examples/quick/demos/calqlatr/content/NumberPad.qml index 3203e18431..c7f2680651 100644 --- a/examples/quick/demos/calqlatr/content/NumberPad.qml +++ b/examples/quick/demos/calqlatr/content/NumberPad.qml @@ -60,7 +60,7 @@ Grid { Button { text: "±"; color: "#6da43d"; operator: true } Button { text: "−"; color: "#6da43d"; operator: true } Button { text: "+"; color: "#6da43d"; operator: true } - Button { text: " "; color: "#6da43d"; operator: true } + Button { text: "√"; color: "#6da43d"; operator: true } Button { text: "÷"; color: "#6da43d"; operator: true } Button { text: "×"; color: "#6da43d"; operator: true } Button { text: "C"; color: "#6da43d"; operator: true } diff --git a/examples/quick/demos/calqlatr/content/calculator.js b/examples/quick/demos/calqlatr/content/calculator.js index d86fecbf39..da8e940b16 100644 --- a/examples/quick/demos/calqlatr/content/calculator.js +++ b/examples/quick/demos/calqlatr/content/calculator.js @@ -84,7 +84,7 @@ function operatorPressed(op) } else if (previousOperator == "×") { digits = Number(curVal) * Number(digits.valueOf()) } else if (previousOperator == "÷") { - digits = Number(Number(curVal) / Number(digits.valueOf())).toString() + digits = Number(curVal) / Number(digits.valueOf()) } else if (previousOperator == "=") { } @@ -110,9 +110,9 @@ function operatorPressed(op) digits = (Math.abs(digits.valueOf())).toString() } else if (op == "Int") { digits = (Math.floor(digits.valueOf())).toString() - } else if (op == window.plusminus) { + } else if (op == "±") { digits = (digits.valueOf() * -1).toString() - } else if (op == window.squareRoot) { + } else if (op == "√") { digits = (Math.sqrt(digits.valueOf())).toString() } else if (op == "mc") { memory = 0; @@ -130,7 +130,7 @@ function operatorPressed(op) } else if (op == "Off") { Qt.quit(); } else if (op == "C") { - digits = "0" + display.clear() } else if (op == "AC") { curVal = 0 memory = 0 -- cgit v1.2.3 From 84adf4ff5b6b459c5dfc084b12f8ce6b58e5f5b7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 29 May 2013 10:29:08 +0200 Subject: Added QQuickWindow::setDefaultAlphaBuffer() All QQuickWindows will render using the same OpenGL context, so for a window to support transparency, the OpenGL context needs to be created with support for transparency from the very start. Therefore the application needs to call setDefaultAlphaBuffer() before creating windows. There are some relevant comments in QTBUG-20768 although the bug itself is not the same use case (it was already OK as long as the first window had a translucent color, because of setAlphaBufferSize in QQuickWindow::setColor()). Change-Id: I92e111c1a62c0d510821b646fd334e52254f8f57 Reviewed-by: Gunnar Sletta --- examples/quick/window/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'examples') diff --git a/examples/quick/window/main.cpp b/examples/quick/window/main.cpp index 2223c607b4..7872c7183c 100644 --- a/examples/quick/window/main.cpp +++ b/examples/quick/window/main.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,7 @@ int main(int argc, char* argv[]) QGuiApplication app(argc, argv); QQmlEngine engine; QQmlComponent component(&engine); + QQuickWindow::setDefaultAlphaBuffer(true); component.loadUrl(QUrl("qrc:///window/window.qml")); if ( component.isReady() ) component.create(); -- cgit v1.2.3 From 9d75626b1073113d77988bcb52e99215d5af4787 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 31 May 2013 10:38:33 -0700 Subject: Set incubation controller when a Window{} is loaded via QQmlApplicationEngine This was the one convenience that was lost when transitioning templates from QQuickView + Item{} to QQmlApplicationEngine + Window{}. As the default window incubation controller was tied to the first window's frameSwapped, we could easily run into a situation where a secondary window required incubation while the first window was idle. This would then starve the incubation controller. Instead make it so that the renderloop emits "timeToIncubate" once it is done with a renderpass over all windows, so the incubator gets to run once and exactly once per vsync when animating. The incubator logic was also flawed in that it could post a lot of events to itself as a result of incubatingObjectCountChanged and thus starve system events while processing incubation requests. Now we start a timer and don't start it again until we have completed an incubation pass. Task-number: QTBUG-31203 Change-Id: Iea9e2c81efb46bb7875c70ccda0cdc4b3b3e58e7 Reviewed-by: Alan Alpert Reviewed-by: Gunnar Sletta --- examples/quick/customitems/painteditem/painteditem.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'examples') diff --git a/examples/quick/customitems/painteditem/painteditem.pro b/examples/quick/customitems/painteditem/painteditem.pro index 77e4d146e1..3ec6420abf 100644 --- a/examples/quick/customitems/painteditem/painteditem.pro +++ b/examples/quick/customitems/painteditem/painteditem.pro @@ -18,3 +18,6 @@ qmldir.files = TextBalloonPlugin/qmldir qmldir.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/TextBalloonPlugin INSTALLS += qmldir target + +OTHER_FILES += \ + textballoons.qml -- cgit v1.2.3 From 5ce41d1e77db3f46c396834f698826f4fd998344 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 11 Jun 2013 09:55:14 +0200 Subject: Clean up qt quick dialogs example again I5245a6931606673733130b1f168fddafe8def695 took us the wrong direction: the intention was to put ALL dialogs in one example, because each example has some overhead (project, docs, screenshot, c++ launcher) and we don't want to have several more separate examples after the other dialog types are added. Color and file dialogs have no relationship to each other except that they happened to be implemented first. This is analogous to qtbase/examples/widgets/dialogs/standarddialogs And in fact, each dialog type is in a separate qml file, so you can run them individually with qmlscene anyway, which will keep this from becoming unwieldy and hard to understand. Change-Id: Id28d5718b4b7b475dcd7d62e31c4634219dc3ddc Reviewed-by: Jerome Pasion Reviewed-by: Caroline Chao --- examples/quick/dialogs/ColorDialogs.qml | 145 ++++++++++++++++++ examples/quick/dialogs/FileDialogs.qml | 169 +++++++++++++++++++++ .../dialogs/colorandfiledialogs/ColorDialogs.qml | 145 ------------------ .../dialogs/colorandfiledialogs/FileDialogs.qml | 169 --------------------- .../colorandfiledialogs/colorandfiledialogs.pro | 17 --- .../colorandfiledialogs/colorandfiledialogs.qrc | 7 - .../quick/dialogs/colorandfiledialogs/dialogs.qml | 59 ------- .../doc/images/qml-colorandfiledialogs-example.jpg | Bin 47413 -> 0 bytes .../doc/src/colorandfiledialogs.qdoc | 44 ------ .../quick/dialogs/colorandfiledialogs/main.cpp | 41 ----- examples/quick/dialogs/dialogs.pro | 19 ++- examples/quick/dialogs/dialogs.qml | 59 +++++++ examples/quick/dialogs/dialogs.qrc | 7 + .../quick/dialogs/doc/images/dialogs-example.jpg | Bin 0 -> 47413 bytes examples/quick/dialogs/doc/src/dialogs.qdoc | 44 ++++++ examples/quick/dialogs/main.cpp | 41 +++++ 16 files changed, 481 insertions(+), 485 deletions(-) create mode 100644 examples/quick/dialogs/ColorDialogs.qml create mode 100644 examples/quick/dialogs/FileDialogs.qml delete mode 100644 examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml delete mode 100644 examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml delete mode 100644 examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro delete mode 100644 examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc delete mode 100644 examples/quick/dialogs/colorandfiledialogs/dialogs.qml delete mode 100644 examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg delete mode 100644 examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc delete mode 100644 examples/quick/dialogs/colorandfiledialogs/main.cpp create mode 100644 examples/quick/dialogs/dialogs.qml create mode 100644 examples/quick/dialogs/dialogs.qrc create mode 100644 examples/quick/dialogs/doc/images/dialogs-example.jpg create mode 100644 examples/quick/dialogs/doc/src/dialogs.qdoc create mode 100644 examples/quick/dialogs/main.cpp (limited to 'examples') diff --git a/examples/quick/dialogs/ColorDialogs.qml b/examples/quick/dialogs/ColorDialogs.qml new file mode 100644 index 0000000000..6a0af7f730 --- /dev/null +++ b/examples/quick/dialogs/ColorDialogs.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** 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: 320 + height: 200 + color: palette.window + SystemPalette { id: palette } + clip: true + + //! [colordialog] + ColorDialog { + id: colorDialog + visible: colorDialogVisible.checked + modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal + title: "Choose a color" + color: "green" + showAlphaChannel: colorDialogAlpha.checked + onAccepted: { console.log("Accepted: " + color) } + onRejected: { console.log("Rejected") } + } + //! [colordialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + font.bold: true + text: "Color dialog properties:" + } + CheckBox { + id: colorDialogModal + text: "Modal" + checked: true + Binding on checked { value: colorDialog.modality != Qt.NonModal } + } + CheckBox { + id: colorDialogAlpha + text: "Show alpha channel" + Binding on checked { value: colorDialog.showAlphaChannel } + } + CheckBox { + id: colorDialogVisible + text: "Visible" + Binding on checked { value: colorDialog.visible } + } + Row { + id: colorRow + spacing: parent.spacing + height: colorLabel.implicitHeight * 2.0 + Rectangle { + color: colorDialog.color + height: parent.height + width: height * 2 + border.color: "black" + MouseArea { + anchors.fill: parent + onClicked: colorDialog.open() + } + } + Text { + id: colorLabel + color: palette.windowText + text: "current color: " + colorDialog.color + anchors.verticalCenter: parent.verticalCenter + } + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.close() + } + Button { + text: "set to green" + anchors.verticalCenter: parent.verticalCenter + onClicked: colorDialog.color = "green" + } + } + } +} diff --git a/examples/quick/dialogs/FileDialogs.qml b/examples/quick/dialogs/FileDialogs.qml new file mode 100644 index 0000000000..d1278609f9 --- /dev/null +++ b/examples/quick/dialogs/FileDialogs.qml @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** 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: 400 + color: palette.window + SystemPalette { id: palette } + clip: true + + //! [filedialog] + 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") } + } + //! [filedialog] + + Column { + anchors.fill: parent + anchors.margins: 12 + spacing: 8 + Text { + color: palette.windowText + 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: palette.windowText + text: "current view folder: " + fileDialog.folder + } + Text { + color: palette.windowText + text: "name filters: {" + fileDialog.nameFilters + "}" + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "current filter:" + fileDialog.selectedNameFilter + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "chosen files: " + fileDialog.fileUrls + width: parent.width + wrapMode: Text.Wrap + } + Text { + color: palette.windowText + text: "chosen single path: " + fileDialog.fileUrl + width: parent.width + wrapMode: Text.Wrap + } + } + + Rectangle { + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + height: 50 + color: Qt.darker(palette.window, 1.1) + border.color: Qt.darker(palette.window, 1.3) + Row { + spacing: 6 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 12 + height: parent.height - 6 + width: parent.width + Button { + text: "Open" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.open() + } + Button { + text: "Close" + anchors.verticalCenter: parent.verticalCenter + onClicked: fileDialog.close() + } + Button { + text: "go to /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" + } + } + } +} diff --git a/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml deleted file mode 100644 index 6a0af7f730..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/ColorDialogs.qml +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** 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: 320 - height: 200 - color: palette.window - SystemPalette { id: palette } - clip: true - - //! [colordialog] - ColorDialog { - id: colorDialog - visible: colorDialogVisible.checked - modality: colorDialogModal.checked ? Qt.WindowModal : Qt.NonModal - title: "Choose a color" - color: "green" - showAlphaChannel: colorDialogAlpha.checked - onAccepted: { console.log("Accepted: " + color) } - onRejected: { console.log("Rejected") } - } - //! [colordialog] - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - font.bold: true - text: "Color dialog properties:" - } - CheckBox { - id: colorDialogModal - text: "Modal" - checked: true - Binding on checked { value: colorDialog.modality != Qt.NonModal } - } - CheckBox { - id: colorDialogAlpha - text: "Show alpha channel" - Binding on checked { value: colorDialog.showAlphaChannel } - } - CheckBox { - id: colorDialogVisible - text: "Visible" - Binding on checked { value: colorDialog.visible } - } - Row { - id: colorRow - spacing: parent.spacing - height: colorLabel.implicitHeight * 2.0 - Rectangle { - color: colorDialog.color - height: parent.height - width: height * 2 - border.color: "black" - MouseArea { - anchors.fill: parent - onClicked: colorDialog.open() - } - } - Text { - id: colorLabel - color: palette.windowText - text: "current color: " + colorDialog.color - anchors.verticalCenter: parent.verticalCenter - } - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 50 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: parent.height - 6 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.close() - } - Button { - text: "set to green" - anchors.verticalCenter: parent.verticalCenter - onClicked: colorDialog.color = "green" - } - } - } -} diff --git a/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml b/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml deleted file mode 100644 index d1278609f9..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/FileDialogs.qml +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** -** -** 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: 400 - color: palette.window - SystemPalette { id: palette } - clip: true - - //! [filedialog] - 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") } - } - //! [filedialog] - - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - 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: palette.windowText - text: "current view folder: " + fileDialog.folder - } - Text { - color: palette.windowText - text: "name filters: {" + fileDialog.nameFilters + "}" - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "current filter:" + fileDialog.selectedNameFilter - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "chosen files: " + fileDialog.fileUrls - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "chosen single path: " + fileDialog.fileUrl - width: parent.width - wrapMode: Text.Wrap - } - } - - Rectangle { - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - height: 50 - color: Qt.darker(palette.window, 1.1) - border.color: Qt.darker(palette.window, 1.3) - Row { - spacing: 6 - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 12 - height: parent.height - 6 - width: parent.width - Button { - text: "Open" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.open() - } - Button { - text: "Close" - anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.close() - } - Button { - text: "go to /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" - } - } - } -} diff --git a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro deleted file mode 100644 index 3a7b25c91a..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp -RESOURCES += colorandfiledialogs.qrc ../../shared/shared.qrc - -OTHER_FILES += \ - dialogs.qml \ - FileDialogs.qml \ - ColorDialogs.qml - -EXAMPLE_FILES = \ - FileDialogs.qml \ - ColorDialogs.qml - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs -INSTALLS += target diff --git a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc b/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc deleted file mode 100644 index efebfe4845..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/colorandfiledialogs.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - dialogs.qml - FileDialogs.qml - ColorDialogs.qml - - diff --git a/examples/quick/dialogs/colorandfiledialogs/dialogs.qml b/examples/quick/dialogs/colorandfiledialogs/dialogs.qml deleted file mode 100644 index b5f9841a3f..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/dialogs.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** 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 "../shared" - -TabSet { - width: 580 - height: 440 - - FileDialogs { - property string title: "File Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png - } - - ColorDialogs { - property string title: "Color Dialog" - anchors.fill: parent - color: "#e3e3e3" // to match tab.png - } -} diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg b/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg deleted file mode 100644 index 4517a39308..0000000000 Binary files a/examples/quick/dialogs/colorandfiledialogs/doc/images/qml-colorandfiledialogs-example.jpg and /dev/null differ diff --git a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc b/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc deleted file mode 100644 index 68804649a9..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/doc/src/colorandfiledialogs.qdoc +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -/*! - \title Qt Quick ColorDialog and FileDialog Examples - \example colorandfiledialogs - \brief This example demonstrates the color and file dialog types in QML - \image qml-colorandfiledialogs-example.jpg - \ingroup qtquickdialog_examples - - This example demonstrates the color and file system dialogs in the \l{Qt Quick Dialogs} - module. The appearance and behavior is platform-dependent. - - A \l FileDialog is used to choose a single file, multiple files or a - single directory, depending on how it is configured. - \snippet colorandfiledialogs/FileDialogs.qml filedialog - - A \l ColorDialog is used to choose a color, with or without alpha (transparency) - depending on how it is configured. - \snippet colorandfiledialogs/ColorDialogs.qml colordialog -*/ diff --git a/examples/quick/dialogs/colorandfiledialogs/main.cpp b/examples/quick/dialogs/colorandfiledialogs/main.cpp deleted file mode 100644 index e8c2ae6aaa..0000000000 --- a/examples/quick/dialogs/colorandfiledialogs/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** 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 "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) diff --git a/examples/quick/dialogs/dialogs.pro b/examples/quick/dialogs/dialogs.pro index 275e36470f..b76f396e9d 100644 --- a/examples/quick/dialogs/dialogs.pro +++ b/examples/quick/dialogs/dialogs.pro @@ -1,4 +1,17 @@ -TEMPLATE = subdirs +TEMPLATE = app -SUBDIRS = \ - colorandfiledialogs +QT += quick qml +SOURCES += main.cpp +RESOURCES += dialogs.qrc ../shared/shared.qrc + +OTHER_FILES += \ + dialogs.qml \ + FileDialogs.qml \ + ColorDialogs.qml + +EXAMPLE_FILES = \ + FileDialogs.qml \ + ColorDialogs.qml + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/dialogs +INSTALLS += target diff --git a/examples/quick/dialogs/dialogs.qml b/examples/quick/dialogs/dialogs.qml new file mode 100644 index 0000000000..b5f9841a3f --- /dev/null +++ b/examples/quick/dialogs/dialogs.qml @@ -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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +TabSet { + width: 580 + height: 440 + + FileDialogs { + property string title: "File Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } + + ColorDialogs { + property string title: "Color Dialog" + anchors.fill: parent + color: "#e3e3e3" // to match tab.png + } +} diff --git a/examples/quick/dialogs/dialogs.qrc b/examples/quick/dialogs/dialogs.qrc new file mode 100644 index 0000000000..efebfe4845 --- /dev/null +++ b/examples/quick/dialogs/dialogs.qrc @@ -0,0 +1,7 @@ + + + dialogs.qml + FileDialogs.qml + ColorDialogs.qml + + diff --git a/examples/quick/dialogs/doc/images/dialogs-example.jpg b/examples/quick/dialogs/doc/images/dialogs-example.jpg new file mode 100644 index 0000000000..4517a39308 Binary files /dev/null and b/examples/quick/dialogs/doc/images/dialogs-example.jpg differ diff --git a/examples/quick/dialogs/doc/src/dialogs.qdoc b/examples/quick/dialogs/doc/src/dialogs.qdoc new file mode 100644 index 0000000000..daac914c60 --- /dev/null +++ b/examples/quick/dialogs/doc/src/dialogs.qdoc @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ +/*! + \title Qt Quick Dialog Examples + \example dialogs + \brief This example demonstrates the dialog types in QML + \image dialogs-example.jpg + \ingroup qtquickdialog_examples + + This example demonstrates the system dialogs in the \l{Qt Quick Dialogs} + module. The appearance and behavior is platform-dependent. + + A \l FileDialog is used to choose a single file, multiple files or a + single directory, depending on how it is configured. + \snippet dialogs/FileDialogs.qml filedialog + + A \l ColorDialog is used to choose a color, with or without alpha (transparency) + depending on how it is configured. + \snippet dialogs/ColorDialogs.qml colordialog +*/ diff --git a/examples/quick/dialogs/main.cpp b/examples/quick/dialogs/main.cpp new file mode 100644 index 0000000000..bbf0c48104 --- /dev/null +++ b/examples/quick/dialogs/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** 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 "../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(dialogs/dialogs) -- cgit v1.2.3 From 76d8f8a5d3a6229c49b072c5872cd99649210107 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 11 Jun 2013 20:47:54 +0200 Subject: Graph example Change-Id: I4a7b52f6e14182aed31354dc3860ef187e1899a4 Reviewed-by: Alan Alpert --- .../scenegraph/graph/doc/images/graph-example.jpg | Bin 0 -> 18923 bytes examples/quick/scenegraph/graph/doc/src/graph.qdoc | 38 ++++++ examples/quick/scenegraph/graph/graph.cpp | 128 +++++++++++++++++ examples/quick/scenegraph/graph/graph.h | 67 +++++++++ examples/quick/scenegraph/graph/graph.pro | 34 +++++ examples/quick/scenegraph/graph/graph.qrc | 9 ++ examples/quick/scenegraph/graph/gridnode.cpp | 95 +++++++++++++ examples/quick/scenegraph/graph/gridnode.h | 59 ++++++++ examples/quick/scenegraph/graph/linenode.cpp | 151 +++++++++++++++++++++ examples/quick/scenegraph/graph/linenode.h | 58 ++++++++ examples/quick/scenegraph/graph/main.cpp | 60 ++++++++ examples/quick/scenegraph/graph/main.qml | 85 ++++++++++++ examples/quick/scenegraph/graph/noisynode.cpp | 142 +++++++++++++++++++ examples/quick/scenegraph/graph/noisynode.h | 56 ++++++++ examples/quick/scenegraph/graph/shaders/line.fsh | 54 ++++++++ examples/quick/scenegraph/graph/shaders/line.vsh | 56 ++++++++ examples/quick/scenegraph/graph/shaders/noisy.fsh | 55 ++++++++ examples/quick/scenegraph/graph/shaders/noisy.vsh | 54 ++++++++ 18 files changed, 1201 insertions(+) create mode 100644 examples/quick/scenegraph/graph/doc/images/graph-example.jpg create mode 100644 examples/quick/scenegraph/graph/doc/src/graph.qdoc create mode 100644 examples/quick/scenegraph/graph/graph.cpp create mode 100644 examples/quick/scenegraph/graph/graph.h create mode 100644 examples/quick/scenegraph/graph/graph.pro create mode 100644 examples/quick/scenegraph/graph/graph.qrc create mode 100644 examples/quick/scenegraph/graph/gridnode.cpp create mode 100644 examples/quick/scenegraph/graph/gridnode.h create mode 100644 examples/quick/scenegraph/graph/linenode.cpp create mode 100644 examples/quick/scenegraph/graph/linenode.h create mode 100644 examples/quick/scenegraph/graph/main.cpp create mode 100644 examples/quick/scenegraph/graph/main.qml create mode 100644 examples/quick/scenegraph/graph/noisynode.cpp create mode 100644 examples/quick/scenegraph/graph/noisynode.h create mode 100644 examples/quick/scenegraph/graph/shaders/line.fsh create mode 100644 examples/quick/scenegraph/graph/shaders/line.vsh create mode 100644 examples/quick/scenegraph/graph/shaders/noisy.fsh create mode 100644 examples/quick/scenegraph/graph/shaders/noisy.vsh (limited to 'examples') diff --git a/examples/quick/scenegraph/graph/doc/images/graph-example.jpg b/examples/quick/scenegraph/graph/doc/images/graph-example.jpg new file mode 100644 index 0000000000..74975ee7c4 Binary files /dev/null and b/examples/quick/scenegraph/graph/doc/images/graph-example.jpg differ diff --git a/examples/quick/scenegraph/graph/doc/src/graph.qdoc b/examples/quick/scenegraph/graph/doc/src/graph.qdoc new file mode 100644 index 0000000000..d5a07cdc48 --- /dev/null +++ b/examples/quick/scenegraph/graph/doc/src/graph.qdoc @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** 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 scenegraph/graph + \title Scene Graph - Graph + \ingroup qtquickexamples + + \brief Demonstrates how one can combine custom materials and geometries + under a single QQuickItem. + + \image graph-example.jpg + + */ diff --git a/examples/quick/scenegraph/graph/graph.cpp b/examples/quick/scenegraph/graph/graph.cpp new file mode 100644 index 0000000000..ad75307e57 --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** 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 "graph.h" + +#include "noisynode.h" +#include "gridnode.h" +#include "linenode.h" + +Graph::Graph() + : m_samplesChanged(false) + , m_geometryChanged(false) +{ + setFlag(ItemHasContents, true); +} + + +void Graph::appendSample(qreal value) +{ + m_samples << value; + m_samplesChanged = true; + update(); +} + + +void Graph::removeFirstSample() +{ + m_samples.removeFirst(); + m_samplesChanged = true; + update(); +} + +void Graph::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + m_geometryChanged = true; + update(); + QQuickItem::geometryChanged(newGeometry, oldGeometry); +} + + +class GraphNode : public QSGNode +{ +public: + NoisyNode *background; + GridNode *grid; + LineNode *line; + LineNode *shadow; +}; + + +QSGNode *Graph::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) +{ + GraphNode *n= static_cast(oldNode); + + QRectF rect = boundingRect(); + + if (rect.isEmpty()) { + delete n; + return 0; + } + + if (!n) { + n = new GraphNode(); + + n->background = new NoisyNode(window()); + n->grid = new GridNode(); + n->line = new LineNode(10, 0.5, QColor("steelblue")); + n->shadow = new LineNode(20, 0.2, QColor::fromRgbF(0.2, 0.2, 0.2, 0.4)); + + n->appendChildNode(n->background); + n->appendChildNode(n->grid); + n->appendChildNode(n->shadow); + n->appendChildNode(n->line); + } + + if (m_geometryChanged) { + n->background->setRect(rect); + n->grid->setRect(rect); + } + + if (m_geometryChanged || m_samplesChanged) { + n->line->updateGeometry(rect, m_samples); + // We don't need to calculate the geometry twice, so just steal it from the other one... + n->shadow->setGeometry(n->line->geometry()); + } + + m_geometryChanged = false; + m_samplesChanged = false; + + return n; +} diff --git a/examples/quick/scenegraph/graph/graph.h b/examples/quick/scenegraph/graph/graph.h new file mode 100644 index 0000000000..28d14f166a --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 GRAPH_H +#define GRAPH_H + +#include + +class Graph : public QQuickItem +{ + Q_OBJECT +public: + Graph(); + +protected: + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + +public slots: + void appendSample(qreal value); + void removeFirstSample(); + +private: + QList m_samples; + + bool m_samplesChanged; + bool m_geometryChanged; +}; + +#endif // GRAPH_H diff --git a/examples/quick/scenegraph/graph/graph.pro b/examples/quick/scenegraph/graph/graph.pro new file mode 100644 index 0000000000..5991f799dc --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-06-11T13:13:18 +# +#------------------------------------------------- + +QT += core gui quick + +TARGET = graph + +TEMPLATE = app + +SOURCES += main.cpp \ + graph.cpp \ + noisynode.cpp \ + gridnode.cpp \ + linenode.cpp + +HEADERS += \ + graph.h \ + noisynode.h \ + gridnode.h \ + linenode.h + +RESOURCES += \ + graph.qrc + +OTHER_FILES += \ + main.qml \ + shaders/noisy.vsh \ + shaders/noisy.fsh \ + shaders/line.fsh \ + shaders/line.vsh + diff --git a/examples/quick/scenegraph/graph/graph.qrc b/examples/quick/scenegraph/graph/graph.qrc new file mode 100644 index 0000000000..2adaeac751 --- /dev/null +++ b/examples/quick/scenegraph/graph/graph.qrc @@ -0,0 +1,9 @@ + + + main.qml + shaders/noisy.vsh + shaders/noisy.fsh + shaders/line.vsh + shaders/line.fsh + + diff --git a/examples/quick/scenegraph/graph/gridnode.cpp b/examples/quick/scenegraph/graph/gridnode.cpp new file mode 100644 index 0000000000..2b5e8cac16 --- /dev/null +++ b/examples/quick/scenegraph/graph/gridnode.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "gridnode.h" + +#include "qmath.h" + +#define GRID_SIZE 32 + +GridNode::GridNode() + : m_geometry(QSGGeometry::defaultAttributes_Point2D(), 0) +{ + setGeometry(&m_geometry); + m_geometry.setDrawingMode(GL_LINES); + + setMaterial(&m_material); + m_material.setColor(Qt::gray); +} + +/* + * The function hardcodes a fixed set of grid lines and scales + * those to the bounding rect. + */ +void GridNode::setRect(const QRectF &rect) +{ + int vCount = int((rect.width() - 1) / GRID_SIZE); + int hCount = int((rect.height() - 1) / GRID_SIZE); + + int lineCount = vCount + hCount; + + QSGGeometry *g = geometry(); + + g->allocate(lineCount * 2); + + float x = rect.x(); + float y = rect.y(); + float w = rect.width(); + float h = rect.height(); + + QSGGeometry::Point2D *v = g->vertexDataAsPoint2D(); + + // Then write the vertical lines + for (int i=0; i +#include + +class GridNode : public QSGGeometryNode +{ +public: + GridNode(); + + void setRect(const QRectF &rect); + +private: + QSGFlatColorMaterial m_material; + QSGGeometry m_geometry; +}; + +#endif // GRIDNODE_H diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp new file mode 100644 index 0000000000..0d1229cf1d --- /dev/null +++ b/examples/quick/scenegraph/graph/linenode.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** 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 "linenode.h" + +#include + +#include + +#include + +struct LineMaterial +{ + QColor color; + float spread; + float size; +}; + +class LineShader : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial) + +public: + const char *vertexShader() const { + QResource r(":/scenegraph/graph/shaders/line.vsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + const char *fragmentShader() const { + QResource r(":/scenegraph/graph/shaders/line.fsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + QList attributes() const { return QList() << "pos" << "t"; } + + void updateState(const LineMaterial *m, const LineMaterial *) { + program()->setUniformValue(id_color, m->color); + program()->setUniformValue(id_spread, m->spread); + program()->setUniformValue(id_size, m->size); + } + + void resolveUniforms() { + id_spread = program()->uniformLocation("spread"); + id_size = program()->uniformLocation("size"); + id_color = program()->uniformLocation("color"); + } + +private: + int id_color; + int id_spread; + int id_size; +}; + +struct LineVertex { + float x; + float y; + float t; + inline void set(float xx, float yy, float tt) { x = xx; y = yy; t = tt; } +}; + +static const QSGGeometry::AttributeSet &attributes() +{ + static QSGGeometry::Attribute attr[] = { + QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), + QSGGeometry::Attribute::create(1, 1, GL_FLOAT) + }; + static QSGGeometry::AttributeSet set = { 2, 3 * sizeof(float), attr }; + return set; +} + +LineNode::LineNode(float size, float spread, const QColor &color) + : m_geometry(attributes(), 0) +{ + setGeometry(&m_geometry); + m_geometry.setDrawingMode(GL_TRIANGLE_STRIP); + + QSGSimpleMaterial *m = LineShader::createMaterial(); + m->state()->color = color; + m->state()->size = size; + m->state()->spread = spread; + m->setFlag(QSGMaterial::Blending); + setMaterial(m); + setFlag(OwnsMaterial); +} + +/* + * Assumes that samples have values in the range of 0 to 1 and scales them to + * the height of bounds. The samples are stretched out horizontally along the + * width of the bounds. + * + * The position of each pair of points is identical, but we use the third value + * "t" to shift the point up or down and to add antialiasing. + */ +void LineNode::updateGeometry(const QRectF &bounds, const QList &samples) +{ + m_geometry.allocate(samples.size() * 2); + + float x = bounds.x(); + float y = bounds.y(); + float w = bounds.width(); + float h = bounds.height(); + + float dx = w / (samples.size() - 1); + + LineVertex *v = (LineVertex *) m_geometry.vertexData(); + for (int i=0; i + +class LineNode : public QSGGeometryNode +{ +public: + LineNode(float size, float spread, const QColor &color); + + void updateGeometry(const QRectF &bounds, const QList &samples); + +private: + QSGGeometry m_geometry; + +}; + +#endif // LINENODE_H diff --git a/examples/quick/scenegraph/graph/main.cpp b/examples/quick/scenegraph/graph/main.cpp new file mode 100644 index 0000000000..ed54ae59b1 --- /dev/null +++ b/examples/quick/scenegraph/graph/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 +#include + +#include "graph.h" +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication a(argc, argv); + + qmlRegisterType("Graph", 1, 0, "Graph"); + + QQuickView view; + view.resize(800, 400); + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///scenegraph/graph/main.qml")); + view.show(); + + return a.exec(); +} diff --git a/examples/quick/scenegraph/graph/main.qml b/examples/quick/scenegraph/graph/main.qml new file mode 100644 index 0000000000..ad952bcf1a --- /dev/null +++ b/examples/quick/scenegraph/graph/main.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 Graph 1.0 + +Item { + width: 800 + height: 400 + + Graph { + id: graph + anchors.fill: parent + anchors.margins: 100 + + function newSample(i) { + return (Math.sin(i / 100.0 * Math.PI * 2) + 1) * 0.4 + Math.random() * 0.05; + } + + Component.onCompleted: { + for (var i=0; i<100; ++i) + appendSample(newSample(i)); + } + + property int offset: 100; + } + + Timer { + id: timer + interval: 500 + repeat: true + running: true + onTriggered: { + graph.removeFirstSample(); + graph.appendSample(graph.newSample(++graph.offset)); + } + + } + + Rectangle { + anchors.fill: graph + color: "transparent" + border.color: "black" + border.width: 2 + } + +} diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp new file mode 100644 index 0000000000..1fc87a2b97 --- /dev/null +++ b/examples/quick/scenegraph/graph/noisynode.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** 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 "noisynode.h" + +#include + +#include +#include +#include + +#define NOISE_SIZE 64 + +struct NoisyMaterial +{ + ~NoisyMaterial() { + delete texture; + } + + QColor color; + QSGTexture *texture; +}; + +class NoisyShader : public QSGSimpleMaterialShader +{ + QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial) + +public: + const char *vertexShader() const { + QResource r(":/scenegraph/graph/shaders/noisy.vsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + const char *fragmentShader() const { + QResource r(":/scenegraph/graph/shaders/noisy.fsh"); + Q_ASSERT(r.isValid()); + return (const char *) r.data(); + } + + QList attributes() const { return QList() << "aVertex" << "aTexCoord"; } + + void updateState(const NoisyMaterial *m, const NoisyMaterial *) { + + // Set the color + program()->setUniformValue(id_color, m->color); + + // Bind the texture and set program to use texture unit 0 (the default) + m->texture->bind(); + + // Then set the texture size so we can adjust the texture coordinates accordingly in the + // vertex shader.. + QSize s = m->texture->textureSize(); + program()->setUniformValue(id_textureSize, QSizeF(1.0 / s.width(), 1.0 / s.height())); + } + + void resolveUniforms() { + id_texture = program()->uniformLocation("texture"); + id_textureSize = program()->uniformLocation("textureSize"); + id_color = program()->uniformLocation("color"); + + // We will only use texture unit 0, so set it only once. + program()->setUniformValue(id_texture, 0); + } + +private: + int id_color; + int id_texture; + int id_textureSize; +}; + +NoisyNode::NoisyNode(QQuickWindow *window) +{ + // Make some noise... + QImage image(NOISE_SIZE, NOISE_SIZE, QImage::Format_RGB32); + uint *data = (uint *) image.bits(); + for (int i=0; icreateTextureFromImage(image); + t->setFiltering(QSGTexture::Nearest); + t->setHorizontalWrapMode(QSGTexture::Repeat); + t->setVerticalWrapMode(QSGTexture::Repeat); + + QSGSimpleMaterial *m = NoisyShader::createMaterial(); + m->state()->texture = t; + m->state()->color = QColor::fromRgbF(0.95, 0.95, 0.97); + m->setFlag(QSGMaterial::Blending); + + setMaterial(m); + setFlag(OwnsMaterial, true); + + QSGGeometry *g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); + QSGGeometry::updateTexturedRectGeometry(g, QRect(), QRect()); + setGeometry(g); + setFlag(OwnsGeometry, true); +} + +void NoisyNode::setRect(const QRectF &bounds) +{ + QSGGeometry::updateTexturedRectGeometry(geometry(), bounds, QRectF(0, 0, 1, 1)); + markDirty(QSGNode::DirtyGeometry); +} diff --git a/examples/quick/scenegraph/graph/noisynode.h b/examples/quick/scenegraph/graph/noisynode.h new file mode 100644 index 0000000000..b5a291330f --- /dev/null +++ b/examples/quick/scenegraph/graph/noisynode.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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 NOISYNODE_H +#define NOISYNODE_H + +#include + +class QQuickWindow; + +class NoisyNode : public QSGGeometryNode +{ +public: + NoisyNode(QQuickWindow *window); + + void setRect(const QRectF &bounds); +}; + +#endif // NOISYNODE_H diff --git a/examples/quick/scenegraph/graph/shaders/line.fsh b/examples/quick/scenegraph/graph/shaders/line.fsh new file mode 100644 index 0000000000..b07558c2ab --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/line.fsh @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +uniform lowp vec4 color; +uniform lowp float qt_Opacity; +uniform lowp float spread; + +varying lowp float vT; + +#define PI 3.14159265359 + +void main(void) +{ + lowp float tt = smoothstep(spread, 1.0, sin(vT * PI)); + + gl_FragColor = color * qt_Opacity * tt; +} diff --git a/examples/quick/scenegraph/graph/shaders/line.vsh b/examples/quick/scenegraph/graph/shaders/line.vsh new file mode 100644 index 0000000000..84353b852c --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/line.vsh @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +attribute highp vec4 pos; +attribute highp float t; + +uniform lowp float size; +uniform highp mat4 qt_Matrix; + +varying lowp float vT; + +void main(void) +{ + vec4 adjustedPos = pos; + adjustedPos.y += (t * size); + gl_Position = qt_Matrix * adjustedPos; + + vT = t; +} diff --git a/examples/quick/scenegraph/graph/shaders/noisy.fsh b/examples/quick/scenegraph/graph/shaders/noisy.fsh new file mode 100644 index 0000000000..227c2b5974 --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/noisy.fsh @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +uniform sampler2D texture; +uniform lowp float qt_Opacity; +uniform lowp vec4 color; + +varying highp vec2 vTexCoord; +varying lowp vec2 vShadeCoord; + +#define PI 3.14159265359 + +void main() +{ + lowp float shade = texture2D(texture, vTexCoord).r * 0.05 - length(vec2(0.5, 0.4) - vShadeCoord) * 0.3; + lowp vec4 c = vec4(color.xyz + shade, color.w); + gl_FragColor = c * qt_Opacity; +} diff --git a/examples/quick/scenegraph/graph/shaders/noisy.vsh b/examples/quick/scenegraph/graph/shaders/noisy.vsh new file mode 100644 index 0000000000..ce648e51b9 --- /dev/null +++ b/examples/quick/scenegraph/graph/shaders/noisy.vsh @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +attribute highp vec4 aVertex; +attribute highp vec2 aTexCoord; + +uniform highp mat4 qt_Matrix; +uniform highp vec2 textureSize; + +varying highp vec2 vTexCoord; +varying lowp vec2 vShadeCoord; + +void main() { + gl_Position = qt_Matrix * aVertex; + vTexCoord = aVertex.xy * textureSize; + vShadeCoord = aTexCoord; +} -- cgit v1.2.3