Warning, /plasma/plank-player/app/qml/SeekBar.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 2.15 0006 import QtQuick.Layouts 1.15 0007 import QtQuick.Templates 2.15 as QQCT 0008 import org.kde.kirigami 2.19 as Kirigami 0009 import QtQuick.Controls 2.15 as Controls 0010 0011 Item { 0012 id: seekControl 0013 property int duration 0014 property int seekPosition 0015 property int value: 0 0016 0017 onActiveFocusChanged: { 0018 if(activeFocus){ 0019 slider.forceActiveFocus() 0020 } 0021 } 0022 0023 RowLayout { 0024 anchors.fill: parent 0025 anchors.margins: Kirigami.Units.largeSpacing 0026 0027 QQCT.Slider { 0028 id: slider 0029 Layout.fillWidth: true 0030 Layout.fillHeight: true 0031 value: seekControl.value 0032 to: seekControl.duration || 100 0033 property int minimumValue: 0 0034 property int maximumValue: 20 0035 property bool navSliderItem 0036 0037 onMoved: { 0038 video.seek(value); 0039 } 0040 0041 onNavSliderItemChanged: { 0042 if(slider.navSliderItem){ 0043 recthandler.color = "red" 0044 } else if (slider.focus) { 0045 recthandler.color = Kirigami.Theme.linkColor 0046 } 0047 } 0048 0049 onFocusChanged: { 0050 if(!slider.focus){ 0051 recthandler.color = Kirigami.Theme.textColor 0052 } else { 0053 recthandler.color = Kirigami.Theme.linkColor 0054 } 0055 } 0056 0057 handle: Rectangle { 0058 id: recthandler 0059 x: slider.position * (parent.width - width) 0060 implicitWidth: Kirigami.Units.largeSpacing 0061 implicitHeight: parent.height 0062 radius: 6 0063 color: Kirigami.Theme.textColor 0064 } 0065 0066 background: Item { 0067 Rectangle { 0068 id: groove 0069 anchors { 0070 verticalCenter: parent.verticalCenter 0071 left: parent.left 0072 right: parent.right 0073 } 0074 height: parent.height 0075 radius: 6 0076 color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.3) 0077 Rectangle { 0078 anchors { 0079 left: parent.left 0080 top: parent.top 0081 bottom: parent.bottom 0082 } 0083 radius: 6 0084 color: Kirigami.Theme.highlightColor 0085 width: slider.position * (parent.width - slider.handle.width/2) + slider.handle.width/2 0086 } 0087 } 0088 } 0089 0090 Keys.onReturnPressed: (event)=> { 0091 if(!navSliderItem){ 0092 navSliderItem = true 0093 } else { 0094 navSliderItem = false 0095 } 0096 } 0097 0098 Keys.onLeftPressed: (event)=> { 0099 if(navSliderItem) { 0100 video.seek(video.position - 5000) 0101 } else { 0102 mediaSkipFwdButton.forceActiveFocus() 0103 } 0104 } 0105 0106 Keys.onRightPressed: (event)=> { 0107 if(navSliderItem) { 0108 video.seek(video.position + 5000) 0109 } else { 0110 pinOsdButton.forceActiveFocus() 0111 } 0112 } 0113 0114 } 0115 0116 Controls.Label { 0117 Layout.preferredWidth: contentWidth + Kirigami.Units.gridUnit 0118 Layout.fillHeight: true 0119 horizontalAlignment: Text.AlignHCenter 0120 verticalAlignment: Text.AlignVCenter 0121 text: formatTime(duration) 0122 color: "white" 0123 } 0124 } 0125 0126 function formatTime(timeInMs) { 0127 if (!timeInMs || timeInMs <= 0) return "0:00" 0128 var seconds = timeInMs / 1000; 0129 var minutes = Math.floor(seconds / 60) 0130 seconds = Math.floor(seconds % 60) 0131 if (seconds < 10) seconds = "0" + seconds; 0132 return minutes + "." + seconds 0133 } 0134 }