matrixion/qml/ui/NhekoSlider.qml

47 lines
1.5 KiB
QML
Raw Normal View History

2021-11-11 08:16:25 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
// SPDX-FileCopyrightText: 2022 Nheko Contributors
2021-11-11 08:16:25 +03:00
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15
import im.nheko
2021-11-11 08:16:25 +03:00
Slider {
2021-11-11 21:18:45 +03:00
id: control
2021-11-11 08:16:25 +03:00
property bool alwaysShowSlider: true
2022-04-16 03:13:01 +03:00
property color progressColor: timelineRoot.palette.highlight
2021-11-11 21:18:45 +03:00
property int sliderRadius: 16
2021-11-11 08:16:25 +03:00
2021-11-11 23:32:38 +03:00
implicitHeight: sliderRadius
padding: 0
2022-04-16 03:13:01 +03:00
value: 0
2021-11-11 08:16:25 +03:00
background: Rectangle {
2022-04-16 03:13:01 +03:00
color: timelineRoot.palette.placeholderText
2021-11-11 21:18:45 +03:00
height: implicitHeight
2022-04-16 03:13:01 +03:00
implicitHeight: control.sliderRadius / 4
implicitWidth: 200
2021-11-11 23:32:38 +03:00
radius: height / 2
2022-04-16 03:13:01 +03:00
width: control.availableWidth - handle.width
x: control.leftPadding + handle.width / 2
y: control.topPadding + control.availableHeight / 2 - height / 2
2021-11-11 08:16:25 +03:00
Rectangle {
2021-11-11 21:18:45 +03:00
color: control.progressColor
2022-04-16 03:13:01 +03:00
height: parent.height
2021-11-11 08:16:25 +03:00
radius: 2
2022-04-16 03:13:01 +03:00
width: control.visualPosition * parent.width
2021-11-11 08:16:25 +03:00
}
}
handle: Rectangle {
2022-04-16 03:13:01 +03:00
border.color: control.progressColor
color: control.progressColor
2021-11-11 21:18:45 +03:00
implicitHeight: control.sliderRadius
2022-04-16 03:13:01 +03:00
implicitWidth: control.sliderRadius
2021-11-11 23:32:38 +03:00
radius: control.sliderRadius / 2
visible: Settings.mobileMode || control.alwaysShowSlider || control.hovered || control.pressed
2022-04-16 03:13:01 +03:00
x: control.leftPadding + control.visualPosition * background.width
y: control.topPadding + control.availableHeight / 2 - height / 2
2021-11-11 08:16:25 +03:00
}
}