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 2 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 textFormat: Text.RichText
104 text: "Tháng <b>"+screen.curMonth+"</b> Năm <b>"+screen.curYear+"</b>"
105 anchors.horizontalCenter: parent.horizontalCenter
107 font.family: "Tahoma"
109 horizontalAlignment: Text.AlignHCenter
113 //------------------------------------------------
120 anchors.horizontalCenter: parent.horizontalCenter
121 property int index: 0
122 onIndexChanged: txtDATEpv.currentIndex = reelx.index
133 font.pixelSize: wrapper.PathView.isCurrentItem ? 80 : 40
135 if (wrapper.PathView.isCurrentItem){
136 var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7);
137 if (CNLTN.is_holiday(txtDATEpv.currentIndex+1,curMonth, stemp[0], stemp[1])){
138 return theme_manager.theme.markdate.holidays;
140 var mark_day = (AmLich.getLunarDate(txtDATEpv.currentIndex+1,curMonth,curYear).jd+1)%7;
141 if (mark_day === 0) //sunday
142 return theme_manager.theme.markdate.sunday;
143 if (mark_day == 6) //saturday
144 return theme_manager.theme.markdate.saturday;
146 return theme_manager.theme.markdate.otherday_selected;
150 return "transparent";//theme_manager.theme.markdate.otherday;
163 Keys.onLeftPressed: decrementCurrentIndex()
164 Keys.onRightPressed: incrementCurrentIndex()
165 highlightMoveDuration:500
166 preferredHighlightBegin: 0.5
167 preferredHighlightEnd: 0.5
168 highlightRangeMode: PathView.StrictlyEnforceRange
171 highlight: Rectangle{
172 anchors.topMargin: 10;
182 PathLine {x: reelx.width; y: 50}
190 calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
198 var days_of_this_month = LC.calDays(screen.curMonth,screen.curYear);
199 var days_of_changes = days_of_this_month - maindatemodel.count;
203 if (days_of_changes<0){
204 ifs=Math.abs(days_of_changes);
206 maindatemodel.remove(maindatemodel.count-1);
209 }else if(days_of_changes>0){
210 ifs=maindatemodel.count;
211 for (var i=1;i<=days_of_changes;i++)
215 reelx.index = -1; // I dont now why must be added -1 before screen.curDay-1
216 reelx.index = screen.curDay-1;
221 for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
224 reelx.index = screen.curDay -1
228 //-------------------------------------------------
237 text: AmLich.getTHU(screen.jd)
238 horizontalAlignment: Text.AlignHCenter
239 anchors.horizontalCenter: parent.horizontalCenter
248 y: (screen.is_holiday ? 270 : 250)
251 color: (screen.is_holiday ? theme_manager.theme.markdate.holidays : theme_manager.theme.markdate.not_holidays)
252 text: screen.day_info
253 horizontalAlignment: Text.AlignHCenter
254 anchors.horizontalCenter: parent.horizontalCenter
256 font.bold: (screen.is_holiday ? true : false)
257 font.pixelSize: (screen.is_holiday ? 25 : 20)
268 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>"
269 horizontalAlignment: Text.AlignHCenter
270 anchors.horizontalCenter: parent.horizontalCenter
280 anchors.verticalCenter: parent.verticalCenter
281 width: parent.width; height: parent.height-60;
282 x: -(screen.width * 1.5)
287 state:"optionsscreen"
288 anchors.verticalCenter: parent.verticalCenter
289 width: parent.width; height: parent.height-60;
290 x: -(screen.width * 1.5)
296 anchors.verticalCenter: parent.verticalCenter
297 width: parent.width; height: parent.height-60;
298 x: -(screen.width * 1.5)
301 XemNgayTotXauHoangDao{
303 state:"xemngaytotxauhoangdao"
304 anchors.verticalCenter: parent.verticalCenter
305 width: parent.width; height: parent.height-60;
306 x: -(screen.width * 1.5)
311 state:"datetimedialog"
312 anchors.verticalCenter: parent.verticalCenter
313 width: parent.width; height: parent.height-60;
314 x: -(screen.width * 1.5)
319 state:"amdatetimedialog"
320 anchors.verticalCenter: parent.verticalCenter
321 width: parent.width; height: parent.height-60;
322 x: -(screen.width * 1.5)
328 anchors.verticalCenter: parent.verticalCenter
329 width: parent.width; height: parent.height-60;
330 x: -(screen.width * 1.5)
336 anchors.verticalCenter: parent.verticalCenter
337 width: parent.width; height: parent.height-60;
338 x: -(screen.width * 1.5)
344 anchors.verticalCenter: parent.verticalCenter
345 width: parent.width; height: parent.height-60;
346 x: -(screen.width * 1.5)
350 MultiTitleBar { id: titleBar; width: parent.width }
351 ToolBar { id: toolBar; height: 50;
352 y: screen.height - 48
353 width: parent.width; opacity: 0.9
355 button2Label: "Lựa Chọn"
358 screen.state="menuscreen"
361 screen.state="optionsscreen"
376 PropertyChanges { target: menuScreen; x: 0; focus:true}
377 PropertyChanges { target: toolBar; y: screen.height }
378 PropertyChanges { target: toolBar }
379 PropertyChanges { target: mouseareaMM;enabled:false }
384 PropertyChanges { target: fileBrowser; x: 0; focus:true; visible:true;}
385 PropertyChanges { target: toolBar; y: screen.height }
386 PropertyChanges { target: toolBar }
389 fileBrowser.refresh();
394 name: "optionsscreen";
395 PropertyChanges { target: optionsScreen; x: 0; focus:true}
396 PropertyChanges { target: toolBar; y: screen.height }
397 PropertyChanges { target: toolBar }
398 PropertyChanges { target: mouseareaMM;enabled:false }
403 PropertyChanges { target: changeTheme; x: 0; focus:true}
404 PropertyChanges { target: toolBar; y: screen.height }
405 PropertyChanges { target: toolBar }
406 PropertyChanges { target: reelx;enabled:false }
407 PropertyChanges { target: mouseareaMM;enabled:false }
411 name: "xemngaytotxauhoangdao";
412 PropertyChanges { target: xntxhdScreen; x: 0; focus:true;visible:true;}
413 PropertyChanges { target: toolBar; y: screen.height }
414 PropertyChanges { target: toolBar }
415 PropertyChanges { target: mouseareaMM;enabled:false }
425 name: "datetimedialog";
426 PropertyChanges { target: datetimeDialog; x: 0; focus:true}
427 PropertyChanges { target: toolBar; y: screen.height }
428 PropertyChanges { target: toolBar }
429 PropertyChanges { target: mouseareaMM;enabled:false }
430 PropertyChanges { target: reelx;enabled:false }
433 datetimeDialog.reset()
438 name: "amdatetimedialog";
439 PropertyChanges { target: amdatetimeDialog; x: 0; focus:true}
440 PropertyChanges { target: toolBar; y: screen.height }
441 PropertyChanges { target: toolBar }
442 PropertyChanges { target: mouseareaMM;enabled:false }
443 PropertyChanges { target: reelx;enabled:false }
446 amdatetimeDialog.reset()
452 PropertyChanges { target: aboutDialog; x: 0; focus:true; visible: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; visible:true;}
460 PropertyChanges { target: toolBar; y: screen.height }
461 PropertyChanges { target: toolBar }
464 fullmonthDialog.reset()
467 PropertyChanges { target: mouseareaMM;enabled:false }
472 //normally i used InOutBack
473 Transition { NumberAnimation { properties: "x,y,opacity"; duration: 300; easing.type: Easing.InOutBack } }
477 function lunarTietKhi(){
478 return AmLich.TIETKHI[AmLich.getSunLongitude(screen.jd+1,7.0)];
482 function calculateLunar(D,M,Y){
486 screen.lunarDay = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).day
487 screen.lunarMonth = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).month
488 screen.lunarYearInt = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).year
489 screen.lunarYear = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[2]//AmLich.getYearCanChi(screen.curYear)
490 screen.jd = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd
491 screen.lunarGioHoangDao = AmLich.getGioHoangDao(screen.jd)
493 screen.lunarDayCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[0]
494 screen.lunarMonthCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[1]
499 calculateLunar(initcurDay, initcurMonth, initcurYear)
500 LC.reset(initcurDay, initcurMonth, initcurYear)
501 screen.state="mainscreen"
502 maindatemodel.reset()
503 txtDATEpv.currentIndex = initcurDay-1;
510 Component.onCompleted: {
511 amdatetimeDialog.reset()