* Theme now is simple and very fast
[lichviet] / qml / LichViet / FullMonth.qml
index a2be992..80e98b4 100644 (file)
@@ -71,7 +71,7 @@ Item{
 
                 text: model.modelData
                 font.bold: true
-                font.pointSize: width ? width / 6 : 1
+                font.pointSize: parent.width > parent.height ? width ? width / 6 : 1 : width / 4
             }
         }
     }
@@ -97,20 +97,20 @@ Item{
             Text {
                 id:txt_solar_day
                 anchors.fill: parent
-                anchors.leftMargin: 10
+                anchors.leftMargin: parent.width > parent.height ? 10 : 5
 
                 verticalAlignment: Text.AlignVCenter
                 horizontalAlignment: Text.AlignLeft
 
                 text: model ? model.day : ""
                 color: model ? model.inmonth ? (model.current ? "red" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red"
-                font.pointSize: parent.width ? parent.width / 6 : 1
+                font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 6 : 1 : parent.width / 4
                 font.bold: true
             }
 
             Text {
                 anchors.fill: parent
-                anchors.leftMargin: txt_solar_day.anchors.leftMargin+40
+                anchors.leftMargin: txt_solar_day.anchors.leftMargin+ parent.width > parent.height ? 60 : 35
                 anchors.topMargin: 20
 
                 verticalAlignment: Text.AlignVCenter
@@ -118,59 +118,80 @@ Item{
 
                 text: model ? model.lunar_day : ""
                 color: model ? model.inmonth ? (model.current ? "red" : "#700070") : "grey" : "red"
-                font.pointSize: parent.width ? parent.width / 8 : 1
+                font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 8 : 1 : parent.width / 5
             }
 
             MouseArea {
+                id:memouse
                 anchors.fill: parent
 
                 property real mX
                 property real mY
                 property bool hold: false
+                property bool clicked: false
 
                 onClicked: {
-                    /*LC.reset(model.day,m_month,m_year)
-                    screen.calculateLunar(model.day,m_month,m_year)
-                    screen.state="mainscreen"
-                    screen.refresh()
-                    maindatemodel.reset()*/
-                    fullmonth.state="close";
-                    fullmonth.toolbar();
-                    fullmonth.updatedate(model.day, m_month, m_year)
+                    if (model.inmonth){
+                        fullmonth.updatedate(model.day, m_month, m_year)
+                        hold=false;
+                        m_day = model.day;
+                        fullmonth.state="close";
+                        fullmonth.toolbar();
+
+                    }else{
+                        if (model.isprevmonth){
+                            m_month--;
+                            if(m_month<=0){
+                                m_month=12;
+                                m_year--;
+                            }
+                        }else{
+                            m_month++;
+                            if (m_month >=13){
+                                m_month=1;
+                                m_year++;
+                            }
+                        }
+                        fullmonth.reset();
+                    }
                 }
 
                 onPositionChanged: {
                     mX = mouseX;
                     mY = mouseY;
                     hold=true;
+                    clicked=false;
                 }
 
                 onPressed: {
                     recms.color="#F0F0F0"
+                    clicked=true;
                 }
 
                 onReleased: {
+                    recms.color=model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black";
                     if (hold){
                         if (mouseY+mY<0){
-                           if (Math.abs(mouseY) >= 30){
-                              m_month+=1;
+                           if (Math.abs(mouseY) >= 100){
+                              m_month++;
                                if (m_month >=13){
                                    m_month=1;
                                    m_year++;
                                }
+                               reset();
                            }
                         }
                         else
                         {
-                           if (mouseY >= 50){
-                              m_month-=1;
+                           if (mouseY >= 100){
+                              m_month--;
                                if(m_month<=0){
                                    m_month=12;
                                    m_year--;
                                }
+                               reset();
                            }
                         }
-                        reset();
                         hold=false;
                     }
                 }
@@ -296,7 +317,7 @@ Item{
         var prevmonth = get_prevmonth(startfrom)
 
         var dayclick, monthclick, yearclick;
-        var datas1,datas,lunarclmonth,inmonth;
+        var datas1,datas,lunarclmonth,inmonth,isprevmonth;
 
         for (var i=0;i<42;i++){
             if (i >= startfrom && j<= daysofthemonthyear){
@@ -304,12 +325,17 @@ Item{
                 monthclick = m_month;
                 yearclick = m_year;
                 inmonth = true;
+                isprevmonth=false;
                 j++;
             }else{
-                if (i<startfrom)
+                if (i<startfrom){
                     datas1=prevmonth[i];
-                else
+                    isprevmonth = true;
+                }
+                else{
                     datas1=nextmonth[(totalslot-i)-1];
+                    isprevmonth = false;
+                }
 
                 dayclick = datas1.duong;
                 monthclick = datas1.month;
@@ -330,7 +356,7 @@ Item{
             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})
+            monthModel.append({"day": dayclick, "current": current, "lunar_day":lunar_day, "inmonth":inmonth,"inholiday":inholiday,"isprevmonth":isprevmonth})
         }
 
     }
@@ -382,6 +408,6 @@ Item{
 
     transitions: Transition {
         AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
-    }
+       }
 
 }