[844] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
| 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the demonstration applications of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
| 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | import QtQuick 1.0
|
---|
| 43 |
|
---|
| 44 | Item {
|
---|
| 45 | id: main
|
---|
| 46 | //height and width set by program to fill window
|
---|
| 47 | //below properties are sometimes set from C++
|
---|
| 48 | property url qmlFile: ''
|
---|
| 49 | property bool show: false
|
---|
| 50 |
|
---|
| 51 | Item{ id:embeddedViewer
|
---|
| 52 | width: parent.width
|
---|
| 53 | height: parent.height
|
---|
| 54 | opacity: 0;
|
---|
| 55 | z: 10
|
---|
| 56 | Loader{
|
---|
| 57 | id: loader
|
---|
| 58 | z: 10
|
---|
| 59 | focus: true //Automatic FocusScope
|
---|
| 60 | clip: true
|
---|
| 61 | source: qmlFile
|
---|
| 62 | anchors.centerIn: parent
|
---|
| 63 | onStatusChanged:{
|
---|
| 64 | if(status == Loader.Null) {
|
---|
| 65 | loader.focus = false;//fixes QTBUG11411, probably because the focusScope needs to gain focus to focus the right child
|
---|
| 66 | }else if(status == Loader.Ready) {
|
---|
| 67 | if(loader.item.width > 640)
|
---|
| 68 | loader.item.width = 640;
|
---|
| 69 | if(loader.item.height > 480)
|
---|
| 70 | loader.item.height = 480;
|
---|
| 71 | }}
|
---|
| 72 |
|
---|
| 73 | }
|
---|
| 74 | Rectangle{ id: frame
|
---|
| 75 | z: 9
|
---|
| 76 | anchors.fill: loader.status == Loader.Ready ? loader : errorTxt
|
---|
| 77 | anchors.margins: -8
|
---|
| 78 | radius: 4
|
---|
| 79 | smooth: true
|
---|
| 80 | border.color: "#88aaaaaa"
|
---|
| 81 | gradient: Gradient{
|
---|
| 82 | GradientStop{ position: 0.0; color: "#14FFFFFF" }
|
---|
| 83 | GradientStop{ position: 1.0; color: "#5AFFFFFF" }
|
---|
| 84 | }
|
---|
| 85 | MouseArea{
|
---|
| 86 | anchors.fill: parent
|
---|
| 87 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
---|
| 88 | onClicked: loader.focus=true;/* and don't propagate to the 'exit' area*/
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | Rectangle{ id: innerFrame
|
---|
| 92 | anchors.margins: 7
|
---|
| 93 | anchors.bottomMargin: 8
|
---|
| 94 | anchors.rightMargin: 8
|
---|
| 95 | color: "black"
|
---|
| 96 | border.color: "#44000000"
|
---|
| 97 | anchors.fill:parent
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | }
|
---|
| 101 | Rectangle{ id: closeButton
|
---|
| 102 | width: 24
|
---|
| 103 | height: 24
|
---|
| 104 | z: 11
|
---|
| 105 | border.color: "#aaaaaaaa"
|
---|
| 106 | gradient: Gradient{
|
---|
| 107 | GradientStop{ position: 0.0; color: "#34FFFFFF" }
|
---|
| 108 | GradientStop{ position: 1.0; color: "#7AFFFFFF" }
|
---|
| 109 | }
|
---|
| 110 | anchors.left: frame.right
|
---|
| 111 | anchors.bottom: frame.top
|
---|
| 112 | anchors.margins: -(2*width/3)
|
---|
| 113 | Text{
|
---|
| 114 | text: 'X'
|
---|
| 115 | font.bold: true
|
---|
| 116 | color: "white"
|
---|
| 117 | font.pixelSize: 12
|
---|
| 118 | anchors.centerIn: parent
|
---|
| 119 | }
|
---|
| 120 | MouseArea{
|
---|
| 121 | anchors.fill: parent
|
---|
| 122 | onClicked: main.show = false;
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | Text{
|
---|
| 127 | id: errorTxt
|
---|
| 128 | z: 10
|
---|
| 129 | anchors.centerIn: parent
|
---|
| 130 | color: 'white'
|
---|
| 131 | smooth: true
|
---|
| 132 | visible: loader.status == Loader.Error
|
---|
| 133 | textFormat: Text.RichText
|
---|
| 134 | //Note that if loader is Error, it is because the file was found but there was an error creating the component
|
---|
| 135 | //This means either we have a bug in our demos, or the required modules (which ship with Qt) did not deploy correctly
|
---|
| 136 | text: "The example has failed to load.<br />If you installed all Qt's C++ and QML modules then this is a bug!<br />"
|
---|
| 137 | + 'Report it at <a href="http://bugreports.qt.nokia.com">http://bugreports.qt.nokia.com</a>';
|
---|
| 138 | onLinkActivated: Qt.openUrlExternally(link);
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 | Rectangle{ id: blackout //Maybe use a colorize effect instead?
|
---|
| 142 | z: 8
|
---|
| 143 | anchors.fill: parent
|
---|
| 144 | color: "#000000"
|
---|
| 145 | opacity: 0
|
---|
| 146 | }
|
---|
| 147 | MouseArea{
|
---|
| 148 | z: 8
|
---|
| 149 | enabled: main.show
|
---|
| 150 | hoverEnabled: main.show //To steal focus from the buttons
|
---|
| 151 | acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
---|
| 152 | anchors.fill: parent
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | states: [
|
---|
| 156 | State {
|
---|
| 157 | name: "show"
|
---|
| 158 | when: show == true
|
---|
| 159 | PropertyChanges {
|
---|
| 160 | target: embeddedViewer
|
---|
| 161 | opacity: 1
|
---|
| 162 | }
|
---|
| 163 | PropertyChanges {
|
---|
| 164 | target: blackout
|
---|
| 165 | opacity: 0.5
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 | ]
|
---|
| 169 | transitions: [//Should not be too long, because the component has already started running
|
---|
| 170 | Transition { from: ''; to: "show"; reversible: true
|
---|
| 171 | ParallelAnimation{
|
---|
| 172 | NumberAnimation{ properties: "opacity"; easing.type: Easing.InQuad; duration: 500}
|
---|
| 173 | PropertyAction { target: loader; property: "focus"; value: true}//Might be needed to ensure the focus stays with us
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 | ]
|
---|
| 177 | }
|
---|