From: Cuong Le Date: Wed, 24 Aug 2011 17:40:00 +0000 (+0700) Subject: Added minimize button and event handler X-Git-Tag: v1.0.2-4~6^2 X-Git-Url: http://git.maemo.org/git/?p=lichviet;a=commitdiff_plain;h=c9c55fd162c91c5adb4e194a556417ac5cfda611;ds=sidebyside Added minimize button and event handler --- diff --git a/LichViet.pro b/LichViet.pro index 5e1e4da..77f3e01 100644 --- a/LichViet.pro +++ b/LichViet.pro @@ -8,6 +8,7 @@ themes_qml.source = qml/themes themes_qml.target = / DEPLOYMENTFOLDERS = themes_qml +QT += dbus # Additional import path used to resolve QML modules in Creator's code model #QML_IMPORT_PATH = diff --git a/Makefile b/Makefile index d2eaf80..5690bd6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: LichViet -# Generated by qmake (2.01a) (Qt 4.7.3) on: Wed Aug 24 08:25:07 2011 +# Generated by qmake (2.01a) (Qt 4.7.3) on: Thu Aug 25 00:22:47 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 @@ -10,13 +10,13 @@ CC = gcc CXX = g++ -DEFINES = -DAPP_VERSION=\"1.0.2\" -DQT_NO_DEBUG -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_CORE_LIB +DEFINES = -DAPP_VERSION=\"1.0.2\" -DQT_NO_DEBUG -DQT_DECLARATIVE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_CORE_LIB CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) -INCPATH = -I/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 -I. -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtDeclarative -I/opt/QtSDK/Desktop/Qt/473/gcc/include -Iqmlapplicationviewer -I. +INCPATH = -I/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64 -I. -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtCore -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtGui -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtDBus -I/opt/QtSDK/Desktop/Qt/473/gcc/include/QtDeclarative -I/opt/QtSDK/Desktop/Qt/473/gcc/include -Iqmlapplicationviewer -I. LINK = g++ LFLAGS = -m64 -Wl,-O1 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/473/gcc/lib -LIBS = $(SUBLIBS) -L/opt/QtSDK/Desktop/Qt/473/gcc/lib -lQtDeclarative -lQtGui -lQtCore -lpthread +LIBS = $(SUBLIBS) -L/opt/QtSDK/Desktop/Qt/473/gcc/lib -lQtDeclarative -lQtDBus -lQtGui -lQtCore -lpthread AR = ar cqs RANLIB = QMAKE = /opt/QtSDK/Desktop/Qt/473/gcc/bin/qmake @@ -68,8 +68,10 @@ DIST = /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/common/g++.conf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/default_post.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/warn_on.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/qt.prf \ - /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/moc.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusinterfaces.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusadaptors.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/resources.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/uic.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/yacc.prf \ @@ -121,8 +123,10 @@ Makefile: LichViet.pro /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/linux-g++-64/qmake /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/default_post.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/warn_on.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/qt.prf \ - /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/moc.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusinterfaces.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusadaptors.prf \ + /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/resources.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/uic.prf \ /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/yacc.prf \ @@ -143,8 +147,10 @@ qmlapplicationviewer/qmlapplicationviewer.pri: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/default_post.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/warn_on.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/qt.prf: -/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/moc.prf: +/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusinterfaces.prf: +/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/dbusadaptors.prf: +/opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/unix/thread.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/resources.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/uic.prf: /opt/QtSDK/Desktop/Qt/473/gcc/mkspecs/features/yacc.prf: @@ -190,6 +196,10 @@ moc_qmlapplicationviewer.cpp: qmlapplicationviewer/qmlapplicationviewer.h moc_lunarcalendar.cpp: lunarcalendar.h /opt/QtSDK/Desktop/Qt/473/gcc/bin/moc $(DEFINES) $(INCPATH) lunarcalendar.h -o moc_lunarcalendar.cpp +compiler_dbus_interface_source_make_all: +compiler_dbus_interface_source_clean: +compiler_dbus_adaptor_source_make_all: +compiler_dbus_adaptor_source_clean: compiler_rcc_make_all: qrc_lichviet.cpp compiler_rcc_clean: -$(DEL_FILE) qrc_lichviet.cpp @@ -225,6 +235,14 @@ compiler_image_collection_clean: -$(DEL_FILE) qmake_image_collection.cpp compiler_moc_source_make_all: compiler_moc_source_clean: +compiler_dbus_interface_header_make_all: +compiler_dbus_interface_header_clean: +compiler_dbus_interface_moc_make_all: +compiler_dbus_interface_moc_clean: +compiler_dbus_adaptor_header_make_all: +compiler_dbus_adaptor_header_clean: +compiler_dbus_adaptor_moc_make_all: +compiler_dbus_adaptor_moc_clean: compiler_uic_make_all: compiler_uic_clean: compiler_yacc_decl_make_all: diff --git a/main.cpp b/main.cpp index 4e3c667..59e8d84 100644 --- a/main.cpp +++ b/main.cpp @@ -40,7 +40,6 @@ int main(int argc, char *argv[]) viewer.rootContext()->setContextProperty("LC", &lc); viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - //viewer.setMainQmlFile(QLatin1String("qml/LichViet/main.qml")); viewer.setSource(QUrl("qrc:/qml/LichViet/main.qml")); viewer.setWindowTitle(QString::fromUtf8("Lịch Việt")); diff --git a/qml/LichViet/TitleBar.qml b/qml/LichViet/TitleBar.qml index 651cf69..ac7657a 100644 --- a/qml/LichViet/TitleBar.qml +++ b/qml/LichViet/TitleBar.qml @@ -77,14 +77,33 @@ Item { } } + 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(); + } + } + Text { id: categoryText - x:10 + x:60 anchors { verticalCenter: parent.verticalCenter } elide: Text.ElideLeft - text: "Lịch Âm" + text: "Lịch Việt" font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" font.pixelSize: 24 font.family: "Tahoma" diff --git a/qml/LichViet/XemNgayTotXauHoangDao.qml b/qml/LichViet/XemNgayTotXauHoangDao.qml index 512680b..cfe9aae 100644 --- a/qml/LichViet/XemNgayTotXauHoangDao.qml +++ b/qml/LichViet/XemNgayTotXauHoangDao.qml @@ -34,28 +34,35 @@ Item{ Component { id: listDelegate - Item { - height: lheight+5 - Rectangle { - width:rectangle1.width-20; - y:10; - x:10 - height:lheight - color: "#ffffff" - radius: 8 - border.color: "#b57e8f" + Column { - Text { x:5;y:50;text:name;color:"blue"; font.pixelSize: 20 - font.family: "Tahoma" } - Text { x:5;y:50;text:getHD(idm) ; font.pixelSize: 20 - font.family: "Tahoma"} - } anchors.bottomMargin: -10 - } - } - } + Rectangle { + width:rectangle1.width; + y:30; + x:0 + height:1 + border.color: "#b57e8f" + } + width:rectangle1.width + Rectangle{ + width:rectangle1.width; + height:10; + } + + Text { x:5;y:50;text:getHD(name,idm) ;textFormat: Text.RichText;wrapMode: Text.WordWrap; font.pixelSize: 20 + font.family: "Tahoma";width:parent.width;} + + Rectangle{ + width:rectangle1.width; + height:10; + } + } + + + } ListModel { id: listModel @@ -108,17 +115,21 @@ Item{ } } - function getHD(idm){ + function getHD(name,idm){ + if (name.length){ + name=""+name+"
"; + } + NTX.test(); switch(idm){ - case 0 : return 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+")";break; - case 1 : return screen.lunarGioHoangDao;break; - case 2 : return screen.lunarTietKhi();break; - case 3 : return NTX.sao(screen.curYear,AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd - AmLich.getLunarDate(1,1,screen.curYear).jd);break; - case 5 : return NTX.luangiai(screen.curDay);break; - case -1: return NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi);break;//"Là ngày: Thiên Lao Hắc Đạo Trực: Định" - case 6: return NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi);break; - case 7: return NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi);break; + case 0 : return name+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+")";break; + case 1 : return name+screen.lunarGioHoangDao;break; + case 2 : return name+screen.lunarTietKhi();break; + case 3 : return name+NTX.sao(screen.curYear,AmLich.getLunarDate(screen.curDay,screen.curMonth,screen.curYear).jd - AmLich.getLunarDate(1,1,screen.curYear).jd);break; + case 5 : return name+NTX.luangiai(screen.curDay);break; + case -1: return name+NTX.truc(screen.lunarMonth, screen.lunarDayCanChi, screen.lunarMonthCanChi);break;//"Là ngày: Thiên Lao Hắc Đạo Trực: Định" + case 6: return name+NTX.cacsaotot(screen.lunarMonth, screen.lunarDayCanChi);break; + case 7: return name+NTX.cacsaoxau(screen.lunarMonth, screen.lunarDayCanChi);break; } } diff --git a/qml/LichViet/main.qml b/qml/LichViet/main.qml index 99ca088..599d5cf 100644 --- a/qml/LichViet/main.qml +++ b/qml/LichViet/main.qml @@ -75,7 +75,7 @@ Item { property int fixed: 40 property int rise: 0 - anchors.fill: parent + anchors.fill: parent;anchors.topMargin: 60;anchors.bottomMargin:60; onPressAndHold:{ if (Settings.pressandhold()==1){ @@ -89,23 +89,6 @@ Item { screen.state="datetimedialog" } } - - /* onPressed: { - xfrom=mouseX; - yfrom=mouseY; - } - - onReleased : { - rise = mouseX - xfrom - if (rise > fixed || rise < -fixed){ - if (mouseX < xfrom){ - calculateLunar(LC.nextDay(), LC.curMonth(), LC.curYear()) - }else{ - calculateLunar(LC.prevDay(), LC.curMonth(), LC.curYear()) - } - } - - }*/ } Text { @@ -124,23 +107,6 @@ Item { font.pixelSize: 28 } - /* - Text { - id: txtDAY - x: 151 - y: 126 - width: 80 - height: 20 - color: "#f0f0f5" - text: screen.curDay - horizontalAlignment: Text.AlignHCenter - anchors.horizontalCenter: parent.horizontalCenter - opacity: 0.6 - font.bold: true - font.pixelSize: 80 - } -*/ - //------------------------------------------------ Rectangle { @@ -424,8 +390,6 @@ Item { 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] - //console.log(screen.curDay+" "+screen.curMonth+" "+screen.curYear) - //console.log( AmLich.getCanChi(AmLich.getLunarDate(30,1,2007))) } function reset(){ diff --git a/qml/themes/default/default.qml b/qml/themes/default/default.qml index c38a499..1edd266 100644 --- a/qml/themes/default/default.qml +++ b/qml/themes/default/default.qml @@ -18,6 +18,9 @@ Item { 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{ diff --git a/qml/themes/default/minimize.png b/qml/themes/default/minimize.png new file mode 100644 index 0000000..54a93af Binary files /dev/null and b/qml/themes/default/minimize.png differ diff --git a/qml/themes/default/minimize_pressed.png b/qml/themes/default/minimize_pressed.png new file mode 100644 index 0000000..1856670 Binary files /dev/null and b/qml/themes/default/minimize_pressed.png differ diff --git a/qmlapplicationviewer/qmlapplicationviewer.cpp b/qmlapplicationviewer/qmlapplicationviewer.cpp index e28f583..d3901bd 100644 --- a/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -17,6 +17,10 @@ #include #include +#include +#include +#include + #if defined(QMLJSDEBUGGER) #include #endif @@ -160,3 +164,9 @@ void QmlApplicationViewer::initScreenOrientation(int OO){ else this->setOrientation(this->ScreenOrientationLockLandscape); } + +void QmlApplicationViewer::minimize(){ + QDBusConnection c = QDBusConnection::sessionBus(); + QDBusMessage m = QDBusMessage::createSignal("/", "com.nokia.hildon_desktop", "exit_app_view"); + c.send(m); +} diff --git a/qmlapplicationviewer/qmlapplicationviewer.h b/qmlapplicationviewer/qmlapplicationviewer.h index 6eaf6b8..e22f909 100644 --- a/qmlapplicationviewer/qmlapplicationviewer.h +++ b/qmlapplicationviewer/qmlapplicationviewer.h @@ -33,6 +33,7 @@ public: void showExpanded(); Q_INVOKABLE void initScreenOrientation(int); + Q_INVOKABLE void minimize(); private: class QmlApplicationViewerPrivate *m_d;