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
|
2023-02-27 23:04:52 +08:00
|
|
|
|
color: {
|
|
|
|
|
if(FluApp.isDark){
|
|
|
|
|
if(root.checked){
|
|
|
|
|
return checkedColor
|
|
|
|
|
}
|
|
|
|
|
if(switch_mouse.containsMouse){
|
|
|
|
|
return "#3E3E3C"
|
|
|
|
|
}
|
|
|
|
|
return "#323232"
|
|
|
|
|
}else{
|
|
|
|
|
if(switch_mouse.containsMouse){
|
|
|
|
|
return "#F4F4F4"
|
|
|
|
|
}
|
|
|
|
|
return root.checked ? checkedColor : "white"
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: root.checked ? checkedColor : "#666666"
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2023-02-27 23:04:52 +08:00
|
|
|
|
x: root.checked ? root.implicitWidth - width - 4 : 4
|
|
|
|
|
width: root.height - 8
|
|
|
|
|
height: root.height - 8
|
2023-02-26 23:47:07 +08:00
|
|
|
|
radius: width / 2
|
2023-02-27 23:04:52 +08:00
|
|
|
|
scale: switch_mouse.containsMouse ? 1.2 : 1.0
|
2023-02-26 23:47:07 +08:00
|
|
|
|
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
|
|
|
|
}
|