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
+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,
*/
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 "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 lunarCanHour : AmLich.getCanHour0(LC.curHour())
+ signal dialogClose
- state:"mainscreen"
+ property int curMonth: Script.curMonth
+ property int curYear: Script.curYear
Loader {
id: theme_manager
source: Themes.default_theme()
}
+ Component.onCompleted: {
+ Settings.restore_nomodel();
+ Script.createDateTimeDialog(screen);
+ Script.datetimedlg.toolbar.connect(show_toolbar);
+ Script.datetimedlg.updatedate.connect(update_date);
+ Script.amdatetimedlg.toolbar.connect(show_toolbar);
+ Script.amdatetimedlg.updatedate.connect(update_date);
+ 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);
+ Script.fullmonth.m_day=Script.curDay;
+ Script.fullmonth.m_month=Script.curMonth;
+ Script.fullmonth.m_year=Script.curYear;
+ Script.fullmonth.reset();
+ maindatemodel.reset();
+ }
+
Rectangle {
- id: background
+ id: mecal
anchors.fill: parent
- color: "#343434"
+ color: "white"
state:"jumptodate"
+
Image {
- source: theme_manager.theme.background_image; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3
+ source: theme_manager.theme.background_image; fillMode: Image.Stretch; anchors.fill: parent
+ opacity: theme_manager.theme.background_opacity
}
onPressAndHold:{
if (Settings.pressandhold()==1){
- screen.state="xemngaytotxauhoangdao"
+ menu_item_Clicked(4);
}
}
onDoubleClicked:{
if (Settings.doubleclicked()==1){
- screen.state="datetimedialog"
+ screen.state="switchX";
+ Script.datetimedlg.state="show";
}
}
}
- Text {
- id: txtDMY
- x: 140
- y: 77
- width: 80
- height: 20
- color: "#29d999"
- text: "Tháng "+screen.curMonth+" Năm "+screen.curYear
- anchors.horizontalCenter: parent.horizontalCenter
- font.bold: true
- font.family: "Tahoma"
- smooth: true
- horizontalAlignment: Text.AlignHCenter
- font.pixelSize: 28
- }
-
//------------------------------------------------
Rectangle {
id:reelx
- width: 300
- height: 100
- y: 126
- anchors.horizontalCenter: parent.horizontalCenter
- property int index: 0
- onIndexChanged: txtDATEpv.currentIndex = reelx.index
- color: "transparent"
+ width: 260
+ height: 90
+ y: 116
+ anchors.horizontalCenter: parent.horizontalCenter
+ property int index: 0
+ onIndexChanged: txtDATEpv.currentIndex = reelx.index
+ color: "transparent"
+
Component {
id: delegate
Column {
text: name
font.bold: true
font.pixelSize: wrapper.PathView.isCurrentItem ? 80 : 40
- color: wrapper.PathView.isCurrentItem ? "#FFFFFF" : "grey"
+ color: {
+ if (wrapper.PathView.isCurrentItem){
+ var stemp = Script.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7);
+ if (Script.is_holiday(txtDATEpv.currentIndex+1,curMonth, stemp[0], stemp[1])){
+ return theme_manager.theme.markdate.holidays;
+ }else{
+ var mark_day = (Script.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;
+ }
}
}
}
delegate: delegate
pathItemCount: 3
clip: true
+ Keys.onLeftPressed: decrementCurrentIndex()
+ Keys.onRightPressed: incrementCurrentIndex()
+ highlightMoveDuration:500
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
highlightRangeMode: PathView.StrictlyEnforceRange
focus: true
+ interactive: true
+ highlight: Rectangle{
+ anchors.topMargin: 10;
+ width:110;
+ height:80;
+ radius: 8;
+ color:"#000000"
+ opacity: 0.3
+ }
path: Path {
startX: 0
startY: 50
PathLine {x: reelx.width; y: 50}
}
+
+ onMovementStarted:{
+
+ }
+
onMovementEnded: {
- calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
+ Script.changeDay(txtDATEpv.currentIndex+1, txtTHU, txtInfo, txtDAYAmLich);
+ Script.fullmonth.m_day=Script.curDay;
+ Script.fullmonth.m_month=Script.curMonth;
+ Script.fullmonth.m_year=Script.curYear;
+ Script.fullmonth.reset();
}
}
}
id:maindatemodel
function reset(){
- while(maindatemodel.count>0){
- try{maindatemodel.remove(maindatemodel.count-1)}catch(e){}
+ var days_of_this_month = Script.calDays();
+ var days_of_changes = days_of_this_month - maindatemodel.count;
+
+ var ifs;
+
+ if (days_of_changes<0){
+ ifs=Math.abs(days_of_changes);
+ while(ifs>0){
+ maindatemodel.remove(maindatemodel.count-1);
+ ifs-=1;
+ }
+ }else if(days_of_changes>0){
+ ifs=maindatemodel.count;
+ for (var i=1;i<=days_of_changes;i++)
+ append({name:i+ifs})
}
- for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
- append({name:i})
- reelx.index = screen.curDay -1
+ reelx.index = -1;
+ reelx.index = Script.curDay - 1;
+
+ }
+
+ function init(){
+ for(var i=1;i<=Script.calDays();i++)
+ append({name:i});
+
+ reelx.index = Script.curDay - 1;
}
}
//-------------------------------------------------
- Component.onCompleted: {
- maindatemodel.reset()
- }
+
+ Text {
+ id: txtDMY
+ x: 151
+ y: 77
+ height: 20
+ color: "#29d999"
+ text: "Tháng <b>"+screen.curMonth+"</b> Năm <b>"+screen.curYear+"</b>"
+ horizontalAlignment: Text.AlignHCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.bold: false
+ font.family: "Tahoma"
+ smooth: true
+ font.pixelSize: 28
+ }
Text {
id: txtTHU
x: 151
- y: 240
- width: 80
+ y: 210
height: 20
color: "#f0f0f5"
- text: AmLich.getTHU(screen.jd)
+ text: Script.__txtTHU_format()
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
opacity: 0.6
}
Text {
-
- id: txtDAYAmLich
+ id: txtInfo
x: 151
- y: 300
- width: 80
+ y: (screen.is_holiday ? 270 : 250)
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>"
+ 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
- font.bold: true
- font.pixelSize: 28
- }
-
-
- 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)
- }
-
- 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)
- }
-
- NoFeatureDialog{
- id: nofeatureDialog
- state:"nofeaturedialog"
- anchors.verticalCenter: parent.verticalCenter
- width: parent.width; height: parent.height-60;
- x: -(screen.width * 1.5)
+ font.bold: (screen.is_holiday ? true : false)
+ font.pixelSize: (screen.is_holiday ? 25 : 20)
}
+ Text {
- About{
- id: aboutDialog
- state:"aboutdialog"
- anchors.verticalCenter: parent.verticalCenter
- width: parent.width; height: parent.height-60;
- x: -(screen.width * 1.5)
+ id: txtDAYAmLich
+ x: 151
+ y: 330
+ height: 20
+ color: theme_manager.theme.markdate.lunardate
+ text: Script.__txtDAYAmLich_format()
+ horizontalAlignment: Text.AlignHCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ opacity: 0.6
+ font.bold: true
+ font.pixelSize: 25
}
-
- 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: "menuscreen";
- PropertyChanges { target: menuScreen; 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: "optionsscreen";
- PropertyChanges { target: optionsScreen; x: 0; focus:true}
- PropertyChanges { target: toolBar; y: screen.height }
- PropertyChanges { target: toolBar }
- PropertyChanges { target: mouseareaMM;enabled:false }
+ }
- },
- State {
- name: "xemngaytotxauhoangdao";
- PropertyChanges { target: xntxhdScreen; x: 0; focus:true}
- PropertyChanges { target: toolBar; y: screen.height }
- PropertyChanges { target: toolBar }
- PropertyChanges { target: mouseareaMM;enabled:false }
+ function closeDialogs(){
+ dialogClose();
+ screen.state="mainscreen";
+ }
- },
- 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()
- }
- }
- },
+ function menu_item_Clicked(id){
+ var qmlF = "";
+ if (id!=1)
+ screen.state="switchX";
+ switch(id){
+ case 1: Script.reset_to_default_day(txtTHU, txtInfo, txtDAYAmLich);
+ txtDATEpv.currentIndex = Script.curDay-1;
+ screen.curMonth = Script.curMonth;
+ screen.curYear = Script.curYear;
+ Script.fullmonth.m_day= Script.curDay-1;
+ Script.fullmonth.m_month= Script.curMonth;
+ Script.fullmonth.m_year= Script.curYear;
+ break;
+ 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";
+ }
+ }
+
+ 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: "nofeaturedialog";
- PropertyChanges { target: nofeatureDialog; x: 0; focus:true}
- PropertyChanges { target: toolBar; y: screen.height }
- PropertyChanges { target: toolBar }
- PropertyChanges { target: mouseareaMM;enabled:false }
- PropertyChanges { target: reelx;enabled:false }
- },
- State {
- name: "aboutdialog";
- PropertyChanges { target: aboutDialog; x: 0; focus:true}
+ name: "switchX";
+ PropertyChanges { target: titleBar; y: -50 }
PropertyChanges { target: toolBar; y: screen.height }
PropertyChanges { target: toolBar }
PropertyChanges { target: mouseareaMM;enabled:false }
- },
- State {
- name: "xemtheothang";
- PropertyChanges { target: fullmonthDialog; x: 0; focus:true}
- PropertyChanges { target: toolBar; y: screen.height }
- PropertyChanges { target: toolBar }
- StateChangeScript {
- script:{
- fullmonthDialog.reset()
- }
- }
- PropertyChanges { target: mouseareaMM;enabled:false }
}
]
transitions: [
- Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.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)
- LC.reset(initcurDay, initcurMonth, initcurYear)
- screen.state="mainscreen"
- maindatemodel.reset()
- txtDATEpv.currentIndex = initcurDay-1;
- }
-
- function refresh(){
- }
-
- Component.onCompleted: {
-
- }
}