FluentUI/src/controls/FluToggleSwitch.qml

43 lines
1.1 KiB
QML
Raw Normal View History

2023-02-26 23:47:07 +08:00
import QtQuick 2.0
import QtQuick.Controls 2.0
Switch {
id: root
property color checkedColor: "#0064B0"
2023-02-27 18:46:39 +08:00
signal clicked2
width: 40
implicitWidth: 40
height: 20
implicitHeight: 20
checkable: false
2023-02-26 23:47:07 +08:00
indicator: Rectangle {
2023-02-27 18:46:39 +08:00
width: root.width
height: root.height
2023-02-26 23:47:07 +08:00
radius: height / 2
color: root.checked ? checkedColor : "white"
border.width: 1
border.color: root.checked ? checkedColor : "#666666"
Rectangle {
x: root.checked ? parent.width - width - 4 : 4
width: root.checked ? parent.height - 8 : parent.height - 8
height: width
radius: width / 2
anchors.verticalCenter: parent.verticalCenter
color: root.checked ? "#FFFFFF" : "#666666"
// border.color: "#D5D5D5"
Behavior on x {
NumberAnimation { duration: 200 }
}
}
}
2023-02-27 18:46:39 +08:00
MouseArea{
id:switch_mouse
anchors.fill: parent
hoverEnabled: true
onClicked: {
root.clicked2()
}
}
2023-02-26 23:47:07 +08:00
}