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
69 opacity: theme_manager.theme.background_opacity
78 property int fixed: 40
81 anchors.fill: parent;anchors.topMargin: 60;anchors.bottomMargin:60;
84 if (Settings.pressandhold()==1){
85 screen.state="xemngaytotxauhoangdao"
91 if (Settings.doubleclicked()==1){
92 screen.state="datetimedialog"
104 textFormat: Text.RichText
105 text: "Tháng <b>"+screen.curMonth+"</b> Năm <b>"+screen.curYear+"</b>"
106 anchors.horizontalCenter: parent.horizontalCenter
108 font.family: "Tahoma"
110 horizontalAlignment: Text.AlignHCenter
114 //------------------------------------------------
121 anchors.horizontalCenter: parent.horizontalCenter
122 property int index: 0
123 onIndexChanged: txtDATEpv.currentIndex = reelx.index
134 font.pixelSize: wrapper.PathView.isCurrentItem ? 80 : 40
136 if (wrapper.PathView.isCurrentItem){
137 var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7);
138 if (CNLTN.is_holiday(txtDATEpv.currentIndex+1,curMonth, stemp[0], stemp[1])){
139 return theme_manager.theme.markdate.holidays;
141 var mark_day = (AmLich.getLunarDate(txtDATEpv.currentIndex+1,curMonth,curYear).jd+1)%7;
142 if (mark_day === 0) //sunday
143 return theme_manager.theme.markdate.sunday;
144 if (mark_day == 6) //saturday
145 return theme_manager.theme.markdate.saturday;
147 return theme_manager.theme.markdate.otherday_selected;
151 return "transparent";//theme_manager.theme.markdate.otherday;
164 Keys.onLeftPressed: decrementCurrentIndex()
165 Keys.onRightPressed: incrementCurrentIndex()
166 highlightMoveDuration:500
167 preferredHighlightBegin: 0.5
168 preferredHighlightEnd: 0.5
169 highlightRangeMode: PathView.StrictlyEnforceRange
172 highlight: Rectangle{
173 anchors.topMargin: 10;
183 PathLine {x: reelx.width; y: 50}
191 calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear())
199 var days_of_this_month = LC.calDays(screen.curMonth,screen.curYear);
200 var days_of_changes = days_of_this_month - maindatemodel.count;
204 if (days_of_changes<0){
205 ifs=Math.abs(days_of_changes);
207 maindatemodel.remove(maindatemodel.count-1);
210 }else if(days_of_changes>0){
211 ifs=maindatemodel.count;
212 for (var i=1;i<=days_of_changes;i++)
216 reelx.index = -1; // I dont now why must be added -1 before screen.curDay-1
217 reelx.index = screen.curDay-1;
222 for(var i=1;i<=LC.calDays(screen.curMonth,screen.curYear);i++)
225 reelx.index = screen.curDay -1
229 //-------------------------------------------------
238 text: AmLich.getTHU(screen.jd)
239 horizontalAlignment: Text.AlignHCenter
240 anchors.horizontalCenter: parent.horizontalCenter
249 y: (screen.is_holiday ? 270 : 250)
252 color: (screen.is_holiday ? theme_manager.theme.markdate.holidays : theme_manager.theme.markdate.not_holidays)
253 text: screen.day_info
254 horizontalAlignment: Text.AlignHCenter
255 anchors.horizontalCenter: parent.horizontalCenter
257 font.bold: (screen.is_holiday ? true : false)
258 font.pixelSize: (screen.is_holiday ? 25 : 20)
269 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>"
270 horizontalAlignment: Text.AlignHCenter
271 anchors.horizontalCenter: parent.horizontalCenter
281 anchors.verticalCenter: parent.verticalCenter
282 width: parent.width; height: parent.height-60;
283 x: -(screen.width * 1.5)
288 state:"optionsscreen"
289 anchors.verticalCenter: parent.verticalCenter
290 width: parent.width; height: parent.height-60;
291 x: -(screen.width * 1.5)
297 anchors.verticalCenter: parent.verticalCenter
298 width: parent.width; height: parent.height-60;
299 x: -(screen.width * 1.5)
302 XemNgayTotXauHoangDao{
304 state:"xemngaytotxauhoangdao"
305 anchors.verticalCenter: parent.verticalCenter
306 width: parent.width; height: parent.height-60;
307 x: -(screen.width * 1.5)
312 state:"datetimedialog"
313 anchors.verticalCenter: parent.verticalCenter
314 width: parent.width; height: parent.height-60;
315 x: -(screen.width * 1.5)
320 state:"amdatetimedialog"
321 anchors.verticalCenter: parent.verticalCenter
322 width: parent.width; height: parent.height-60;
323 x: -(screen.width * 1.5)
329 anchors.verticalCenter: parent.verticalCenter
330 width: parent.width; height: parent.height-60;
331 x: -(screen.width * 1.5)
337 anchors.verticalCenter: parent.verticalCenter
338 width: parent.width; height: parent.height-60;
339 x: -(screen.width * 1.5)
345 anchors.verticalCenter: parent.verticalCenter
346 width: parent.width; height: parent.height-60;
347 x: -(screen.width * 1.5)
351 MultiTitleBar { id: titleBar; width: parent.width }
352 ToolBar { id: toolBar; height: 50;
353 y: screen.height - 48
354 width: parent.width; opacity: 0.9
356 button2Label: "Lựa Chọn"
359 screen.state="menuscreen"
362 screen.state="optionsscreen"
377 PropertyChanges { target: menuScreen; x: 0; focus:true}
378 PropertyChanges { target: toolBar; y: screen.height }
379 PropertyChanges { target: toolBar }
380 PropertyChanges { target: mouseareaMM;enabled:false }
385 PropertyChanges { target: fileBrowser; x: 0; focus:true; visible:true;}
386 PropertyChanges { target: toolBar; y: screen.height }
387 PropertyChanges { target: toolBar }
390 fileBrowser.refresh();
395 name: "optionsscreen";
396 PropertyChanges { target: optionsScreen; x: 0; focus:true}
397 PropertyChanges { target: toolBar; y: screen.height }
398 PropertyChanges { target: toolBar }
399 PropertyChanges { target: mouseareaMM;enabled:false }
404 PropertyChanges { target: changeTheme; x: 0; focus:true}
405 PropertyChanges { target: toolBar; y: screen.height }
406 PropertyChanges { target: toolBar }
407 PropertyChanges { target: reelx;enabled:false }
408 PropertyChanges { target: mouseareaMM;enabled:false }
412 name: "xemngaytotxauhoangdao";
413 PropertyChanges { target: xntxhdScreen; x: 0; focus:true;visible:true;}
414 PropertyChanges { target: toolBar; y: screen.height }
415 PropertyChanges { target: toolBar }
416 PropertyChanges { target: mouseareaMM;enabled:false }
426 name: "datetimedialog";
427 PropertyChanges { target: datetimeDialog; x: 0; focus:true}
428 PropertyChanges { target: toolBar; y: screen.height }
429 PropertyChanges { target: toolBar }
430 PropertyChanges { target: mouseareaMM;enabled:false }
431 PropertyChanges { target: reelx;enabled:false }
434 datetimeDialog.reset()
439 name: "amdatetimedialog";
440 PropertyChanges { target: amdatetimeDialog; x: 0; focus:true}
441 PropertyChanges { target: toolBar; y: screen.height }
442 PropertyChanges { target: toolBar }
443 PropertyChanges { target: mouseareaMM;enabled:false }
444 PropertyChanges { target: reelx;enabled:false }
447 amdatetimeDialog.reset()
453 PropertyChanges { target: aboutDialog; x: 0; focus:true; visible:true;}
454 PropertyChanges { target: toolBar; y: screen.height }
455 PropertyChanges { target: toolBar }
456 PropertyChanges { target: mouseareaMM;enabled:false }
459 name: "xemtheothang";
460 PropertyChanges { target: fullmonthDialog; x: 0; focus:true; visible:true;}
461 PropertyChanges { target: toolBar; y: screen.height }
462 PropertyChanges { target: toolBar }
465 fullmonthDialog.reset()
468 PropertyChanges { target: mouseareaMM;enabled:false }
473 //normally i used InOutBack
474 Transition { NumberAnimation { properties: "x,y,opacity"; duration: 300; easing.type: Easing.InOutBack } }
478 function lunarTietKhi(){
479 return AmLich.TIETKHI[AmLich.getSunLongitude(screen.jd+1,7.0)];
483 function calculateLunar(D,M,Y){
487 screen.lunarDay = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).day
488 screen.lunarMonth = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).month
489 screen.lunarYearInt = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).year
490 screen.lunarYear = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[2]//AmLich.getYearCanChi(screen.curYear)
491 screen.jd = AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd
492 screen.lunarGioHoangDao = AmLich.getGioHoangDao(screen.jd)
494 screen.lunarDayCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[0]
495 screen.lunarMonthCanChi = AmLich.getCanChi(AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear))[1]
500 calculateLunar(initcurDay, initcurMonth, initcurYear)
501 LC.reset(initcurDay, initcurMonth, initcurYear)
502 screen.state="mainscreen"
503 maindatemodel.reset()
504 txtDATEpv.currentIndex = initcurDay-1;
511 Component.onCompleted: {
512 amdatetimeDialog.reset()