*/
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
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 {
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 {
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"
}
}
}
}
onMovementEnded: {
- calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
+ Script.changeDay(txtDATEpv.currentIndex+1, txtTHU, txtInfo, txtDAYAmLich);
}
}
}
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;
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
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
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
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;*/
}
}