From: Cuong Le Date: Fri, 16 Sep 2011 13:28:43 +0000 (+0700) Subject: Merge branch 'develop' X-Git-Tag: v1.0.2-4^0 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=67ff5ae94ce65b3b1bb04a1eddcea356fd81a1aa;hp=149fae2a60de58d911839daae8700ba3a6e2069a;p=lichviet Merge branch 'develop' --- diff --git a/LichViet.pro b/LichViet.pro index 4fc68cc..06f3e1b 100644 --- a/LichViet.pro +++ b/LichViet.pro @@ -30,7 +30,6 @@ QT += dbus # The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp \ - lunarcalendar.cpp \ controller.cpp # Please do not modify the following two lines. Required for deployment. @@ -41,7 +40,6 @@ RESOURCES += \ lichviet.qrc HEADERS += \ - lunarcalendar.h \ controller.h OTHER_FILES += \ @@ -75,4 +73,25 @@ OTHER_FILES += \ qml/LichViet/ChangeTheme.qml \ qml/LichViet/MenuButton.qml \ qml/LichViet/ScrollBar.qml \ - qml/LichViet/FileBrowser.qml + qml/LichViet/FileBrowser.qml \ + qml/LichViet/main.js + +unix:!symbian:!maemo5 { + target.path = /opt/LichViet/bin + INSTALLS += target +} + +unix:!symbian:!maemo5 { + target.path = /opt/LichViet/bin + INSTALLS += target +} + +unix:!symbian:!maemo5 { + target.path = /opt/LichViet/bin + INSTALLS += target +} + +maemo5 { + target.path = /opt/LichViet/bin + INSTALLS += target +} diff --git a/Makefile b/Makefile index e71dc73..3683fb4 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ ############################################################################# # Makefile for building: LichViet -# Generated by qmake (2.01a) (Qt 4.7.3) on: Sun Aug 28 12:42:23 2011 +# Generated by qmake (2.01a) (Qt 4.7.3) on: Tue Sep 6 21:29:40 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 +# Command: /opt/QtSDK/Desktop/Qt/473/gcc/bin/qmake -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 QMLJSDEBUGGER_PATH=/opt/qtcreator-2.1.0/share/qtcreator/qml/qmljsdebugger -o Makefile LichViet.pro ############################################################################# ####### Compiler, tools and options @@ -136,7 +136,7 @@ Makefile: LichViet.pro /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64/qmake /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/yacc.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/lex.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/include_source_dir.prf - $(QMAKE) -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 -o Makefile LichViet.pro + $(QMAKE) -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 QMLJSDEBUGGER_PATH=/opt/qtcreator-2.1.0/share/qtcreator/qml/qmljsdebugger -o Makefile LichViet.pro /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/common/g++.conf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/common/unix.conf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/common/linux.conf: @@ -161,7 +161,7 @@ qmlapplicationviewer/qmlapplicationviewer.pri: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/lex.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/include_source_dir.prf: qmake: FORCE - @$(QMAKE) -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 -o Makefile LichViet.pro + @$(QMAKE) -spec /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 QMLJSDEBUGGER_PATH=/opt/qtcreator-2.1.0/share/qtcreator/qml/qmljsdebugger -o Makefile LichViet.pro dist: @$(CHK_DIR_EXISTS) .tmp/LichViet1.0.2 || $(MKDIR) .tmp/LichViet1.0.2 @@ -183,7 +183,7 @@ distclean: clean first: $(first) copydeploymentfolders copydeploymentfolders: - @echo Copying application data... && $(MKDIR) "/home/cuongle/Garage/lichviet//" && $(COPY_DIR) "/home/cuongle/Garage/lichviet/qml/themes" "/home/cuongle/Garage/lichviet//" + @echo Copying application data... && $(MKDIR) "/home/cle/Garage/lichviet//" && $(COPY_DIR) "/home/cle/Garage/lichviet/qml/themes" "/home/cle/Garage/lichviet//" check: first @@ -295,7 +295,7 @@ qrc_lichviet.o: qrc_lichviet.cpp install_itemthemes_qml: first FORCE @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/share/LichViet// || $(MKDIR) $(INSTALL_ROOT)/usr/local/share/LichViet// - -$(INSTALL_DIR) /home/cuongle/Garage/lichviet/qml/themes $(INSTALL_ROOT)/usr/local/share/LichViet// + -$(INSTALL_DIR) /home/cle/Garage/lichviet/qml/themes $(INSTALL_ROOT)/usr/local/share/LichViet// uninstall_itemthemes_qml: FORCE @@ -305,7 +305,7 @@ uninstall_itemthemes_qml: FORCE install_desktopfile: first FORCE @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/share/applications/ || $(MKDIR) $(INSTALL_ROOT)/usr/share/applications/ - -$(INSTALL_FILE) /home/cuongle/Garage/lichviet/LichViet.desktop $(INSTALL_ROOT)/usr/share/applications/ + -$(INSTALL_FILE) /home/cle/Garage/lichviet/LichViet.desktop $(INSTALL_ROOT)/usr/share/applications/ uninstall_desktopfile: FORCE @@ -315,7 +315,7 @@ uninstall_desktopfile: FORCE install_icon: first FORCE @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/ || $(MKDIR) $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/ - -$(INSTALL_FILE) /home/cuongle/Garage/lichviet/LichViet.png $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/ + -$(INSTALL_FILE) /home/cle/Garage/lichviet/LichViet.png $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/ uninstall_icon: FORCE diff --git a/lichviet.qrc b/lichviet.qrc index 4acb97c..61702b4 100644 --- a/lichviet.qrc +++ b/lichviet.qrc @@ -31,6 +31,7 @@ qml/LichViet/Settings.js qml/LichViet/Themes.js qml/LichViet/xemngaytotxau.js + qml/LichViet/main.js qml/LichViet/CacNgayLeTrongNam.js diff --git a/lunarcalendar.cpp b/lunarcalendar.cpp deleted file mode 100644 index f2c0b48..0000000 --- a/lunarcalendar.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* -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 -*/ - - -#include -#include "lunarcalendar.h" - -LunarCalendar::LunarCalendar(QObject *parent) : - QObject(parent) -{ - this->curDayA = QDateTime::currentDateTime().toString("d").toUInt(); - this->curMonthA = QDateTime::currentDateTime().toString("M").toUInt(); - this->curYearA = QDateTime::currentDateTime().toString("yyyy").toUInt(); -} - -/* - Calendar - */ -QString LunarCalendar::nextDay(){ - int value = this->curDayA+1; - int days = calDays(this->curMonthA,this->curYearA); - if (value>days){ - value = 1; - this->curMonthA++; - if (this->curMonthA > 12){ - this->curMonthA = 1; - this->curYearA++; - } - } - this->curDayA=value; - return QString::number(value); -} - -QString LunarCalendar::prevDay(){ - int value = this->curDayA-1; - if(!value){ - this->curMonthA--; - if (!this->curMonthA){ - this->curMonthA = 12; - this->curYearA--; - } - value = calDays( this->curMonthA,this->curYearA); - } - this->curDayA=value; - return QString::number(value); -} - -int LunarCalendar::curDay(){ - return this->curDayA; -} - -int LunarCalendar::curMonth(){ - return this->curMonthA; -} - -int LunarCalendar::curYear(){ - return this->curYearA; -} - -int LunarCalendar::curHour(){ - return QDateTime::currentDateTime().toString("H").toUInt(); -} - -int LunarCalendar::curMinute(){ - return QDateTime::currentDateTime().toString("m").toUInt(); -} - -void LunarCalendar::reset(int D, int M, int Y){ - this->curDayA = D; - this->curMonthA = M; - this->curYearA = Y; -} - - -int LunarCalendar::calDays(int Month, int Year){ - if (Month == 4 || Month == 6 || Month == 9 || Month == 11) - return 30; - else - if (Month == 2) { - bool isLeapYear = (Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0); - if (isLeapYear == 0) - return 28; - else - return 29; - } - else - return 31; -} - diff --git a/lunarcalendar.h b/lunarcalendar.h deleted file mode 100644 index 72867c5..0000000 --- a/lunarcalendar.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -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 -*/ - - -#ifndef LUNARCALENDAR_H -#define LUNARCALENDAR_H - -#include - -class LunarCalendar : public QObject -{ - Q_OBJECT - - int curDayA; - int curMonthA; - int curYearA; - - int jdn(); - -public: - explicit LunarCalendar(QObject *parent = 0); - - Q_INVOKABLE QString nextDay(); - Q_INVOKABLE QString prevDay(); - - Q_INVOKABLE int curDay(); - Q_INVOKABLE int curMonth(); - Q_INVOKABLE int curYear(); - - Q_INVOKABLE int curHour(); - Q_INVOKABLE int curMinute(); - - Q_INVOKABLE void reset(int,int,int); - - Q_INVOKABLE int calDays(int, int); - - -signals: - -public slots: - -}; - -#endif // LUNARCALENDAR_H diff --git a/main.cpp b/main.cpp index 436a4c8..8ab3a75 100644 --- a/main.cpp +++ b/main.cpp @@ -22,7 +22,6 @@ along with this program. If not, see #include "qmlapplicationviewer.h" -#include "lunarcalendar.h" #include "controller.h" #ifdef Q_WS_MAEMO_5 @@ -36,11 +35,9 @@ int main(int argc, char *argv[]) app.setApplicationVersion(APP_VERSION); - LunarCalendar lc; Controller ctrller; viewer.rootContext()->setContextProperty("ROOT", &viewer); - viewer.rootContext()->setContextProperty("LC", &lc); viewer.rootContext()->setContextProperty("Controller", &ctrller); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); diff --git a/qml/DatePicker/component/Button.qml b/qml/DatePicker/component/Button.qml index eb58bbb..febd872 100644 --- a/qml/DatePicker/component/Button.qml +++ b/qml/DatePicker/component/Button.qml @@ -1,8 +1,6 @@ -import QtQuick 1.0 +import QtQuick 1.1 Item { - id: container - property string buttonName: "NOT SET" property string target: "NOT SET" property string text: "NOT SET" @@ -13,49 +11,19 @@ Item { property bool active: false - property string bgImage: theme_manager.theme.datepicker.button - property string bgImagePressed: theme_manager.theme.datepicker.button_pressed - property string bgImageActive: theme_manager.theme.datepicker.button_active - - // These Component properties can be used to modify the Button's LaF - // from the calling component. They have to define a BorderImage component. - property Component bg: defaultBackground - property Component bgPressed: defaultPressedBackground - property Component bgActive: defaultActiveBackground - signal clicked(string target, string button) width: 140 height: 60 - opacity: enabled ? 1.0 : 0.5 + opacity: enabled ? 1.0 : 0.5 - Loader { - id: background - sourceComponent: container.bg + Rectangle{ anchors.fill: parent - } - - Component { - id: defaultBackground - BorderImage { - border { top: 8; bottom: 8; left: 8; right: 8 } - source: bgImage - } - } - Component { - id: defaultPressedBackground - BorderImage { - border { top: 8; bottom: 8; left: 8; right: 8 } - source: bgImagePressed - } - } - - Component { - id: defaultActiveBackground - BorderImage { - border { top: 8; bottom: 8; left: 8; right: 8 } - source: bgImageActive - } + width: container.width + height: container.height + color:"white" + border.color: "black" + radius: 8 } Text { @@ -73,22 +41,4 @@ Item { } color: container.fontColor } - - MouseArea { - id: mouseArea - anchors.fill: parent - - } - - states: [ - State { - name: 'pressed'; when: mouseArea.pressed - PropertyChanges { target: background; sourceComponent: container.bgPressed } - }, - State { - name: 'active'; when: container.active - PropertyChanges { target: background; sourceComponent: container.defaultActiveBackground; } - } - ] - } diff --git a/qml/DatePicker/component/DateReel.qml b/qml/DatePicker/component/DateReel.qml index 8ae694b..bc4d49b 100644 --- a/qml/DatePicker/component/DateReel.qml +++ b/qml/DatePicker/component/DateReel.qml @@ -1,4 +1,6 @@ -import QtQuick 1.0 +import QtQuick 1.1 + +import "../../LichViet/main.js" as Script Item { id: container @@ -19,18 +21,6 @@ Item { // Spacing between items property int spacing: 8 - property Component itemBackground: Component { - BorderImage { - border { top: 8; bottom: 8; left: 8; right: 8 } - source: theme_manager.theme.datepicker.button - } - } - property Component itemBackgroundPressed: Component { - BorderImage { - border { top: 8; bottom: 8; left: 8; right: 8 } - source: theme_manager.theme.datepicker.button_pressed - } - } width: 240 height: 90 @@ -47,8 +37,6 @@ Item { fontColor: container.fontColor fontName: container.fontName fontSize: container.fontSize - bg: itemBackground - bgPressed: itemBackgroundPressed opacity: (index+1 < days.start || index+1 > days.end) ? 0.5 : 1.0 } } @@ -62,8 +50,6 @@ Item { fontColor: container.fontColor fontName: container.fontName fontSize: container.fontSize - bg: itemBackground - bgPressed: itemBackgroundPressed } } @@ -77,8 +63,6 @@ Item { fontColor: container.fontColor fontName: container.fontName fontSize: container.fontSize - bg: itemBackground - bgPressed: itemBackgroundPressed } } @@ -149,12 +133,12 @@ Item { Component.onCompleted: { appends() - day.index = screen.curDay - 1 - end = LC.calDays(month.index+1,year.index+1900); + day.index = Script.curDay - 1 + end = Script.calDaysX(month.index+1,year.index+1900); } function reset(){ - var howmanydays = LC.calDays(month.index+1,year.index+1900); + var howmanydays = Script.calDaysX(month.index+1,year.index+1900); end = howmanydays; if (day.index+1 < days.start) day.index = days.start-1; @@ -171,7 +155,7 @@ Item { } function change(){ - day.index = screen.curDay-1; + day.index = Script.curDay-1; } } @@ -184,11 +168,11 @@ Item { else append({number:j}) } - month.index = screen.curMonth - 1 + month.index = Script.curMonth - 1 } function change(){ - month.index = screen.curMonth - 1; + month.index = Script.curMonth - 1; } } @@ -198,26 +182,26 @@ Item { for(var i=1900;i<2099;i++){ append({number:i}) } - year.index = screen.curYear - 1900 + year.index = Script.curYear - 1900 } function change(){ - year.index = screen.curYear - 1900 + year.index = Script.curYear - 1900 } } function day_reset(){ - datePicker.mDay = screen.curDay + datePicker.mDay = Script.curDay days.change() } function month_reset(){ - datePicker.mMonth = screen.curMonth + datePicker.mMonth = Script.curMonth months.change() } function year_reset(){ - datePicker.mYear = screen.curYear + datePicker.mYear = Script.curYear years.change() } diff --git a/qml/DatePicker/component/Reel.qml b/qml/DatePicker/component/Reel.qml index dc5b3a1..eb1ab26 100644 --- a/qml/DatePicker/component/Reel.qml +++ b/qml/DatePicker/component/Reel.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 1.1 Rectangle { id: reel @@ -15,7 +15,7 @@ Rectangle { function open() { focus = true; clip = false } function close() { clip = true } - function toggle() { clip ? open() : close() } + function shiftZ(obj, delta) { if (typeof obj.z != 'undefined') obj.z += delta if (obj.parent) shiftZ(obj.parent, delta) // Set z recursively to parent @@ -28,7 +28,7 @@ Rectangle { // Close reel when the focus is lost onFocusChanged: if (!focus) close() // Bring to front if not clipped - onClipChanged: { clip ? shiftZ(reel, -500) : shiftZ(reel, 500) } + onIndexChanged: path.currentIndex = reel.index diff --git a/qml/LichViet/About.qml b/qml/LichViet/About.qml index af36f5b..58665d6 100644 --- a/qml/LichViet/About.qml +++ b/qml/LichViet/About.qml @@ -14,83 +14,138 @@ 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 QtQuick 1.1 + +import "Themes.js" as Themes Item{ - id: item1 + + id: aboutdlg + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:(parent.width * 1.5) + + signal close + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + Connections { + target: aboutdlg.parent + + onDialogClose: { + aboutdlg.state = "close"; + aboutdlg.destroy(600); + } + } + + Rectangle { id: rectangle1 anchors.fill: parent; anchors.bottomMargin: 0 visible: true opacity:0.8 - - Image { - id: image1 - x: 0 - y: 43 - width: 100 - height: 100 - anchors.horizontalCenterOffset: 0 - anchors.horizontalCenter: parent.horizontalCenter - source: "qrc:/LichViet.png" - + + Image { + id: image1 + x: 0 + y: 43 + width: 100 + height: 100 + anchors.horizontalCenterOffset: 0 + anchors.horizontalCenter: parent.horizontalCenter + source: "qrc:/LichViet.png" + + Text { + id: text3 + x: 10 + y: 261 + height: 20 + text: "Chương trình có tham khảo thuật toán tính
Âm Lịch của tác giả Hồ Ngọc Đức.
http://www.informatik.uni-leipzig.de/~duc/amlich/" + anchors.horizontalCenterOffset: 0 + anchors.horizontalCenter: parent.horizontalCenter + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 16 + } + } + + Text { + id: text1 + x: 11 + y: 171 + height: 20 + text: "Lịch Âm Việt Nam
OS: Maemo 5 (Fremantle)" + anchors.horizontalCenterOffset: 1 + font.bold: true + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 23 + } + Text { - id: text3 + id: text2 x: 10 - y: 261 - width: 80 + y: 234 height: 20 - text: "Chương trình có tham khảo thuật toán tính
Âm Lịch của tác giả Hồ Ngọc Đức.
http://www.informatik.uni-leipzig.de/~duc/amlich/" + text: "Phiên bản : 1.0.2-4 (15/09/2011)
\ +Phát triển bởi : metacuong@gmail.com" anchors.horizontalCenterOffset: 0 - anchors.horizontalCenter: parent.horizontalCenter + wrapMode: Text.NoWrap verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter - font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 24 + } + + } - } + Rectangle { + width : aboutdlg.width + height: 45 + color:"white" + opacity: 0.5 + } + Text { - id: text1 - x: 11 - y: 171 - width: 80 - height: 20 - text: "Lịch Âm Việt Nam
OS: Maemo 5" - anchors.horizontalCenterOffset: 1 + id: title + + anchors { horizontalCenter: aboutdlg.horizontalCenter; top: aboutdlg.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: qsTr("About") + smooth: true font.bold: true - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 26 - } - - Text { - id: text2 - x: 10 - y: 234 - width: 80 - height: 20 - text: "Phiên bản : 1.0.2-3 (25/08/2011)
\ -Phát triển bởi : metacuong@gmail.com" -anchors.horizontalCenterOffset: 0 -wrapMode: Text.NoWrap - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 24 - } - - -} - - ToolBarSingle { id: toolBar; height: 50; - y: screen.height-78 + } + + + ToolBarSingle { + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Quay Về" - onButton1Clicked: - { - screen.state="mainscreen" + onButton1Clicked:aboutdlg.close() } + + states: [ + State { + name: "show" + AnchorChanges { target: aboutdlg; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: aboutdlg; anchors.right: parent.left } + } + ] + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } + } - -} diff --git a/qml/LichViet/AmDateTimeDialog.qml b/qml/LichViet/AmDateTimeDialog.qml index 63890b7..9c9d133 100644 --- a/qml/LichViet/AmDateTimeDialog.qml +++ b/qml/LichViet/AmDateTimeDialog.qml @@ -15,14 +15,28 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 -import "amlich-hnd.js" as AmLich -import "amlich-aa98.js" as AmLich98 +import QtQuick 1.1 + +import "Themes.js" as Themes +import "main.js" as Script Item{ id: amdatetime state: "switch_me" - + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:(parent.width * 1.5) + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + signal toolbar + signal updatedate(int day, int month, int year) + Rectangle { id: rectangle1 x: 0 @@ -35,47 +49,44 @@ Item{ border.color: "#b57e8f" visible: true opacity:0.9 - + Button { id: button2 - x: 313 - anchors.right: parent.right; anchors.rightMargin: 8; y: 185; width: 140; height: 40 + anchors.right: parent.right; anchors.rightMargin: 145; y: 185; width: 100; height: 40 + anchors.horizontalCenter: parent.horizontalCenter + text: "OK" onClicked: { - var lday = lunarday_pathview.currentIndex+1; - var lmonth=lunarmonth_pathview.currentIndex+1; - var lyear=lunaryear_pathview.currentIndex+1900; - + var lday = lunarday_pathview.currentIndex+1; + var lmonth=lunarmonth_pathview.currentIndex+1; + var lyear=lunaryear_pathview.currentIndex+1900; + var lnhuan=0; - + var thangnhuan = -1; - + for (var l=0;l<12;l++) - if (lunarmonth_model.get(l).nhuan){ - thangnhuan = l; + if (lunarmonth_model.get(l).nhuan){ + thangnhuan = l; } - - if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){ - lnhuan=1; - lmonth=lmonth-1; - } - - if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan) - lmonth-=1; - - var finalSolarDay = AmLich98.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7) - - LC.reset(finalSolarDay[0],finalSolarDay[1],finalSolarDay[2]) - screen.calculateLunar( finalSolarDay[0], finalSolarDay[1], finalSolarDay[2]) - screen.state="mainscreen" - screen.refresh() - - maindatemodel.reset() - txtDATEpv.currentIndex = finalSolarDay[0]-1; - + + if(lunarmonth_model.get(lunarmonth_pathview.currentIndex).nhuan){ + lnhuan=1; + lmonth=lmonth-1; + } + + if (thangnhuan!=-1 && lunarmonth_pathview.currentIndex> thangnhuan) + lmonth-=1; + + var finalSolarDay = Script.convertLunar2Solar(lday,lmonth,lyear,lnhuan,7); + + amdatetime.state="close"; + amdatetime.toolbar(); + amdatetime.updatedate(finalSolarDay[0], finalSolarDay[1], finalSolarDay[2]) + + } } - } - + Button { id: button3 x: 413 @@ -84,11 +95,14 @@ Item{ height: 40 text: "X" anchors.rightMargin: 56 - onClicked: {screen.state="mainscreen"} - } - + onClicked: { + amdatetime.state="close" + amdatetime.toolbar() + } + } + Rectangle { - id: rectangle2 + id: rec22 x: 23 y: 89 width: 415 @@ -98,15 +112,15 @@ Item{ GradientStop { position: 0 color: "#ffffff" - } - + } + GradientStop { position: 0.1 color: "#7c6969" + } } - } border.color: "#b57e8f" - + Rectangle { id:lmk x: 207 @@ -116,25 +130,57 @@ Item{ GradientStop { position: 0.89 color: "#148ebe" - } - + } + GradientStop { position: 0.01 color: "#19262b" - } - + } + GradientStop { position: 0.13 color: "#6eb3d5" - } - + } + GradientStop { position: 1 color: "#19262b" + } } } - } - + + states: [ + State { + name: "switch_to_day"; + PropertyChanges { target:lmk;x:10;width:60;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} + PropertyChanges { target:lunarday_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:false;} + PropertyChanges { target:lunaryear_mousearea;visible:true;} + PropertyChanges { target:lunarmonth_mousearea;visible:true;} + }, + State { + name: "switch_to_year"; + PropertyChanges { target:lmk;x:207;width:198;} + PropertyChanges { target:lunarday_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:true;} + PropertyChanges { target:lunaryear_mousearea;visible:false;} + PropertyChanges { target:lunarmonth_mousearea;visible:true;} + }, + State { + name: "switch_to_month"; + PropertyChanges { target:lmk;x:60;width:150;} + PropertyChanges { target:lunarday_pathview;pathItemCount:1;} + PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} + PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;} + PropertyChanges { target:lunarday_mousearea;visible:true;} + PropertyChanges { target:lunaryear_mousearea;visible:true;} + PropertyChanges { target:lunarmonth_mousearea;visible:false;} + }] + /**LUNAR YEAR**/ Rectangle { id:lunaryear_rec @@ -143,10 +189,10 @@ Item{ y: -39 width: 178; height: 129 color:"transparent" - + property int index: 0 onIndexChanged: lunaryear_pathview.currentIndex = lunaryear_rec.index - + Component { id: lunaryear_delegate Column { @@ -168,361 +214,299 @@ Item{ anchors.fill: parent model: lunaryear_model delegate: lunaryear_delegate - pathItemCount: 3 - clip: true - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlightRangeMode: PathView.StrictlyEnforceRange - focus: true - path: Path { - startX: 90 - startY: 0 - PathLine {x: 90; y: lunaryear_rec.height} - } - - onMovementEnded: { - //console.log(lunaryear_pathview.currentIndex) - AmLich.getYearInfo(lunaryear_pathview.currentIndex+1900); - lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1); - } - } + pathItemCount: 3 + clip: true + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlightRangeMode: PathView.StrictlyEnforceRange + focus: true + path: Path { + startX: 90 + startY: 0 + PathLine {x: 90; y: lunaryear_rec.height} + } + + onMovementEnded: { + Script.getYearInfo(lunaryear_pathview.currentIndex+1900); + lunarmonth_model.change(lunaryear_pathview.currentIndex+1900, lunarmonth_pathview.currentIndex+1); + } + } MouseArea { id:lunaryear_mousearea anchors.fill: parent onClicked: { - amdatetime.state="switch_to_year" + rec22.state="switch_to_year" + } } } - } - + ListModel { id:lunaryear_model - Component.onCompleted: { - init() - } function init(){ for(var i=1900;i<2099;i++){ - var lunarYear = AmLich.getYearCanChi(i) + var lunarYear = Script.getYearCanChi(i) append({name:i+" ("+lunarYear+")"}) + } } - } - + function change(YYYY){ + lunaryear_pathview.currentIndex=-1; lunaryear_pathview.currentIndex = YYYY - 1900 + } } - } /***/ - + /**LUNAR DAY*/ - Rectangle{ - state:"switch_to_day" - id:lunarday_rec - x: -20 - y: -39 - width: 80; height: 129 - color:"transparent" - - property int index: 0 - onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index - - Component { - id: lunarday_delegate - Column { - id: wrapper - - Text { - id: nameText - text: name - font.pointSize: 18 - width: lunarday_rec.width - color: PathView.isCurrentItem ? "#FFFFFF" : "grey" - verticalAlignment:Text.AlignVCenter - font.bold: true + Rectangle{ + state:"switch_to_day" + id:lunarday_rec + x: -20 + y: -39 + width: 80; height: 129 + color:"transparent" + + property int index: 0 + onIndexChanged: lunarday_pathview.currentIndex = lunarday_rec.index + + Component { + id: lunarday_delegate + Column { + id: wrapper + + Text { + id: nameText + text: name + font.pointSize: 18 + width: lunarday_rec.width + color: PathView.isCurrentItem ? "#FFFFFF" : "grey" + verticalAlignment:Text.AlignVCenter + font.bold: true } - + } } - - PathView { - id:lunarday_pathview - anchors.fill: parent - model: lunarday_model - delegate: lunarday_delegate - pathItemCount: 1 - clip: true - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlightRangeMode: PathView.StrictlyEnforceRange - focus: true - path: Path { - startX: 90 - startY: 0 - PathLine {x: 90; y: lunarday_rec.height} - } + + PathView { + id:lunarday_pathview + anchors.fill: parent + model: lunarday_model + delegate: lunarday_delegate + pathItemCount: 1 + clip: true + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlightRangeMode: PathView.StrictlyEnforceRange + focus: true + path: Path { + startX: 90 + startY: 0 + PathLine {x: 90; y: lunarday_rec.height} + } } - - MouseArea { - id:lunarday_mousearea - anchors.fill: parent - onClicked: { - amdatetime.state="switch_to_day" + + MouseArea { + id:lunarday_mousearea + anchors.fill: parent + onClicked: { + rec22.state="switch_to_day" } } - + } + + ListModel { + id:lunarday_model - ListModel { - id:lunarday_model - Component.onCompleted: { - for(var i=1;i<=30;i++) - append({name:i}) + function init(){ + for(var i=1;i<=30;i++) + lunarday_model.append({name:i}) } - - function change(MM,DD){ - - while(lunarday_model.count>0){ - lunarday_model.remove(lunarday_model.count-1) + + function change(MM,DD){ + + while(lunarday_model.count>0){ + lunarday_model.remove(lunarday_model.count-1) } - - - var daystotal = AmLich.RMM[MM-1]; - - if(lunarmonth_model.get(MM-1).nhuan){ - - for (var i=1;i<=AmLich.LML;i++) - lunarday_model.append({name:i}) - - }else{ - for (var i=1;i<=daystotal;i++) - lunarday_model.append({name:i}) - + + + var daystotal = Script.RMM[MM-1]; + + if(lunarmonth_model.get(MM-1).nhuan){ + for (var i=1;i<=Script.LML;i++) + lunarday_model.append({name:i}) + }else{ + for (var i=1;i<=daystotal;i++) + lunarday_model.append({name:i}) } - /*if(lunarmonth_model.get(MM-1).nhuan){ - if(AmLich.LML > lunarday_model.count){ - for (var i=lunarday_model.count+1;i<=AmLich.LML;i++) - lunarday_model.append({name:i}) - }else - if(AmLich.LML< lunarday_model.count){ - while(lunarday_model.count>AmLich.LML){ - lunarday_model.remove(lunarday_model.count-1); - } - } - - }else{ - if(daystotal > lunarday_model.count){ - for (var i=lunarday_model.count+1;i<=daystotal;i++) - lunarday_model.append({name:i}) - }else - if(daystotal < lunarday_model.count){ - while(lunarday_model.count>daystotal){ - lunarday_model.remove(lunarday_model.count-1); - } - } - }*/ - - /* - var nhuansetru = 30 - AmLich.LML; - - if(lunarmonth_model.get(MM-1).nhuan && lunarday_model.count==30){ - var j=0; - while(j0){ - lunarmonth_model.remove(lunarmonth_model.count-1) - } - readd(YYYY, MM) - - lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1); + } + + } + + ListModel { + id:lunarmonth_model + + Component.onCompleted: { + + } + + function change(YYYY, MM){ + while(lunarmonth_model.count>0){ + lunarmonth_model.remove(lunarmonth_model.count-1) } + readd(YYYY, MM) + + lunarday_model.change(lunarmonth_pathview.currentIndex+1,lunarday_pathview.currentIndex+1); + } - function readd(YYYY, MM){ - var yTest = YYYY; - var preFix = "Tháng "; - var a=AmLich.leapMonth(yTest) - var t=0; - if(a){ // nam nhuan - for(var i=0;i<=12;i++){ - var l=AmLich.getYearInfo(yTest)[i].month - if (t==l) - lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true}) - else - lunarmonth_model.append({name:preFix+l, nhuan:false}) - t=l - } - - }else - { - for(var i=1;i<=12;i++) - lunarmonth_model.append({name:preFix+i, nhuan:false}) + function readd(YYYY, MM){ + var yTest = YYYY; + var preFix = "Tháng "; + var a=Script.leapMonth(yTest) + var t=0; + if(a){ // nam nhuan + for(var i=0;i<=12;i++){ + var l=Script.getYearInfo(yTest)[i].month + if (t==l) + lunarmonth_model.append({name:preFix+l+" (N)", nhuan:true}) + else + lunarmonth_model.append({name:preFix+l, nhuan:false}) + t=l } - - lunarmonth_rec.index = MM -1; - lunarmonth_pathview.currentIndex = MM-1; - + + }else + { + for(var i=1;i<=12;i++) + lunarmonth_model.append({name:preFix+i, nhuan:false}) } + + lunarmonth_pathview.currentIndex=-1; + lunarmonth_pathview.currentIndex = MM-1; + } - - /***/ + } + + /***/ + } + } - - } - + Component.onCompleted: { - - } - + reset(); + } + states: [ State { - name: "switch_to_day"; - PropertyChanges { target:lmk;x:10;width:60;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} - PropertyChanges { target:lunarday_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:false;} - PropertyChanges { target:lunaryear_mousearea;visible:true;} - PropertyChanges { target:lunarmonth_mousearea;visible:true;} - }, - State { - name: "switch_to_year"; - PropertyChanges { target:lmk;x:207;width:198;} - PropertyChanges { target:lunarday_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:1;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:true;} - PropertyChanges { target:lunaryear_mousearea;visible:false;} - PropertyChanges { target:lunarmonth_mousearea;visible:true;} - }, + name: "show" + AnchorChanges { target: amdatetime; anchors.right: parent.right } + }, State { - name: "switch_to_month"; - PropertyChanges { target:lmk;x:60;width:150;} - PropertyChanges { target:lunarday_pathview;pathItemCount:1;} - PropertyChanges { target:lunaryear_pathview;pathItemCount:1;} - PropertyChanges { target:lunarmonth_pathview;pathItemCount:3;} - PropertyChanges { target:lunarday_mousearea;visible:true;} - PropertyChanges { target:lunaryear_mousearea;visible:true;} - PropertyChanges { target:lunarmonth_mousearea;visible:false;} - } - ] - + name: "close" + AnchorChanges { target: amdatetime; anchors.right: parent.left } + } + ] + function reset(){ - var acs = AmLich.getYearInfo(screen.curYear) - var a=AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear) - var finalmonth=a.month; + var acs = Script.getYearInfo(Script.curYear) + var a=Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear) + var finalmonth=a.month; if (a.leap) - finalmonth+=1; + finalmonth+=1; else{ - var aaa=AmLich.leapMonth(screen.curYear) - var t=-1; - - if (aaa){ - for (var i=0;i<=12;i++){ - var l=acs[i].month - if (t==l && a.leap===0){ - if (a.month>i){ - finalmonth = finalmonth+1; - break; + var aaa=Script.leapMonth(Script.curYear) + var t=-1; + + if (aaa){ + for (var i=0;i<=12;i++){ + var l=acs[i].month + if (t==l && a.leap===0){ + if (a.month>i){ + finalmonth = finalmonth+1; + break; + } + } + t=l } + } - t=l } - - } - } - + + lunaryear_model.init() + lunarday_model.init() lunaryear_model.change(a.year) lunarmonth_model.change(a.year, finalmonth) lunarday_model.change(finalmonth,a.day) - + + } + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } } -} diff --git a/qml/LichViet/Button.qml b/qml/LichViet/Button.qml index c1a24d7..d8138bc 100644 --- a/qml/LichViet/Button.qml +++ b/qml/LichViet/Button.qml @@ -15,53 +15,46 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 Item { id: container signal clicked - + property string text - property bool keyUsing: false - - BorderImage { - id: buttonImage - source: theme_manager.theme.toolbar.button_sci - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: theme_manager.theme.toolbar.button_pressed_sci - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: btnText - color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} - anchors.centerIn: buttonImage; font.bold: true - text: container.text; style: Text.Raised; styleColor: "black" - font.pixelSize: 24 - font.family: "Tahoma" - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - }, - State { - name: "Focused" - when: container.activeFocus == true - PropertyChanges { target: btnText; color: "#FFFFFF" } + + Rectangle { + anchors.fill: parent + y:parent.y + width:parent.width + height:parent.height + + radius: 4 + border.color: "grey" + + Text { + id: button1 + color: "#000000" + anchors.centerIn: parent; font.bold: true + text: container.text; style: Text.Raised; styleColor: "black" + font.pixelSize: 22 + font.family: "Tahoma" + } + + MouseArea { + id: mouseRegion + anchors.fill: parent + onClicked: { container.clicked(); } + + onPressed: { + parent.color = "blue" + } + + onReleased: { + parent.color = "white" + } + } } - ] - transitions: Transition { - ColorAnimation { target: btnText; } + } -} diff --git a/qml/LichViet/CacNgayLeTrongNam.js b/qml/LichViet/CacNgayLeTrongNam.js index 0af4c81..06db5ab 100644 --- a/qml/LichViet/CacNgayLeTrongNam.js +++ b/qml/LichViet/CacNgayLeTrongNam.js @@ -88,17 +88,17 @@ var Loi_Hay_Y_Dep = new Array( "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) { +function get(curDay, curMonth,lunarDay, lunarMonth) { var day_info = ""; for (var i=0;i */ -import QtQuick 1.0 +import QtQuick 1.1 import "Themes.js" as Themes Item{ diff --git a/qml/LichViet/DateTimeDialog.qml b/qml/LichViet/DateTimeDialog.qml index 8b9df0f..398e975 100644 --- a/qml/LichViet/DateTimeDialog.qml +++ b/qml/LichViet/DateTimeDialog.qml @@ -14,11 +14,27 @@ 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 QtQuick 1.1 import "../DatePicker/component" as Comp +import "Themes.js" as Themes +import "main.js" as Script + Item{ - id: item1 + id: datetimedlg + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:(parent.width * 1.5) + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + signal toolbar + signal updatedate(int day, int month, int year) Rectangle { id: rectangle1 @@ -38,9 +54,9 @@ Item{ Column { id: datePicker width: 260 - property int mDay: screen.curDay - property int mMonth: screen.curMonth - property int mYear: screen.curYear + property int mDay: Script.curDay + property int mMonth: Script.curMonth + property int mYear: Script.curYear anchors.centerIn: parent Comp.DateReel { @@ -56,11 +72,10 @@ Item{ text: "OK" visible: true onClicked: { - LC.reset(datePicker.mDay,datePicker.mMonth,datePicker.mYear) - screen.calculateLunar(datePicker.mDay,datePicker.mMonth,datePicker.mYear) - screen.state="mainscreen" - screen.refresh() - maindatemodel.reset() + datetimedlg.state="close"; + datetimedlg.toolbar(); + datetimedlg.updatedate(datePicker.mDay, datePicker.mMonth, datePicker.mYear) + } } @@ -72,7 +87,10 @@ Item{ height: 40 text: "X" anchors.rightMargin: 56 - onClicked: {screen.state="mainscreen";screen.refresh();} + onClicked: { + datetimedlg.state="close"; + datetimedlg.toolbar(); + } } } @@ -82,4 +100,19 @@ Item{ dateReel.year_reset() } + states: [ + State { + name: "show" + AnchorChanges { target: datetimedlg; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: datetimedlg; anchors.right: parent.left } + } + ] + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } + } diff --git a/qml/LichViet/FileBrowser.qml b/qml/LichViet/FileBrowser.qml index 4d78ec7..45ace00 100644 --- a/qml/LichViet/FileBrowser.qml +++ b/qml/LichViet/FileBrowser.qml @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 Item{ diff --git a/qml/LichViet/FullMonth.qml b/qml/LichViet/FullMonth.qml index 331b3f7..4c31568 100644 --- a/qml/LichViet/FullMonth.qml +++ b/qml/LichViet/FullMonth.qml @@ -15,227 +15,372 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 -import "../DatePicker/component" as Comp +import QtQuick 1.1 -import "amlich-hnd.js" as AmLich -import "amlich-aa98.js" as AmLich98 - -import "CacNgayLeTrongNam.js" as CNLTN +import "Themes.js" as Themes +import "main.js" as Script Item{ - id: item1 + id: fullmonth - Rectangle{ - id: fullmonthREC - anchors.fill: parent; anchors.bottomMargin: 0 - opacity:0.9 + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:-(parent.width * 1.5) - Component { - id: contactDelegate - Item { - width: grid.cellWidth; height: { - if (header) - return grid.cellHeight - 15; - else return grid.cellHeight; - } - Rectangle { - anchors.fill: parent;anchors.rightMargin: 2;anchors.topMargin: 2; - Text { color: { - if (header) - return "#000000"; - 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" - } - } + signal toolbar + signal updatedate(int day, int month, int year) - text: name; anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 21;font.bold: true;font.family: "Tahoma" - anchors.topMargin: 0; - } + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } - color: { - if (header) - return "#FAFAFF"; - else{ - if (inmonth){ - if (day==initcurDay && month==initcurMonth && year==initcurYear) - return "#00EBEB"; - else - return "lightsteelblue"; - } - else - return "#AAAAAA"; - } - } - radius: 4 - MouseArea{ - id:fullmonthMouse - anchors.fill: parent - - onClicked: { - if (index >= 7){ - LC.reset(day,month,year) - screen.calculateLunar(day,month,year) - screen.state="mainscreen" - screen.refresh() - maindatemodel.reset() - txtDATEpv.currentIndex = day-1; - } - } -onPressed:{ - if (index >= 7) - parent.color="#F0F0F0" -} + Component.onCompleted: { + reset(); + } -onReleased:{ - if (index >= 7){ - if (inmonth){ - if (day==initcurDay && month==initcurMonth && year==initcurYear) - parent.color="#00EBEB"; - else - parent.color="lightsteelblue"; - }else - parent.color="#AAAAAA"; - } -} + property int m_day: Script.curDay + property int m_month: Script.curMonth + property int m_year: Script.curYear + + property Component headerRenderer:Component { + id: defaultHeaderRenderer + + Item { + width: cellWidth + height: cellHeight + + Rectangle { + width: parent.width - 4 + height: parent.height - 4 -onCanceled:{ - if (index >= 7){ - if (inmonth) - {if (day==initcurDay && month==initcurMonth && year==initcurYear) parent.color="#00EBEB"; else parent.color="lightsteelblue";} - else - parent.color="#AAAAAA"; + anchors.centerIn: parent + + radius: 4 + color: "#FAFAFF" + } + + Text { + width: cellWidth + height: cellHeight + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + text: model.modelData + font.bold: true + font.pointSize: parent.width > parent.height ? width ? width / 6 : 1 : width / 4 + } + } } -} - } - } - } + property Component daysRenderer: + Component { + Item { + width: cellWidth + height: cellHeight + + Rectangle { + id:recms + width: parent.width - 4 + height: parent.height - 4 + + anchors.centerIn: parent + + radius: 4 + color: model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black" } - GridView { - id: grid - x: -335 - y: 41 - width:800 - height: 480 - anchors.horizontalCenterOffset: 15 - anchors.bottomMargin: -52 - anchors.topMargin: 42 - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.top: parent.top - cellWidth: 110; cellHeight: 50 - //Dung : 64 | Nam :110 - model:lmodel - delegate: contactDelegate - focus: false + Text { + id:txt_solar_day + anchors.fill: parent + anchors.leftMargin: parent.width > parent.height ? 10 : 5 + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + + text: model ? model.day : "" + color: model ? model.inmonth ? (model.current ? "grey" : model.inholiday ? theme_manager.theme.markdate.holidays : "black") : "grey" : "red" + font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 6 : 1 : parent.width / 4 + font.bold: true } - ListModel { - id:lmodel + Text { + anchors.fill: parent + anchors.leftMargin: txt_solar_day.anchors.leftMargin+ parent.width > parent.height ? 60 : 35 + anchors.topMargin: 20 - Component.onCompleted: { - reset() - } + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignBottom - function reset(){ - for(var i=0;i<42;i++){ - append({header:false,name:"",inmonths:false,day:0,month:0,year:0}) + text: model ? model.lunar_day : "" + color: model ? model.inmonth ? (model.current ? "white" : "#700070") : "grey" : "red" + font.pointSize: parent.width > parent.height ? parent.width ? parent.width / 8 : 1 : parent.width / 5 + } + + MouseArea { + id:memouse + anchors.fill: parent + + property real mX + property real mY + property bool hold: false + property bool clicked: false + + onClicked: { + if (model.inmonth){ + fullmonth.updatedate(model.day, m_month, m_year) + hold=false; + m_day = model.day; + fullmonth.state="close"; + fullmonth.toolbar(); + + }else{ + if (model.isprevmonth){ + m_month--; + if(m_month<=0){ + m_month=12; + m_year--; + } + }else{ + m_month++; + if (m_month >=13){ + m_month=1; + m_year++; + } + } + fullmonth.reset(); } } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "CN" + onPositionChanged: { + mX = mouseX; + mY = mouseY; + hold=true; + clicked=false; } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Hai" + onPressed: { + recms.color="#F0F0F0" + clicked=true; } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Ba" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Tư" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Năm" - } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Sáu" + onReleased: { + recms.color=model ? model.inmonth ? (model.current ? "blue" : "lightsteelblue") : "#AAAAAA" : "black"; + if (hold){ + if (mouseY+mY<0){ + if (Math.abs(mouseY) >= 100){ + m_month++; + if (m_month >=13){ + m_month=1; + m_year++; + } + reset(); + } + } + else + { + if (mouseY >= 100){ + m_month--; + if(m_month<=0){ + m_month=12; + m_year--; + } + reset(); + } + } + hold=false; + } } - ListElement { - header:true;inmonth:false;day:0;month:0;year:0 - name: "Bảy" + } + } + } + + Rectangle{ + id: fullmonthREC + anchors.fill: parent; anchors.bottomMargin: 0 + opacity:0.9 + + ListModel { + id: monthModel + } + + Grid { + id: grid + + anchors.topMargin: 40 + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.top: parent.top + + columns: 7 + rows: 7 + + Repeater { + model: ["CN", "Hai", "Ba", "Tư", "Năm", "Sáu", "Bảy"] + + delegate: Item { + id: headerDelegate + + width: fullmonthREC.width / grid.columns + height: (fullmonthREC.height-92) / grid.rows + + property int theIndex: index + property variant theModel: model + + Loader { + property alias model: headerDelegate.theModel + property alias index: headerDelegate.theIndex + property alias cellWidth: headerDelegate.width + property alias cellHeight: headerDelegate.height + + anchors.fill: parent + + sourceComponent: headerRenderer + } } } - Component.onCompleted: { + Repeater { + model: monthModel + + delegate: Item { + id: daysDelegate + + property int theIndex: index + property variant theModel: model + + width: fullmonthREC.width / grid.columns + height: (fullmonthREC.height-92) / grid.rows + + Loader { + property alias model: daysDelegate.theModel + property alias index: daysDelegate.theIndex + property alias cellWidth: daysDelegate.width + property alias cellHeight: daysDelegate.height + + anchors.fill: parent + + sourceComponent: daysRenderer + } + + } } + + } + } - ToolBarSingle { id: toolBar; height: 50; - y: screen.height-78 + Rectangle { + width : fullmonth.width + height: 45 + color:"white" + opacity: 0.5 + } + + Text { + id: title + + anchors { horizontalCenter: fullmonth.horizontalCenter; top: fullmonth.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: "Tháng "+fullmonth.m_month+", "+fullmonth.m_year + smooth: true + font.bold: true + } + + ToolBarSingle { + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Quay Về" - onButton1Clicked: - { - screen.state="mainscreen" + onButton1Clicked:{ + fullmonth.state="close"; + fullmonth.toolbar(); } } - states: [ - State { - name: "xemtheothang" - PropertyChanges { - target: grid - width : screen.width - height: screen.height - cellWidth: { - if (screen.width>=800) - return 110; - else - return 64; + function reset() { + monthModel.clear() + + var firstdayofthemonthyear = Script.getLunarDate(1,m_month,m_year).jd; + var startfrom = (firstdayofthemonthyear+1)%7; + var daysofthemonthyear = Script.calDays(m_month,m_year); + var j=1; + var totalslot = 42; + + var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear)) + var prevmonth = get_prevmonth(startfrom) + + var dayclick, monthclick, yearclick; + var datas1,datas,lunarclmonth,inmonth,isprevmonth; + + for (var i=0;i<42;i++){ + if (i >= startfrom && j<= daysofthemonthyear){ + dayclick = j; + monthclick = m_month; + yearclick = m_year; + inmonth = true; + isprevmonth=false; + j++; + }else{ + if (idaysofthemonthyear-startfrom;i--){ - var lunarcl = AmLich.getLunarDate(i,cMonth,cYear) + var lunarcl = Script.getLunarDate(i,cMonth,cYear) pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear}) } return pmonth.reverse() } function get_nextmonth(startfrom){ - var cMonth=screen.curMonth; - var cYear=screen.curYear; + var cMonth=m_month; + var cYear=m_year; var pmonth = []; if (cMonth==12){ cMonth = 1; @@ -244,62 +389,25 @@ onCanceled:{ cMonth++; for (var i=1;i<=startfrom;i++){ - var lunarcl = AmLich.getLunarDate(i,cMonth,cYear) + var lunarcl = Script.getLunarDate(i,cMonth,cYear) pmonth.push({duong:i, am:lunarcl.day, month:cMonth, year:cYear}); } return pmonth.reverse(); } - function reset(){ - var firstdayofthemonthyear = AmLich.getLunarDate(1,screen.curMonth,screen.curYear).jd; - var startfrom = (firstdayofthemonthyear+1)%7; - var daysofthemonthyear = LC.calDays(screen.curMonth,screen.curYear); - var j=1; - - var totalslot = 42; - - var nextmonth = get_nextmonth(totalslot - (startfrom+daysofthemonthyear)) - var prevmonth = get_prevmonth(startfrom) - - var dayclick, monthclick, yearclick; - - while(lmodel.count>7){ - lmodel.remove(lmodel.count-1); + states: [ + State { + name: "show" + AnchorChanges { target: fullmonth; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: fullmonth; anchors.right: parent.left } } + ] - var datas1,datas,lunarclmonth,inmonths; + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } - 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){ - lunarclmonth = "/"+lunarcl.month - }else{ - lunarclmonth = "" - } - - datas = j+"
  "+lunarcl.day+lunarclmonth+""; - dayclick = j; - monthclick = screen.curMonth; - yearclick = screen.curYear; - inmonths = true; - j++; - }else{ - if (realnumber
  "+datas1.am+""; - inmonths=false; - } - - lmodel.append({header:false,name:datas,inmonth:inmonths,day:dayclick,month:monthclick,year:yearclick}) - } - } } diff --git a/qml/LichViet/MenuButton.qml b/qml/LichViet/MenuButton.qml index f07330c..4a09e50 100644 --- a/qml/LichViet/MenuButton.qml +++ b/qml/LichViet/MenuButton.qml @@ -14,7 +14,7 @@ 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 QtQuick 1.1 Item { id:menubutton diff --git a/qml/LichViet/MenuScreen.qml b/qml/LichViet/MenuScreen.qml index 26f6a29..b125939 100644 --- a/qml/LichViet/MenuScreen.qml +++ b/qml/LichViet/MenuScreen.qml @@ -15,15 +15,39 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 + +import "Themes.js" as Themes Item{ id:menuscreen + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:-(parent.width * 1.5) + + signal close + signal item_click(int pos) + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + Connections { + target: menuscreen.parent + + onDialogClose: { + menuscreen.state = "close"; + menuscreen.destroy(600); + } + } + Rectangle { id: rectangle1 - anchors.fill: parent; anchors.bottomMargin: 16 + anchors.fill: parent; anchors.bottomMargin: 0; visible: true opacity:0.9 @@ -73,7 +97,7 @@ Item{ ListView { id: listView - anchors.fill: parent;anchors.topMargin: 35;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 12 + anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 55 model: listModel delegate: listDelegate focus: true @@ -81,38 +105,62 @@ Item{ } + Rectangle { + width : menuscreen.width + height: 45 + color:"white" + opacity: 0.5 + } + + Text { + id: title + + anchors { horizontalCenter: menuscreen.horizontalCenter; top: menuscreen.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: qsTr("Menu") + smooth: true + font.bold: true + } + + ToolBarSingle { - id: toolBar; height: 50; - y: screen.height-78 + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Quay Về" - onButton1Clicked: - { - screen.state="mainscreen" - } + onButton1Clicked:menuscreen.close() } + function getText(id) { - switch(id){ + /*switch(id){ case 1:screen.reset();break; case 2: screen.state="amdatetimedialog";break; case 3: screen.state="datetimedialog";break; case 4: screen.state="xemngaytotxauhoangdao";break; case 5: screen.state="xemtheothang";break; - case 6: screen.state="aboutdialog";break; + case 6: menuscreen.close();screen.state="aboutdialog";break; case 7: screen.state="changetheme";break; case 8: screen.state="filebrowser";break; - } - + }*/ + menuscreen.close(); + menuscreen.item_click(id); } - FileBrowser{ - id: fileBrowser - state:"filebrowser" - anchors.verticalCenter: parent.verticalCenter - width: parent.width; height: parent.height-60; - x: -(screen.width * 1.5) - } + states: [ + State { + name: "show" + AnchorChanges { target: menuscreen; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: menuscreen; anchors.right: parent.left } + } + ] + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } } diff --git a/qml/LichViet/MultiTitleBar.qml b/qml/LichViet/MultiTitleBar.qml index b571804..f29a5a1 100644 --- a/qml/LichViet/MultiTitleBar.qml +++ b/qml/LichViet/MultiTitleBar.qml @@ -15,21 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 Item { - TitleBar { id: titleBar; width: parent.width; height: 60; - y: -80 - untaggedString: "" - taggedString: "" + TitleBar { id: titleBar; width: parent.width; + onMinimize: ROOT.minimize(); + onClose: Qt.quit(); + + caption: "Lịch Việt" } - states: [ - State { - name: "search"; when: screen.state!="search" - PropertyChanges { target: titleBar; y: 0 } - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } - ] } diff --git a/qml/LichViet/OptionsScreen.qml b/qml/LichViet/OptionsScreen.qml index fdf9bda..e2939a2 100644 --- a/qml/LichViet/OptionsScreen.qml +++ b/qml/LichViet/OptionsScreen.qml @@ -15,11 +15,35 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 import "Settings.js" as Settings +import "Themes.js" as Themes Item{ + id:optionsscreen + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:-(parent.width * 1.5) + + signal close + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + Connections { + target: optionsscreen.parent + + onDialogClose: { + optionsscreen.state = "close"; + optionsscreen.destroy(600); + } + } + Rectangle { id: rectangle1 anchors.fill: parent; anchors.bottomMargin: 16 @@ -77,27 +101,61 @@ Item{ model: listModel delegate: listDelegate focus: true + ScrollBar{} } } - ToolBar { id: toolBar; height: 50; - y: screen.height-78 + Rectangle { + width : optionsscreen.width + height: 45 + color:"white" + opacity: 0.5 + } + + Text { + id: title + + anchors { horizontalCenter: optionsscreen.horizontalCenter; top: optionsscreen.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: "Lá»±a Chọn" + smooth: true + font.bold: true + } + + ToolBar { + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Đồng Ý" button2Label: "Hủy Bỏ" onButton1Clicked: { Settings.save(listModel) - screen.state="mainscreen" + optionsscreen.close(); var cdx = Settings.chedoxoay(); ROOT.initScreenOrientation(cdx); } onButton2Clicked: { Settings.restore(listModel) - screen.state="mainscreen" + optionsscreen.close(); } } + states: [ + State { + name: "show" + AnchorChanges { target: optionsscreen; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: optionsscreen; anchors.right: parent.left } + } + ] + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } + } } diff --git a/qml/LichViet/ScrollBar.qml b/qml/LichViet/ScrollBar.qml index 63dd0bd..da1edfb 100644 --- a/qml/LichViet/ScrollBar.qml +++ b/qml/LichViet/ScrollBar.qml @@ -1,74 +1,14 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ +import QtQuick 1.1 -import QtQuick 1.0 +Rectangle { + id: scrollbar -Item { - id: scrollBar + anchors.right: parent.right + y: parent.visibleArea.yPosition * parent.height + width: 8 + height: parent.visibleArea.heightRatio * parent.height + color: "#000000" + opacity: parent.movingVertically ? 0.5 : 0 - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } + Behavior on opacity { PropertyAnimation { properties: "opacity"; duration: 500 } } } diff --git a/qml/LichViet/Settings.js b/qml/LichViet/Settings.js index 242c91d..d08c357 100644 --- a/qml/LichViet/Settings.js +++ b/qml/LichViet/Settings.js @@ -40,6 +40,27 @@ function init_default(){ ]; } +function restore_nomodel(){ + var db = get_db(); + optsGlobal = []; + + function readEntry(json) { + var parsed = JSON.parse(json); + optsGlobal.push(parsed); + } + + db.transaction( function(tx) { + try { + var rs = tx.executeSql('SELECT * FROM Settings'); + for (var i = 0; i < rs.rows.length; i++) { + readEntry(rs.rows.item(i).json) + } + } catch (error) { + init_nomodel(); + } + } ); +} + function restore(objmodel){ var db = get_db(); objmodel.clear(); @@ -107,6 +128,14 @@ function save(obj){ store(lopts); } +function init_nomodel(){ + var listopts = init_default(); + optsGlobal = []; + for(var i=0;i< listopts.length;i++){ + optsGlobal.push(listopts[i]); + } +} + function init(obj){ var listopts = init_default(); optsGlobal = []; @@ -132,7 +161,7 @@ function chedoxoay(){ function get_opt(idm){ for(var i=0;i */ -import QtQuick 1.0 +import QtQuick 1.1 + +import "Themes.js" as Themes Item { id: container + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + // Font properties property string fontName: "Nokia Sans" property int fontSize: 18 diff --git a/qml/LichViet/Themes.js b/qml/LichViet/Themes.js index 8690364..b28e045 100644 --- a/qml/LichViet/Themes.js +++ b/qml/LichViet/Themes.js @@ -22,9 +22,3 @@ var root_dir = "/opt/usr/share/LichViet/"; function default_theme(){ return "file:"+root_dir+"themes/default/default.qml"; } - -function init(Controller, Model){ - if(Controller.pathExists(root_dir)){ - Model.append({idm:2,name: "BLACK",title:"",can_be_deleted:false,is_selected:false}) - } -} diff --git a/qml/LichViet/TitleBar.qml b/qml/LichViet/TitleBar.qml index ac7657a..b1acba1 100644 --- a/qml/LichViet/TitleBar.qml +++ b/qml/LichViet/TitleBar.qml @@ -1,122 +1,191 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 +/* +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 2 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.1 Item { - id: titleBar - property string untaggedString: " " - property string taggedString: " " - BorderImage { source: theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 } + id:title_bar + + height: 46 + width: parent.width + + opacity: 0.8 + + /* + Default value of properties + */ + + property int radius: 4 + property string border_color: "#e28282" + property string background_color: "white" + + property int shadow_height: 10 + property string shadow_begin_color: "#000000" + property string shadow_end_color: "#fff7f7" + + property string caption: "" + property string caption_color: "black" + property string caption_font: "Tahoma" + property int caption_font_size: 18 + property bool caption_font_bold : true + + /* + Signals + */ + + signal minimize + signal close + + /* + Title Bar Init + */ + + Rectangle { + id:main_title + + width: parent.width + height: parent.height + + color: parent.background_color + radius: parent.radius + border.color: parent.border_color + } + + Text { + id:title_bar_caption + + text: parent.caption + + font.bold: parent.caption_font_bold + font.pointSize: parent.caption_font_size + font.family: parent.caption_font + + color: parent.caption_color + + x:btn_minimize.width + 5*2 + y:(main_title.height/2) - (height/2) + } + + /* + Title Bar Buttons + */ + + /* + Minimize button + */ + + Rectangle { + id: btn_minimize + + x:title_bar.x + 5 + y:title_bar.y + 5 - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height + height: title_bar.height - 10 + width: 45 - function accept() { - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text + color: "transparent" + + border.color: "grey" + border.width: 1 + + radius: parent.radius + + Rectangle { + x:parent.x + y:parent.y + + width: parent.width - 15 + height: parent.height - 15 + + border.color: "white" + color: "black" + border.width: 1 } + Rectangle { + x:parent.x + 5 + y:parent.y + 5 + width: parent.width - 15 + height: parent.height - 15 - Image { - id: quitButton - x: screen.width - 50 - anchors.verticalCenter: parent.verticalCenter - source: theme_manager.theme.titlebar.button - MouseArea { - anchors.fill: parent - onPressed:{ - parent.source= theme_manager.theme.titlebar.button_pressed - } - onReleased:{ - parent.source=theme_manager.theme.titlebar.button - } - - onClicked: Qt.quit() - } + border.color: "white" + color: "black" + border.width: 1 } - Image { - id: minimizeButton - x:4 - anchors.verticalCenter: parent.verticalCenter - source: theme_manager.theme.titlebar.minimize_button - - MouseArea { - anchors.fill: parent - onPressed:{ - parent.source= theme_manager.theme.titlebar.minimize_button_pressed - } - onReleased:{ - parent.source=theme_manager.theme.titlebar.minimize_button - } - - onClicked: ROOT.minimize(); + MouseArea { + anchors.fill: parent + + onClicked: title_bar.minimize() + + onPressed: { + parent.color = "blue" + } + + onReleased: { + parent.color = "transparent" } } + } + + /* + Close button + */ + + Rectangle { + id: btn_close + + x:title_bar.width - 50 + y:title_bar.y + 5 + + width: 45 + height: title_bar.height - 10 + + color: "transparent" + + border.color: "grey" + border.width: 1 + + radius: parent.radius + Text { - id: categoryText - x:60 - anchors { - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: "Lịch Việt" - font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" - font.pixelSize: 24 + id: button1 + color: "#000000" + anchors.centerIn: parent; font.bold: true + text: "X"; style: Text.Raised; styleColor: "black" + font.pixelSize: 26 font.family: "Tahoma" } - } - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: editor; focus: true } + MouseArea { + anchors.fill: parent + + onClicked: title_bar.close() + + onPressed: { + parent.color = "blue" + } + + onReleased: { + parent.color = "transparent" + } + } } - /*transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - }*/ } diff --git a/qml/LichViet/ToolBar.qml b/qml/LichViet/ToolBar.qml index cfa4f61..d592c49 100644 --- a/qml/LichViet/ToolBar.qml +++ b/qml/LichViet/ToolBar.qml @@ -1,64 +1,57 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +/* +Copyright (C) 2011 by Cuong Le -import QtQuick 1.0 +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 2 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.1 Item { id: toolbar property alias button1Label: button1.text property alias button2Label: button2.text + signal button1Clicked signal button2Clicked - focus:true - BorderImage { source: theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 } + + Rectangle { + color:"#7373b1" + width: parent.width + height: parent.height + 14 + + radius: 4 + } + Button { - id: button1 - anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 40 - onClicked: toolbar.button1Clicked() - focus:true + id:button1 + anchors.left: parent.left + anchors.leftMargin: 5 + y: 5 + width: 140 + height: 42 + onClicked: toolbar.button1Clicked(); } + Button { - id: button2 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 40 - onClicked: toolbar.button2Clicked() + id:button2 + anchors.right: parent.right + anchors.rightMargin: 5 + y: 5 + width: 140 + height: 42 + onClicked: toolbar.button2Clicked(); } + } diff --git a/qml/LichViet/ToolBarSingle.qml b/qml/LichViet/ToolBarSingle.qml index 0225060..2607d01 100644 --- a/qml/LichViet/ToolBarSingle.qml +++ b/qml/LichViet/ToolBarSingle.qml @@ -15,19 +15,33 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 Item { - id: toolbarsingle + id: toolbar property alias button1Label: button1.text + + opacity: 0.8 + signal button1Clicked - focus:true - BorderImage { source: theme_manager.theme.titlebar.sci; width: parent.width; height: parent.height + 14; y: -7 } + + Rectangle { + color:"#7373b1" + width: parent.width + height: parent.height + 14 + + radius: 4 + } + Button { - id: button1 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 40 - onClicked: toolbarsingle.button1Clicked() - focus:true + id:button1 + anchors.right: parent.right + anchors.rightMargin: 5 + y: 5 + width: 140 + height: 42 + onClicked: toolbar.button1Clicked(); } + } diff --git a/qml/LichViet/TopBar.qml b/qml/LichViet/TopBar.qml index fc1dd1c..70f77ee 100644 --- a/qml/LichViet/TopBar.qml +++ b/qml/LichViet/TopBar.qml @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 Rectangle{ width:parent.width diff --git a/qml/LichViet/XemNgayTotXauHoangDao.qml b/qml/LichViet/XemNgayTotXauHoangDao.qml index c305e12..914304a 100644 --- a/qml/LichViet/XemNgayTotXauHoangDao.qml +++ b/qml/LichViet/XemNgayTotXauHoangDao.qml @@ -15,13 +15,34 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 +import QtQuick 1.1 -import "amlich-hnd.js" as AmLich -import "xemngaytotxau.js" as NTX +import "main.js" as Script +import "Themes.js" as Themes Item{ - id:main_item + id:xntxhd + + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height; + x:(parent.width * 1.5) + + signal close + + Loader { + id: theme_manager + property alias theme: theme_manager.item + source: Themes.default_theme() + } + + Connections { + target: xntxhd.parent + + onDialogClose: { + xntxhd.state = "close"; + xntxhd.destroy(600); + } + } property string day_month_year_LN_CN: "" property string nhi_thap_bat_tu: "" @@ -35,12 +56,8 @@ Item{ Rectangle { id: rectangle1 - x: 0 - y: -5 - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.topMargin:30 - anchors.fill: parent; anchors.bottomMargin: 16 + + anchors.fill: parent; anchors.bottomMargin: 0; visible: true opacity:0.9 @@ -66,7 +83,7 @@ Item{ } Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20 - font.family: "Tahoma";width:parent.width;} + font.family: "Tahoma";width:parent.width-10;} Rectangle{ width:rectangle1.width; @@ -117,22 +134,22 @@ Item{ ListView { id: listView - anchors.fill: parent;anchors.topMargin: 0;anchors.leftMargin: 0; anchors.bottomMargin: 16 + anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 0;anchors.rightMargin: 0;anchors.bottomMargin: 55 model: listModel delegate: listDelegate focus: true + + ScrollBar{} } } - ToolBarSingle { id: toolBar; height: 50; - y: screen.height-78 + ToolBarSingle { + id: toolBar; height: 42; + y: parent.height-52 width: parent.width; button1Label: "Quay Về" - onButton1Clicked: - { - screen.state="mainscreen" - } + onButton1Clicked:xntxhd.close() } function getHD(name,idm){ @@ -140,28 +157,63 @@ Item{ name=""+name+"
"; } + reset(); + switch(idm){ - case 0 : return name+ main_item.day_month_year_LN_CN;break; - case 1 : return name+screen.lunarGioHoangDao;break; - case 2 : return name+screen.lunarTietKhi();break; - case 3 : return name+main_item.nhi_thap_bat_tu; break; - case 5 : return name+main_item.luan_giai;break; - case -1: return name+main_item.truc;break; - case 6: return name+main_item.cac_sao_tot;break; - case 7: return name+main_item.cac_sao_xau;break; - case -2: return name+main_item.huong_xuat_hanh;break; - case 8: return main_item.warnning;break; + case 0 : return name+ xntxhd.day_month_year_LN_CN;break; + case 1 : return name+Script.lunarGioHoangDao;break; + case 2 : return name+Script.lunarTietKhi();break; + case 3 : return name+xntxhd.nhi_thap_bat_tu; break; + case 5 : return name+xntxhd.luan_giai;break; + case -1: return name+xntxhd.truc;break; + case 6: return name+xntxhd.cac_sao_tot;break; + case 7: return name+xntxhd.cac_sao_xau;break; + case -2: return name+xntxhd.huong_xuat_hanh;break; + case 8: return xntxhd.warnning;break; } } function reset(){ - main_item.day_month_year_LN_CN = AmLich.getTHU(screen.jd)+",ngày "+screen.curDay+" tháng "+screen.curMonth+" năm "+screen.curYear+"
Ngày "+screen.lunarDay+" tháng "+screen.lunarMonth+" năm "+screen.lunarYear+" ("+screen.lunarYearInt+")"; - main_item.nhi_thap_bat_tu = NTX.sao(screen.curYear,AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd - AmLich.getLunarDate(1,1,screen.curYear).jd); - main_item.truc = NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi); - main_item.cac_sao_tot = NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi); - main_item.cac_sao_xau = NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi); - main_item.luan_giai = NTX.luangiai(screen.curDay); - main_item.huong_xuat_hanh = NTX.huong_xuat_hanh(screen.lunarDayCanChi); + xntxhd.day_month_year_LN_CN = Script.thu()+",ngày "+Script.curDay+" tháng "+Script.curMonth+" năm "+Script.curYear+"
Ngày "+Script.lunarDay+" tháng "+Script.lunarMonth+" năm "+Script.lunarYear+" ("+Script.lunarYearInt+")"; + xntxhd.nhi_thap_bat_tu = Script.sao(Script.curYear,Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear).jd - Script.getLunarDate(1,1,Script.curYear).jd); + xntxhd.truc = Script.truc(Script.lunarMonth, Script.lunarDayCanChi, Script.lunarMonthCanChi); + xntxhd.cac_sao_tot = Script.cacsaotot(Script.lunarMonth, Script.lunarDayCanChi); + xntxhd.cac_sao_xau = Script.cacsaoxau(Script.lunarMonth, Script.lunarDayCanChi); + xntxhd.luan_giai = Script.luangiai(Script.curDay); + xntxhd.huong_xuat_hanh = Script.huong_xuat_hanh(Script.lunarDayCanChi); + } + + Rectangle { + width : xntxhd.width + height: 45 + color:"white" + opacity: 0.5 + } + + Text { + id: title + + anchors { horizontalCenter: xntxhd.horizontalCenter; top: xntxhd.top; topMargin: 10 } + font.pixelSize: 22 + color: "black" + text: "Xem Ngày Tốt/Xấu" + smooth: true + font.bold: true + } + + states: [ + State { + name: "show" + AnchorChanges { target: xntxhd; anchors.right: parent.right } + }, + State { + name: "close" + AnchorChanges { target: xntxhd; anchors.right: parent.left } + } + ] + + transitions: Transition { + AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } } } diff --git a/qml/LichViet/main.js b/qml/LichViet/main.js new file mode 100644 index 0000000..fce97ab --- /dev/null +++ b/qml/LichViet/main.js @@ -0,0 +1,145 @@ +.pragma library + +Qt.include("amlich-hnd.js"); +Qt.include("amlich-aa98.js"); +Qt.include("Settings.js"); +Qt.include("Themes.js"); +Qt.include("CacNgayLeTrongNam.js"); +Qt.include("xemngaytotxau.js"); + +var localdate = new Date(); + +var curDay=localdate.getDate(); +var curMonth=localdate.getMonth()+1; +var curYear=localdate.getFullYear(); + +var initcurDay; +var initcurMonth; +var initcurYear; + +var lunarDay = getLunarDate(curDay,curMonth,curYear).day; +var lunarMonth = getLunarDate(curDay,curMonth,curYear).month; +var lunarYear = getCanChi(getLunarDate(curDay,curMonth,curYear))[2]; +var lunarYearInt = getLunarDate(curDay,curMonth,curYear).year; +var jd = getLunarDate(curDay,curMonth,curYear).jd; +var lunarGioHoangDao = getGioHoangDao(jd); + +var lunarDayCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[0]; +var lunarMonthCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[1]; + +var day_info = get(curDay,curMonth, curYear, lunarDay, lunarMonth); +var isholiday = is_holiday(curDay,curMonth, curYear, lunarDay, lunarMonth); + +var datetimedlg; +var amdatetimedlg; +var fullmonth; + +function init(){ + initcurDay = curDay; + initcurMonth = curMonth; + initcurYear = curYear; +} + +function day_reset(){ + curDay = initcurDay; +} + +function calDays(){ + if (curMonth == 4 || curMonth == 6 || curMonth == 9 || curMonth == 11) + return 30; + else + if (curMonth == 2){ + var isLeapYear = (curYear % 4 === 0 && curYear % 100 !== 0) || (curYear % 400 ===0); + if (isLeapYear) + return 29; + else + return 28; + } + return 31; +} + +function calDaysX(month, year){ + if (month == 4 || month == 6 || month == 9 || month == 11) + return 30; + else + if (month == 2){ + var isLeapYear = (year % 4 === 0 && year % 100 !== 0) || (year % 400 ===0); + if (isLeapYear) + return 29; + else + return 28; + } + return 31; +} + +function thu(){ + return getTHU(jd); +} + +function lunarTietKhi(){ + return TIETKHI[getSunLongitude(jd+1,7.0)]; +} + +function reset_to_default_day(txtTHU, txtInfo, txtDAYAmLich){ + localdate = new Date(); + + curDay=localdate.getDate(); + curMonth=localdate.getMonth()+1; + curYear=localdate.getFullYear(); + + changeDay(curDay, txtTHU, txtInfo, txtDAYAmLich); +} + +function changeDay(newday, txtTHU, txtInfo, txtDAYAmLich){ + curDay = newday; + recalculate(); + + txtTHU.text=__txtTHU_format(); + txtInfo.text=__txtInfo_format(); + txtDAYAmLich.text=__txtDAYAmLich_format(); +} + +function createDateTimeDialog(parent){ + datetimedlg = createObject("DateTimeDialog.qml", parent); + amdatetimedlg = createObject("AmDateTimeDialog.qml", parent); + fullmonth = createObject("FullMonth.qml", parent); +} + +function __txtTHU_format(){ + return getTHU(jd); +} + +function __txtInfo_format(){ + return day_info; +} + +function __txtDAYAmLich_format(){ + return "Ngày "+lunarDay+" ("+lunarDayCanChi+")
Tháng "+lunarMonth+" ("+lunarMonthCanChi+")
Năm "+lunarYearInt+" ("+lunarYear+")"; +} + +function recalculate(){ + lunarDay = getLunarDate(curDay,curMonth,curYear).day; + lunarMonth = getLunarDate(curDay,curMonth,curYear).month; + lunarYear = getCanChi(getLunarDate(curDay,curMonth,curYear))[2]; + lunarYearInt = getLunarDate(curDay,curMonth,curYear).year; + jd = getLunarDate(curDay,curMonth,curYear).jd; + lunarGioHoangDao = getGioHoangDao(jd); + + lunarDayCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[0]; + lunarMonthCanChi = getCanChi(getLunarDate(curDay,curMonth,curYear))[1]; + + day_info = get(curDay,curMonth, lunarDay, lunarMonth); + isholiday = is_holiday(curDay,curMonth, curYear, lunarDay, lunarMonth); +} + +function createObject(sourceFile, parentObject) { + var component = Qt.createComponent(sourceFile); + var guiObject = component.createObject(parentObject); + + if (guiObject === null) { + console.log("Error creating object"); + } + else { + return guiObject + } +} diff --git a/qml/LichViet/main.qml b/qml/LichViet/main.qml index 805f0a0..74af3b6 100644 --- a/qml/LichViet/main.qml +++ b/qml/LichViet/main.qml @@ -15,42 +15,23 @@ You should have received a copy of the GNU General Public License along with this program. If not, see */ -import QtQuick 1.0 -import "amlich-hnd.js" as AmLich -import "amlich-aa98.js" as AmLich98 +import QtQuick 1.1 -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 @@ -58,14 +39,46 @@ Item { source: Themes.default_theme() } + Component.onCompleted: { + Settings.restore_nomodel(); + Script.createDateTimeDialog(screen); + Script.datetimedlg.toolbar.connect(show_toolbar); + Script.datetimedlg.updatedate.connect(update_date); + Script.amdatetimedlg.toolbar.connect(show_toolbar); + Script.amdatetimedlg.updatedate.connect(update_date); + 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); + Script.fullmonth.m_day=Script.curDay; + Script.fullmonth.m_month=Script.curMonth; + Script.fullmonth.m_year=Script.curYear; + Script.fullmonth.reset(); + } + Rectangle { - id: background + id: mecal anchors.fill: parent - color: "#343434" + color: "white" state:"jumptodate" + Image { - source: theme_manager.theme.background_image; fillMode: Image.Stretch; anchors.fill: parent; opacity: 0.3 + source: theme_manager.theme.background_image; fillMode: Image.Stretch; anchors.fill: parent + opacity: theme_manager.theme.background_opacity } @@ -81,35 +94,19 @@ Item { onPressAndHold:{ if (Settings.pressandhold()==1){ - screen.state="xemngaytotxauhoangdao" + menu_item_Clicked(4); } } onDoubleClicked:{ if (Settings.doubleclicked()==1){ - screen.state="datetimedialog" + screen.state="switchX"; + Script.datetimedlg.state="show"; } } } - Text { - id: txtDMY - x: 140 - y: 77 - width: 80 - height: 20 - color: "#29d999" - textFormat: Text.RichText - text: "Tháng "+screen.curMonth+" Năm "+screen.curYear+"" - anchors.horizontalCenter: parent.horizontalCenter - font.bold: false - font.family: "Tahoma" - smooth: true - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 28 - } - //------------------------------------------------ Rectangle { @@ -133,11 +130,11 @@ Item { 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])){ + var stemp = Script.convertSolar2Lunar(txtDATEpv.currentIndex+1,curMonth,curYear,7); + if (Script.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; + var mark_day = (Script.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 @@ -160,9 +157,9 @@ Item { delegate: delegate pathItemCount: 3 clip: true + Keys.onLeftPressed: decrementCurrentIndex() + Keys.onRightPressed: incrementCurrentIndex() highlightMoveDuration:500 - Keys.onDownPressed: if (!moving && interactive) incrementCurrentIndex() - Keys.onUpPressed: if (!moving && interactive) decrementCurrentIndex() preferredHighlightBegin: 0.5 preferredHighlightEnd: 0.5 highlightRangeMode: PathView.StrictlyEnforceRange @@ -181,11 +178,17 @@ Item { startY: 50 PathLine {x: reelx.width; y: 50} } - onFlickEnded : { + + onMovementStarted:{ + } onMovementEnded: { - calculateLunar(txtDATEpv.currentIndex+1, LC.curMonth(), LC.curYear()) + Script.changeDay(txtDATEpv.currentIndex+1, txtTHU, txtInfo, txtDAYAmLich); + Script.fullmonth.m_day=Script.curDay; + Script.fullmonth.m_month=Script.curMonth; + Script.fullmonth.m_year=Script.curYear; + Script.fullmonth.reset(); } } } @@ -193,7 +196,7 @@ Item { 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; @@ -210,29 +213,43 @@ Item { 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: 151 + y: 77 + height: 20 + color: "#29d999" + text: "Tháng "+screen.curMonth+" Năm "+screen.curYear+"" + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + font.bold: false + font.family: "Tahoma" + smooth: true + 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 @@ -244,10 +261,9 @@ Item { 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 + 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 @@ -260,10 +276,9 @@ Item { id: txtDAYAmLich x: 151 y: 330 - width: 80 height: 20 - color: "#f0f0f5" - text: "Ngày "+screen.lunarDay+" ("+screen.lunarDayCanChi+")
Tháng "+screen.lunarMonth+" ("+screen.lunarMonthCanChi+")
Năm "+screen.lunarYearInt+" ("+screen.lunarYear+")" + color: theme_manager.theme.markdate.lunardate + text: Script.__txtDAYAmLich_format() horizontalAlignment: Text.AlignHCenter anchors.horizontalCenter: parent.horizontalCenter opacity: 0.6 @@ -271,243 +286,83 @@ Item { 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 = ""; + if (id!=1) + screen.state="switchX"; + switch(id){ + case 1: Script.reset_to_default_day(txtTHU, txtInfo, txtDAYAmLich); + txtDATEpv.currentIndex = Script.curDay-1; + screen.curMonth = Script.curMonth; + screen.curYear = Script.curYear; + Script.fullmonth.m_day= Script.curDay-1; + Script.fullmonth.m_month= Script.curMonth; + Script.fullmonth.m_year= Script.curYear; + break; + 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;} - 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;} + name: "switchX"; + PropertyChanges { target: titleBar; y: -50 } 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) - LC.reset(initcurDay, initcurMonth, initcurYear) - screen.state="mainscreen" - maindatemodel.reset() - txtDATEpv.currentIndex = initcurDay-1; - } - - function refresh(){ - - } - - Component.onCompleted: { - amdatetimeDialog.reset() - maindatemodel.init() - } - } diff --git a/qml/themes/default/background.jpg b/qml/themes/default/background.jpg index c61f523..da5eafe 100644 Binary files a/qml/themes/default/background.jpg and b/qml/themes/default/background.jpg differ diff --git a/qml/themes/default/default.qml b/qml/themes/default/default.qml index c9e2466..30f4928 100644 --- a/qml/themes/default/default.qml +++ b/qml/themes/default/default.qml @@ -2,43 +2,15 @@ import QtQuick 1.0 Item { id:theme - 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 root_dir : "file:/opt/usr/share/LichViet/themes/default/" property string background_image: root_dir+"background.jpg" + property real background_opacity: 1.0 property string switch_on: root_dir+"switch_on.png" property string switch_off: root_dir+"switch_off.png" - Item{ - id:titlebar - property string button: root_dir+"quit.png" - property string button_pressed: root_dir+"quit_pressed.png" - property string button_active: root_dir+"quit.png" - property string sci: root_dir+"titlebar.sci" - - property string minimize_button: root_dir+"minimize.png" - property string minimize_button_pressed: root_dir+"minimize_pressed.png" - } - - Item{ - id:toolbar - property string sci: root_dir+"titlebar.sci" - property string button_sci: root_dir+"toolbutton.sci" - property string button_pressed_sci: root_dir+"toolbutton_pressed.sci" - property string button_active_sci: root_dir+"toolbutton.sci" - } - - Item{ - id:datepicker - property string button: root_dir+"dp_button.png" - 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" @@ -46,6 +18,7 @@ Item { property string otherday:"grey" property string otherday_selected:"#FFFFFF" property string holidays:"yellow" - property string not_holidays:"#FFFF99" + property string not_holidays:"#FFFF99" + property string lunardate:"white" } } diff --git a/qml/themes/default/dp_button.png b/qml/themes/default/dp_button.png deleted file mode 100644 index fcdc4ff..0000000 Binary files a/qml/themes/default/dp_button.png and /dev/null differ diff --git a/qml/themes/default/dp_button_active.png b/qml/themes/default/dp_button_active.png deleted file mode 100644 index 604d829..0000000 Binary files a/qml/themes/default/dp_button_active.png and /dev/null differ diff --git a/qml/themes/default/dp_button_pressed.png b/qml/themes/default/dp_button_pressed.png deleted file mode 100644 index 162b194..0000000 Binary files a/qml/themes/default/dp_button_pressed.png and /dev/null differ diff --git a/qml/themes/default/gloss.png b/qml/themes/default/gloss.png deleted file mode 100644 index 5d370cd..0000000 Binary files a/qml/themes/default/gloss.png and /dev/null differ diff --git a/qml/themes/default/lineedit.png b/qml/themes/default/lineedit.png deleted file mode 100644 index 2cc38dc..0000000 Binary files a/qml/themes/default/lineedit.png and /dev/null differ diff --git a/qml/themes/default/lineedit.sci b/qml/themes/default/lineedit.sci deleted file mode 100644 index 054bff7..0000000 --- a/qml/themes/default/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/qml/themes/default/minimize.png b/qml/themes/default/minimize.png deleted file mode 100644 index 9568fbc..0000000 Binary files a/qml/themes/default/minimize.png and /dev/null differ diff --git a/qml/themes/default/minimize_pressed.png b/qml/themes/default/minimize_pressed.png deleted file mode 100644 index 1856670..0000000 Binary files a/qml/themes/default/minimize_pressed.png and /dev/null differ diff --git a/qml/themes/default/quit.png b/qml/themes/default/quit.png deleted file mode 100644 index 69dc1b8..0000000 Binary files a/qml/themes/default/quit.png and /dev/null differ diff --git a/qml/themes/default/quit_pressed.png b/qml/themes/default/quit_pressed.png deleted file mode 100644 index 972ece5..0000000 Binary files a/qml/themes/default/quit_pressed.png and /dev/null differ diff --git a/qml/themes/default/stripes.png b/qml/themes/default/stripes.png deleted file mode 100644 index 9f36727..0000000 Binary files a/qml/themes/default/stripes.png and /dev/null differ diff --git a/qml/themes/default/titlebar.png b/qml/themes/default/titlebar.png deleted file mode 100644 index 51c9008..0000000 Binary files a/qml/themes/default/titlebar.png and /dev/null differ diff --git a/qml/themes/default/titlebar.sci b/qml/themes/default/titlebar.sci deleted file mode 100644 index 0418d94..0000000 --- a/qml/themes/default/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/qml/themes/default/toolbutton-back.png b/qml/themes/default/toolbutton-back.png deleted file mode 100644 index 1131001..0000000 Binary files a/qml/themes/default/toolbutton-back.png and /dev/null differ diff --git a/qml/themes/default/toolbutton.png b/qml/themes/default/toolbutton.png deleted file mode 100644 index 9ecc83b..0000000 Binary files a/qml/themes/default/toolbutton.png and /dev/null differ diff --git a/qml/themes/default/toolbutton.sci b/qml/themes/default/toolbutton.sci deleted file mode 100644 index 9e4f965..0000000 --- a/qml/themes/default/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/qml/themes/default/toolbutton_pressed.png b/qml/themes/default/toolbutton_pressed.png deleted file mode 100644 index 4d2969f..0000000 Binary files a/qml/themes/default/toolbutton_pressed.png and /dev/null differ diff --git a/qml/themes/default/toolbutton_pressed.sci b/qml/themes/default/toolbutton_pressed.sci deleted file mode 100644 index 95a4502..0000000 --- a/qml/themes/default/toolbutton_pressed.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton_pressed.png diff --git a/qtc_packaging/debian_fremantle/README b/qtc_packaging/debian_fremantle/README old mode 100644 new mode 100755 diff --git a/qtc_packaging/debian_fremantle/changelog b/qtc_packaging/debian_fremantle/changelog old mode 100644 new mode 100755 index 9ccfe2a..d31866f --- a/qtc_packaging/debian_fremantle/changelog +++ b/qtc_packaging/debian_fremantle/changelog @@ -1,5 +1,5 @@ -lichviet (1.0.2-3) unstable-develop; urgency=low +lichviet (1.0.2-4) unstable-develop; urgency=low - * Fixes for pathview date component (slowly in date switching) + * Fixes for month view - -- Cuong Le Thu, 27 Aug 2011 14:40:37 +0700 + -- Cuong Le Thu, 13 Sep 2011 14:40:37 +0700 diff --git a/qtc_packaging/debian_fremantle/compat b/qtc_packaging/debian_fremantle/compat old mode 100644 new mode 100755 diff --git a/qtc_packaging/debian_fremantle/control b/qtc_packaging/debian_fremantle/control old mode 100644 new mode 100755 index 3b9f7b3..fccfa3a --- a/qtc_packaging/debian_fremantle/control +++ b/qtc_packaging/debian_fremantle/control @@ -8,7 +8,7 @@ Homepage: http://lichviet.garage.maemo.org Package: lichviet Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, mcsp, qtquickcompat +Depends: ${shlibs:Depends}, ${misc:Depends} Description: VietNamese Lunar Calendar XSBC-Maemo-Display-Name: Lich Viet XSBC-Bugtracker: https://garage.maemo.org/tracker/?group_id=2235 diff --git a/qtc_packaging/debian_fremantle/copyright b/qtc_packaging/debian_fremantle/copyright old mode 100644 new mode 100755