Warning, /network/kdeconnect-kde/app/qml/MprisSlider.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Controls
0009 
0010 Loader {
0011 
0012     property var plugin
0013     property var lastPosition: plugin.position
0014     property date lastPositionTime: new Date()
0015     property bool updatePositionSlider: true
0016 
0017     sourceComponent: plugin.canSeek ? seekBar : progressBar
0018 
0019     onLastPositionChanged: {
0020         if (item != null) {
0021             item.value = lastPosition
0022             lastPositionTime = new Date();
0023         }
0024     }
0025 
0026     Component {
0027         id: seekBar
0028 
0029         Slider {
0030             from: 0
0031             to: plugin.length
0032             onPressedChanged: {
0033                 if (pressed) {
0034                     updatePositionSlider = false
0035                 } else {
0036                     updatePositionSlider = true
0037                     plugin.position = value
0038                 }
0039             }
0040         }
0041     }
0042 
0043     Component {
0044         id: progressBar
0045 
0046         ProgressBar {
0047             from: 0
0048             to: plugin.length
0049         }
0050     }
0051 
0052     Timer {
0053         id: positionUpdateTimer
0054         interval: 1000
0055         repeat: true
0056         running: updatePositionSlider && plugin.isPlaying
0057 
0058         onTriggered: item.value = lastPosition + (new Date().getTime() - lastPositionTime.getTime())
0059     }
0060 }