Initial Release
[marketstoday] / src / qml / Library / TitleBar.qml
1 /*
2 @version: 0.1
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5
6 Based on Nokia Qt Quick Demos with copyright notice below.
7
8 Source: http://doc.qt.nokia.com/4.7-snapshot/demos-declarative-twitter-twittercore-titlebar-qml.html
9 */
10
11 /****************************************************************************
12 **
13 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
14 ** All rights reserved.
15 ** Contact: Nokia Corporation (qt-info@nokia.com)
16 **
17 ** This file is part of the QtDeclarative module of the Qt Toolkit.
18 **
19 ** $QT_BEGIN_LICENSE:LGPL$
20 ** No Commercial Usage
21 ** This file contains pre-release code and may not be distributed.
22 ** You may use this file in accordance with the terms and conditions
23 ** contained in the Technology Preview License Agreement accompanying
24 ** this package.
25 **
26 ** GNU Lesser General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU Lesser
28 ** General Public License version 2.1 as published by the Free Software
29 ** Foundation and appearing in the file LICENSE.LGPL included in the
30 ** packaging of this file.  Please review the following information to
31 ** ensure the GNU Lesser General Public License version 2.1 requirements
32 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
33 **
34 ** In addition, as a special exception, Nokia gives you certain additional
35 ** rights.  These rights are described in the Nokia Qt LGPL Exception
36 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
37 **
38 ** If you have questions regarding the use of this file, please contact
39 ** Nokia at qt-info@nokia.com.
40 **
41 **
42 **
43 **
44 **
45 **
46 **
47 **
48 ** $QT_END_LICENSE$
49 **
50 ****************************************************************************/
51
52 import Qt 4.7
53
54 Item {
55     id: titleBar
56     property string title: "Markets Today"
57     property string buttonType: "Config"
58     signal settingsClicked
59     signal closeClicked
60     signal backClicked
61
62     BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
63
64     Item {
65         id: container
66         width: parent.width; height: parent.height
67
68         Text {
69             id: categoryText            
70             anchors {
71                 leftMargin: 5; rightMargin: 10
72                 verticalCenter: parent.verticalCenter
73                 horizontalCenter: parent.horizontalCenter
74             }
75             elide: Text.ElideMiddle
76             text: title
77             font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
78             font.pixelSize: 18
79         }
80
81         Component {
82             id: configButton
83
84             Rectangle {
85                 id: configButtonArea
86                 anchors.fill: parent
87                 color: "#00000000"
88
89                 Image {
90                     source: "images/config.png"
91                     width: 40; height: 40
92                     anchors.centerIn: parent
93                 }
94
95                 MouseArea{
96                   id: configButtonMouseArea
97                   anchors.fill: parent
98                   onClicked: {
99                       titleBar.settingsClicked();
100                   }
101                 }
102
103                 states: State {
104                          name: "pressed"; when: configButtonMouseArea.pressed
105                          PropertyChanges { target: configButtonArea; color: "#9a9a9a"}
106                 }
107             }
108         }
109
110         Component {
111             id: closeButton
112
113             Rectangle {
114                 id: closeButtonArea
115                 anchors.fill: parent
116                 color: "#00000000"
117
118                 Image {
119                     source: "images/close.png"
120                     width: 32; height: 32
121                     anchors.centerIn: parent
122                 }
123
124                 MouseArea{
125                   id: closeButtonMouseArea
126                   anchors.fill: parent
127                   onClicked: titleBar.closeClicked();
128                 }
129
130                 states: State {
131                          name: "pressed"; when: closeButtonMouseArea.pressed
132                          PropertyChanges { target: closeButtonArea; color: "#9a9a9a"}
133                 }
134             }
135         }
136
137         Component {
138             id: backButton
139
140             Rectangle {
141                 id: backButtonArea
142                 anchors.fill: parent
143                 color: "#00000000"
144
145                 Image {
146                     source: "images/back.png"
147                     width: 32; height: 32
148                     anchors.centerIn: parent
149                 }
150                 MouseArea{
151                   id: backButtonMouseArea
152                   anchors.fill: parent
153                   onClicked: titleBar.backClicked();
154                 }
155
156                 states: State {
157                          name: "pressed"; when: backButtonMouseArea.pressed
158                          PropertyChanges { target: backButtonArea; color: "#9a9a9a"}
159                 }
160             }
161         }
162
163         Loader {
164             width: 80
165             height: parent.height
166             anchors.right: parent.right
167             sourceComponent: buttonType == "Config" ? configButton : (buttonType == "Close"? closeButton: backButton)
168         }
169     }
170 }