Warning, /plasma/bluedevil/src/applet/package/contents/ui/MediaPlayerItem.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
0003
0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.kirigami 2.20 as Kirigami
0012
0013 import org.kde.bluezqt 1.0 as BluezQt
0014
0015 ColumnLayout {
0016 id: mediaPlayer
0017
0018 spacing: 0
0019
0020 PlasmaComponents3.Label {
0021 id: trackTitleLabel
0022 Layout.fillWidth: true
0023 elide: Text.ElideRight
0024 font.weight: MediaPlayer && MediaPlayer.track.title ? Font.DemiBold : Font.Normal
0025 font.italic: MediaPlayer && MediaPlayer.status === BluezQt.MediaPlayer.Playing
0026 font.pointSize: Kirigami.Theme.smallFont.pointSize
0027 font.family: Kirigami.Theme.smallFont.family
0028 opacity: 0.6
0029 text: trackTitleText()
0030 textFormat: Text.PlainText
0031 visible: text.length
0032 }
0033
0034 PlasmaComponents3.Label {
0035 id: trackArtistLabel
0036 Layout.fillWidth: true
0037 elide: Text.ElideRight
0038 font: Kirigami.Theme.smallFont
0039 opacity: 0.6
0040 text: MediaPlayer ? MediaPlayer.track.artist : ""
0041 textFormat: Text.PlainText
0042 visible: text.length
0043 }
0044
0045 PlasmaComponents3.Label {
0046 id: trackAlbumLabel
0047 Layout.fillWidth: true
0048 elide: Text.ElideRight
0049 font: Kirigami.Theme.smallFont
0050 opacity: 0.6
0051 text: MediaPlayer ? MediaPlayer.track.album : ""
0052 textFormat: Text.PlainText
0053 visible: text.length
0054 }
0055
0056 RowLayout {
0057 spacing: 0
0058
0059 PlasmaComponents3.ToolButton {
0060 id: previousButton
0061 icon.name: "media-skip-backward-symbolic"
0062
0063 onClicked: MediaPlayer.previous()
0064 }
0065
0066 PlasmaComponents3.ToolButton {
0067 id: playPauseButton
0068 icon.name: playPauseButtonIcon()
0069
0070 onClicked: playPauseButtonClicked()
0071 }
0072
0073 PlasmaComponents3.ToolButton {
0074 id: stopButton
0075 icon.name: "media-playback-stop-symbolic"
0076 enabled: MediaPlayer && MediaPlayer.status !== BluezQt.MediaPlayer.Stopped
0077
0078 onClicked: MediaPlayer.stop()
0079 }
0080
0081 PlasmaComponents3.ToolButton {
0082 id: nextButton
0083 icon.name: "media-skip-forward-symbolic"
0084
0085 onClicked: MediaPlayer.next()
0086 }
0087 }
0088
0089 function trackTitleText() {
0090 if (!MediaPlayer) {
0091 return "";
0092 }
0093
0094 const play = "\u25B6";
0095
0096 if (MediaPlayer.status === BluezQt.MediaPlayer.Playing) {
0097 return "%1 %2".arg(play).arg(MediaPlayer.track.title);
0098 }
0099 return MediaPlayer.track.title;
0100 }
0101
0102 function playPauseButtonIcon() {
0103 if (!MediaPlayer) {
0104 return "";
0105 }
0106
0107 if (MediaPlayer.status !== BluezQt.MediaPlayer.Playing) {
0108 return "media-playback-start-symbolic";
0109 } else {
0110 return "media-playback-pause-symbolic";
0111 }
0112 }
0113
0114 function playPauseButtonClicked() {
0115 if (MediaPlayer.status !== BluezQt.MediaPlayer.Playing) {
0116 MediaPlayer.play()
0117 } else {
0118 MediaPlayer.pause()
0119 }
0120 }
0121 }