Warning, /multimedia/audiotube/src/contents/ui/MinimizedPlayerControls.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020-2022 Devin Lin <devin@kde.org>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004
0005 import QtQuick 2.15
0006 import QtQuick.Controls 2.15
0007 import QtQuick.Layouts 1.15
0008
0009 import QtMultimedia
0010
0011 import org.kde.kirigami 2.19 as Kirigami
0012 import org.kde.ytmusic 1.0
0013
0014 Item {
0015 id: root
0016 z: 2000
0017
0018 required property int progressBarHeight
0019 required property int minimizedPlayerContentHeight
0020
0021 required property VideoInfoExtractor info
0022 required property MediaPlayer audio
0023 required property string thumbnail
0024
0025 readonly property bool isWidescreen: width >= Kirigami.Units.gridUnit * 50
0026 signal requestOpen()
0027 Shortcut {
0028 sequence: "Ctrl+P"
0029 onActivated: root.requestOpen()
0030 }
0031 Rectangle {
0032 id: miniProgressBar
0033 z: 1
0034 anchors.top: parent.top
0035 anchors.left: parent.left
0036 height: root.progressBarHeight
0037 color: Kirigami.Theme.highlightColor
0038 width: parent.width * (audio?.position / audio?.duration)
0039 }
0040
0041 states: [
0042 State {
0043 when: root.isWidescreen
0044 AnchorChanges {
0045 target: controlButtonBox
0046 anchors.horizontalCenter: root.horizontalCenter
0047 }
0048 },
0049 State {
0050 when: true // default (fallback) state
0051 AnchorChanges {
0052 target: controlButtonBox
0053 anchors.right: root.right
0054 }
0055 }
0056 ]
0057
0058 Rectangle {
0059 id: trackInfoLayout
0060
0061 anchors {
0062 top: parent.top
0063 left: parent.left
0064 bottom: parent.bottom
0065
0066 right: controlButtonBox.left
0067 rightMargin: Kirigami.Units.largeSpacing
0068 }
0069
0070 color: Qt.rgba(0, 0, 0, trackClick.containsMouse ? 0.1 : trackClick.pressed ? 0.3 : 0)
0071
0072 RowLayout {
0073 anchors.fill: parent
0074 anchors.leftMargin: Kirigami.Units.largeSpacing
0075 spacing: Kirigami.Units.largeSpacing
0076
0077 // track image
0078 Item {
0079 property double imageSize: root.height - Kirigami.Units.largeSpacing * 2
0080
0081 Layout.alignment: Qt.AlignVCenter
0082 Layout.maximumWidth: imageSize
0083 Layout.preferredWidth: imageSize
0084 Layout.maximumHeight: imageSize
0085 Layout.minimumHeight: imageSize
0086
0087 RoundedImage {
0088 id: mainIcon
0089 anchors.fill: parent
0090 visible: !loadingIndicator.visible && source.toString() !== ""
0091 source: root.thumbnail
0092 radius: 5
0093 }
0094
0095 BusyIndicator {
0096 id: loadingIndicator
0097 anchors.centerIn: parent
0098 visible: UserPlaylistModel.loading
0099 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0100 Kirigami.Theme.inherit: false
0101 }
0102 }
0103
0104 // track information
0105 ColumnLayout {
0106 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0107 Layout.fillWidth: true
0108 Layout.fillHeight: true
0109
0110 Label {
0111 id: mainLabel
0112 text: info.title ? info.title : i18n("No media playing")
0113 textFormat: Text.PlainText
0114 wrapMode: Text.Wrap
0115 Layout.fillWidth: true
0116 horizontalAlignment: Text.AlignLeft
0117 elide: Text.ElideRight
0118 maximumLineCount: 1
0119 // Hardcoded because the footerbar blur always makes a dark-ish
0120 // background, so we don't want to use a color scheme color that
0121 // might also be dark
0122 color: Kirigami.Theme.textColor
0123 font.weight: Font.Bold
0124 }
0125
0126 Label {
0127 id: authorLabel
0128 text: info.artist ? info.artist : info.channel
0129 textFormat: Text.PlainText
0130 wrapMode: Text.Wrap
0131 Layout.fillWidth: true
0132 horizontalAlignment: Text.AlignLeft
0133 elide: Text.ElideRight
0134 maximumLineCount: 1
0135 // Hardcoded because the footerbar blur always makes a dark-ish
0136 // background, so we don't want to use a color scheme color that
0137 // might also be dark
0138 color: Kirigami.Theme.disabledTextColor
0139 }
0140 }
0141 }
0142 MouseArea {
0143 id: trackClick
0144 anchors.fill: parent
0145 hoverEnabled: true
0146 onClicked: root.requestOpen()
0147 }
0148 }
0149
0150 RowLayout {
0151 id: controlButtonBox
0152
0153 anchors.top: parent.top
0154 anchors.bottom: parent.bottom
0155 // horizontal anchors (center or right) are managed by state
0156 // transitions at the root component
0157
0158 spacing: 2
0159
0160 Label {
0161 color: "white"
0162 visible: info.title && root.isWidescreen
0163 text: PlayerUtils.formatTimestamp(audio.position)
0164 Layout.rightMargin: 20
0165 }
0166
0167 Button {
0168 id: skipBackwardButton
0169 implicitHeight: 40
0170 implicitWidth: 40
0171 Layout.fillHeight: !isWidescreen
0172
0173 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0174 Kirigami.Theme.inherit: false
0175
0176 enabled: UserPlaylistModel.canSkipBack
0177 onClicked: UserPlaylistModel.previous()
0178
0179 contentItem: Item {
0180 Kirigami.Icon {
0181 anchors.centerIn: parent
0182 source:"media-skip-backward"
0183 color: "white"
0184 width: Kirigami.Units.gridUnit
0185 height: Kirigami.Units.gridUnit
0186 }
0187 }
0188
0189 background: Kirigami.ShadowedRectangle {
0190 corners.topLeftRadius: isWidescreen ? 7 : 0
0191 corners.bottomLeftRadius: isWidescreen ? 7 : 0
0192
0193 color: if (isWidescreen) {
0194 if (parent.down) {
0195 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0196 } else if(parent.hovered) {
0197 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0198 } else {
0199 Qt.rgba(1, 1, 1, 0.2)
0200 }
0201 } else {
0202 if (parent.down) {
0203 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0204 } else if (parent.hovered){
0205 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0206 } else {
0207 "transparent"
0208 }
0209 }
0210 }
0211 }
0212
0213 Button {
0214 id: playPauseButton
0215 implicitHeight: 40
0216 implicitWidth: 60
0217 Layout.fillHeight: !isWidescreen
0218
0219 onClicked: audio.playbackState === MediaPlayer.PlayingState ? audio.pause() : audio.play()
0220 contentItem: Item {
0221 Kirigami.Icon {
0222 anchors.centerIn:parent
0223 source: audio.playbackState === MediaPlayer.PlayingState ? "media-playback-pause" : "media-playback-start"
0224 color: "white"
0225 width: Kirigami.Units.gridUnit
0226 height: Kirigami.Units.gridUnit
0227 }
0228 }
0229
0230 background: Kirigami.ShadowedRectangle {
0231 color: if (isWidescreen) {
0232 if (parent.down) {
0233 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0234 } else if (parent.hovered) {
0235 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0236 } else {
0237 Qt.rgba(1, 1, 1, 0.2)
0238 }
0239 } else {
0240 if (parent.down) {
0241 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0242 } else if (parent.hovered) {
0243 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0244 } else {
0245 "transparent"
0246 }
0247 }
0248
0249 }
0250
0251 }
0252
0253 Button {
0254 id: skipForwardButton
0255 implicitHeight: 40
0256 implicitWidth: 40
0257 Layout.fillHeight: !isWidescreen
0258 Layout.rightMargin: isWidescreen ? 0 : 10
0259 Layout.alignment: !Qt.AlignVCenter
0260
0261 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0262 Kirigami.Theme.inherit: false
0263
0264 enabled: UserPlaylistModel.canSkip
0265 onClicked: UserPlaylistModel.next()
0266 contentItem: Item {
0267 Kirigami.Icon {
0268 anchors.centerIn: parent
0269 source:"media-skip-forward"
0270 color: "white"
0271 width: Kirigami.Units.gridUnit
0272 height: Kirigami.Units.gridUnit
0273 }
0274 }
0275 background: Kirigami.ShadowedRectangle {
0276 corners.topRightRadius: isWidescreen ? 7 : 0
0277 corners.bottomRightRadius: isWidescreen ? 7 : 0
0278 color: if (isWidescreen) {
0279 if (parent.down) {
0280 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0281 } else if (parent.hovered) {
0282 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0283 } else {
0284 Qt.rgba(1, 1, 1, 0.2)
0285 }
0286 } else {
0287 if (parent.down) {
0288 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.3)
0289 } else if(parent.hovered) {
0290 Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.hoverColor, "transparent", 0.7)
0291 } else {
0292 "transparent"
0293 }
0294 }
0295 }
0296 }
0297
0298 Label {
0299 color: "white"
0300 visible: info.title && root.isWidescreen
0301 text: PlayerUtils.formatTimestamp(audio.duration)
0302 Layout.leftMargin: 20
0303 }
0304 }
0305 }