From 5e2b3c9e7b8302cf58a799cdfc718fc7137abd21 Mon Sep 17 00:00:00 2001 From: Cuong Le Date: Thu, 15 Sep 2011 21:52:03 +0700 Subject: [PATCH] * Fixes for ScrollBar --- qml/LichViet/About.qml | 144 ++++----- qml/LichViet/AmDateTimeDialog.qml | 596 +++++++++++++++++-------------------- qml/LichViet/Button.qml | 23 +- 3 files changed, 355 insertions(+), 408 deletions(-) diff --git a/qml/LichViet/About.qml b/qml/LichViet/About.qml index bc11951..b9e696d 100644 --- a/qml/LichViet/About.qml +++ b/qml/LichViet/About.qml @@ -19,136 +19,136 @@ import QtQuick 1.0 import "Themes.js" as Themes Item{ - + 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 + width: 80 + 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: text3 + id: text1 + x: 11 + y: 171 + width: 80 + 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: text2 x: 10 - y: 261 + y: 234 width: 80 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 + } + + } - } - - Text { - id: text1 - x: 11 - y: 171 - width: 80 - height: 20 - text: "Lịch Âm Việt Nam
OS: Maemo 5" - anchors.horizontalCenterOffset: 1 - 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-4 (13/09/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 - } - - -} Rectangle { width : aboutdlg.width height: 45 color:"white" opacity: 0.5 - } - + } + Text { id: title - + anchors { horizontalCenter: aboutdlg.horizontalCenter; top: aboutdlg.top; topMargin: 10 } font.pixelSize: 22 color: "black" text: qsTr("About") smooth: true font.bold: true - } - - + } + + ToolBarSingle { id: toolBar; height: 42; y: parent.height-52 width: parent.width; button1Label: "Quay Về" 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 2cafdd2..33d24ec 100644 --- a/qml/LichViet/AmDateTimeDialog.qml +++ b/qml/LichViet/AmDateTimeDialog.qml @@ -23,20 +23,20 @@ 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 @@ -49,44 +49,44 @@ Item{ border.color: "#b57e8f" visible: true opacity:0.9 - + Button { id: button2 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; - + + 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]) - + + amdatetime.state="close"; + amdatetime.toolbar(); + amdatetime.updatedate(finalSolarDay[0], finalSolarDay[1], finalSolarDay[2]) + + } } - } - + Button { id: button3 x: 413 @@ -98,9 +98,9 @@ Item{ onClicked: { amdatetime.state="close" amdatetime.toolbar() + } } - } - + Rectangle { id: rec22 x: 23 @@ -112,15 +112,15 @@ Item{ GradientStop { position: 0 color: "#ffffff" - } - + } + GradientStop { position: 0.1 color: "#7c6969" + } } - } border.color: "#b57e8f" - + Rectangle { id:lmk x: 207 @@ -130,25 +130,25 @@ 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"; @@ -159,7 +159,7 @@ Item{ 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;} @@ -169,7 +169,7 @@ Item{ 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;} @@ -179,8 +179,8 @@ Item{ PropertyChanges { target:lunarday_mousearea;visible:true;} PropertyChanges { target:lunaryear_mousearea;visible:true;} PropertyChanges { target:lunarmonth_mousearea;visible:false;} - }] - + }] + /**LUNAR YEAR**/ Rectangle { id:lunaryear_rec @@ -189,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 { @@ -214,351 +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) - Script.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: { rec22.state="switch_to_year" + } } } - } - + ListModel { id:lunaryear_model - Component.onCompleted: { - //init() - } function init(){ for(var i=1900;i<2099;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: { - rec22.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: { - - } - - function init(){ - for(var i=1;i<=30;i++) - lunarday_model.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) - } - - - 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}) - + + function change(MM,DD){ + + while(lunarday_model.count>0){ + lunarday_model.remove(lunarday_model.count-1) } - - /*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=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 - } - - }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=-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: "show" AnchorChanges { target: amdatetime; anchors.right: parent.right } - }, + }, State { name: "close" AnchorChanges { target: amdatetime; anchors.right: parent.left } - } - ] - + } + ] + function reset(){ var acs = Script.getYearInfo(Script.curYear) var a=Script.getLunarDate(Script.curDay,Script.curMonth,Script.curYear) - var finalmonth=a.month; + var finalmonth=a.month; if (a.leap) - finalmonth+=1; + finalmonth+=1; else{ - 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; + 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 662c714..20563aa 100644 --- a/qml/LichViet/Button.qml +++ b/qml/LichViet/Button.qml @@ -21,19 +21,18 @@ Item { id: container signal clicked - + property string text - + Rectangle { - anchors.fill: parent y:parent.y width:parent.width height:parent.height - + radius: 4 border.color: "grey" - + Text { id: button1 color: "#000000" @@ -41,21 +40,21 @@ Item { 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" + } } } + } - -} -- 1.7.9.5