Version 0.2
[marketstoday] / src / qml / Library / ToolBar.qml
1 /*
2 @version: 0.1
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5 */
6
7 import Qt 4.7
8
9 Item {
10     id: toolbar
11     property bool updatePending: false
12     property bool displayIcons: true
13     property bool displayNavigation: false
14     property int componentHeight: toolbar.height
15
16     signal reloadButtonClicked
17     signal downButtonClicked
18     signal upButtonClicked
19     signal newsButtonClicked
20
21     BorderImage { source: "images/toolbar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
22
23     Rectangle {
24         id: reloadButtonArea
25         width: 60
26         height: parent.height
27         anchors.left: parent.left
28         color: "#00000000"
29         visible: toolbar.displayIcons
30
31         Image {
32             id: reloadButton
33             source: "images/reload.png"
34             width: 32; height: 32
35             anchors.centerIn: parent
36
37             NumberAnimation on rotation {
38                 from: 0; to: 360; running: toolbar.updatePending == true; loops: Animation.Infinite; duration: 900
39             }
40         }
41
42         MouseArea{
43           id: reloadButtonMouseArea
44           anchors.fill: parent
45           onClicked: {
46               toolbar.updatePending = true;
47               toolbar.reloadButtonClicked();
48           }
49         }
50
51         states: State {
52                  name: "pressed"; when: reloadButtonMouseArea.pressed
53                  PropertyChanges { target: reloadButtonArea; color: "#9a9a9a"}
54         }
55     }
56
57     Rectangle {
58         id: downButtonArea
59         width: 60
60         height: parent.height
61         anchors.right: parent.horizontalCenter; anchors.horizontalCenterOffset: -60;
62         color: "#00000000"
63         visible: (toolbar.displayIcons && toolbar.displayNavigation)
64
65         Image {
66             id: downButton
67             source: "images/down.png"
68             width: 32; height: 32
69             anchors.verticalCenter: parent.verticalCenter
70             anchors.right: parent.right
71             anchors.rightMargin: 5
72         }
73
74         MouseArea{
75           id: downButtonMouseArea
76           anchors.fill: parent
77           onClicked: toolbar.downButtonClicked()
78         }
79
80         states: State {
81                  name: "pressed"; when: downButtonMouseArea.pressed
82                  PropertyChanges { target: downButtonArea; color: "#9a9a9a"}
83         }
84     }
85
86
87     Rectangle {
88         id: upButtonArea
89         width: 60
90         height: parent.height
91         anchors.left: parent.horizontalCenter; anchors.horizontalCenterOffset: 60;
92         color: "#00000000"
93         visible: (toolbar.displayIcons && toolbar.displayNavigation)
94
95         Image {
96             id: upButton
97             source: "images/up.png"
98             width: 32; height: 32
99             anchors.verticalCenter: parent.verticalCenter
100             anchors.left: parent.left
101             anchors.leftMargin: 5
102         }
103
104         MouseArea{
105           id: upButtonMouseArea
106           anchors.fill: parent
107           onClicked: toolbar.upButtonClicked()
108         }
109
110         states: State {
111                  name: "pressed"; when: upButtonMouseArea.pressed
112                  PropertyChanges { target: upButtonArea; color: "#9a9a9a"}
113         }
114     }
115
116
117
118     Rectangle {
119         id: newsButtonArea
120         width: 60
121         height: parent.height
122         anchors.right: parent.right
123         color: "#00000000"
124         visible: toolbar.displayIcons
125
126         Image {
127             id: newsButton
128             source: "images/news.png"
129             width: 32; height: 32
130             anchors.centerIn: parent
131         }
132
133         MouseArea{
134           id: newsButtonMouseArea
135           anchors.fill: parent
136           onClicked: toolbar.newsButtonClicked()
137         }
138
139         states: State {
140                  name: "pressed"; when: newsButtonMouseArea.pressed
141                  PropertyChanges { target: newsButtonArea; color: "#9a9a9a"}
142         }
143     }
144
145 }