| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2023 George Florea Bănuș <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
import QtQuick |
| 8 |
import QtQuick.Controls |
| 9 |
import Qt5Compat.GraphicalEffects |
| 10 |
|
| 11 |
import org.kde.kirigami as Kirigami |
| 12 |
import org.kde.haruna |
| 13 |
import org.kde.haruna.settings |
| 14 |
|
| 15 |
Slider { |
| 16 |
id: root |
| 17 |
|
| 18 |
required property MpvItem m_mpv |
| 19 |
|
| 20 |
property alias label: volumeLabel |
| 21 |
|
| 22 |
from: 0 |
| 23 |
to: root.m_mpv.volumeMax |
| 24 |
value: root.m_mpv.volume |
| 25 |
implicitWidth: 100 |
| 26 |
implicitHeight: 25 |
| 27 |
wheelEnabled: true |
| 28 |
stepSize: AudioSettings.volumeStep |
| 29 |
leftPadding: 0 |
| 30 |
rightPadding: 0 |
| 31 |
|
| 32 |
handle: Item { visible: false } |
| 33 |
background: Rectangle { |
| 34 |
color: Kirigami.Theme.alternateBackgroundColor |
| 35 |
scale: root.mirrored ? -1 : 1 |
| 36 |
|
| 37 |
Rectangle { |
| 38 |
width: root.position * parent.width |
| 39 |
height: parent.height |
| 40 |
color: Kirigami.Theme.highlightColor |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
onPressedChanged: { |
| 45 |
root.m_mpv.volume = value.toFixed(0) |
| 46 |
} |
| 47 |
|
| 48 |
onValueChanged: { |
| 49 |
if (!root.m_mpv.isReady) { |
| 50 |
return |
| 51 |
} |
| 52 |
|
| 53 |
root.m_mpv.volume = value.toFixed(0) |
| 54 |
} |
| 55 |
|
| 56 |
Label { |
| 57 |
id: volumeLabel |
| 58 |
text: root.value |
| 59 |
anchors.centerIn: root |
| 60 |
color: "#fff" |
| 61 |
layer.enabled: true |
| 62 |
layer.effect: DropShadow { verticalOffset: 1; color: "#111"; radius: 5; spread: 0.3; samples: 17 } |
| 63 |
} |
| 64 |
} |