components for android added
[mardrone] / mardrone / imports / Qt / labs / components / native / CommonDialog.qml
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 Qt Components project.
8 **
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
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
20 **     distribution.
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
24 **     permission.
25 **
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."
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 1.1
42 import "." 1.0
43
44 Dialog {
45     id: genericDialog
46
47     property string titleText: ""
48
49     property Style platformStyle: SelectionDialogStyle {}
50
51     //Deprecated, TODO Remove this on w13
52     property alias style: genericDialog.platformStyle
53
54     //private
55     property bool __drawFooterLine: false
56
57     title: Item {
58         id: header
59         height: genericDialog.platformStyle.titleBarHeight
60
61         anchors.left: parent.left
62         anchors.right: parent.right
63         anchors.top: parent.top
64         anchors.bottom: parent.bottom
65
66         Item {
67             id: labelField
68
69             anchors.fill:  parent
70
71             Item {
72                 id: labelWrapper
73                 anchors.left: labelField.left
74                 anchors.right: closeButton.left
75
76                 anchors.bottom:  parent.bottom
77                 anchors.bottomMargin: genericDialog.platformStyle.titleBarLineMargin
78
79                 //anchors.verticalCenter: labelField.verticalCenter
80
81                 height: titleLabel.height
82
83                 Label {
84                     id: titleLabel
85                     x: genericDialog.platformStyle.titleBarIndent
86                     width: parent.width - closeButton.width
87                     //anchors.baseline:  parent.bottom
88                     font: genericDialog.platformStyle.titleBarFont
89                     color: genericDialog.platformStyle.commonLabelColor
90                     elide: genericDialog.platformStyle.titleElideMode
91                     text: genericDialog.titleText
92                 }
93
94             }
95
96             Image {
97                 id: closeButton
98                 anchors.bottom:  parent.bottom
99                 anchors.bottomMargin: genericDialog.platformStyle.titleBarLineMargin-6
100                 //anchors.verticalCenter: labelField.verticalCenter
101                 anchors.right: labelField.right
102
103                 opacity: closeButtonArea.pressed ? 0.5 : 1.0
104
105                 source: "image://theme/icon-m-common-dialog-close"
106
107                 MouseArea {
108                     id: closeButtonArea
109                     anchors.fill: parent
110                     onClicked:  {genericDialog.reject();}
111                 }
112
113             }
114
115         }
116
117         Rectangle {
118             id: headerLine
119
120             anchors.left: parent.left
121             anchors.right: parent.right
122
123             anchors.bottom:  header.bottom
124
125             height: 1
126
127             color: "#4D4D4D"
128         }
129
130     }
131
132     content: Item {id: contentField}
133
134     buttons: Item {
135          id: footer
136
137          width: parent.width
138          height: childrenRect.height
139
140          //hack to make sure, we're evaluating the correct height
141          Item {
142              id: lineWrapper
143              width: parent.width
144              height: childrenRect.height
145              y: 10
146
147              Rectangle {
148                  id: footerLine
149
150                  anchors.left: parent.left
151                  anchors.right: parent.right
152                  anchors.top: parent.top
153                  height: genericDialog.__drawFooterLine ? 1 : 0
154
155                  color: "#4D4D4D"
156              }
157          }
158
159          //ugly hack to assure, that we're always evaluating the correct height
160          Item {id: dummy; anchors.fill:  parent}
161
162      }
163
164 }