X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fqml%2FLibrary%2FTitleBar.qml;h=6e17b451804dd8a41f1fb62d1773ffe0bf14746f;hb=0f8d4b44f550d528c2b6b09fb0f6a8c7821caf9f;hp=f6dff315a87042ccc18543f3b7b6ac5b5ed77dd2;hpb=2b13ee54b100838b12d7cadea2aaf6608b0c1a04;p=marketstoday diff --git a/src/qml/Library/TitleBar.qml b/src/qml/Library/TitleBar.qml index f6dff31..6e17b45 100644 --- a/src/qml/Library/TitleBar.qml +++ b/src/qml/Library/TitleBar.qml @@ -1,5 +1,5 @@ /* -@version: 0.1 +@version: 0.5 @author: Sudheer K. @license: GNU General Public License @@ -53,31 +53,141 @@ import Qt 4.7 Item { id: titleBar + + //Default height and width will be overwritten by parent object + width: 800 + height: 60 + property string title: "Markets Today" property string buttonType: "Config" + property bool displayMenu: false + property bool displayMenuIcon: true + property int displayMenuTimeout: 8000 + signal menuDisplayed signal settingsClicked signal closeClicked signal backClicked + signal tickersClicked + signal optionsClicked + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } Item { id: container width: parent.width; height: parent.height - Text { - id: categoryText + Component{ + id: contextMenuComponent + + MenuBar{ + id: menuBar + + width: 450 + height: 60 + + opacity: 0 + onTickersClicked: titleBar.tickersClicked(); + onOptionsClicked: titleBar.optionsClicked(); + + states: [ + State { + name: "visible"; when: titleBar.displayMenu === true; + PropertyChanges { target: menuBar; opacity:1} + AnchorChanges { target: contextMenuLoader; anchors { bottom: titleArea.bottom; top: parent.top } } + PropertyChanges { target: contextMenuLoader; anchors.topMargin: 0; anchors.bottomMargin: -5} + }, + State { + name: "hidden"; when: titleBar.displayMenu === false; + PropertyChanges { target: menuBar; opacity:0} + AnchorChanges { target: contextMenuLoader; anchors { bottom: parent.top; top: parent.top } } + PropertyChanges { target: contextMenuLoader; anchors.topMargin: 0;anchors.bottomMargin: 0} + } + ] + + transitions: [ + //Sequential transition is not working otherway round + Transition { + from: "*"; to: "visible" + SequentialAnimation{ + PropertyAnimation{target: menuBar; property: "opacity"; easing.type:Easing.InExpo; duration: 1000 } + AnchorAnimation { easing.type: Easing.InOutQuad; duration: 500 } + } + }, + //Hidden transition is not working as expected + Transition { + from: "*"; to: "hidden" + SequentialAnimation{ + PropertyAnimation{target: menuBar; property: "opacity"; easing.type:Easing.OutExpo; duration: 1000 } + AnchorAnimation { easing.type: Easing.InExpo; duration: 500 } + } + } + ] + } + } + + Timer { + id: contextMenuTimer + interval: displayMenuTimeout + repeat: false + onTriggered: { + if (displayMenu) { + displayMenu = false; + } + } + } + + Loader { + id: contextMenuLoader + //width: 450 + anchors {top: parent.top; horizontalCenter: parent.horizontalCenter} + z: 10 + sourceComponent: contextMenuComponent + } + + Rectangle { + id: titleArea + width: parent.width/3 + height: parent.height + color: "#00000000" + anchors { leftMargin: 5; rightMargin: 10 - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter + centerIn: parent + } + + Text { + id: categoryText + anchors.centerIn: parent + elide: Text.ElideMiddle + text: title + font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" + font.pixelSize: 20 + } + + Image { + source: "images/menu_icon.png" + width: 24; height: 24 + anchors.verticalCenter: parent.verticalCenter + anchors.left: categoryText.right + visible: titleBar.displayMenuIcon + } + + MouseArea{ + id: contextMenuMouseArea + anchors.fill: parent + visible: displayMenuIcon + onClicked: { + if (!displayMenu) { + displayMenu = true; + //Start timer to hide context menu after 5 sec. + contextMenuTimer.start(); + } + } } - elide: Text.ElideMiddle - text: title - font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" - font.pixelSize: 18 } + Component { id: configButton @@ -88,7 +198,7 @@ Item { Image { source: "images/config.png" - width: 40; height: 40 + width: 32; height: 32 anchors.centerIn: parent } @@ -160,11 +270,19 @@ Item { } } + Component { + id: blankComponent + + Item{ + + } + } + Loader { width: 80 height: parent.height anchors.right: parent.right - sourceComponent: buttonType == "Config" ? configButton : (buttonType == "Close"? closeButton: backButton) + sourceComponent: buttonType == "Config" ? configButton : (buttonType == "Close"? closeButton: (buttonType == "Back"? backButton:blankComponent)) } } }