2023-02-28 23:57:55 +08:00
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
|
import QtGraphicalEffects 1.15
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
2023-02-28 23:57:55 +08:00
|
|
|
|
Item{
|
|
|
|
|
|
|
|
|
|
id:root
|
|
|
|
|
|
2023-03-09 16:44:24 +08:00
|
|
|
|
property int lineWidth: 5
|
|
|
|
|
property int dotSize: 26
|
2023-02-28 23:57:55 +08:00
|
|
|
|
property int value: 50
|
|
|
|
|
|
2023-03-09 16:44:24 +08:00
|
|
|
|
enum Orientation {
|
|
|
|
|
Horizontal,
|
|
|
|
|
Vertical
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
height: control.height
|
|
|
|
|
width: control.width
|
|
|
|
|
|
|
|
|
|
property int orientation: FluSlider.Horizontal
|
|
|
|
|
|
|
|
|
|
property bool isHorizontal: orientation === FluSlider.Horizontal
|
|
|
|
|
|
2023-02-28 23:57:55 +08:00
|
|
|
|
Component.onCompleted: {
|
2023-03-09 16:44:24 +08:00
|
|
|
|
if(isHorizontal){
|
|
|
|
|
dot.x =value/100*control.width - dotSize/2
|
|
|
|
|
root.value = Qt.binding(function(){
|
|
|
|
|
return (dot.x+dotSize/2)/control.width*100
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
dot.y =value/100*control.height - dotSize/2
|
|
|
|
|
root.value = Qt.binding(function(){
|
|
|
|
|
return (dot.y+dotSize/2)/control.height*100
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-02-28 23:57:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluRectangle {
|
|
|
|
|
id: control
|
2023-03-09 16:44:24 +08:00
|
|
|
|
width: isHorizontal ? 200 : root.lineWidth
|
|
|
|
|
height: isHorizontal ? root.lineWidth : 200
|
2023-02-28 23:57:55 +08:00
|
|
|
|
radius: [3,3,3,3]
|
|
|
|
|
clip: true
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:FluTheme.isDark ? Qt.rgba(162/255,162/255,162/255,1) : Qt.rgba(138/255,138/255,138/255,1)
|
2023-02-28 23:57:55 +08:00
|
|
|
|
Rectangle{
|
|
|
|
|
id:rect
|
|
|
|
|
radius: 3
|
2023-03-09 16:44:24 +08:00
|
|
|
|
width: isHorizontal ? control.width*(value/100) : control.width
|
|
|
|
|
height: isHorizontal ? control.height : control.height*(value/100)
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
2023-02-28 23:57:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-01 11:58:30 +08:00
|
|
|
|
|
2023-02-28 23:57:55 +08:00
|
|
|
|
Rectangle{
|
|
|
|
|
id:dot
|
|
|
|
|
width: dotSize
|
|
|
|
|
height: dotSize
|
2023-03-09 16:44:24 +08:00
|
|
|
|
FluShadow{
|
|
|
|
|
radius: dotSize/2
|
|
|
|
|
}
|
|
|
|
|
radius: dotSize/2
|
|
|
|
|
anchors.verticalCenter: isHorizontal ? parent.verticalCenter : undefined
|
|
|
|
|
anchors.horizontalCenter: isHorizontal ? undefined :parent.horizontalCenter
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:FluTheme.isDark ? Qt.rgba(69/255,69/255,69/255,1) :Qt.rgba(1,1,1,1)
|
2023-02-28 23:57:55 +08:00
|
|
|
|
Rectangle{
|
|
|
|
|
width: dotSize/2
|
|
|
|
|
height: dotSize/2
|
|
|
|
|
radius: dotSize/4
|
2023-03-06 14:22:13 +08:00
|
|
|
|
color:FluTheme.isDark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
|
2023-02-28 23:57:55 +08:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
scale: control_mouse.containsMouse ? 1.2 : 1
|
|
|
|
|
Behavior on scale {
|
|
|
|
|
NumberAnimation{
|
|
|
|
|
duration: 150
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MouseArea{
|
|
|
|
|
id:control_mouse
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
drag {
|
|
|
|
|
target: dot
|
2023-03-09 16:44:24 +08:00
|
|
|
|
axis: isHorizontal ? Drag.XAxis : Drag.YAxis
|
|
|
|
|
minimumX: isHorizontal ? -dotSize/2 : 0
|
|
|
|
|
maximumX: isHorizontal ? (control.width - dotSize/2) : 0
|
|
|
|
|
minimumY: isHorizontal ? 0 : -dotSize/2
|
|
|
|
|
maximumY: isHorizontal ? 0 : (control.height - dotSize/2)
|
2023-02-28 23:57:55 +08:00
|
|
|
|
}
|
|
|
|
|
onPressed: {
|
|
|
|
|
tool_tip.visible = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onReleased: {
|
|
|
|
|
tool_tip.visible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluTooltip{
|
|
|
|
|
id:tool_tip
|
|
|
|
|
text:String(root.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
|
|
|
|
}
|
2023-02-28 23:57:55 +08:00
|
|
|
|
|