1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt Components project.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
47 property alias title: titleItem.children
48 property alias content: contentItem.children
49 property alias buttons: buttonItem.children
50 property alias visualParent: dialog.visualParent
51 property alias status: dialog.status
53 // Symbian specific API
54 property bool platformInverted: false
56 property int platformContentMaximumWidth: dialog.width
58 property int platformContentMaximumHeight:
59 dialog.maxHeight() - titleBar.height - buttonItem.height
61 property alias privateTitleHeight: titleBar.height
62 property alias privateButtonsHeight: buttonItem.height
74 if (status == DialogStatus.Open) {
81 if (status == DialogStatus.Open) {
96 function defaultHeight() {
100 return titleBar.height + contentItem.childrenRect.height + buttonItem.height
103 function defaultWidth() {
104 return root.width > 0 ? root.width : maxWidth()
107 function maxWidth() {
108 return Math.min(screen.width - 2 * platformStyle.paddingMedium, privateStyle.dialogMaxSize)
111 function maxHeight() {
112 return inputContext.visible
113 ? Math.min(privateStyle.dialogMaxSize, screen.height-inputContext.height)
114 : Math.min(privateStyle.dialogMaxSize, screen.height-2*platformStyle.paddingMedium);
117 function minWidth() {
118 return Math.min(screen.displayWidth, screen.displayHeight) - 2 * platformStyle.paddingMedium
121 function minHeight() {
122 return inputContext.visible
123 ? Math.min(privateStyle.dialogMinSize, screen.height-inputContext.height)
124 : Math.min(privateStyle.dialogMinSize, screen.height-2*platformStyle.paddingMedium);
127 function updateSize() {
128 width = Math.max(Math.min(defaultWidth(), maxWidth()), minWidth())
129 height = Math.max(Math.min(defaultHeight(), maxHeight()), minHeight())
132 Connections { target: inputContext; onVisibleChanged: updateTimer.start() }
133 Connections { target: screen; onHeightChanged: updateTimer.start(); onWidthChanged: updateTimer.start() }
134 Connections { target: root; onHeightChanged: updateTimer.start(); onWidthChanged: updateTimer.start() }
136 Component.onCompleted: updateTimer.start()
140 interval: 1; repeat: false
141 onTriggered: dialog.updateSize()
144 onFaderClicked: root.clickedOutside()
146 width: 0 // Defined in updateSize()
147 height: 0 // Defined in updateSize()
151 anchors.centerIn: parent
152 animationDuration: 250
153 platformInverted: root.platformInverted
155 // Consume all key events that are not processed by children
156 Keys.onPressed: event.accepted = true
157 Keys.onReleased: event.accepted = true
160 source: privateStyle.imagePath("qtg_fr_popup", root.platformInverted)
161 border { left: 20; top: 20; right: 20; bottom: 20 }
168 height: platformStyle.graphicSizeSmall + 2 * platformStyle.paddingLarge
176 source: privateStyle.imagePath("qtg_fr_popup_heading", root.platformInverted)
177 border { left: 40; top: 0; right: 40; bottom: 0 }
199 bottom: buttonItem.top
206 height: childrenRect.height
211 bottom: parent.bottom
218 when: status == DialogStatus.Opening || status == DialogStatus.Open
219 PropertyChanges { target: dialog; opacity: 1.0; scale: 1; }
223 when: status == DialogStatus.Closing || status == DialogStatus.Closed
224 PropertyChanges { target: dialog; opacity: 0.0; scale: 0.9; }
230 from: "Visible"; to: "Hidden"
231 SequentialAnimation {
232 ScriptAction {script: status = DialogStatus.Closing }
235 properties: "opacity"
236 duration: dialog.animationDuration
237 easing.type: Easing.Linear
241 duration: dialog.animationDuration
242 easing.type: Easing.InQuad
245 ScriptAction {script: status = DialogStatus.Closed }
249 from: "Hidden"; to: "Visible"
250 SequentialAnimation {
251 ScriptAction { script: status = DialogStatus.Opening }
252 PropertyAction { target: dialog; property: "visible"; value: true}
255 properties: "opacity"
256 duration: dialog.animationDuration
257 easing.type: Easing.Linear
261 duration: dialog.animationDuration
262 easing.type: Easing.OutQuad
265 ScriptAction { script: status = DialogStatus.Open }