Warning, /plasma/plasma-desktop/applets/taskmanager/package/contents/ui/PlayerController.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2013 Sebastian Kügler <sebas@kde.org>
0003     SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
0004     SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
0005     SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
0006     SPDX-FileCopyrightText: 2020 Nate Graham <nate@kde.org>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 import QtQuick
0012 import QtQuick.Layouts
0013 
0014 import org.kde.plasma.components 3.0 as PlasmaComponents3
0015 import org.kde.plasma.extras 2.0 as PlasmaExtras
0016 import org.kde.kirigami 2 as Kirigami
0017 import org.kde.plasma.private.mpris as Mpris
0018 
0019 RowLayout {
0020     enabled: toolTipDelegate.playerData.canControl
0021 
0022     readonly property bool isPlaying: toolTipDelegate.playerData.playbackStatus === Mpris.PlaybackStatus.Playing
0023 
0024     ColumnLayout {
0025         Layout.fillWidth: true
0026         Layout.topMargin: Kirigami.Units.smallSpacing
0027         Layout.bottomMargin: Kirigami.Units.smallSpacing
0028         Layout.rightMargin: isWin ? Kirigami.Units.smallSpacing : Kirigami.Units.gridUnit
0029         spacing: 0
0030 
0031         ScrollableTextWrapper {
0032             id: songTextWrapper
0033 
0034             Layout.fillWidth: true
0035             Layout.preferredHeight: songText.height
0036             implicitWidth: songText.implicitWidth
0037 
0038             PlasmaComponents3.Label {
0039                 id: songText
0040                 parent: songTextWrapper
0041                 width: parent.width
0042                 height: undefined
0043                 lineHeight: 1
0044                 maximumLineCount: artistText.visible? 1 : 2
0045                 wrapMode: Text.NoWrap
0046                 elide: parent.state ? Text.ElideNone : Text.ElideRight
0047                 text: toolTipDelegate.playerData.track
0048                 textFormat: Text.PlainText
0049             }
0050         }
0051 
0052         ScrollableTextWrapper {
0053             id: artistTextWrapper
0054 
0055             Layout.fillWidth: true
0056             Layout.preferredHeight: artistText.height
0057             implicitWidth: artistText.implicitWidth
0058             visible: artistText.text.length > 0
0059 
0060             PlasmaExtras.DescriptiveLabel {
0061                 id: artistText
0062                 parent: artistTextWrapper
0063                 width: parent.width
0064                 height: undefined
0065                 wrapMode: Text.NoWrap
0066                 lineHeight: 1
0067                 elide: parent.state ? Text.ElideNone : Text.ElideRight
0068                 text: toolTipDelegate.playerData.artist
0069                 font: Kirigami.Theme.smallFont
0070                 textFormat: Text.PlainText
0071             }
0072         }
0073     }
0074 
0075     PlasmaComponents3.ToolButton {
0076         enabled: toolTipDelegate.playerData.canGoPrevious
0077         icon.name: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
0078         onClicked: toolTipDelegate.playerData.Previous()
0079     }
0080 
0081     PlasmaComponents3.ToolButton {
0082         enabled: isPlaying ? toolTipDelegate.playerData.canPause : toolTipDelegate.playerData.canPlay
0083         icon.name: isPlaying ? "media-playback-pause" : "media-playback-start"
0084         onClicked: {
0085             if (!isPlaying) {
0086                 toolTipDelegate.playerData.Play();
0087             } else {
0088                 toolTipDelegate.playerData.Pause();
0089             }
0090         }
0091     }
0092 
0093     PlasmaComponents3.ToolButton {
0094         enabled: toolTipDelegate.playerData.canGoNext
0095         icon.name: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
0096         onClicked: toolTipDelegate.playerData.Next()
0097     }
0098 }