* Improved QML/JS.
authorCuong Le <cuonglb@ideapad.(none)>
Thu, 15 Sep 2011 07:27:44 +0000 (14:27 +0700)
committerCuong Le <cuonglb@ideapad.(none)>
Thu, 15 Sep 2011 07:27:44 +0000 (14:27 +0700)
* Removed lunarcalendar c++ source.
* Added some feature in month view.

24 files changed:
LichViet.pro
lichviet.qrc
lunarcalendar.cpp [deleted file]
lunarcalendar.h [deleted file]
main.cpp
qml/DatePicker/component/DateReel.qml
qml/LichViet/About.qml
qml/LichViet/AmDateTimeDialog.qml
qml/LichViet/Button.qml
qml/LichViet/CacNgayLeTrongNam.js
qml/LichViet/DateTimeDialog.qml
qml/LichViet/FullMonth.qml
qml/LichViet/MenuScreen.qml
qml/LichViet/MultiTitleBar.qml
qml/LichViet/OptionsScreen.qml
qml/LichViet/Settings.js
qml/LichViet/Switch.qml
qml/LichViet/Themes.js
qml/LichViet/TitleBar.qml
qml/LichViet/ToolBar.qml
qml/LichViet/ToolBarSingle.qml
qml/LichViet/XemNgayTotXauHoangDao.qml
qml/LichViet/main.js [new file with mode: 0644]
qml/LichViet/main.qml

index bf3543a..06f3e1b 100644 (file)
@@ -30,7 +30,6 @@ QT += dbus
 
 # The .cpp file which was generated for your project. Feel free to hack it.
 SOURCES += main.cpp \
-    lunarcalendar.cpp \
     controller.cpp
 
 # Please do not modify the following two lines. Required for deployment.
@@ -41,7 +40,6 @@ RESOURCES += \
     lichviet.qrc
 
 HEADERS += \
-    lunarcalendar.h \
     controller.h
 
 OTHER_FILES += \
@@ -75,7 +73,8 @@ OTHER_FILES += \
     qml/LichViet/ChangeTheme.qml \
     qml/LichViet/MenuButton.qml \
     qml/LichViet/ScrollBar.qml \
-    qml/LichViet/FileBrowser.qml
+    qml/LichViet/FileBrowser.qml \
+    qml/LichViet/main.js
 
 unix:!symbian:!maemo5 {
     target.path = /opt/LichViet/bin
index 4acb97c..61702b4 100644 (file)
@@ -31,6 +31,7 @@
     <file>qml/LichViet/Settings.js</file>
     <file>qml/LichViet/Themes.js</file>
     <file>qml/LichViet/xemngaytotxau.js</file>
+    <file>qml/LichViet/main.js</file>
     <file>qml/LichViet/CacNgayLeTrongNam.js</file>
 </qresource>
 
diff --git a/lunarcalendar.cpp b/lunarcalendar.cpp
deleted file mode 100644 (file)
index f2c0b48..0000000
+++ /dev/null
@@ -1,103 +0,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 3 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/>
-*/
-
-
-#include <QtCore/QDateTime>
-#include "lunarcalendar.h"
-
-LunarCalendar::LunarCalendar(QObject *parent) :
-    QObject(parent)
-{
-    this->curDayA =  QDateTime::currentDateTime().toString("d").toUInt();
-    this->curMonthA = QDateTime::currentDateTime().toString("M").toUInt();
-    this->curYearA = QDateTime::currentDateTime().toString("yyyy").toUInt();
-}
-
-/*
-  Calendar
-  */
-QString LunarCalendar::nextDay(){
-    int value = this->curDayA+1;
-    int days = calDays(this->curMonthA,this->curYearA);
-    if (value>days){
-        value = 1;
-        this->curMonthA++;
-        if (this->curMonthA > 12){
-            this->curMonthA = 1;
-            this->curYearA++;
-        }
-    }
-    this->curDayA=value;
-    return QString::number(value);
-}
-
-QString LunarCalendar::prevDay(){
-    int value = this->curDayA-1;
-    if(!value){
-        this->curMonthA--;
-        if (!this->curMonthA){
-            this->curMonthA = 12;
-            this->curYearA--;
-        }
-        value = calDays( this->curMonthA,this->curYearA);
-    }
-     this->curDayA=value;
-    return QString::number(value);
-}
-
-int LunarCalendar::curDay(){
-    return this->curDayA;
-}
-
-int LunarCalendar::curMonth(){
-    return this->curMonthA;
-}
-
-int LunarCalendar::curYear(){
-    return this->curYearA;
-}
-
-int LunarCalendar::curHour(){
-    return QDateTime::currentDateTime().toString("H").toUInt();
-}
-
-int LunarCalendar::curMinute(){
-    return QDateTime::currentDateTime().toString("m").toUInt();
-}
-
-void LunarCalendar::reset(int D, int M, int Y){
- this->curDayA = D;
-    this->curMonthA = M;
-    this->curYearA = Y;
-}
-
-
-int LunarCalendar::calDays(int Month, int Year){
-    if (Month == 4 || Month == 6 || Month == 9 || Month == 11)
-        return 30;
-    else
-    if (Month == 2) {
-        bool isLeapYear = (Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0);
-        if (isLeapYear == 0)
-            return 28;
-        else
-            return 29;
-    }
-    else
-    return 31;
-}
-
diff --git a/lunarcalendar.h b/lunarcalendar.h
deleted file mode 100644 (file)
index 72867c5..0000000
+++ /dev/null
@@ -1,58 +0,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 3 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/>
-*/
-
-
-#ifndef LUNARCALENDAR_H
-#define LUNARCALENDAR_H
-
-#include <QtCore/QObject>
-
-class LunarCalendar : public QObject
-{
-    Q_OBJECT
-
-    int curDayA;
-    int curMonthA;
-    int curYearA;
-
-    int jdn();
-
-public:
-    explicit LunarCalendar(QObject *parent = 0);
-
-     Q_INVOKABLE QString nextDay();
-     Q_INVOKABLE QString prevDay();
-
-     Q_INVOKABLE int curDay();
-     Q_INVOKABLE int curMonth();
-     Q_INVOKABLE int curYear();
-
-    Q_INVOKABLE int curHour();
-        Q_INVOKABLE int curMinute();
-
-        Q_INVOKABLE void reset(int,int,int);
-
-       Q_INVOKABLE int calDays(int, int);
-
-
-signals:
-
-public slots:
-
-};
-
-#endif // LUNARCALENDAR_H
index 436a4c8..8ab3a75 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -22,7 +22,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 
 #include "qmlapplicationviewer.h"
 
-#include "lunarcalendar.h"
 #include "controller.h"
 
 #ifdef Q_WS_MAEMO_5
@@ -36,11 +35,9 @@ int main(int argc, char *argv[])
 
      app.setApplicationVersion(APP_VERSION);
 
-    LunarCalendar lc;
     Controller ctrller;
 
     viewer.rootContext()->setContextProperty("ROOT", &viewer);
-    viewer.rootContext()->setContextProperty("LC", &lc);
     viewer.rootContext()->setContextProperty("Controller", &ctrller);
 
     viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
index 8ae694b..bdc3360 100644 (file)
@@ -1,5 +1,7 @@
 import QtQuick 1.0
 
+import "../../LichViet/main.js" as Script
+
 Item {
     id: container
 
@@ -149,12 +151,12 @@ Item {
 
         Component.onCompleted: {
             appends()
-            day.index = screen.curDay - 1
-            end = LC.calDays(month.index+1,year.index+1900);
+            day.index = Script.curDay - 1
+            end = Script.calDaysX(month.index+1,year.index+1900);
         }
 
         function reset(){
-            var howmanydays =  LC.calDays(month.index+1,year.index+1900);
+            var howmanydays =  Script.calDaysX(month.index+1,year.index+1900);
             end = howmanydays;
 
             if (day.index+1 < days.start) day.index = days.start-1;
@@ -171,7 +173,7 @@ Item {
         }
 
         function change(){
-           day.index = screen.curDay-1;
+           day.index = Script.curDay-1;
         }
     }
 
@@ -184,11 +186,11 @@ Item {
                 else
                    append({number:j})
             }
-            month.index = screen.curMonth - 1
+            month.index = Script.curMonth - 1
         }
 
         function change(){
-             month.index = screen.curMonth - 1;
+             month.index = Script.curMonth - 1;
         }
     }
 
@@ -198,26 +200,26 @@ Item {
             for(var i=1900;i<2099;i++){
                 append({number:i})
             }
-            year.index = screen.curYear - 1900
+            year.index = Script.curYear - 1900
         }
 
         function change(){
-              year.index = screen.curYear - 1900
+              year.index = Script.curYear - 1900
         }
     }
 
     function day_reset(){
-         datePicker.mDay = screen.curDay
+         datePicker.mDay = Script.curDay
         days.change()
     }
 
     function month_reset(){
-                 datePicker.mMonth = screen.curMonth
+                 datePicker.mMonth = Script.curMonth
         months.change()
     }
 
     function year_reset(){
-        datePicker.mYear = screen.curYear
+        datePicker.mYear = Script.curYear
         years.change()
     }
 
index c8cdd66..bc11951 100644 (file)
@@ -16,8 +16,34 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
 import QtQuick 1.0
 
+import "Themes.js" as Themes
+
 Item{
-    id: item1
+
+    id: aboutdlg
+
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:(parent.width * 1.5)
+
+    signal close
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    Connections {
+        target: aboutdlg.parent
+
+        onDialogClose: {
+            aboutdlg.state = "close";
+            aboutdlg.destroy(600);
+        }
+    }
+
+
     Rectangle {
         id: rectangle1
         anchors.fill: parent; anchors.bottomMargin: 0
@@ -83,14 +109,46 @@ wrapMode: Text.NoWrap
 
 }
 
-    ToolBarSingle { id: toolBar; height: 50;
-        y: screen.height-78
+    Rectangle {
+        width : aboutdlg.width
+        height: 45
+        color:"white"
+        opacity: 0.5
+    }
+
+    Text {
+        id: title
+
+        anchors { horizontalCenter: aboutdlg.horizontalCenter; top: aboutdlg.top; topMargin: 10 }
+        font.pixelSize: 22
+        color: "black"
+        text: qsTr("About")
+        smooth: true
+        font.bold: true
+    }
+
+
+    ToolBarSingle {
+        id: toolBar; height: 42;
+        y: parent.height-52
         width: parent.width;
         button1Label: "Quay Về"
-        onButton1Clicked:
-        {
-            screen.state="mainscreen"
+        onButton1Clicked:aboutdlg.close()
+    }
+
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: aboutdlg; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: aboutdlg; anchors.right: parent.left }
         }
+    ]
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
     }
 
 }
index 63890b7..83f05cd 100644 (file)
@@ -16,13 +16,26 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
 
 import QtQuick 1.0
-import "amlich-hnd.js" as AmLich
-import "amlich-aa98.js" as AmLich98
+
+import "Themes.js" as Themes
+import "main.js" as Script
 
 Item{
     id: amdatetime
     state: "switch_me"
 
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:(parent.width * 1.5)
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    signal toolbar
+
     Rectangle {
         id: rectangle1
         x: 0
@@ -63,12 +76,12 @@ Item{
                  if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan)
                      lmonth-=1;
 
-                var finalSolarDay = AmLich98.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7)
+                var finalSolarDay = Script.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7)
 
                  LC.reset(finalSolarDay[0],finalSolarDay[1],finalSolarDay[2])
-                 screen.calculateLunar( finalSolarDay[0], finalSolarDay[1], finalSolarDay[2])
-                 screen.state="mainscreen"
-                 screen.refresh()
+                 Script.calculateLunar( finalSolarDay[0], finalSolarDay[1], finalSolarDay[2])
+                 Script.state="mainscreen"
+                 Script.refresh()
 
                  maindatemodel.reset()
                  txtDATEpv.currentIndex =  finalSolarDay[0]-1;
@@ -84,11 +97,14 @@ Item{
             height: 40
             text: "X"
             anchors.rightMargin: 56
-            onClicked: {screen.state="mainscreen"}
+            onClicked: {
+                amdatetime.state="close"
+                amdatetime.toolbar()
+            }
         }
 
         Rectangle {
-            id: rectangle2
+            id: rec22
             x: 23
             y: 89
             width: 415
@@ -135,6 +151,38 @@ Item{
                 }
             }
 
+            states: [
+                State {
+                    name: "switch_to_day";
+                    PropertyChanges { target:lmk;x:10;width:60;}
+                    PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunarday_pathview;pathItemCount:3;}
+                    PropertyChanges { target:lunarday_mousearea;visible:false;}
+                    PropertyChanges { target:lunaryear_mousearea;visible:true;}
+                    PropertyChanges { target:lunarmonth_mousearea;visible:true;}
+                },
+                State {
+                    name: "switch_to_year";
+                    PropertyChanges { target:lmk;x:207;width:198;}
+                    PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunaryear_pathview;pathItemCount:3;}
+                    PropertyChanges { target:lunarday_mousearea;visible:true;}
+                    PropertyChanges { target:lunaryear_mousearea;visible:false;}
+                    PropertyChanges { target:lunarmonth_mousearea;visible:true;}
+                },
+                State {
+                    name: "switch_to_month";
+                    PropertyChanges { target:lmk;x:60;width:150;}
+                    PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
+                    PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;}
+                    PropertyChanges { target:lunarday_mousearea;visible:true;}
+                    PropertyChanges { target:lunaryear_mousearea;visible:true;}
+                    PropertyChanges { target:lunarmonth_mousearea;visible:false;}
+                }]
+
             /**LUNAR YEAR**/
             Rectangle {
                 id:lunaryear_rec
@@ -182,7 +230,7 @@ Item{
 
                      onMovementEnded: {
                          //console.log(lunaryear_pathview.currentIndex)
-                         AmLich.getYearInfo(lunaryear_pathview.currentIndex+1900);
+                         Script.getYearInfo(lunaryear_pathview.currentIndex+1900);
                          lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1);
                      }
                 }
@@ -190,7 +238,7 @@ Item{
                     id:lunaryear_mousearea
                     anchors.fill: parent
                     onClicked: {
-                        amdatetime.state="switch_to_year"
+                        rec22.state="switch_to_year"
                     }
                 }
             }
@@ -198,17 +246,18 @@ Item{
             ListModel {
                 id:lunaryear_model
                 Component.onCompleted: {
-                    init()
+                    //init()
                  }
 
                 function init(){
                     for(var i=1900;i<2099;i++){
-                        var lunarYear = AmLich.getYearCanChi(i)
+                        var lunarYear = Script.getYearCanChi(i)
                         append({name:i+" ("+lunarYear+")"})
                     }
                 }
 
                 function change(YYYY){
+                    lunaryear_pathview.currentIndex=-1;
                     lunaryear_pathview.currentIndex = YYYY - 1900
                 }
             }
@@ -266,7 +315,7 @@ Item{
                         id:lunarday_mousearea
                         anchors.fill: parent
                         onClicked: {
-                            amdatetime.state="switch_to_day"
+                            rec22.state="switch_to_day"
                         }
                     }
 
@@ -275,8 +324,12 @@ Item{
                 ListModel {
                     id:lunarday_model
                     Component.onCompleted: {
+
+                    }
+
+                    function init(){
                         for(var i=1;i<=30;i++)
-                            append({name:i})
+                            lunarday_model.append({name:i})
                     }
 
                     function change(MM,DD){
@@ -286,11 +339,11 @@ Item{
                         }
 
 
-                        var daystotal = AmLich.RMM[MM-1];
+                        var daystotal = Script.RMM[MM-1];
 
                         if(lunarmonth_model.get(MM-1).nhuan){
 
-                                for (var i=1;i<=AmLich.LML;i++)
+                                for (var i=1;i<=Script.LML;i++)
                                      lunarday_model.append({name:i})
 
                         }else{
@@ -337,7 +390,7 @@ Item{
                             lunarday_model.append({name:i})
                         }*/
 
-                        lunarday_rec.index = DD-1;
+                        lunarday_pathview.currentIndex=-1;
                         lunarday_pathview.currentIndex= DD-1;
 
                     }
@@ -404,7 +457,7 @@ Item{
                             id:lunarmonth_mousearea
                             anchors.fill: parent
                             onClicked: {
-                                amdatetime.state="switch_to_month"
+                                rec22.state="switch_to_month"
                             }
                         }
 
@@ -429,11 +482,11 @@ Item{
                         function readd(YYYY, MM){
                             var yTest = YYYY;
                             var preFix = "Tháng ";
-                            var a=AmLich.leapMonth(yTest)
+                            var a=Script.leapMonth(yTest)
                             var t=0;
                             if(a){ // nam nhuan
                                  for(var i=0;i<=12;i++){
-                                    var l=AmLich.getYearInfo(yTest)[i].month
+                                    var l=Script.getYearInfo(yTest)[i].month
                                      if (t==l)
                                          lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true})
                                      else
@@ -447,7 +500,8 @@ Item{
                                     lunarmonth_model.append({name:preFix+i, nhuan:false})
                             }
 
-                            lunarmonth_rec.index = MM -1;
+                            //lunarmonth_rec.index = MM -1;
+                            lunarmonth_pathview.currentIndex=-1;
                             lunarmonth_pathview.currentIndex = MM-1;
 
                         }
@@ -459,50 +513,28 @@ Item{
     }
 
     Component.onCompleted: {
-
+        reset();
     }
 
     states: [
         State {
-            name: "switch_to_day";
-            PropertyChanges { target:lmk;x:10;width:60;}
-            PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
-                                    PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
-            PropertyChanges { target:lunarday_pathview;pathItemCount:3;}
-            PropertyChanges { target:lunarday_mousearea;visible:false;}
-            PropertyChanges { target:lunaryear_mousearea;visible:true;}
-            PropertyChanges { target:lunarmonth_mousearea;visible:true;}
+            name: "show"
+            AnchorChanges { target: amdatetime; anchors.right: parent.right }
         },
         State {
-            name: "switch_to_year";
-            PropertyChanges { target:lmk;x:207;width:198;}
-            PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
-                                    PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;}
-            PropertyChanges { target:lunaryear_pathview;pathItemCount:3;}
-            PropertyChanges { target:lunarday_mousearea;visible:true;}
-            PropertyChanges { target:lunaryear_mousearea;visible:false;}
-                        PropertyChanges { target:lunarmonth_mousearea;visible:true;}
-        },
-        State {
-            name: "switch_to_month";
-            PropertyChanges { target:lmk;x:60;width:150;}
-            PropertyChanges { target:lunarday_pathview;pathItemCount:1;}
-            PropertyChanges { target:lunaryear_pathview;pathItemCount:1;}
-                        PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;}
-            PropertyChanges { target:lunarday_mousearea;visible:true;}
-            PropertyChanges { target:lunaryear_mousearea;visible:true;}
-                        PropertyChanges { target:lunarmonth_mousearea;visible:false;}
+            name: "close"
+            AnchorChanges { target: amdatetime; anchors.right: parent.left }
         }
     ]
 
     function reset(){
-        var acs = AmLich.getYearInfo(screen.curYear)
-        var a=AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear)
+        var acs = Script.getYearInfo(Script.curYear)
+        var a=Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear)
                 var finalmonth=a.month;
         if (a.leap)
             finalmonth+=1;
         else{
-        var aaa=AmLich.leapMonth(screen.curYear)
+        var aaa=Script.leapMonth(Script.curYear)
         var t=-1;
 
         if (aaa){
@@ -520,9 +552,15 @@ Item{
         }
         }
 
+        lunaryear_model.init()
+        lunarday_model.init()
         lunaryear_model.change(a.year)
         lunarmonth_model.change(a.year, finalmonth)
         lunarday_model.change(finalmonth,a.day)
 
     }
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+    }
 }
index c1a24d7..662c714 100644 (file)
@@ -23,45 +23,39 @@ Item {
     signal clicked
 
     property string text
-    property bool keyUsing: false
 
-    BorderImage {
-        id: buttonImage
-        source:  theme_manager.theme.toolbar.button_sci
-        width: container.width; height: container.height
-    }
-    BorderImage {
-        id: pressed
-        opacity: 0
-        source: theme_manager.theme.toolbar.button_pressed_sci
-        width: container.width; height: container.height
-    }
-    MouseArea {
-        id: mouseRegion
-        anchors.fill: buttonImage
-        onClicked: { container.clicked(); }
-    }
-    Text {
-        id: btnText
-        color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";}
-        anchors.centerIn: buttonImage; font.bold: true
-        text: container.text; style: Text.Raised; styleColor: "black"
-        font.pixelSize: 24
-        font.family: "Tahoma"
-    }
-    states: [
-        State {
-            name: "Pressed"
-            when: mouseRegion.pressed == true
-            PropertyChanges { target: pressed; opacity: 1 }
-        },
-        State {
-            name: "Focused"
-            when: container.activeFocus == true
-            PropertyChanges { target: btnText; color: "#FFFFFF" }
+    Rectangle {
+
+        anchors.fill: parent
+        y:parent.y
+        width:parent.width
+        height:parent.height
+
+        radius: 4
+        border.color: "grey"
+
+        Text {
+            id: button1
+            color: "#000000"
+            anchors.centerIn: parent; font.bold: true
+            text: container.text; style: Text.Raised; styleColor: "black"
+            font.pixelSize: 22
+            font.family: "Tahoma"
+        }
+
+        MouseArea {
+            id: mouseRegion
+            anchors.fill: parent
+            onClicked: { container.clicked(); }
+
+            onPressed: {
+                parent.color = "blue"
+            }
+
+            onReleased: {
+                parent.color = "white"
+            }
         }
-    ]
-    transitions: Transition {
-        ColorAnimation { target: btnText; }
     }
+
 }
index fff991a..ace1ed3 100644 (file)
@@ -88,17 +88,17 @@ var Loi_Hay_Y_Dep = new Array(
         "Hãy yêu mến lời khuyên can,<br>đừng yêu mếm lời tâng nịnh.<br><i>(Ngạn ngữ Nga)</i>"
         );
 
-function get(obj) {
+function get(curDay, curMonth,lunarDay, lunarMonth) {
     var day_info = "";
 
     for (var i=0;i<AmLich.length;i++)
-        if (AmLich[i][0] == obj.lunarDay && AmLich[i][1] == obj.lunarMonth){
+        if (AmLich[i][0] == lunarDay && AmLich[i][1] == lunarMonth){
             day_info+=AmLich[i][2];
             break;
          }
 
     for(i=0;i<DuongLich.length;i++)
-        if (DuongLich[i][0] == obj.curDay && DuongLich[i][1] == obj.curMonth){
+        if (DuongLich[i][0] == curDay && DuongLich[i][1] == curMonth){
             if (!day_info)
                 day_info=DuongLich[i][2];
             else
index 8b9df0f..3ebb54f 100644 (file)
@@ -17,8 +17,23 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 import QtQuick 1.0
 import "../DatePicker/component" as Comp
 
+import "Themes.js" as Themes
+import "main.js" as Script
+
 Item{
-    id: item1
+    id: datetimedlg
+
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:(parent.width * 1.5)
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    signal toolbar
 
     Rectangle {
         id: rectangle1
@@ -38,9 +53,9 @@ Item{
         Column {
             id: datePicker
             width: 260
-            property int mDay: screen.curDay
-            property int mMonth: screen.curMonth
-            property int mYear: screen.curYear
+            property int mDay: Script.curDay
+            property int mMonth: Script.curMonth
+            property int mYear: Script.curYear
             anchors.centerIn: parent
 
             Comp.DateReel {
@@ -57,9 +72,9 @@ Item{
             visible: true
             onClicked: {
                 LC.reset(datePicker.mDay,datePicker.mMonth,datePicker.mYear)
-                screen.calculateLunar(datePicker.mDay,datePicker.mMonth,datePicker.mYear)
-                screen.state="mainscreen"
-                screen.refresh()
+                Script.calculateLunar(datePicker.mDay,datePicker.mMonth,datePicker.mYear)
+                Script.state="mainscreen"
+                Script.refresh()
                 maindatemodel.reset()
                 }
         }
@@ -72,7 +87,10 @@ Item{
             height: 40
             text: "X"
             anchors.rightMargin: 56
-            onClicked: {screen.state="mainscreen";screen.refresh();}
+            onClicked: {
+                datetimedlg.state="close";
+                datetimedlg.toolbar();
+            }
         }
     }
 
@@ -82,4 +100,19 @@ Item{
                 dateReel.year_reset()
     }
 
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: datetimedlg; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: datetimedlg; anchors.right: parent.left }
+        }
+    ]
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+    }
+
 }
index a3ba5aa..a2be992 100644 (file)
@@ -16,19 +16,34 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
 
 import QtQuick 1.0
-import "../DatePicker/component" as Comp
 
-import "amlich-hnd.js" as AmLich
-import "amlich-aa98.js" as AmLich98
-
-import "CacNgayLeTrongNam.js" as CNLTN
+import "Themes.js" as Themes
+import "main.js" as Script
 
 Item{
     id: fullmonth
 
-    property int m_day: screen.curDay
-    property int m_month: screen.curMonth
-    property int m_year: screen.curYear
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:-(parent.width * 1.5)
+
+    signal toolbar
+    signal updatedate(int day, int month, int year)
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+
+    Component.onCompleted: {
+        reset();
+    }
+
+    property int m_day: Script.curDay
+    property int m_month: Script.curMonth
+    property int m_year: Script.curYear
 
     property Component headerRenderer:Component {
         id: defaultHeaderRenderer
@@ -114,12 +129,14 @@ Item{
                 property bool hold: false
 
                 onClicked: {
-                    LC.reset(model.day,m_month,m_year)
+                    /*LC.reset(model.day,m_month,m_year)
                     screen.calculateLunar(model.day,m_month,m_year)
                     screen.state="mainscreen"
                     screen.refresh()
-                    maindatemodel.reset()
-                    txtDATEpv.currentIndex = model.day-1;
+                    maindatemodel.reset()*/
+                    fullmonth.state="close";
+                    fullmonth.toolbar();
+                    fullmonth.updatedate(model.day, m_month, m_year)
                 }
 
                 onPositionChanged: {
@@ -173,8 +190,7 @@ Item{
         Grid {
             id: grid
 
-            anchors.bottomMargin: -52
-            anchors.topMargin: 78
+            anchors.topMargin: 40
             anchors.horizontalCenter: parent.horizontalCenter
             anchors.bottom: parent.bottom
             anchors.top: parent.top
@@ -236,34 +252,43 @@ Item{
 
         }
 
-        Text {
-            id: txt_caption
-            y: 40
-            width:parent.width
-            text: "Tháng "+m_month+", "+m_year
-            horizontalAlignment: Text.AlignHCenter
-            font.pixelSize: 24
-            font.bold: true
-        }
+    }
+
+    Rectangle {
+        width : fullmonth.width
+        height: 45
+        color:"white"
+        opacity: 0.5
+    }
+
+    Text {
+        id: title
 
+        anchors { horizontalCenter: fullmonth.horizontalCenter; top: fullmonth.top; topMargin: 10 }
+        font.pixelSize: 22
+        color: "black"
+        text: "Tháng "+fullmonth.m_month+", "+fullmonth.m_year
+        smooth: true
+        font.bold: true
     }
 
-    ToolBarSingle { id: toolBar; height: 50;
-        y: screen.height-78
+    ToolBarSingle {
+        id: toolBar; height: 42;
+        y: parent.height-52
         width: parent.width;
         button1Label: "Quay Về"
-        onButton1Clicked:
-        {
-            screen.state="mainscreen"
+        onButton1Clicked:{
+            fullmonth.state="close";
+            fullmonth.toolbar();
         }
     }
 
     function reset() {
         monthModel.clear()
 
-        var firstdayofthemonthyear = AmLich.getLunarDate(1,m_month,m_year).jd;
+        var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd;
         var startfrom = (firstdayofthemonthyear+1)%7;
-        var daysofthemonthyear = LC.calDays(m_month,m_year);
+        var daysofthemonthyear = Script.calDays(m_month,m_year);
         var j=1;
         var totalslot = 42;
 
@@ -293,17 +318,17 @@ Item{
             }
 
             var current = false;
-            if (dayclick == screen.curDay && monthclick==screen.curMonth && yearclick==screen.curYear)
+            if (dayclick == Script.curDay && monthclick==Script.curMonth && yearclick==Script.curYear)
                 current = true
 
-            var lunarcl = AmLich.getLunarDate(dayclick,monthclick,yearclick)
+            var lunarcl = Script.getLunarDate(dayclick,monthclick,yearclick)
             var lunar_day = lunarcl.day;
 
             if (lunarcl.day === 1)
                 lunar_day = lunarcl.day+"/"+lunarcl.month;
 
-            var stemp = AmLich98.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
-            var inholiday = CNLTN.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
+            var stemp = Script.convertSolar2Lunar(dayclick,monthclick,yearclick,7);
+            var inholiday = Script.is_holiday(dayclick, monthclick, stemp[0], stemp[1]);
 
             monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday})
         }
@@ -319,9 +344,9 @@ Item{
             cYear--;
         }else
             cMonth--;
-         var daysofthemonthyear = LC.calDays(cMonth,cYear);
+         var daysofthemonthyear = Script.calDays(cMonth,cYear);
         for (var i=daysofthemonthyear;i>daysofthemonthyear-startfrom;i--){
-            var lunarcl = AmLich.getLunarDate(i,cMonth,cYear)
+            var lunarcl = Script.getLunarDate(i,cMonth,cYear)
             pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear})
         }
         return pmonth.reverse()
@@ -338,10 +363,25 @@ Item{
             cMonth++;
 
         for (var i=1;i<=startfrom;i++){
-          var lunarcl = AmLich.getLunarDate(i,cMonth,cYear)
+          var lunarcl = Script.getLunarDate(i,cMonth,cYear)
             pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear});
         }
            return pmonth.reverse();
     }
 
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: fullmonth; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: fullmonth; anchors.right: parent.left }
+        }
+    ]
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+    }
+
 }
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 }
+    }
 
 }
index b571804..d998375 100644 (file)
@@ -18,18 +18,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 import QtQuick 1.0
 
 Item {
-    TitleBar { id: titleBar; width: parent.width; height: 60;
-        y: -80
-        untaggedString: ""
-        taggedString: ""
+    TitleBar { id: titleBar; width: parent.width;
+        onMinimize:  ROOT.minimize();
+        onClose: Qt.quit();
+
+        caption: "Lịch Việt"
     }
-    states: [
-        State {
-            name: "search"; when: screen.state!="search"
-            PropertyChanges { target: titleBar; y: 0 }
-        }
-    ]
-    transitions: [
-        Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } }
-    ]
 }
index 69c34f0..c3d3b5d 100644 (file)
@@ -17,9 +17,33 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 
 import QtQuick 1.0
 import "Settings.js" as Settings
+import "Themes.js" as Themes
 
 Item{
 
+    id:optionsscreen
+
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:-(parent.width * 1.5)
+
+    signal close
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    Connections {
+        target: optionsscreen.parent
+
+        onDialogClose: {
+            optionsscreen.state = "close";
+            optionsscreen.destroy(600);
+        }
+    }
+
     Rectangle {
         id: rectangle1
         anchors.fill: parent; anchors.bottomMargin: 16
@@ -82,24 +106,56 @@ Item{
 
     }
 
+    Rectangle {
+        width : optionsscreen.width
+        height: 45
+        color:"white"
+        opacity: 0.5
+    }
+
+    Text {
+        id: title
+
+        anchors { horizontalCenter: optionsscreen.horizontalCenter; top: optionsscreen.top; topMargin: 10 }
+        font.pixelSize: 22
+        color: "black"
+        text: "Lựa Chọn"
+        smooth: true
+        font.bold: true
+    }
 
-    ToolBar { id: toolBar; height: 50;
-        y: screen.height-78
+    ToolBar {
+        id: toolBar; height: 42;
+        y: parent.height-52
         width: parent.width;
         button1Label: "Đồng Ý"
         button2Label: "Hủy Bỏ"
         onButton1Clicked:
         {
             Settings.save(listModel)
-            screen.state="mainscreen"
+            optionsscreen.close();
 
             var cdx = Settings.chedoxoay();
             ROOT.initScreenOrientation(cdx);
         }
         onButton2Clicked: {
             Settings.restore(listModel)
-            screen.state="mainscreen"
+            optionsscreen.close();
         }
     }
 
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: optionsscreen; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: optionsscreen; anchors.right: parent.left }
+        }
+    ]
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
+    }
 }
index 242c91d..d08c357 100644 (file)
@@ -40,6 +40,27 @@ function init_default(){
             ];
 }
 
+function restore_nomodel(){
+    var db = get_db();
+    optsGlobal = [];
+
+    function readEntry(json) {
+        var parsed = JSON.parse(json);
+        optsGlobal.push(parsed);
+    }
+
+    db.transaction( function(tx) {
+                       try {
+                           var rs = tx.executeSql('SELECT * FROM Settings');
+                           for (var i = 0; i < rs.rows.length; i++) {
+                               readEntry(rs.rows.item(i).json)
+                           }
+                       } catch (error) {
+                           init_nomodel();
+                       }
+                   } );
+}
+
 function restore(objmodel){
     var db = get_db();
     objmodel.clear();
@@ -107,6 +128,14 @@ function save(obj){
     store(lopts);
 }
 
+function init_nomodel(){
+    var listopts = init_default();
+    optsGlobal = [];
+    for(var i=0;i< listopts.length;i++){
+        optsGlobal.push(listopts[i]);
+    }
+}
+
 function init(obj){
     var listopts = init_default();
     optsGlobal = [];
@@ -132,7 +161,7 @@ function chedoxoay(){
 function get_opt(idm){
     for(var i=0;i<optsGlobal.length;i++){
         if (optsGlobal[i].idm == idm){
-                if(optsGlobal[i].selected == "true" || optsGlobal[i].selected == true)
+                if(optsGlobal[i].selected == "true" || optsGlobal[i].selected === true)
                     return 1;
         }
     }
index 0942912..a5e94c4 100644 (file)
@@ -17,9 +17,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 \r
 import QtQuick 1.0\r
 \r
+import "Themes.js" as Themes\r
+\r
 Item {\r
     id: container\r
 \r
+    Loader {\r
+        id: theme_manager\r
+        property alias theme: theme_manager.item\r
+        source: Themes.default_theme()\r
+    }\r
+\r
+\r
     // Font properties\r
     property string fontName: "Nokia Sans"\r
     property int fontSize: 18\r
index 8690364..b28e045 100644 (file)
@@ -22,9 +22,3 @@ var root_dir = "/opt/usr/share/LichViet/";
 function default_theme(){
     return "file:"+root_dir+"themes/default/default.qml";
 }
-
-function init(Controller, Model){
-   if(Controller.pathExists(root_dir)){
-       Model.append({idm:2,name: "BLACK",title:"",can_be_deleted:false,is_selected:false})
-   }
-}
index ac7657a..ef54ac7 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$
-**
-****************************************************************************/
+/*
+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.0
 
 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
+
+        height: title_bar.height - 10
+        width: 45
 
-    Item {
-        id: container
-        width: (parent.width * 2) - 55 ; height: parent.height
+        color: "transparent"
 
-        function accept() {
-            titleBar.state = ""
-            background.state = ""
-            rssModel.tags = editor.text
+        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 }
-    }*/
 }
index cfa4f61..ee9e1ab 100644 (file)
@@ -1,43 +1,19 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+/*
+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.0
 
@@ -46,19 +22,36 @@ Item {
 
     property alias button1Label: button1.text
     property alias button2Label: button2.text
+
     signal button1Clicked
     signal button2Clicked
-    focus:true
-    BorderImage { source:  theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 }
+
+    Rectangle {
+        color:"#7373b1"
+        width: parent.width
+        height: parent.height + 14
+
+        radius: 4
+    }
+
     Button {
-        id: button1
-        anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 40
-        onClicked: toolbar.button1Clicked()
-        focus:true
+        id:button1
+        anchors.left: parent.left
+        anchors.leftMargin: 5
+        y: 5
+        width: 140
+        height: 42
+        onClicked: toolbar.button1Clicked();
     }
+
     Button {
-        id: button2
-        anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 40
-        onClicked: toolbar.button2Clicked()
+        id:button2
+        anchors.right: parent.right
+        anchors.rightMargin: 5
+        y: 5
+        width: 140
+        height: 42
+        onClicked: toolbar.button2Clicked();
     }
+
 }
index 0225060..c1593da 100644 (file)
@@ -18,16 +18,30 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 import QtQuick 1.0
 
 Item {
-    id: toolbarsingle
+    id: toolbar
 
     property alias button1Label: button1.text
+
+    opacity: 0.8
+
     signal button1Clicked
-    focus:true
-    BorderImage { source:  theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 }
+
+    Rectangle {
+        color:"#7373b1"
+        width: parent.width
+        height: parent.height + 14
+
+        radius: 4
+    }
+
     Button {
-        id: button1
-       anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 40
-        onClicked: toolbarsingle.button1Clicked()
-        focus:true
+        id:button1
+        anchors.right: parent.right
+        anchors.rightMargin: 5
+        y: 5
+        width: 140
+        height: 42
+        onClicked: toolbar.button1Clicked();
     }
+
 }
index 718efcf..f5f4c3b 100644 (file)
@@ -17,11 +17,32 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 
 import QtQuick 1.0
 
-import "amlich-hnd.js" as AmLich
-import "xemngaytotxau.js" as NTX
+import "main.js" as Script
+import "Themes.js" as Themes
 
 Item{
-    id:main_item
+    id:xntxhd
+
+    anchors.verticalCenter: parent.verticalCenter
+    width: parent.width; height: parent.height;
+    x:(parent.width * 1.5)
+
+    signal close
+
+    Loader {
+        id: theme_manager
+        property alias theme: theme_manager.item
+        source: Themes.default_theme()
+    }
+
+    Connections {
+        target: xntxhd.parent
+
+        onDialogClose: {
+            xntxhd.state = "close";
+            xntxhd.destroy(600);
+        }
+    }
 
     property string day_month_year_LN_CN:  ""
     property string nhi_thap_bat_tu:  ""
@@ -35,12 +56,8 @@ Item{
 
     Rectangle {
         id: rectangle1
-        x: 0
-        y: -5
-        anchors.rightMargin: 0
-        anchors.leftMargin: 0
-        anchors.topMargin:30
-        anchors.fill: parent; anchors.bottomMargin: 16
+
+        anchors.fill: parent; anchors.bottomMargin: 0;
         visible: true
         opacity:0.9
 
@@ -51,7 +68,7 @@ Item{
                 Column {
 
                     Rectangle {
-                                        width:rectangle1.width;
+                                        width:rectangle1.width-10;
                                         y:30;
                                         x:0
                                         height:1
@@ -66,7 +83,7 @@ Item{
                     }
 
                     Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20
-                        font.family: "Tahoma";width:parent.width;}
+                        font.family: "Tahoma";width:parent.width-10;}
 
                     Rectangle{
                         width:rectangle1.width;
@@ -117,7 +134,7 @@ Item{
 
         ListView {
               id: listView
-              anchors.fill: parent;anchors.topMargin: 0;anchors.leftMargin: 0; anchors.bottomMargin: 16
+              anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 55
               model: listModel
               delegate: listDelegate
               focus: true
@@ -127,14 +144,12 @@ Item{
 
     }
 
-    ToolBarSingle { id: toolBar; height: 50;
-        y: screen.height-78
+    ToolBarSingle {
+        id: toolBar; height: 42;
+        y: parent.height-52
         width: parent.width;
         button1Label: "Quay Về"
-        onButton1Clicked:
-        {
-            screen.state="mainscreen"
-        }
+        onButton1Clicked:xntxhd.close()
     }
 
     function getHD(name,idm){
@@ -142,28 +157,63 @@ Item{
             name="<span style='color:blue;'>"+name+"</span><br>";
         }
 
+        reset();
+
         switch(idm){
-        case 0 : return name+ main_item.day_month_year_LN_CN;break;
-        case 1 : return name+screen.lunarGioHoangDao;break;
-        case 2 : return name+screen.lunarTietKhi();break;
-        case 3 : return name+main_item.nhi_thap_bat_tu; break;
-        case 5 :  return name+main_item.luan_giai;break;
-        case -1: return name+main_item.truc;break;
-        case 6: return name+main_item.cac_sao_tot;break;
-        case 7: return name+main_item.cac_sao_xau;break;
-        case -2: return name+main_item.huong_xuat_hanh;break;
-        case 8: return main_item.warnning;break;
+        case 0 : return name+ xntxhd.day_month_year_LN_CN;break;
+        case 1 : return name+Script.lunarGioHoangDao;break;
+        case 2 : return name+Script.lunarTietKhi();break;
+        case 3 : return name+xntxhd.nhi_thap_bat_tu; break;
+        case 5 :  return name+xntxhd.luan_giai;break;
+        case -1: return name+xntxhd.truc;break;
+        case 6: return name+xntxhd.cac_sao_tot;break;
+        case 7: return name+xntxhd.cac_sao_xau;break;
+        case -2: return name+xntxhd.huong_xuat_hanh;break;
+        case 8: return xntxhd.warnning;break;
         }
     }
 
     function reset(){
-        main_item.day_month_year_LN_CN = AmLich.getTHU(screen.jd)+",ngày <b>"+screen.curDay+"</b> tháng <b>"+screen.curMonth+"</b> năm <b>"+screen.curYear+"</b><br>Ngày <b>"+screen.lunarDay+"</b> tháng <b>"+screen.lunarMonth+"</b> năm <b>"+screen.lunarYear+"</b> (<b>"+screen.lunarYearInt+"</b>)";
-        main_item.nhi_thap_bat_tu = NTX.sao(screen.curYear,AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd - AmLich.getLunarDate(1,1,screen.curYear).jd);
-        main_item.truc = NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi);
-        main_item.cac_sao_tot = NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi);
-        main_item.cac_sao_xau = NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi);
-        main_item.luan_giai = NTX.luangiai(screen.curDay);
-        main_item.huong_xuat_hanh = NTX.huong_xuat_hanh(screen.lunarDayCanChi);
+        xntxhd.day_month_year_LN_CN = Script.thu()+",ngày <b>"+Script.curDay+"</b> tháng <b>"+Script.curMonth+"</b> năm <b>"+Script.curYear+"</b><br>Ngày <b>"+Script.lunarDay+"</b> tháng <b>"+Script.lunarMonth+"</b> năm <b>"+Script.lunarYear+"</b> (<b>"+Script.lunarYearInt+"</b>)";
+        xntxhd.nhi_thap_bat_tu = Script.sao(Script.curYear,Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear).jd - Script.getLunarDate(1,1,Script.curYear).jd);
+        xntxhd.truc = Script.truc(Script.lunarMonth, Script.lunarDayCanChi, Script.lunarMonthCanChi);
+        xntxhd.cac_sao_tot = Script.cacsaotot(Script.lunarMonth, Script.lunarDayCanChi);
+        xntxhd.cac_sao_xau = Script.cacsaoxau(Script.lunarMonth, Script.lunarDayCanChi);
+        xntxhd.luan_giai = Script.luangiai(Script.curDay);
+        xntxhd.huong_xuat_hanh = Script.huong_xuat_hanh(Script.lunarDayCanChi);
+    }
+
+    Rectangle {
+        width : xntxhd.width
+        height: 45
+        color:"white"
+        opacity: 0.5
+    }
+
+    Text {
+        id: title
+
+        anchors { horizontalCenter: xntxhd.horizontalCenter; top: xntxhd.top; topMargin: 10 }
+        font.pixelSize: 22
+        color: "black"
+        text: "Xem Ngày Tốt/Xấu"
+        smooth: true
+        font.bold: true
+    }
+
+    states: [
+        State {
+            name: "show"
+            AnchorChanges { target: xntxhd; anchors.right: parent.right }
+        },
+        State {
+            name: "close"
+            AnchorChanges { target: xntxhd; anchors.right: parent.left }
+        }
+    ]
+
+    transitions: Transition {
+        AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
     }
 
 }
diff --git a/qml/LichViet/main.js b/qml/LichViet/main.js
new file mode 100644 (file)
index 0000000..7813d53
--- /dev/null
@@ -0,0 +1,135 @@
+.pragma library
+
+Qt.include("amlich-hnd.js");
+Qt.include("amlich-aa98.js");
+Qt.include("Settings.js");
+Qt.include("Themes.js");
+Qt.include("CacNgayLeTrongNam.js");
+Qt.include("xemngaytotxau.js");
+
+var localdate = new Date();
+
+var curDay=localdate.getDate();
+var curMonth=localdate.getMonth()+1;
+var curYear=localdate.getFullYear();
+
+var initcurDay;
+var initcurMonth;
+var initcurYear;
+
+var lunarDay = getLunarDate(curDay,curMonth,curYear).day;
+var lunarMonth = getLunarDate(curDay,curMonth,curYear).month;
+var lunarYear = getCanChi(getLunarDate(curDay,curMonth,curYear))[2];
+var lunarYearInt = getLunarDate(curDay,curMonth,curYear).year;
+var jd = getLunarDate(curDay,curMonth,curYear).jd;
+var lunarGioHoangDao = getGioHoangDao(jd);
+
+var lunarDayCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[0];
+var lunarMonthCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[1];
+
+var day_info = get(curDay,curMonth, curYear, lunarDay, lunarMonth);
+var isholiday = is_holiday(curDay,curMonth, curYear, lunarDay, lunarMonth);
+
+var datetimedlg;
+var amdatetimedlg;
+var fullmonth;
+
+function init(){
+    initcurDay = curDay;
+    initcurMonth = curMonth;
+    initcurYear = curYear;
+}
+
+function day_reset(){
+    curDay = initcurDay;
+}
+
+function calDays(){
+    if (curMonth == 4 || curMonth == 6 || curMonth == 9 || curMonth == 11)
+        return 30;
+    else
+        if (curMonth == 2){
+            var isLeapYear = (curYear % 4 === 0 && curYear % 100 !== 0) || (curYear % 400 ===0);
+            if (isLeapYear)
+                return 29;
+            else
+                return 28;
+        }
+    return 31;
+}
+
+function calDaysX(month, year){
+    if (month == 4 || month == 6 || month == 9 || month == 11)
+        return 30;
+    else
+        if (month == 2){
+            var isLeapYear = (year % 4 === 0 && year % 100 !== 0) || (year % 400 ===0);
+            if (isLeapYear)
+                return 29;
+            else
+                return 28;
+        }
+    return 31;
+}
+
+function thu(){
+    return getTHU(jd);
+}
+
+function lunarTietKhi(){
+    return TIETKHI[getSunLongitude(jd+1,7.0)];
+}
+
+function changeDay(newday, txtTHU, txtInfo, txtDAYAmLich){
+    curDay = newday;
+    recalculate();
+
+    txtTHU.text=__txtTHU_format();
+    txtInfo.text=__txtInfo_format();
+    txtDAYAmLich.text=__txtDAYAmLich_format();
+}
+
+function createDateTimeDialog(parent){
+    datetimedlg = createObject("DateTimeDialog.qml", parent);
+    amdatetimedlg = createObject("AmDateTimeDialog.qml", parent);
+    fullmonth = createObject("FullMonth.qml", parent);
+}
+
+function __txtTHU_format(){
+    return getTHU(jd);
+}
+
+function __txtInfo_format(){
+    return day_info;
+}
+
+function __txtDAYAmLich_format(){
+    return "Ngày <span style='color:#C0C0C0;'>"+lunarDay+" ("+lunarDayCanChi+")</span><br>Tháng <span style='color:#C0C0C0;'>"+lunarMonth+" ("+lunarMonthCanChi+")</span><br>Năm <span style='color:#C0C0C0;'>"+lunarYearInt+" ("+lunarYear+")</span>";
+}
+
+function recalculate(){
+    lunarDay = getLunarDate(curDay,curMonth,curYear).day;
+    lunarMonth = getLunarDate(curDay,curMonth,curYear).month;
+    lunarYear = getCanChi(getLunarDate(curDay,curMonth,curYear))[2];
+    lunarYearInt = getLunarDate(curDay,curMonth,curYear).year;
+    jd = getLunarDate(curDay,curMonth,curYear).jd;
+    lunarGioHoangDao = getGioHoangDao(jd);
+
+    lunarDayCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[0];
+    lunarMonthCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[1];
+
+    day_info = get(curDay,curMonth, curYear, lunarDay, lunarMonth);
+    isholiday = is_holiday(curDay,curMonth, curYear, lunarDay, lunarMonth);
+}
+
+function createObject(sourceFile, parentObject) {
+    var component = Qt.createComponent(sourceFile);
+    var guiObject = component.createObject(parentObject);
+
+    if (guiObject === null) {
+        console.log("Error creating object");
+    }
+    else {
+        return guiObject
+    }
+}
index bf570b4..d9f2d59 100644 (file)
@@ -16,41 +16,22 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
 
 import QtQuick 1.0
-import "amlich-hnd.js" as AmLich
-import "amlich-aa98.js" as AmLich98
 
-import "Settings.js" as Settings
 import "Themes.js" as Themes
-import "CacNgayLeTrongNam.js" as CNLTN
+import "Settings.js" as Settings
+import "main.js" as Script
 
 Item {
      id: screen
      width: 800
      height: 480
 
-     property int curDay: LC.curDay()
-     property int curMonth: LC.curMonth()
-     property int curYear: LC.curYear()
-
-     property int initcurDay: LC.curDay()
-     property int initcurMonth: LC.curMonth()
-     property int initcurYear:LC.curYear()
-
-     property int lunarDay: AmLich.getLunarDate(curDay,curMonth,curYear).day
-     property int lunarMonth: AmLich.getLunarDate(curDay,curMonth,curYear).month
-     property string lunarYear: AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[2]
-
-     property int lunarYearInt : AmLich.getLunarDate(curDay,curMonth,curYear).year
-     property int jd : AmLich.getLunarDate(curDay,curMonth,curYear).jd
-     property string lunarGioHoangDao : AmLich.getGioHoangDao(jd)
-
-     property string lunarDayCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[0]
-     property string lunarMonthCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[1]
+     state:"mainscreen"
 
-     property string day_info : CNLTN.get(screen)
-     property bool is_holiday : CNLTN.is_holiday(screen.curDay,screen.curMonth, screen.curYear, screen.lunarDay, screen.lunarMonth)
+     signal dialogClose
 
-     state:"mainscreen"
+     property int curMonth: Script.curMonth
+     property int curYear: Script.curYear
 
      Loader {
          id: theme_manager
@@ -58,16 +39,41 @@ Item {
          source: Themes.default_theme()
      }
 
+     Component.onCompleted: {
+        Settings.restore_nomodel();
+        Script.createDateTimeDialog(screen);
+        Script.datetimedlg.toolbar.connect(show_toolbar);
+        Script.amdatetimedlg.toolbar.connect(show_toolbar);
+        Script.fullmonth.toolbar.connect(show_toolbar);
+        Script.fullmonth.updatedate.connect(update_date);
+        maindatemodel.init();
+        Script.init();
+     }
+
+     function show_toolbar(){
+        screen.state="mainscreen";
+     }
+
+     function update_date(day, month, year){
+         txtDATEpv.currentIndex = day-1;
+         screen.curMonth = month;
+         screen.curYear = year;
+         Script.curMonth = month;
+         Script.curYear = year;
+         Script.changeDay(day, txtTHU, txtInfo, txtDAYAmLich);
+     }
+
      Rectangle {
-         id: background
+         id: mecal
          anchors.fill: parent
-         color: "#343434"
+         color: "white"
 
          state:"jumptodate"
-         Image {
+
+         /*Image {
              source: theme_manager.theme.background_image; fillMode: Image.Stretch; anchors.fill: parent
              opacity: theme_manager.theme.background_opacity
-         }
+         }*/
 
 
          MouseArea {
@@ -82,35 +88,19 @@ Item {
 
              onPressAndHold:{
                  if (Settings.pressandhold()==1){
-                    screen.state="xemngaytotxauhoangdao"
+                     menu_item_Clicked(4);
                  }
              }
 
              onDoubleClicked:{
 
                  if (Settings.doubleclicked()==1){
-                     screen.state="datetimedialog"
+                     screen.state="datetimedialog";
+
                  }
              }
          }
 
-         Text {
-             id: txtDMY
-             x: 140
-             y: 77
-             width: 80
-             height: 20
-             color: "#29d999"
-             textFormat: Text.RichText
-             text: "Tháng <b>"+screen.curMonth+"</b> Năm <b>"+screen.curYear+"</b>"
-             anchors.horizontalCenter: parent.horizontalCenter
-             font.bold: false
-             font.family: "Tahoma"
-             smooth: true
-             horizontalAlignment: Text.AlignHCenter
-             font.pixelSize: 28
-         }
-
          //------------------------------------------------
 
                   Rectangle {
@@ -132,24 +122,7 @@ Item {
                                   text: name
                                   font.bold: true
                                   font.pixelSize: wrapper.PathView.isCurrentItem ? 80 : 40
-                                  color: {
-                                      if (wrapper.PathView.isCurrentItem){
-                                          var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7);
-                                          if (CNLTN.is_holiday(txtDATEpv.currentIndex+1,curMonth, stemp[0], stemp[1])){
-                                              return theme_manager.theme.markdate.holidays;
-                                          }else{
-                                          var mark_day = (AmLich.getLunarDate(txtDATEpv.currentIndex+1,curMonth,curYear).jd+1)%7;
-                                          if (mark_day === 0) //sunday
-                                              return theme_manager.theme.markdate.sunday;
-                                          if (mark_day == 6) //saturday
-                                              return theme_manager.theme.markdate.saturday;
-                                          else
-                                              return  theme_manager.theme.markdate.otherday_selected;
-                                          }
-                                      }
-                                      else
-                                          return "transparent";//theme_manager.theme.markdate.otherday;
-                                    }
+                                  color: "black"
                               }
                           }
                       }
@@ -188,7 +161,7 @@ Item {
                           }
 
                           onMovementEnded: {
-                              calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
+                              Script.changeDay(txtDATEpv.currentIndex+1, txtTHU, txtInfo, txtDAYAmLich);
                           }
                       }
                   }
@@ -196,7 +169,7 @@ Item {
                       id:maindatemodel
 
                       function reset(){
-                          var days_of_this_month = LC.calDays(screen.curMonth,screen.curYear);
+                          var days_of_this_month = Script.calDays();
                           var days_of_changes = days_of_this_month - maindatemodel.count;
 
                           var ifs;
@@ -213,29 +186,46 @@ Item {
                                   append({name:i+ifs})
                           }
 
-                         reelx.index = -1; // I dont now why must be added -1 before screen.curDay-1
-                         reelx.index = screen.curDay-1;
+                         reelx.index = -1;
+                         reelx.index = Script.curDay - 1;
 
                       }
 
                       function init(){
-                          for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
-                              append({name:i})
+                          for(var i=1;i<=Script.calDays();i++)
+                              append({name:i});
 
-                          reelx.index = screen.curDay -1
+                          reelx.index = Script.curDay - 1;
                       }
                   }
 
          //-------------------------------------------------
 
          Text {
+             id: txtDMY
+                      x: 140
+                      y: 77
+                      width: 80
+                      height: 20
+                      color: "#29d999"
+                      textFormat: Text.RichText
+                      text: "Tháng <b>"+screen.curMonth+"</b> Năm <b>"+screen.curYear+"</b>"
+                      anchors.horizontalCenter: parent.horizontalCenter
+                      font.bold: false
+                      font.family: "Tahoma"
+                      smooth: true
+                      horizontalAlignment: Text.AlignHCenter
+                      font.pixelSize: 28
+              }
+
+         Text {
              id: txtTHU
              x: 151
              y: 210
              width: 80
              height: 20
              color: "#f0f0f5"
-             text: AmLich.getTHU(screen.jd)
+             text: Script.__txtTHU_format()
              horizontalAlignment: Text.AlignHCenter
              anchors.horizontalCenter: parent.horizontalCenter
              opacity: 0.6
@@ -249,8 +239,8 @@ Item {
              y: (screen.is_holiday ? 270 : 250)
              width: 80
              height: 20
-             color: (screen.is_holiday ? theme_manager.theme.markdate.holidays : theme_manager.theme.markdate.not_holidays)
-             text: screen.day_info
+             color: (Script.is_holiday ? theme_manager.theme.markdate.holidays : theme_manager.theme.markdate.not_holidays)
+             text: Script.__txtInfo_format()
              horizontalAlignment: Text.AlignHCenter
              anchors.horizontalCenter: parent.horizontalCenter
              opacity: 0.6
@@ -266,7 +256,7 @@ Item {
              width: 80
              height: 20
              color: "#f0f0f5"
-             text: "Ngày <span style='color:#C0C0C0;'>"+screen.lunarDay+" ("+screen.lunarDayCanChi+")</span><br>Tháng <span style='color:#C0C0C0;'>"+screen.lunarMonth+" ("+screen.lunarMonthCanChi+")</span><br>Năm <span style='color:#C0C0C0;'>"+screen.lunarYearInt+" ("+screen.lunarYear+")</span>"
+             text: Script.__txtDAYAmLich_format()
              horizontalAlignment: Text.AlignHCenter
              anchors.horizontalCenter: parent.horizontalCenter
              opacity: 0.6
@@ -274,243 +264,82 @@ Item {
              font.pixelSize: 25
          }
 
-
-         MenuScreen{
-             id: menuScreen
-             state:"menuscreen"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         OptionsScreen{
-             id: optionsScreen
-             state:"optionsscreen"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         ChangeTheme{
-             id: changeTheme
-             state:"changetheme"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         XemNgayTotXauHoangDao{
-             id: xntxhdScreen
-             state:"xemngaytotxauhoangdao"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         DateTimeDialog{
-             id: datetimeDialog
-             state:"datetimedialog"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         AmDateTimeDialog{
-             id: amdatetimeDialog
-             state:"amdatetimedialog"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         FullMonth{
-             id: fullmonthDialog
-             state:"xemtheothang"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         About{
-             id: aboutDialog
-             state:"aboutdialog"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-         FileBrowser{
-             id: fileBrowser
-             state:"filebrowser"
-             anchors.verticalCenter: parent.verticalCenter
-             width: parent.width; height: parent.height-60;
-             x: -(screen.width * 1.5)
-         }
-
-
-         MultiTitleBar { id: titleBar; width: parent.width }
-         ToolBar { id: toolBar; height: 50;
-             y: screen.height - 48
-             width: parent.width; opacity: 0.9
+         ToolBar { id: toolBar; height: 42;
+             y: screen.height - 52
+             width: parent.width; opacity: 0.8
              button1Label: "Menu"
              button2Label: "Lựa Chọn"
              onButton1Clicked:
              {
-                 screen.state="menuscreen"
+                 screen.state="switchX"
+                 var menuscreen = Script.createObject("MenuScreen.qml", screen);
+                 menuscreen.close.connect(closeDialogs);
+                 menuscreen.item_click.connect(menu_item_Clicked);
+                 menuscreen.state = "show";
              }
              onButton2Clicked: {
-                 screen.state="optionsscreen"
+                 screen.state="switchX"
+                 var optionsscreen = Script.createObject("OptionsScreen.qml", screen);
+                 optionsscreen.close.connect(closeDialogs);
+                 optionsscreen.state = "show";
              }
-         }
-     }
 
-     states: [
-         State {
-             name:"mainscreen"
-             StateChangeScript {
-                 script:{
-                 }
-                }
-         },
-         State {
-             name: "menuscreen";
-             PropertyChanges { target: menuScreen; x: 0; focus:true}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-                          PropertyChanges { target: mouseareaMM;enabled:false }
+         }
 
-         },
-             State{
-                 name:"filebrowser"
-                 PropertyChanges { target: fileBrowser; x: 0; focus:true; visible:true;}
-                 PropertyChanges { target: toolBar; y: screen.height }
-                 PropertyChanges { target: toolBar }
-                 StateChangeScript {
-                     script:{
-                         fileBrowser.refresh();
-                     }
-                    }
-             },
-         State {
-             name: "optionsscreen";
-             PropertyChanges { target: optionsScreen; x: 0; focus:true}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-                          PropertyChanges { target: mouseareaMM;enabled:false }
+         MultiTitleBar { id: titleBar; width: parent.width }
 
-         },
-         State {
-             name: "changetheme";
-             PropertyChanges { target: changeTheme; x: 0; focus:true}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-             PropertyChanges { target: reelx;enabled:false }
-             PropertyChanges { target: mouseareaMM;enabled:false }
+     }
 
-         },
-         State {
-             name: "xemngaytotxauhoangdao";
-             PropertyChanges { target: xntxhdScreen; x: 0; focus:true;visible:true;}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-             PropertyChanges { target: mouseareaMM;enabled:false }
+     function closeDialogs(){
+         dialogClose();
+         screen.state="mainscreen";
+     }
 
-             StateChangeScript {
-                 script:{
-                     xntxhdScreen.reset()
-                 }
-                }
+     function menu_item_Clicked(id){
+         var qmlF = "";
+         screen.state="switchX";
+         switch(id){
+            case 2: Script.amdatetimedlg.state="show";break;
+            case 3: Script.datetimedlg.state="show";break;
+            case 4: qmlF="XemNgayTotXauHoangDao";break;
+            case 5: Script.fullmonth.state="show";break;
+            case 6: qmlF = "About";break;
+            default:screen.state = "mainscreen";qmlF="";break;
+         }
+         if (qmlF){
+             var qmlobj = Script.createObject(qmlF+".qml", screen);
+             qmlobj.close.connect(closeDialogs);
+             qmlobj.state = "show";
+         }
+     }
 
-         },
-         State {
-             name: "datetimedialog";
-             PropertyChanges { target: datetimeDialog; x: 0; focus:true}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-             PropertyChanges { target: mouseareaMM;enabled:false }
-                                                                 PropertyChanges { target: reelx;enabled:false }
-             StateChangeScript {
-                 script:{
-                     datetimeDialog.reset()
-                 }
-                }
-         },
+     states: [
          State {
-             name: "amdatetimedialog";
-             PropertyChanges { target: amdatetimeDialog; x: 0; focus:true}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-             PropertyChanges { target: mouseareaMM;enabled:false }
-                                                                 PropertyChanges { target: reelx;enabled:false }
+             name:"mainscreen"
              StateChangeScript {
                  script:{
-                     amdatetimeDialog.reset()
                  }
                 }
          },
          State {
-             name: "aboutdialog";
-             PropertyChanges { target: aboutDialog; x: 0; focus:true; visible:true;}
+             name: "switchX";
              PropertyChanges { target: toolBar; y: screen.height }
              PropertyChanges { target: toolBar }
              PropertyChanges { target: mouseareaMM;enabled:false }
-         },
-         State {
-             name: "xemtheothang";
-             PropertyChanges { target: fullmonthDialog; x: 0; focus:true; visible:true;}
-             PropertyChanges { target: toolBar; y: screen.height }
-             PropertyChanges { target: toolBar }
-             StateChangeScript {
-                 script:{
-                     fullmonthDialog.reset()
-                 }
-                }
-             PropertyChanges { target: mouseareaMM;enabled:false }
          }
      ]
 
      transitions: [
-         //normally i used InOutBack
          Transition { NumberAnimation { properties: "x,y,opacity"; duration: 300; easing.type: Easing.InOutBack } }
      ]
 
 
-     function lunarTietKhi(){
-         return AmLich.TIETKHI[AmLich.getSunLongitude(screen.jd+1,7.0)];
-     }
-
-
-     function calculateLunar(D,M,Y){
-         screen.curDay =D
-         screen.curMonth = M
-         screen.curYear = Y
-         screen.lunarDay = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).day
-         screen.lunarMonth = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).month
-         screen.lunarYearInt = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).year
-         screen.lunarYear = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[2]//AmLich.getYearCanChi(screen.curYear)
-         screen.jd = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd
-         screen.lunarGioHoangDao = AmLich.getGioHoangDao(screen.jd)
-
-         screen.lunarDayCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[0]
-         screen.lunarMonthCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[1]
-
-     }
-
      function reset(){
-         calculateLunar(initcurDay, initcurMonth, initcurYear)
+         /*calculateLunar(initcurDay, initcurMonth, initcurYear)
          LC.reset(initcurDay, initcurMonth, initcurYear)
          screen.state="mainscreen"
          maindatemodel.reset()
-         txtDATEpv.currentIndex = initcurDay-1;
-     }
-
-     function refresh(){
-
-     }
-
-     Component.onCompleted: {
-        amdatetimeDialog.reset()
-        maindatemodel.init()
+         txtDATEpv.currentIndex = initcurDay-1;*/
      }
 
 }