This commit is contained in:
朱子楚\zhuzi
2023-03-12 22:36:31 +08:00
parent f75da5e3ce
commit 23bc5cdf68
10 changed files with 72 additions and 86 deletions

View File

@ -3,23 +3,35 @@ import QtQuick.Controls 2.0
import FluentUI 1.0
Button {
id: root
property bool selected: false
property var clickFunc
id: control
width: 40
implicitWidth: 40
height: 20
implicitHeight: 20
checkable: true
focusPolicy:Qt.TabFocus
Keys.onSpacePressed: control.visualFocus&&clicked()
onClicked: {
if(clickFunc){
clickFunc()
return
}
selected = !selected
}
background : Rectangle {
width: root.width
height: root.height
width: control.width
height: control.height
radius: height / 2
FluFocusRectangle{
visible: root.focus
visible: control.visualFocus
radius: 20
}
color: {
if(FluTheme.isDark){
if(checked){
if(selected){
return FluTheme.primaryColor.dark
}
if(hovered){
@ -27,7 +39,7 @@ Button {
}
return "#323232"
}else{
if(checked){
if(selected){
return FluTheme.primaryColor.dark
}
if(hovered){
@ -37,18 +49,19 @@ Button {
}
}
border.width: 1
border.color: checked ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
border.color: selected ? Qt.lighter(FluTheme.primaryColor.dark,1.2) : "#666666"
Rectangle {
x: checked ? root.implicitWidth - width - 4 : 4
width: root.height - 8
height: root.height - 8
x: selected ? control.implicitWidth - width - 4 : 4
width: control.height - 8
height: control.height - 8
radius: width / 2
scale: hovered ? 1.2 : 1.0
anchors.verticalCenter: parent.verticalCenter
color: checked ? "#FFFFFF" : "#666666"
color: selected ? "#FFFFFF" : "#666666"
Behavior on x {
NumberAnimation { duration: 200 }
}
}
}
}