* Improved QML/JS.
[lichviet] / qml / LichViet / MenuScreen.qml
index 26f6a29..02f1dcc 100644 (file)
@@ -17,13 +17,37 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 
 import QtQuick 1.0
 
+import "Themes.js" as Themes
+
 Item{
 
     id:menuscreen
 
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:-(parent.width * 1.5)
+
+    signal close
+    signal item_click(int pos)
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    Connections {
+        target: menuscreen.parent
+
+        onDialogClose: {
+            menuscreen.state = "close";
+            menuscreen.destroy(600);
+        }
+    }
+
     Rectangle {
         id: rectangle1
-        anchors.fill: parent; anchors.bottomMargin: 16
+        anchors.fill: parent; anchors.bottomMargin: 0;
         visible: true
         opacity:0.9
 
@@ -73,7 +97,7 @@ Item{
 
         ListView {
               id: listView
-              anchors.fill: parent;anchors.topMargin: 35;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 12
+              anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 55
               model: listModel
               delegate: listDelegate
               focus: true
@@ -81,38 +105,62 @@ Item{
 
     }
 
+    Rectangle {
+        width : menuscreen.width
+        height: 45
+        color:"white"
+        opacity: 0.5
+    }
+
+    Text {
+        id: title
+
+        anchors { horizontalCenter: menuscreen.horizontalCenter; top: menuscreen.top; topMargin: 10 }
+        font.pixelSize: 22
+        color: "black"
+        text: qsTr("Menu")
+        smooth: true
+        font.bold: true
+    }
+
+
     ToolBarSingle {
-        id: toolBar; height: 50;
-        y: screen.height-78
+        id: toolBar; height: 42;
+        y: parent.height-52
         width: parent.width;
         button1Label: "Quay Về"
-        onButton1Clicked:
-        {
-            screen.state="mainscreen"
-        }
+        onButton1Clicked:menuscreen.close()
     }
 
+
     function getText(id) {
-        switch(id){
+        /*switch(id){
         case 1:screen.reset();break;
         case 2: screen.state="amdatetimedialog";break;
         case 3: screen.state="datetimedialog";break;
         case 4: screen.state="xemngaytotxauhoangdao";break;
         case 5: screen.state="xemtheothang";break;
-        case 6: screen.state="aboutdialog";break;
+        case 6: menuscreen.close();screen.state="aboutdialog";break;
         case 7: screen.state="changetheme";break;
         case 8: screen.state="filebrowser";break;
-        }
-
+        }*/
+        menuscreen.close();
+        menuscreen.item_click(id);
     }
 
-    FileBrowser{
-        id: fileBrowser
-        state:"filebrowser"
-        anchors.verticalCenter: parent.verticalCenter
-        width: parent.width; height: parent.height-60;
-        x: -(screen.width * 1.5)
-    }
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: menuscreen; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: menuscreen; anchors.right: parent.left }
+        }
+    ]
 
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+    }
 
 }