Merge branch 'develop'
[lichviet] / qml / LichViet / TitleBar.qml
index ac7657a..b1acba1 100644 (file)
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights.  These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 1.0
+/*
+Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>
+*/
+
+import QtQuick 1.1
 
 Item {
-    id: titleBar
-    property string untaggedString: " "
-    property string taggedString: " "
 
-    BorderImage { source: theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 }
+    id:title_bar
+
+    height: 46
+    width: parent.width
+
+    opacity: 0.8
+
+    /*
+      Default value of properties
+      */
+
+    property int radius: 4
+    property string border_color: "#e28282"
+    property string background_color: "white"
+
+    property int shadow_height: 10
+    property string shadow_begin_color: "#000000"
+    property string shadow_end_color: "#fff7f7"
+
+    property string caption: ""
+    property string caption_color: "black"
+    property string caption_font: "Tahoma"
+    property int caption_font_size: 18
+    property bool caption_font_bold : true
+
+    /*
+      Signals
+      */
+
+    signal minimize
+    signal close
+
+    /*
+      Title Bar Init
+      */
+
+    Rectangle {
+        id:main_title
+
+        width: parent.width
+        height: parent.height
+
+        color: parent.background_color
+        radius: parent.radius
+        border.color: parent.border_color
+    }
+
+    Text {
+        id:title_bar_caption
+
+        text: parent.caption
+
+        font.bold: parent.caption_font_bold
+        font.pointSize: parent.caption_font_size
+        font.family: parent.caption_font
+
+        color: parent.caption_color
+
+        x:btn_minimize.width + 5*2
+        y:(main_title.height/2) - (height/2)
+    }
+
+    /*
+      Title Bar Buttons
+      */
+
+    /*
+      Minimize button
+      */
+
+    Rectangle {
+        id: btn_minimize
+
+        x:title_bar.x + 5
+        y:title_bar.y + 5
 
-    Item {
-        id: container
-        width: (parent.width * 2) - 55 ; height: parent.height
+        height: title_bar.height - 10
+        width: 45
 
-        function accept() {
-            titleBar.state = ""
-            background.state = ""
-            rssModel.tags = editor.text
+        color: "transparent"
+
+        border.color: "grey"
+        border.width: 1
+
+        radius: parent.radius
+
+        Rectangle {
+            x:parent.x
+            y:parent.y
+
+            width: parent.width - 15
+            height: parent.height - 15
+
+            border.color: "white"
+            color: "black"
+            border.width: 1
         }
 
+        Rectangle {
+            x:parent.x + 5
+            y:parent.y + 5
+            width: parent.width - 15
+            height: parent.height - 15
 
-        Image {
-            id: quitButton
-            x: screen.width - 50
-            anchors.verticalCenter: parent.verticalCenter
-            source:  theme_manager.theme.titlebar.button
-            MouseArea {
-                anchors.fill: parent
-                onPressed:{
-                    parent.source= theme_manager.theme.titlebar.button_pressed
-                }
-                onReleased:{
-                     parent.source=theme_manager.theme.titlebar.button
-                }
-
-                onClicked: Qt.quit()
-            }
+            border.color: "white"
+            color: "black"
+            border.width: 1
         }
 
-        Image {
-            id: minimizeButton
-            x:4
-            anchors.verticalCenter: parent.verticalCenter
-            source:  theme_manager.theme.titlebar.minimize_button
-
-            MouseArea {
-                anchors.fill: parent
-                onPressed:{
-                    parent.source= theme_manager.theme.titlebar.minimize_button_pressed
-                }
-                onReleased:{
-                     parent.source=theme_manager.theme.titlebar.minimize_button
-                }
-
-                onClicked: ROOT.minimize();
+        MouseArea {
+            anchors.fill: parent
+
+            onClicked: title_bar.minimize()
+
+            onPressed: {
+                parent.color = "blue"
+            }
+
+            onReleased: {
+                parent.color = "transparent"
             }
         }
 
+    }
+
+    /*
+      Close button
+      */
+
+    Rectangle {
+        id: btn_close
+
+        x:title_bar.width - 50
+        y:title_bar.y + 5
+
+        width: 45
+        height: title_bar.height - 10
+
+        color: "transparent"
+
+        border.color: "grey"
+        border.width: 1
+
+        radius: parent.radius
+
         Text {
-            id: categoryText
-            x:60
-            anchors {
-                verticalCenter: parent.verticalCenter
-            }
-            elide: Text.ElideLeft
-            text: "Lịch Việt"
-            font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black"
-            font.pixelSize: 24
+            id: button1
+            color: "#000000"
+            anchors.centerIn: parent; font.bold: true
+            text: "X"; style: Text.Raised; styleColor: "black"
+            font.pixelSize: 26
             font.family: "Tahoma"
         }
-    }
 
-    states: State {
-        name: "Tags"
-        PropertyChanges { target: container; x: -tagButton.x + 5 }
-        PropertyChanges { target: editor; focus: true }
+        MouseArea {
+            anchors.fill: parent
+
+            onClicked: title_bar.close()
+
+            onPressed: {
+                parent.color = "blue"
+            }
+
+            onReleased: {
+                parent.color = "transparent"
+            }
+        }
     }
 
-    /*transitions: Transition {
-        NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
-    }*/
 }