1/**************************************************************************** 2** 3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4** Contact: http://www.qt-project.org/legal 5** 6** This file is part of the examples of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:BSD$ 9** You may use this file under the terms of the BSD license as follows: 10** 11** "Redistribution and use in source and binary forms, with or without 12** modification, are permitted provided that the following conditions are 13** met: 14** * Redistributions of source code must retain the above copyright 15** notice, this list of conditions and the following disclaimer. 16** * Redistributions in binary form must reproduce the above copyright 17** notice, this list of conditions and the following disclaimer in 18** the documentation and/or other materials provided with the 19** distribution. 20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21** of its contributors may be used to endorse or promote products derived 22** from this software without specific prior written permission. 23** 24** 25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36** 37** $QT_END_LICENSE$ 38** 39****************************************************************************/ 40import QtQuick 2.0 41 42Rectangle { 43 //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"} 44 //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments 45 46 color: "#eee" 47 function addExample(name, desc, url) 48 { 49 myModel.append({"name":name, "description":desc, "url":url}) 50 } 51 function hideExample() 52 { 53 ei.visible = false; 54 } 55 56 ListView { 57 clip: true 58 delegate: SimpleLauncherDelegate{exampleItem: ei} 59 model: ListModel {id:myModel} 60 anchors.fill: parent 61 } 62 63 Item { 64 id: ei 65 visible: false 66 clip: true 67 property url exampleUrl 68 onExampleUrlChanged: visible = (exampleUrl == '' ? false : true); //Setting exampleUrl automatically shows example 69 anchors.fill: parent 70 anchors.bottomMargin: 40 71 Rectangle { 72 id: bg 73 anchors.fill: parent 74 color: "white" 75 } 76 MouseArea{ 77 anchors.fill: parent 78 enabled: ei.visible 79 //Eats mouse events 80 } 81 Loader{ 82 focus: true 83 source: ei.exampleUrl 84 anchors.fill: parent 85 } 86 } 87 Rectangle { 88 id: bar 89 visible: ei.visible 90 anchors.bottom: parent.bottom 91 width: parent.width 92 height: 40 93 94 Rectangle { 95 height: 1 96 color: "#ccc" 97 anchors.top: parent.top 98 anchors.left: parent.left 99 anchors.right: parent.right 100 } 101 102 Rectangle { 103 height: 1 104 color: "#fff" 105 anchors.top: parent.top 106 anchors.topMargin: 1 107 anchors.left: parent.left 108 anchors.right: parent.right 109 } 110 111 gradient: Gradient { 112 GradientStop { position: 0 ; color: "#eee" } 113 GradientStop { position: 1 ; color: "#ccc" } 114 } 115 116 MouseArea{ 117 anchors.fill: parent 118 enabled: ei.visible 119 //Eats mouse events 120 } 121 122 Image { 123 id: back 124 source: "images/back.png" 125 anchors.verticalCenter: parent.verticalCenter 126 anchors.verticalCenterOffset: 2 127 anchors.left: parent.left 128 anchors.leftMargin: 16 129 130 MouseArea { 131 id: mouse 132 hoverEnabled: true 133 anchors.centerIn: parent 134 width: 38 135 height: 31 136 anchors.verticalCenterOffset: -1 137 onClicked: ei.exampleUrl = "" 138 Rectangle { 139 anchors.fill: parent 140 opacity: mouse.pressed ? 1 : 0 141 Behavior on opacity { NumberAnimation{ duration: 100 }} 142 gradient: Gradient { 143 GradientStop { position: 0 ; color: "#22000000" } 144 GradientStop { position: 0.2 ; color: "#11000000" } 145 } 146 border.color: "darkgray" 147 antialiasing: true 148 radius: 4 149 } 150 } 151 } 152 } 153} 154