2 Copyright (C) 2011 by Cuong Le <metacuong@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>
19 import "amlich-hnd.js" as AmLich
20 import "amlich-aa98.js" as AmLich98
22 import "Settings.js" as Settings
23 import "Themes.js" as Themes
24 import "CacNgayLeTrongNam.js" as CNLTN
31 property int curDay: LC.curDay()
32 property int curMonth: LC.curMonth()
33 property int curYear: LC.curYear()
35 property int initcurDay: LC.curDay()
36 property int initcurMonth: LC.curMonth()
37 property int initcurYear:LC.curYear()
39 property int lunarDay: AmLich.getLunarDate(curDay,curMonth,curYear).day
40 property int lunarMonth: AmLich.getLunarDate(curDay,curMonth,curYear).month
41 property string lunarYear: AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[2]
43 property int lunarYearInt : AmLich.getLunarDate(curDay,curMonth,curYear).year
44 property int jd : AmLich.getLunarDate(curDay,curMonth,curYear).jd
45 property string lunarGioHoangDao : AmLich.getGioHoangDao(jd)
47 property string lunarDayCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[0]
48 property string lunarMonthCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[1]
50 property string day_info : CNLTN.get(screen)
51 property bool is_holiday : CNLTN.is_holiday(screen.curDay,screen.curMonth, screen.curYear, screen.lunarDay, screen.lunarMonth)
57 property alias theme: theme_manager.item
58 source: Themes.default_theme()
68 source: theme_manager.theme.background_image; fillMode: Image.Stretch; anchors.fill: parent; opacity: 0.3
77 property int fixed: 40
80 anchors.fill: parent;anchors.topMargin: 60;anchors.bottomMargin:60;
83 if (Settings.pressandhold()==1){
84 screen.state="xemngaytotxauhoangdao"
90 if (Settings.doubleclicked()==1){
91 screen.state="datetimedialog"
103 text: "Tháng "+screen.curMonth+" Năm "+screen.curYear
104 anchors.horizontalCenter: parent.horizontalCenter
106 font.family: "Tahoma"
108 horizontalAlignment: Text.AlignHCenter
112 //------------------------------------------------
119 anchors.horizontalCenter: parent.horizontalCenter
120 property int index: 0
121 onIndexChanged: txtDATEpv.currentIndex = reelx.index
131 font.pixelSize: wrapper.PathView.isCurrentItem ? 80 : 40
133 if (wrapper.PathView.isCurrentItem){
134 var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7);
135 if (CNLTN.is_holiday(txtDATEpv.currentIndex+1,curMonth, stemp[0], stemp[1])){
136 return theme_manager.theme.markdate.holidays;
138 var mark_day = (AmLich.getLunarDate(txtDATEpv.currentIndex+1,curMonth,curYear).jd+1)%7;
139 if (mark_day === 0) //sunday
140 return theme_manager.theme.markdate.sunday;
141 if (mark_day == 6) //saturday
142 return theme_manager.theme.markdate.saturday;
144 return theme_manager.theme.markdate.otherday_selected;
148 return theme_manager.theme.markdate.otherday;
161 highlightMoveDuration:500
162 Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex()
163 Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex()
164 preferredHighlightBegin: 0.5
165 preferredHighlightEnd: 0.5
166 highlightRangeMode: PathView.StrictlyEnforceRange
169 highlight: Rectangle{
170 anchors.topMargin: 10;
180 PathLine {x: reelx.width; y: 50}
186 calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
194 var days_of_this_month = LC.calDays(screen.curMonth,screen.curYear);
195 var days_of_changes = days_of_this_month - maindatemodel.count;
199 if (days_of_changes<0){
200 ifs=Math.abs(days_of_changes);
202 maindatemodel.remove(maindatemodel.count-1);
205 }else if(days_of_changes>0){
206 ifs=maindatemodel.count;
207 for (var i=1;i<=days_of_changes;i++)
211 reelx.index = -1; // I dont now why must be added -1 before screen.curDay-1
212 reelx.index = screen.curDay-1;
217 while(maindatemodel.count>0){
218 try{maindatemodel.remove(maindatemodel.count-1)}catch(e){}
221 for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
224 reelx.index = screen.curDay -1
228 //-------------------------------------------------
229 Component.onCompleted: {
240 text: AmLich.getTHU(screen.jd)
241 horizontalAlignment: Text.AlignHCenter
242 anchors.horizontalCenter: parent.horizontalCenter
251 y: (screen.is_holiday ? 270 : 250)
254 color: (screen.is_holiday ? theme_manager.theme.markdate.holidays : theme_manager.theme.markdate.not_holidays)
255 text: screen.day_info
256 horizontalAlignment: Text.AlignHCenter
257 anchors.horizontalCenter: parent.horizontalCenter
259 font.bold: (screen.is_holiday ? true : false)
260 font.pixelSize: (screen.is_holiday ? 25 : 20)
271 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>"
272 horizontalAlignment: Text.AlignHCenter
273 anchors.horizontalCenter: parent.horizontalCenter
283 anchors.verticalCenter: parent.verticalCenter
284 width: parent.width; height: parent.height-60;
285 x: -(screen.width * 1.5)
290 state:"optionsscreen"
291 anchors.verticalCenter: parent.verticalCenter
292 width: parent.width; height: parent.height-60;
293 x: -(screen.width * 1.5)
299 anchors.verticalCenter: parent.verticalCenter
300 width: parent.width; height: parent.height-60;
301 x: -(screen.width * 1.5)
304 XemNgayTotXauHoangDao{
306 state:"xemngaytotxauhoangdao"
307 anchors.verticalCenter: parent.verticalCenter
308 width: parent.width; height: parent.height-60;
309 x: -(screen.width * 1.5)
314 state:"datetimedialog"
315 anchors.verticalCenter: parent.verticalCenter
316 width: parent.width; height: parent.height-60;
317 x: -(screen.width * 1.5)
322 state:"amdatetimedialog"
323 anchors.verticalCenter: parent.verticalCenter
324 width: parent.width; height: parent.height-60;
325 x: -(screen.width * 1.5)
331 anchors.verticalCenter: parent.verticalCenter
332 width: parent.width; height: parent.height-60;
333 x: -(screen.width * 1.5)
338 state:"nofeaturedialog"
339 anchors.verticalCenter: parent.verticalCenter
340 width: parent.width; height: parent.height-60;
341 x: -(screen.width * 1.5)
348 anchors.verticalCenter: parent.verticalCenter
349 width: parent.width; height: parent.height-60;
350 x: -(screen.width * 1.5)
354 MultiTitleBar { id: titleBar; width: parent.width }
355 ToolBar { id: toolBar; height: 50;
356 y: screen.height - 48
357 width: parent.width; opacity: 0.9
359 button2Label: "Lựa Chọn"
362 screen.state="menuscreen"
365 screen.state="optionsscreen"
380 PropertyChanges { target: menuScreen; x: 0; focus:true}
381 PropertyChanges { target: toolBar; y: screen.height }
382 PropertyChanges { target: toolBar }
383 PropertyChanges { target: mouseareaMM;enabled:false }
387 name: "optionsscreen";
388 PropertyChanges { target: optionsScreen; x: 0; focus:true}
389 PropertyChanges { target: toolBar; y: screen.height }
390 PropertyChanges { target: toolBar }
391 PropertyChanges { target: mouseareaMM;enabled:false }
396 PropertyChanges { target: changeTheme; x: 0; focus:true}
397 PropertyChanges { target: toolBar; y: screen.height }
398 PropertyChanges { target: toolBar }
399 PropertyChanges { target: mouseareaMM;enabled:false }
403 name: "xemngaytotxauhoangdao";
404 PropertyChanges { target: xntxhdScreen; x: 0; focus:true}
405 PropertyChanges { target: toolBar; y: screen.height }
406 PropertyChanges { target: toolBar }
407 PropertyChanges { target: mouseareaMM;enabled:false }
417 name: "datetimedialog";
418 PropertyChanges { target: datetimeDialog; x: 0; focus:true}
419 PropertyChanges { target: toolBar; y: screen.height }
420 PropertyChanges { target: toolBar }
421 PropertyChanges { target: mouseareaMM;enabled:false }
422 PropertyChanges { target: reelx;enabled:false }
425 datetimeDialog.reset()
430 name: "amdatetimedialog";
431 PropertyChanges { target: amdatetimeDialog; x: 0; focus:true}
432 PropertyChanges { target: toolBar; y: screen.height }
433 PropertyChanges { target: toolBar }
434 PropertyChanges { target: mouseareaMM;enabled:false }
435 PropertyChanges { target: reelx;enabled:false }
438 amdatetimeDialog.reset()
443 name: "nofeaturedialog";
444 PropertyChanges { target: nofeatureDialog; x: 0; focus:true}
445 PropertyChanges { target: toolBar; y: screen.height }
446 PropertyChanges { target: toolBar }
447 PropertyChanges { target: mouseareaMM;enabled:false }
448 PropertyChanges { target: reelx;enabled:false }
452 PropertyChanges { target: aboutDialog; x: 0; focus:true}
453 PropertyChanges { target: toolBar; y: screen.height }
454 PropertyChanges { target: toolBar }
455 PropertyChanges { target: mouseareaMM;enabled:false }
458 name: "xemtheothang";
459 PropertyChanges { target: fullmonthDialog; x: 0; focus:true}
460 PropertyChanges { target: toolBar; y: screen.height }
461 PropertyChanges { target: toolBar }
464 fullmonthDialog.reset()
467 PropertyChanges { target: mouseareaMM;enabled:false }
472 Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutBack } }
476 function lunarTietKhi(){
477 return AmLich.TIETKHI[AmLich.getSunLongitude(screen.jd+1,7.0)];
481 function calculateLunar(D,M,Y){
485 screen.lunarDay = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).day
486 screen.lunarMonth = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).month
487 screen.lunarYearInt = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).year
488 screen.lunarYear = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[2]//AmLich.getYearCanChi(screen.curYear)
489 screen.jd = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd
490 screen.lunarGioHoangDao = AmLich.getGioHoangDao(screen.jd)
492 screen.lunarDayCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[0]
493 screen.lunarMonthCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[1]
498 calculateLunar(initcurDay, initcurMonth, initcurYear)
499 LC.reset(initcurDay, initcurMonth, initcurYear)
500 screen.state="mainscreen"
501 maindatemodel.reset()
502 txtDATEpv.currentIndex = initcurDay-1;
509 Component.onCompleted: {