Warning, /multimedia/elisa/src/qml/DurationSlider.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 (c) Devin Lin <espidev@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 2.7 0008 import QtQuick.Layouts 1.2 0009 import QtQuick.Controls 2.3 0010 import org.kde.elisa 1.0 0011 import org.kde.kirigami 2.5 as Kirigami 0012 import ".." 0013 0014 RowLayout { 0015 id: root 0016 property int position 0017 property int duration 0018 property bool seekable 0019 property bool playEnabled 0020 0021 property color labelColor 0022 0023 signal seek(int position) 0024 0025 onPositionChanged: { 0026 if (!slider.pressed) { 0027 slider.value = position / 1000 0028 } 0029 } 0030 onDurationChanged: { 0031 slider.to = duration / 1000 0032 } 0033 0034 Connections { 0035 target: ElisaApplication.mediaPlayListProxyModel 0036 function onClearPlayListPlayer() { 0037 slider.value = 0; 0038 } 0039 } 0040 0041 spacing: 0 0042 0043 TextMetrics { 0044 id: durationTextMetrics 0045 text: i18nc("@info:placeholder This is used to preserve a fixed width for the duration text.", "00:00:00") 0046 } 0047 0048 LabelWithToolTip { 0049 id: positionLabel 0050 0051 text: timeIndicator.progressDuration 0052 0053 color: root.labelColor 0054 0055 Layout.alignment: Qt.AlignVCenter 0056 Layout.fillHeight: true 0057 Layout.rightMargin: !LayoutMirroring.enabled ? Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing * 2 0058 Layout.preferredWidth: (durationTextMetrics.boundingRect.width - durationTextMetrics.boundingRect.x) + Kirigami.Units.smallSpacing 0059 0060 verticalAlignment: Text.AlignVCenter 0061 horizontalAlignment: Text.AlignRight 0062 0063 ProgressIndicator { 0064 id: timeIndicator 0065 position: root.position 0066 } 0067 } 0068 0069 Slider { 0070 id: slider 0071 Layout.alignment: Qt.AlignVCenter 0072 Layout.fillHeight: true 0073 Layout.fillWidth: true 0074 Layout.rightMargin: !LayoutMirroring.enabled ? Kirigami.Units.largeSpacing : 0 0075 Layout.leftMargin: LayoutMirroring.enabled ? Kirigami.Units.largeSpacing : 0 0076 0077 // from, to and value of Slider are rescaled to seconds to avoid integer overflow issues 0078 from: 0 0079 to: root.duration / 1000 0080 0081 enabled: root.seekable && root.playEnabled 0082 live: true 0083 0084 onMoved: { 0085 root.seek(value * 1000) 0086 } 0087 0088 MouseArea { 0089 anchors.fill: parent 0090 acceptedButtons: Qt.NoButton 0091 onWheel: wheel => { 0092 if (wheel.angleDelta.y > 0) { 0093 root.seek((slider.value + 10) * 1000) 0094 } else { 0095 root.seek((slider.value - 10) * 1000) 0096 } 0097 } 0098 } 0099 } 0100 0101 LabelWithToolTip { 0102 id: durationLabel 0103 0104 text: durationIndicator.progressDuration 0105 0106 color: root.labelColor 0107 0108 Layout.alignment: Qt.AlignVCenter 0109 Layout.fillHeight: true 0110 Layout.leftMargin: LayoutMirroring.enabled ? (Kirigami.Units.largeSpacing * 2) : 0 0111 Layout.preferredWidth: (durationTextMetrics.boundingRect.width - durationTextMetrics.boundingRect.x) 0112 0113 verticalAlignment: Text.AlignVCenter 0114 horizontalAlignment: Text.AlignLeft 0115 0116 ProgressIndicator { 0117 id: durationIndicator 0118 position: root.duration 0119 } 0120 } 0121 }