1 /****************************************************************************
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
6 ** This file is part of the demonstration applications of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file. Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
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
51 Item{ id:embeddedViewer
59 focus: true //Automatic FocusScope
62 anchors.centerIn: parent
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;
76 anchors.fill: loader.status == Loader.Ready ? loader : errorTxt
80 border.color: "#88aaaaaa"
82 GradientStop{ position: 0.0; color: "#14FFFFFF" }
83 GradientStop{ position: 1.0; color: "#5AFFFFFF" }
87 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
88 onClicked: loader.focus=true;/* and don't propagate to the 'exit' area*/
91 Rectangle{ id: innerFrame
93 anchors.bottomMargin: 8
94 anchors.rightMargin: 8
96 border.color: "#44000000"
101 Rectangle{ id: closeButton
105 border.color: "#aaaaaaaa"
107 GradientStop{ position: 0.0; color: "#34FFFFFF" }
108 GradientStop{ position: 1.0; color: "#7AFFFFFF" }
110 anchors.left: frame.right
111 anchors.bottom: frame.top
112 anchors.margins: -(2*width/3)
118 anchors.centerIn: parent
122 onClicked: main.show = false;
129 anchors.centerIn: parent
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-project.org">http://bugreports.qt-project.org</a>';
138 onLinkActivated: Qt.openUrlExternally(link);
141 Rectangle{ id: blackout //Maybe use a colorize effect instead?
150 hoverEnabled: main.show //To steal focus from the buttons
151 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
160 target: embeddedViewer
169 transitions: [//Should not be too long, because the component has already started running
170 Transition { from: ''; to: "show"; reversible: true
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