main
朱子楚\zhuzi 2023-03-21 23:52:29 +08:00
parent 5fcd95611f
commit 83f97159e9
2 changed files with 171 additions and 57 deletions

View File

@ -29,29 +29,35 @@ Item {
return {type:1,date:date} return {type:1,date:date}
} }
function createItemMonth(name){ function createItemMonth(date){
return {type:2,name:name} return {type:2,date:date}
} }
function createItemYear(date){
return {type:3,date:date}
}
function updateYear(data){ function updateDecade(date){
list_model.clear() list_model.clear()
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() const decadeStart = Math.floor(year / 10) * 10;
var nextMonthYear = year for(var i = decadeStart ; i< decadeStart+10 ; i++){
var nextMonth = month + 1 list_model.append(createItemYear(new Date(i,0,1)));
if (month === 11) {
nextMonthYear = year + 1
nextMonth = 0
} }
for(var i = 0 ; i< 12 ;i++){ }
list_model.append(createItemMonth((i+1)+"月"));
function updateYear(date){
list_model.clear()
var year = date.getFullYear()
for(var i = 0 ; i< 12 ; i++){
list_model.append(createItemMonth(new Date(year,i)));
} }
list_model.append(createItemMonth("1月")); for(var j = 0 ; j< 4 ; j++){
list_model.append(createItemMonth("2月")); list_model.append(createItemMonth(new Date(year+1,j)));
list_model.append(createItemMonth("3月")); }
list_model.append(createItemMonth("4月")); title.text = year+"年"
} }
function updateMouth(date){ function updateMouth(date){
@ -107,36 +113,121 @@ Item {
} }
Component{ Component{
id:com_month id:com_year
Item{ Button{
// property bool isYear: control.date.getFullYear() === date.getFullYear() id:item_control
// property bool isMonth: control.currentDate.getFullYear() === date.getFullYear() && control.currentDate.getMonth() property bool isYear: control.date.getFullYear() === date.getFullYear()
height: 70 height: 70
width: 70 width: 70
onClicked:{
Rectangle{ control.date = date
id:backgound_selected displayMode = FluCalenderView.Year
anchors.centerIn: parent updateYear(date)
width: 50
height: 50
radius: 25
visible: false
color: FluTheme.primaryColor.dark
} }
background: Item{
FluText{ Rectangle{
text:name width: 60
anchors.centerIn: parent height: 60
color: { radius: 4
// if(isMonth){ anchors.centerIn: parent
// return "#FFFFFF" color:{
// } if(FluTheme.isDark){
// if(isYear){ if(item_control.hovered){
// return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A" return Qt.rgba(1,1,1,0.05)
// } }
return Qt.rgba(150/255,150/255,150/255,1) return Qt.rgba(0,0,0,0)
}else{
if(item_control.hovered){
return Qt.rgba(0,0,0,0.05)
}
return Qt.rgba(0,0,0,0)
}
}
}
Rectangle{
id:backgound_selected
anchors.centerIn: parent
width: 50
height: 50
radius: 25
visible: isYear
color: FluTheme.primaryColor.dark
}
FluText{
text:date.getFullYear()
anchors.centerIn: parent
color: {
if(isYear){
return "#FFFFFF"
}
// if(isYear){
// return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
// }
return Qt.rgba(150/255,150/255,150/255,1)
}
} }
} }
contentItem: Item{}
}
}
Component{
id:com_month
Button{
id:item_control
property bool isYear: control.date.getFullYear() === date.getFullYear()
property bool isMonth: control.currentDate.getFullYear() === date.getFullYear() && control.currentDate.getMonth() === date.getMonth()
height: 70
width: 70
onClicked:{
control.date = date
displayMode = FluCalenderView.Month
updateMouth(date)
}
background: Item{
Rectangle{
width: 60
height: 60
radius: 4
anchors.centerIn: parent
color:{
if(FluTheme.isDark){
if(item_control.hovered){
return Qt.rgba(1,1,1,0.05)
}
return Qt.rgba(0,0,0,0)
}else{
if(item_control.hovered){
return Qt.rgba(0,0,0,0.05)
}
return Qt.rgba(0,0,0,0)
}
}
}
Rectangle{
id:backgound_selected
anchors.centerIn: parent
width: 50
height: 50
radius: 25
visible: isMonth
color: FluTheme.primaryColor.dark
}
FluText{
text:(date.getMonth()+1)+"月"
anchors.centerIn: parent
color: {
if(isMonth){
return "#FFFFFF"
}
if(isYear){
return FluTheme.isDark ? "#FFFFFF" : "#1A1A1A"
}
return Qt.rgba(150/255,150/255,150/255,1)
}
}
}
contentItem: Item{}
} }
} }
@ -237,9 +328,15 @@ Item {
left: parent.left left: parent.left
leftMargin: 14 leftMargin: 14
} }
disabled: displayMode === FluCalenderView.Decade
onClicked:{ onClicked:{
displayMode = FluCalenderView.Year if(displayMode === FluCalenderView.Month){
updateYear(data) displayMode = FluCalenderView.Year
updateYear(date)
}else if(displayMode === FluCalenderView.Year){
displayMode = FluCalenderView.Decade
updateDecade(date)
}
} }
} }
@ -255,14 +352,20 @@ Item {
onClicked: { onClicked: {
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() var month = date.getMonth()
var lastMonthYear = year; if(displayMode === FluCalenderView.Month){
var lastMonthMonth = month - 1 var lastMonthYear = year;
if (month === 0) { var lastMonthMonth = month - 1
lastMonthYear = year - 1 if (month === 0) {
lastMonthMonth = 11 lastMonthYear = year - 1
lastMonthMonth = 11
}
date = new Date(lastMonthYear,lastMonthMonth,1)
updateMouth(date)
}
if(displayMode === FluCalenderView.Year){
date = new Date(year-1,month,1)
updateYear(date)
} }
date = new Date(lastMonthYear,lastMonthMonth,1)
updateMouth(date)
} }
} }
@ -278,14 +381,20 @@ Item {
onClicked: { onClicked: {
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() var month = date.getMonth()
var nextMonthYear = year if(displayMode === FluCalenderView.Month){
var nextMonth = month + 1 var nextMonthYear = year
if (month === 11) { var nextMonth = month + 1
nextMonthYear = year + 1 if (month === 11) {
nextMonth = 0 nextMonthYear = year + 1
nextMonth = 0
}
date = new Date(nextMonthYear,nextMonth,1)
updateMouth(date)
}
if(displayMode === FluCalenderView.Year){
date = new Date(year+1,month,1)
updateYear(date)
} }
date = new Date(nextMonthYear,nextMonth,1)
updateMouth(date)
} }
} }
} }
@ -308,6 +417,8 @@ Item {
anchors.fill: parent anchors.fill: parent
cellHeight: displayMode === FluCalenderView.Month ? 40 : 70 cellHeight: displayMode === FluCalenderView.Month ? 40 : 70
cellWidth: displayMode === FluCalenderView.Month ? 40 : 70 cellWidth: displayMode === FluCalenderView.Month ? 40 : 70
clip: true
boundsBehavior:Flickable.StopAtBounds
delegate: Loader{ delegate: Loader{
property var modelData : model property var modelData : model
property var name : model.name property var name : model.name
@ -322,6 +433,9 @@ Item {
if(model.type === 2){ if(model.type === 2){
return com_month return com_month
} }
if(model.type === 3){
return com_year
}
return com_day return com_day
} }
} }

View File

@ -22,7 +22,7 @@ if %1 == SHARED (
echo running install to qtqml folder echo running install to qtqml folder
del /s /q %PRESET_PATH%\plugins.qmltypes del /s /q %PRESET_PATH%\plugins.qmltypes
%QT_QML_FLUENT_PATH%\..\..\bin\qmlplugindump.exe -nonrelocatable FluentUI 1.0 > %PRESET_PATH%\plugins.qmltypes %QT_QML_FLUENT_PATH%\..\..\bin\qmlplugindump.exe -nonrelocatable FluentUI 1.0 > %PRESET_PATH%\plugins.qmltypes
rem rmdir /s /q %QT_QML_FLUENT_PATH% & md %QT_QML_FLUENT_PATH% rmdir /s /q %QT_QML_FLUENT_PATH% & md %QT_QML_FLUENT_PATH%
copy /y %BUILDER_BIN_PATH% %QT_QML_FLUENT_PATH% copy /y %BUILDER_BIN_PATH% %QT_QML_FLUENT_PATH%
xcopy %PRESET_PATH% %QT_QML_FLUENT_PATH% /s/e/i/y xcopy %PRESET_PATH% %QT_QML_FLUENT_PATH% /s/e/i/y
cd %QT_QML_FLUENT_PATH% cd %QT_QML_FLUENT_PATH%