From: Cuong Le Date: Fri, 26 Aug 2011 08:07:21 +0000 (+0700) Subject: Added more information to the lunar calendar X-Git-Tag: v1.0.2-4~3^2 X-Git-Url: http://git.maemo.org/git/?p=lichviet;a=commitdiff_plain;h=496786469533e364ff9bce99fe0dc8710ee21956 Added more information to the lunar calendar Code clean-up --- diff --git a/LichViet.pro b/LichViet.pro index 77f3e01..ab80377 100644 --- a/LichViet.pro +++ b/LichViet.pro @@ -69,4 +69,6 @@ OTHER_FILES += \ qml/LichViet/About.qml \ qml/LichViet/amlich-aa98.js \ qml/LichViet/AmDateTimeDialog.qml \ - qml/LichViet/xemngaytotxau.js + qml/LichViet/xemngaytotxau.js \ + qml/LichViet/CacNgayLeTrongNam.js \ + qml/LichViet/ChangeTheme.qml diff --git a/Makefile b/Makefile index 5690bd6..2f5b216 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: LichViet -# Generated by qmake (2.01a) (Qt 4.7.3) on: Thu Aug 25 00:22:47 2011 +# Generated by qmake (2.01a) (Qt 4.7.3) on: Fri Aug 26 14:38:18 2011 # Project: LichViet.pro # Template: app # Command: /opt/QtSDK/Desktop/Qt/473/gcc/bin/qmake -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 -o Makefile LichViet.pro @@ -213,6 +213,7 @@ qrc_lichviet.cpp: lichviet.qrc \ qml/LichViet/NoFeatureDialog.qml \ qml/LichViet/FullMonth.qml \ qml/LichViet/ToolBarSingle.qml \ + qml/LichViet/CacNgayLeTrongNam.js \ qml/LichViet/Switch.qml \ qml/LichViet/amlich-aa98.js \ qml/LichViet/XemNgayTotXauHoangDao.qml \ @@ -225,6 +226,7 @@ qrc_lichviet.cpp: lichviet.qrc \ qml/LichViet/Button.qml \ qml/LichViet/xemngaytotxau.js \ qml/LichViet/TitleBar.qml \ + qml/LichViet/ChangeTheme.qml \ qml/DatePicker/component/Reel.qml \ qml/DatePicker/component/Button.qml \ qml/DatePicker/component/DateReel.qml diff --git a/lichviet.qrc b/lichviet.qrc index 36718f2..5b42758 100644 --- a/lichviet.qrc +++ b/lichviet.qrc @@ -15,9 +15,9 @@ qml/LichViet/ToolBarSingle.qml qml/LichViet/XemNgayTotXauHoangDao.qml qml/LichViet/DateTimeDialog.qml - qml/LichViet/AmDateTimeDialog.qmls + qml/LichViet/AmDateTimeDialog.qmls qml/LichViet/NoFeatureDialog.qml - + qml/LichViet/ChangeTheme.qml qml/DatePicker/component/Button.qml qml/DatePicker/component/DateReel.qml qml/DatePicker/component/Reel.qml @@ -25,10 +25,11 @@ LichViet.png qml/LichViet/amlich-hnd.js - qml/LichViet/amlich-aa98.js + qml/LichViet/amlich-aa98.js qml/LichViet/Settings.js qml/LichViet/Themes.js - qml/LichViet/xemngaytotxau.js + qml/LichViet/xemngaytotxau.js + qml/LichViet/CacNgayLeTrongNam.js diff --git a/qml/LichViet/AmDateTimeDialog.qml b/qml/LichViet/AmDateTimeDialog.qml index 70fa1f4..d7d9a09 100644 --- a/qml/LichViet/AmDateTimeDialog.qml +++ b/qml/LichViet/AmDateTimeDialog.qml @@ -22,7 +22,7 @@ import "amlich-aa98.js" as AmLich98 Item{ id: amdatetime state: "switch_me" - BorderImage { anchors.centerIn: parent;source: "./img/titlebar.sci"; width: 344+2; height: 234+14; y: +7 } + Rectangle { id: rectangle1 x: 0 diff --git a/qml/LichViet/CacNgayLeTrongNam.js b/qml/LichViet/CacNgayLeTrongNam.js new file mode 100644 index 0000000..8717ede --- /dev/null +++ b/qml/LichViet/CacNgayLeTrongNam.js @@ -0,0 +1,128 @@ +/* +Copyright (C) 2011 by Cuong Le + +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 +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +.pragma library + +/* + @spec : [day,month,detail] + */ +var DuongLich = new Array( + [1,1,"Tết Dương lịch"], + [3,2,"Thành lập ĐCS Việt Nam"], + [14,2,"Lễ tình nhân (Valentin day)"], + [27,2,"Ngày thầy thuốc Việt Nam"], + [8,3,"Quốc tế phụ nữ"], + [17,3,"Thánh Phatrick"], + [1,4," Cá tháng tư"], + [30,4,"Giải phóng miền Nam"], + [1,5,"Quốc tế lao động"], + [19,5,"Sinh nhật Bác Hồ"], + [1,6,"Quốc tế thiếu nhi"], + [5,6,"Ngày môi trường Thế giới"], + [28,6," Gia đình Việt Nam"], + [27,7,"Thương binh liệt sĩ"], + [1,9,"Ngày lao động"], + [2,9,"Quốc Khánh
Nước CHXH CN Việt Nam"], + [10,10,"Giải phóng thủ đô (Hà Nội)"], + [13,10," Ngày doanh nhân Việt Nam"], + [20,10,"Phụ nữ Việt Nam"], + [30,10,"Halloween"], + [11/11,"Cựu chiến binh"], + [20,11,"Nhà giáo Việt Nam"], + [22,11,"Thành lập quân đội nhân dân VN"], + [25,12,"Giáng sinh (Chirstmas day)"] + ); + +var AmLich = new Array( + [1,1,"Tết Nguyên Đán"], + [15,1,"Lễ Thượng Nguyên"], + [3,3,"Tết Hàn thực"], + [10,3,"Giỗ tổ Hùng Vương"], + [14,4,"Tết dân tộc Khmer (Nam bộ)"], + [15,4,"Lễ Phật Đản"], + [5,5,"Tết Đoan Ngọ"], + [15,7,"Lễ Vu Lan"], + [1,8,"Tết Katê (dân tộc Chăm)"], + [15,8,"Tết Trung Thu"], + [10,10,"Tết Thường Tân"], + [15,11,"Tết Hạ Nguyên"], + [23,12,"Lễ Táo Quân lên trời"], + [30,12,"Giao thừa"] + ); + +var Loi_Hay_Y_Dep = new Array( + "Ái tình giống như rượu mùi,
càng ít tỏa hương lại càng nồng.
(Charles Duclos)", + "Không phải lập được những kỳ công
thì cuộc đời mới tốt đẹp.
(Herry Bordeaux)", + "Hãy yêu thương khi còn trẻ,
hãy lo cứu tế lúc về già.
(Stendhal)", + "Mọi người đều nói đến quyền lợi,
không mấy ai nói đến bổn phận.
(Alfred Mortier)", + "Con người là nô lệ vì chưa hủy diệt
được ý tưởng về bản ngã trong nội tâm.
(Kinh Phật)", + "Dù đá có biến thành vàng
thì lòng con người vẫn không thỏa mãn.
(Ngạn ngữ Trung Hoa)", + "Cuộc sống đơn điệu không có sự cố gắng
là cuộc sống vô vị.
(Amiel)", + "Bạc kém giá trị hơn vàng,
vàng lại kém giá trị hơn đạo đức.
(Horace)", + "Bí quyết để sống hạnh phúc
là biết chờ đợi hạnh phúc của mình.
(Rivière)", + "Đọc sách không bằng suy gẫm.
Học trường học không bằng học trường đời.
(Kant)", + "Người khôn ngoan
là kẻ là cái gì cũng thấy mới lạ.
(André Gide)", + "Hãy kiêu hãnh trong khiêm tốn,
kiêu hãnh như vậy mới là không kiêu.
(Burton)", + "Bạn không cần hòan hảo nhưng bạn phải biết
rút kinh nghiệm từ những sai lầm của mình.
(Mc Cormack)", + "Nhan sắc chỉ làm vui thỏa đôi mắt,
còn nét dịu dàng lại ấm áp cõi lòng.
(Voltaire)", + "Chớ bảo điều thiện này nhỏ mà không làm,
chớ bảo điều ác kia nhỏ mà cứ làm.
(Lưu Bị)", + "Đời không tình yêu như trời không có nắng.
(Ngạn ngữ Pháp)", + "Lạc thú ái tình trong chốc lát,
muộn phiền lôi kéo mãi trọn đời.
(Florian)", + "Nhân từ, ngọt ngào
là dấu hiệu của tính cao thượng.
(Pythagor)", + "Hãy giữ người bạn chân thành
với cả hai tay của bạn.
(Khuyết Danh)", + "Đời dù sướng hay khổ cũng vẫn đẹp,
hãy chờ đón nó.
(Fernand Gregh)", + "Hãy yêu mến lời khuyên can,
đừng yêu mếm lời tâng nịnh.
(Ngạn ngữ Nga)" + ); + +function get(obj) { + var day_info = ""; + + for (var i=0;i"; + break; + } + + + if (!day_info){ + var rannum=Math.floor(Math.random()*Loi_Hay_Y_Dep.length) + day_info = Loi_Hay_Y_Dep[rannum]; + } + return day_info; +} + +function is_holiday(day, month, lunar_day, lunar_month){ + for(var i=0;i + +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 +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +import QtQuick 1.0 +import "Themes.js" as Themes + +Item{ + + Rectangle { + id: rectangle1 + anchors.fill: parent; anchors.bottomMargin: 0 + visible: true + opacity:0.9 + color:"black" + } + + ToolBar { id: toolBar; height: 50; + y: screen.height-78 + width: parent.width; + button1Label: "Đồng Ý" + button2Label: "Hủy Bỏ" + onButton1Clicked: + { + screen.state="mainscreen" + } + onButton2Clicked: { + screen.state="mainscreen" + } + } + + transitions: [ + Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutBack } } + ] +} diff --git a/qml/LichViet/DateTimeDialog.qml b/qml/LichViet/DateTimeDialog.qml index 556af62..e6eb564 100644 --- a/qml/LichViet/DateTimeDialog.qml +++ b/qml/LichViet/DateTimeDialog.qml @@ -20,7 +20,7 @@ import "../DatePicker/component" as Comp Item{ id: item1 - BorderImage { anchors.centerIn: parent;source: "./img/titlebar.sci"; width: 344+2; height: 234+14; y: +7 } + Rectangle { id: rectangle1 x: 0 diff --git a/qml/LichViet/FullMonth.qml b/qml/LichViet/FullMonth.qml index 117aaee..992ddf8 100644 --- a/qml/LichViet/FullMonth.qml +++ b/qml/LichViet/FullMonth.qml @@ -17,7 +17,11 @@ along with this program. If not, see import QtQuick 1.0 import "../DatePicker/component" as Comp + import "amlich-hnd.js" as AmLich +import "amlich-aa98.js" as AmLich98 + +import "CacNgayLeTrongNam.js" as CNLTN Item{ id: item1 @@ -41,8 +45,13 @@ Item{ Text { color: { if (header) return "#000000"; - else - return "#007070" + else{ + var stemp = AmLich98.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7); + if (CNLTN.is_holiday(day, month, stemp[0], stemp[1])) + return theme_manager.theme.markdate.holidays; + else + return "#007070" + } } text: name; anchors.horizontalCenter: parent.horizontalCenter @@ -116,14 +125,8 @@ onCanceled:{ id: grid x: -335 y: 41 - width: { - 800 - } - - height: { - 480 - } - + width:800 + height: 480 anchors.horizontalCenterOffset: 15 anchors.bottomMargin: -52 anchors.topMargin: 42 @@ -264,40 +267,41 @@ onCanceled:{ var prevmonth = get_prevmonth(startfrom) var dayclick, monthclick, yearclick; - console.log(lmodel.count) while(lmodel.count>7){ lmodel.remove(lmodel.count-1); } + var datas1,datas,lunarclmonth,inmonths; + for (var i=7;i<49;i++){ var realnumber = i - 7; if (realnumber >= startfrom && j<= daysofthemonthyear){ var lunarcl = AmLich.getLunarDate(j,screen.curMonth,screen.curYear) if (lunarcl.day==1){ - var lunarclmonth = "/"+lunarcl.month + lunarclmonth = "/"+lunarcl.month }else{ - var lunarclmonth = "" + lunarclmonth = "" } - var datas = j+"
  "+lunarcl.day+lunarclmonth+""; + datas = j+"
  "+lunarcl.day+lunarclmonth+""; dayclick = j; monthclick = screen.curMonth; yearclick = screen.curYear; - var inmonths = true; + inmonths = true; j++; }else{ if (realnumber
  "+datas1.am+""; - var inmonths=false; + datas = ""+datas1.duong+"
  "+datas1.am+""; + inmonths=false; } lmodel.append({header:false,name:datas,inmonth:inmonths,day:dayclick,month:monthclick,year:yearclick}) diff --git a/qml/LichViet/MenuScreen.qml b/qml/LichViet/MenuScreen.qml index f511302..ae0c5bd 100644 --- a/qml/LichViet/MenuScreen.qml +++ b/qml/LichViet/MenuScreen.qml @@ -59,6 +59,9 @@ Item{ ListElement { idm:5; name: "Xem Theo Tháng"; } + /*ListElement { + idm:7; name: "Đổi Theme"; + }*/ ListElement { idm:6; name: "Giới Thiệu"; } @@ -92,8 +95,9 @@ Item{ case 4: screen.state="xemngaytotxauhoangdao";break; case 5: screen.state="xemtheothang";break; case 6: screen.state="aboutdialog";break; + case 7: screen.state="changetheme";break; default: - screen.state="nofeaturedialog" + screen.state="nofeaturedialog";break; } } diff --git a/qml/LichViet/NoFeatureDialog.qml b/qml/LichViet/NoFeatureDialog.qml index 6f03f16..02fdde5 100644 --- a/qml/LichViet/NoFeatureDialog.qml +++ b/qml/LichViet/NoFeatureDialog.qml @@ -19,7 +19,7 @@ import QtQuick 1.0 Item{ id: item1 - BorderImage { anchors.centerIn: parent;source: "./img/titlebar.sci"; width: 344+2; height: 234+14; y: +7 } + Rectangle { id: rectangle1 x: 0 diff --git a/qml/LichViet/OptionsScreen.qml b/qml/LichViet/OptionsScreen.qml index f8a571a..2ea89a3 100644 --- a/qml/LichViet/OptionsScreen.qml +++ b/qml/LichViet/OptionsScreen.qml @@ -30,6 +30,15 @@ Item{ id: listDelegate Rectangle { height:60 + + Rectangle { + width:rectangle1.width; + y:0; + x:0 + height:1 + border.color: "#b57e8f" + } + Text { id: text1 text:name @@ -45,13 +54,12 @@ Item{ onSwitched:{ listModel.setProperty(index, "selected", switchedOn); } - switchedOn: { - selected - } - + switchedOn: selected anchors.verticalCenter: parent.verticalCenter } + } + } ListModel { diff --git a/qml/LichViet/amlich-aa98.js b/qml/LichViet/amlich-aa98.js index 0f417bc..c9246fb 100644 --- a/qml/LichViet/amlich-aa98.js +++ b/qml/LichViet/amlich-aa98.js @@ -1,3 +1,10 @@ +/** + * Copyright 2004 Ho Ngoc Duc [http://come.to/duc]. All Rights Reserved.

+ * Permission to use, copy, modify, and redistribute this software and its + * documentation for personal, non-commercial use is hereby granted provided that + * this copyright notice appears in all copies. + */ + var PI = Math.PI; /* Discard the fractional part of a number, e.g., INT(3.2) = 3 */ diff --git a/qml/LichViet/amlich-hnd.js b/qml/LichViet/amlich-hnd.js index 05966dd..fbcdae5 100644 --- a/qml/LichViet/amlich-hnd.js +++ b/qml/LichViet/amlich-hnd.js @@ -1,4 +1,9 @@ - +/** + * Copyright 2004 Ho Ngoc Duc [http://come.to/duc]. All Rights Reserved.

+ * Permission to use, copy, modify, and redistribute this software and its + * documentation for personal, non-commercial use is hereby granted provided that + * this copyright notice appears in all copies. + */ var ABOUT = "\u00C2m l\u1ECBch Vi\u1EC7t Nam - Version 0.8"+"\n\u00A9 2004 H\u1ED3 Ng\u1ECDc \u0110\u1EE9c [http://come.to/duc]"; var TK19 = new Array( diff --git a/qml/LichViet/main.qml b/qml/LichViet/main.qml index aa948ae..565b3ad 100644 --- a/qml/LichViet/main.qml +++ b/qml/LichViet/main.qml @@ -21,11 +21,12 @@ import "amlich-aa98.js" as AmLich98 import "Settings.js" as Settings import "Themes.js" as Themes +import "CacNgayLeTrongNam.js" as CNLTN Item { id: screen - width: 800 - height: 480 + width: 480 + height: 800 property int curDay: LC.curDay() property int curMonth: LC.curMonth() @@ -46,7 +47,8 @@ Item { property string lunarDayCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[0] property string lunarMonthCanChi : AmLich.getCanChi(AmLich.getLunarDate(curDay,curMonth,curYear))[1] - //property string lunarCanHour : AmLich.getCanHour0(LC.curHour()) + property string day_info : CNLTN.get(screen) + property bool is_holiday : CNLTN.is_holiday(screen.curDay,screen.curMonth, screen.curYear, screen.lunarDay, screen.lunarMonth) state:"mainscreen" @@ -63,7 +65,7 @@ Item { 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: 0.3 } @@ -111,13 +113,13 @@ Item { 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: 300 + height: 100 + y: 116 + anchors.horizontalCenter: parent.horizontalCenter + property int index: 0 + onIndexChanged: txtDATEpv.currentIndex = reelx.index + color: "transparent" Component { id: delegate Column { @@ -127,7 +129,24 @@ Item { 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 = 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 theme_manager.theme.markdate.otherday; + } } } } @@ -175,7 +194,7 @@ Item { Text { id: txtTHU x: 151 - y: 240 + y: 210 width: 80 height: 20 color: "#f0f0f5" @@ -188,10 +207,25 @@ Item { } Text { + id: txtInfo + x: 151 + 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 + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + opacity: 0.6 + font.bold: (screen.is_holiday ? true : false) + font.pixelSize: (screen.is_holiday ? 25 : 20) + } + + Text { id: txtDAYAmLich x: 151 - y: 300 + y: 330 width: 80 height: 20 color: "#f0f0f5" @@ -200,7 +234,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter opacity: 0.6 font.bold: true - font.pixelSize: 28 + font.pixelSize: 25 } @@ -220,6 +254,14 @@ Item { 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" @@ -304,6 +346,14 @@ Item { }, State { + name: "changetheme"; + PropertyChanges { target: changeTheme; 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 } diff --git a/qml/themes/default/default.qml b/qml/themes/default/default.qml index 1edd266..c9e2466 100644 --- a/qml/themes/default/default.qml +++ b/qml/themes/default/default.qml @@ -5,6 +5,7 @@ Item { property alias titlebar: titlebar property alias datepicker: datepicker property alias toolbar: toolbar + property alias markdate: markdate property string root_dir : "file:/opt/usr/share/LichViet/themes/default/" property string background_image: root_dir+"background.jpg" @@ -37,4 +38,14 @@ Item { property string button_pressed: root_dir+"dp_button_pressed.png" property string button_active: root_dir+"dp_button_active.png" } + + Item{ + id:markdate + property string sunday:"red" + property string saturday:"blue" + property string otherday:"grey" + property string otherday_selected:"#FFFFFF" + property string holidays:"yellow" + property string not_holidays:"#FFFF99" + } }