Release 0.3-1 (Including all changes)
[marketstoday] / src / qml / Library / ToolBar.qml
index 28b44a2..cdcb59a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-@version: 0.1
+@version: 0.2
 @author: Sudheer K. <scifi1947 at gmail.com>
 @license: GNU General Public License
 */
@@ -11,12 +11,14 @@ Item {
     property bool updatePending: false
     property bool displayIcons: true
     property bool displayNavigation: false
+    property string targetContentType: "News"
     property int componentHeight: toolbar.height
 
     signal reloadButtonClicked
     signal downButtonClicked
     signal upButtonClicked
     signal newsButtonClicked
+    signal stocksButtonClicked
 
     BorderImage { source: "images/toolbar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
 
@@ -33,6 +35,7 @@ Item {
             source: "images/reload.png"
             width: 32; height: 32
             anchors.centerIn: parent
+            smooth: true
 
             NumberAnimation on rotation {
                 from: 0; to: 360; running: toolbar.updatePending == true; loops: Animation.Infinite; duration: 900
@@ -60,7 +63,7 @@ Item {
         height: parent.height
         anchors.right: parent.horizontalCenter; anchors.horizontalCenterOffset: -60;
         color: "#00000000"
-        visible: (toolbar.displayIcons && toolbar.displayNavigation)
+        visible: toolbar.displayNavigation
 
         Image {
             id: downButton
@@ -90,7 +93,7 @@ Item {
         height: parent.height
         anchors.left: parent.horizontalCenter; anchors.horizontalCenterOffset: 60;
         color: "#00000000"
-        visible: (toolbar.displayIcons && toolbar.displayNavigation)
+        visible: toolbar.displayNavigation
 
         Image {
             id: upButton
@@ -113,33 +116,68 @@ Item {
         }
     }
 
-
-
-    Rectangle {
-        id: newsButtonArea
+    Loader {
+        id: contentIconLoader
         width: 60
         height: parent.height
         anchors.right: parent.right
-        color: "#00000000"
         visible: toolbar.displayIcons
+        sourceComponent: targetContentType == "News"? newsButtonComponent:stocksButtonComponent
+    }
 
-        Image {
-            id: newsButton
-            source: "images/news.png"
-            width: 32; height: 32
-            anchors.centerIn: parent
-        }
 
-        MouseArea{
-          id: newsButtonMouseArea
-          anchors.fill: parent
-          onClicked: toolbar.newsButtonClicked()
-        }
+    Component {
+        id: newsButtonComponent
 
-        states: State {
-                 name: "pressed"; when: newsButtonMouseArea.pressed
-                 PropertyChanges { target: newsButtonArea; color: "#9a9a9a"}
+        Rectangle {
+            id: newsButtonArea
+            anchors.fill: parent
+            color: "#00000000"
+
+            Image {
+                id: newsButton
+                source: "images/tab_news.png"
+                width: 32; height: 32
+                anchors.centerIn: parent
+            }
+
+            MouseArea{
+              id: newsButtonMouseArea
+              anchors.fill: parent
+              onClicked: toolbar.newsButtonClicked()
+            }
+
+            states: State {
+                     name: "pressed"; when: newsButtonMouseArea.pressed
+                     PropertyChanges { target: newsButtonArea; color: "#9a9a9a"}
+            }
         }
     }
 
+    Component{
+        id: stocksButtonComponent
+        Rectangle {
+            id: stocksButtonArea
+            anchors.fill: parent
+            color: "#00000000"
+
+            Image {
+                id: stocksButton
+                source: "images/tab_stocks.png"
+                width: 32; height: 32
+                anchors.centerIn: parent
+            }
+
+            MouseArea{
+              id: stocksButtonMouseArea
+              anchors.fill: parent
+              onClicked: toolbar.stocksButtonClicked()
+            }
+
+            states: State {
+                     name: "pressed"; when: stocksButtonMouseArea.pressed
+                     PropertyChanges { target: stocksButtonArea; color: "#9a9a9a"}
+            }
+        }
+    }
 }