matrixion/resources/qml/ui/NhekoSlider.qml

51 lines
1.4 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: 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 1.0
Slider {
2021-11-11 21:18:45 +03:00
id: control
2021-11-11 08:16:25 +03:00
property color progressColor: palette.highlight
2021-11-11 08:16:25 +03:00
property bool alwaysShowSlider: true
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
value: 0
implicitHeight: sliderRadius
padding: 0
2021-11-11 08:16:25 +03:00
background: Rectangle {
2021-11-11 23:32:38 +03:00
x: control.leftPadding + handle.width / 2
2021-11-11 21:18:45 +03:00
y: control.topPadding + control.availableHeight / 2 - height / 2
implicitWidth: 200
2021-11-11 23:32:38 +03:00
implicitHeight: control.sliderRadius / 4
2021-11-11 21:18:45 +03:00
width: control.availableWidth - handle.width
height: implicitHeight
2021-11-11 23:32:38 +03:00
radius: height / 2
color: palette.buttonText
2021-11-11 08:16:25 +03:00
Rectangle {
2021-11-11 21:18:45 +03:00
width: control.visualPosition * parent.width
height: parent.height
color: control.progressColor
2021-11-11 08:16:25 +03:00
radius: 2
}
2021-11-11 23:32:38 +03:00
2021-11-11 08:16:25 +03:00
}
handle: Rectangle {
2021-11-11 21:18:45 +03:00
x: control.leftPadding + control.visualPosition * background.width
y: control.topPadding + control.availableHeight / 2 - height / 2
implicitWidth: control.sliderRadius
implicitHeight: control.sliderRadius
2021-11-11 23:32:38 +03:00
radius: control.sliderRadius / 2
color: control.progressColor
visible: Settings.mobileMode || control.alwaysShowSlider || control.hovered || control.pressed
2021-11-11 21:18:45 +03:00
border.color: control.progressColor
2021-11-11 08:16:25 +03:00
}
2021-11-11 23:32:38 +03:00
2021-11-11 08:16:25 +03:00
}