Warning, /network/kdeconnect-kde/app/qml/mpris.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@kde.org> 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 import QtQuick.Layouts 0010 import org.kde.kirigami as Kirigami 0011 0012 Kirigami.Page 0013 { 0014 id: root 0015 property QtObject pluginInterface 0016 property bool muted: false 0017 property int volumeUnmuted 0018 property var volume: pluginInterface.volume 0019 title: i18nd("kdeconnect-app", "Multimedia Controls") 0020 0021 onVolumeChanged: { 0022 if (muted && volume != 0) { 0023 toggleMute() 0024 volumeUnmuted = volume 0025 } else if (!muted) { 0026 volumeUnmuted = volume 0027 } 0028 } 0029 0030 function soundState(volume) 0031 { 0032 if (volume <= 25) { 0033 return "audio-volume-low" 0034 } else if (volume <= 75) { 0035 return "audio-volume-medium" 0036 } else { 0037 return "audio-volume-high" 0038 } 0039 } 0040 0041 function toggleMute() 0042 { 0043 muted = !muted 0044 root.pluginInterface.volume = muted ? 0 : volumeUnmuted 0045 } 0046 0047 function padTimeNumber(n) { 0048 return (n < 10) ? ("0" + n) : n; 0049 } 0050 0051 function msToTime(totalTimeMs) 0052 { 0053 let hours = Math.floor(totalTimeMs/(1000*60*60)); 0054 let minutes = Math.floor((totalTimeMs-(hours*1000*60*60))/(1000*60)); 0055 let seconds = Math.floor((totalTimeMs-(minutes*1000*60)-(hours*1000*60*60))/1000); 0056 if (hours > 0) { 0057 return `${padTimeNumber(hours)}:${padTimeNumber(minutes)}:${padTimeNumber(seconds)}`; 0058 } else { 0059 return `${padTimeNumber(minutes)}:${padTimeNumber(seconds)}`; 0060 } 0061 } 0062 0063 Kirigami.PlaceholderMessage { 0064 id: noPlayersText 0065 text: i18nd("kdeconnect-app", "No players available") 0066 anchors.centerIn: parent 0067 visible: pluginInterface.playerList.length == 0 0068 } 0069 0070 ColumnLayout 0071 { 0072 anchors.fill: parent 0073 visible: !noPlayersText.visible 0074 0075 Component.onCompleted: { 0076 pluginInterface.requestPlayerList(); 0077 } 0078 0079 Item { Layout.fillHeight: true } 0080 ComboBox { 0081 Layout.fillWidth: true 0082 model: root.pluginInterface.playerList 0083 onCurrentTextChanged: root.pluginInterface.player = currentText 0084 } 0085 Label { 0086 Layout.fillWidth: true 0087 text: root.pluginInterface.title 0088 wrapMode: Text.Wrap 0089 } 0090 Label { 0091 Layout.fillWidth: true 0092 text: root.pluginInterface.artist 0093 visible: !artistAlbum.visible && root.pluginInterface.artist.length > 0 0094 wrapMode: Text.Wrap 0095 } 0096 Label { 0097 Layout.fillWidth: true 0098 text: root.pluginInterface.album 0099 visible: !artistAlbum.visible && root.pluginInterface.album.length > 0 0100 wrapMode: Text.Wrap 0101 } 0102 Label { 0103 id: artistAlbum 0104 Layout.fillWidth: true 0105 text: i18nd("kdeconnect-app", "%1 - %2", root.pluginInterface.artist, root.pluginInterface.album) 0106 visible: root.pluginInterface.album.length > 0 && root.pluginInterface.artist.length > 0 0107 wrapMode: Text.Wrap 0108 } 0109 RowLayout { 0110 Layout.fillWidth: true 0111 Button { 0112 Layout.fillWidth: true 0113 icon.name: "media-skip-backward" 0114 onClicked: root.pluginInterface.sendAction("Previous") 0115 } 0116 Button { 0117 Layout.fillWidth: true 0118 icon.name: root.pluginInterface.isPlaying ? "media-playback-pause" : "media-playback-start" 0119 onClicked: root.pluginInterface.sendAction("PlayPause"); 0120 } 0121 Button { 0122 Layout.fillWidth: true 0123 icon.name: "media-skip-forward" 0124 onClicked: root.pluginInterface.sendAction("Next") 0125 } 0126 } 0127 RowLayout { 0128 Layout.fillWidth: true 0129 Label { 0130 text: msToTime(positionIndicator.item.value) 0131 } 0132 0133 MprisSlider { 0134 id: positionIndicator 0135 plugin: root.pluginInterface 0136 Layout.fillWidth: true 0137 } 0138 0139 Label { 0140 text: msToTime(root.pluginInterface.length) 0141 } 0142 } 0143 RowLayout { 0144 Layout.fillWidth: true 0145 Button { 0146 id: muteButton 0147 icon.name: muted ? "audio-volume-muted" : soundState(root.pluginInterface.volume) 0148 onClicked: toggleMute() 0149 } 0150 Slider { 0151 id: volumeSlider 0152 value: volumeUnmuted 0153 to: 99 0154 enabled: !muted 0155 Layout.fillWidth: true 0156 onValueChanged: { 0157 volumeUnmuted = value 0158 root.pluginInterface.volume = value 0159 } 0160 } 0161 } 0162 Item { Layout.fillHeight: true } 0163 } 0164 0165 Component.onCompleted: volumeUnmuted = root.pluginInterface.volume 0166 }