main
zhuzihcu 2023-03-16 18:11:03 +08:00
parent 96355b0a97
commit 2de9d78f41
4 changed files with 85 additions and 66 deletions

View File

@ -115,6 +115,49 @@ FluScrollablePage{
} }
} }
FluArea{
width: parent.width
height: 68
paddings: 10
FluDropDownButton{
disabled:drop_down_button_switch.selected
text:"DropDownButton"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
items:[
FluMenuItem{
text:"Menu_1"
},
FluMenuItem{
text:"Menu_2"
},
FluMenuItem{
text:"Menu_3"
},
FluMenuItem{
text:"Menu_4"
}
]
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:drop_down_button_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
}
FluArea{ FluArea{
width: parent.width width: parent.width
height: 100 height: 100
@ -190,39 +233,5 @@ FluScrollablePage{
} }
} }
FluArea{
width: parent.width
height: 68
paddings: 10
FluDropDownButton{
disabled:drop_down_button_switch.selected
text:"DropDownButton"
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
items:[
FluMenuItem{
text:"asdf"
}
]
}
Row{
spacing: 5
anchors{
verticalCenter: parent.verticalCenter
right: parent.right
}
FluToggleSwitch{
id:drop_down_button_switch
Layout.alignment: Qt.AlignRight
}
FluText{
text:"Disabled"
}
}
}
} }

View File

@ -205,6 +205,9 @@ Rectangle {
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
model: generateYearArray(1924,2048) model: generateYearArray(1924,2048)
clip: true clip: true
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
visible: showYear visible: showYear
delegate: Loader{ delegate: Loader{
property var model: modelData property var model: modelData
@ -212,11 +215,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
if(currentIndex!==-1){
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
} }
Rectangle{ Rectangle{
width: 1 width: 1
@ -229,6 +227,9 @@ Rectangle {
height: parent.height height: parent.height
clip: true clip: true
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
delegate: Loader{ delegate: Loader{
property var model: modelData property var model: modelData
@ -236,11 +237,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
if(currentIndex!==-1){
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
}
} }
Rectangle{ Rectangle{
width: 1 width: 1
@ -252,6 +248,9 @@ Rectangle {
width: showYear ? 100 : 150 width: showYear ? 100 : 150
height: parent.height height: parent.height
clip: true clip: true
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
@ -261,9 +260,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
} }
} }
@ -348,10 +344,12 @@ Rectangle {
text_day.text = day text_day.text = day
var pos = root.mapToItem(null, 0, 0) var pos = root.mapToItem(null, 0, 0)
if(window.height>pos.y+35+340){ if(window.height>pos.y+root.height+popup.height){
popup.y = 35 popup.y = root.height
}else{ } else if(pos.y>popup.height){
popup.y = window.height-(pos.y+340) popup.y = -popup.height
} else {
popup.y = window.height-(pos.y+popup.height)
} }
popup.open() popup.open()
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import FluentUI 1.0 import FluentUI 1.0
Button { Button {
@ -16,6 +17,7 @@ Button {
rightPadding:35 rightPadding:35
enabled: !disabled enabled: !disabled
focusPolicy:Qt.TabFocus focusPolicy:Qt.TabFocus
property var window : Window.window
property alias items: menu.content property alias items: menu.content
@ -68,12 +70,20 @@ Button {
} }
onClicked: { onClicked: {
var pos = control.mapToItem(null, 0, 0)
if(window.height>pos.y+control.height+menu.height){
menu.y = control.height
}else if(pos.y>menu.height){
menu.y = -menu.height
}else{
popup.y = window.height-(pos.y+menu.height)
}
menu.open() menu.open()
} }
FluMenu{ FluMenu{
id:menu id:menu
width: control.width width: control.width
} }
} }

View File

@ -202,6 +202,9 @@ Rectangle {
height: parent.height height: parent.height
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
model: isH ? generateArray(1,12) : generateArray(0,23) model: isH ? generateArray(1,12) : generateArray(0,23)
clip: true clip: true
delegate: Loader{ delegate: Loader{
@ -210,9 +213,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
list_view_1.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
} }
Rectangle{ Rectangle{
width: 1 width: 1
@ -225,6 +225,9 @@ Rectangle {
height: parent.height height: parent.height
model: generateArray(0,59) model: generateArray(0,59)
clip: true clip: true
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
delegate: Loader{ delegate: Loader{
@ -233,9 +236,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
list_view_2.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
} }
Rectangle{ Rectangle{
width: 1 width: 1
@ -250,6 +250,9 @@ Rectangle {
model: ["上午","下午"] model: ["上午","下午"]
clip: true clip: true
visible: isH visible: isH
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightMoveDuration: 0
ScrollBar.vertical: FluScrollBar {} ScrollBar.vertical: FluScrollBar {}
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
boundsBehavior:Flickable.StopAtBounds boundsBehavior:Flickable.StopAtBounds
@ -259,9 +262,6 @@ Rectangle {
property int position:index property int position:index
sourceComponent: list_delegate sourceComponent: list_delegate
} }
onCurrentIndexChanged: {
list_view_3.positionViewAtIndex(currentIndex, ListView.NoPosition)
}
} }
} }
@ -358,10 +358,12 @@ Rectangle {
} }
var pos = root.mapToItem(null, 0, 0) var pos = root.mapToItem(null, 0, 0)
if(window.height>pos.y+35+340){ if(window.height>pos.y+root.height+popup.height){
popup.y = 35 popup.y = root.height
}else{ } else if(pos.y>popup.height){
popup.y = window.height-(pos.y+340) popup.y = -popup.height
} else {
popup.y = window.height-(pos.y+popup.height)
} }
popup.open() popup.open()
} }