Warning, /multimedia/elisa/src/qml/mobile/MobileMinimizedPlayerControl.qml is written in an unsupported language. File is not indexed.

0001 /*
0002    SPDX-FileCopyrightText: 2016 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
0003    SPDX-FileCopyrightText: 2020 (c) Carson Black <uhhadd@gmail.com>
0004    SPDX-FileCopyrightText: 2020 (c) Devin Lin <espidev@gmail.com>
0005 
0006    SPDX-License-Identifier: LGPL-3.0-or-later
0007  */
0008 
0009 import QtQuick 2.7
0010 import QtQuick.Layouts 1.2
0011 import QtQuick.Controls 2.7
0012 import QtQuick.Window 2.2
0013 import Qt5Compat.GraphicalEffects
0014 import org.kde.kirigami 2.5 as Kirigami
0015 import org.kde.elisa 1.0
0016 
0017 import ".."
0018 import "../shared"
0019 
0020 BasePlayerControl {
0021     id: musicWidget
0022 
0023     property alias volume: volumeButton.sliderValue
0024     property alias volumeSlider: volumeButton.slider
0025 
0026     property string image
0027     property string artist
0028     property string title
0029 
0030     property int imageSourceSize: 512
0031 
0032     property bool isWidescreen: mainWindow.width >= elisaTheme.viewSelectorSmallSizeThreshold
0033 
0034     SystemPalette {
0035         id: myPalette
0036         colorGroup: SystemPalette.Active
0037     }
0038 
0039     Theme {
0040         id: elisaTheme
0041     }
0042 
0043     // background image
0044     ImageWithFallback {
0045         id: oldBackground
0046 
0047         source: image
0048         fallback: elisaTheme.defaultBackgroundImage
0049         asynchronous: true
0050 
0051         anchors.fill: parent
0052         fillMode: Image.PreserveAspectCrop
0053 
0054         // make the FastBlur effect more strong
0055         sourceSize.height: 10
0056 
0057         opacity: 1
0058 
0059         layer.enabled: true
0060         layer.effect: HueSaturation {
0061             cached: true
0062 
0063             lightness: -0.5
0064             saturation: 0.9
0065 
0066             layer.enabled: true
0067             layer.effect: FastBlur {
0068                 cached: true
0069                 radius: 64
0070                 transparentBorder: false
0071             }
0072         }
0073     }
0074 
0075     // darken background
0076     Rectangle {
0077         anchors.fill: parent
0078 
0079         color: myPalette.dark
0080         opacity: elisaTheme.mediaPlayerControlOpacity
0081     }
0082 
0083     // progress bar for limited width (phones)
0084     Rectangle {
0085         z: 1
0086         anchors.top: parent.top
0087         anchors.left: parent.left
0088         height: Kirigami.Units.gridUnit / 6
0089         color: Kirigami.Theme.highlightColor
0090         width: parent.width * musicWidget.position / musicWidget.duration
0091         visible: !musicWidget.isWidescreen
0092     }
0093 
0094     // actual player bar
0095     RowLayout {
0096         anchors.fill: parent
0097         spacing: 0
0098 
0099         Rectangle {
0100             Layout.fillHeight: true
0101             Layout.fillWidth: true
0102             Layout.maximumWidth: Kirigami.Units.gridUnit * 16
0103             Layout.preferredWidth: Kirigami.Units.gridUnit * 16
0104             color: Qt.rgba(0, 0, 0, trackClick.containsMouse ? 0.1 : trackClick.pressed ? 0.3 : 0)
0105 
0106             RowLayout {
0107                 anchors.fill: parent
0108                 anchors.leftMargin: Kirigami.Units.largeSpacing
0109                 spacing: Kirigami.Units.largeSpacing
0110 
0111                 // track image
0112                 Item {
0113                     Layout.alignment: Qt.AlignVCenter
0114                     property double imageSize: musicWidget.height - Kirigami.Units.largeSpacing * 2
0115                     Layout.maximumWidth: imageSize
0116                     Layout.preferredWidth: imageSize
0117                     Layout.maximumHeight: imageSize
0118                     Layout.minimumHeight: imageSize
0119 
0120                     ImageWithFallback {
0121                         id: mainIcon
0122                         anchors.fill: parent
0123 
0124                         asynchronous: true
0125                         mipmap: true
0126 
0127                         source: image
0128                         fallback: Qt.resolvedUrl(elisaTheme.defaultAlbumImage)
0129 
0130                         sourceSize {
0131                             width: imageSourceSize * Screen.devicePixelRatio
0132                             height: imageSourceSize * Screen.devicePixelRatio
0133                         }
0134 
0135                         fillMode: Image.PreserveAspectFit
0136                     }
0137                 }
0138 
0139                 // track information
0140                 ColumnLayout {
0141                     Layout.fillHeight: true
0142                     Layout.fillWidth: true
0143                     Label {
0144                         id: mainLabel
0145                         text: title
0146                         textFormat: Text.PlainText
0147                         wrapMode: Text.Wrap
0148                         Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
0149                         Layout.fillWidth: true
0150                         horizontalAlignment: Text.AlignLeft
0151                         elide: Text.ElideRight
0152                         maximumLineCount: 1
0153                         // Hardcoded because the footerbar blur always makes a dark-ish
0154                         // background, so we don't want to use a color scheme color that
0155                         // might also be dark
0156                         color: "white"
0157                         font.weight: Font.Bold
0158                         font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1
0159                     }
0160 
0161                     Label {
0162                         id: authorLabel
0163                         text: artist
0164                         textFormat: Text.PlainText
0165                         wrapMode: Text.Wrap
0166                         Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
0167                         Layout.fillWidth: true
0168                         horizontalAlignment: Text.AlignLeft
0169                         elide: Text.ElideRight
0170                         maximumLineCount: 1
0171                         // Hardcoded because the footerbar blur always makes a dark-ish
0172                         // background, so we don't want to use a color scheme color that
0173                         // might also be dark
0174                         color: "white"
0175                         font.pointSize: Kirigami.Theme.defaultFont.pointSize * 1
0176                     }
0177                 }
0178             }
0179             MouseArea {
0180                 id: trackClick
0181                 anchors.fill: parent
0182                 hoverEnabled: true
0183                 onClicked: toOpen.restart()
0184             }
0185         }
0186 
0187         Item {
0188             Layout.preferredWidth: 0
0189             Layout.fillHeight: true
0190             Layout.fillWidth: true
0191 
0192             // duration slider for widescreen
0193             DurationSlider {
0194                 anchors.fill: parent
0195                 Layout.fillWidth: true
0196                 Layout.maximumHeight: Math.floor(Kirigami.Units.gridUnit * 2.5)
0197                 visible: musicWidget.isWidescreen
0198                 position: musicWidget.position
0199                 duration: musicWidget.duration
0200                 seekable: musicWidget.seekable
0201                 playEnabled: musicWidget.playEnabled
0202                 onSeek: position => musicWidget.seek(position)
0203 
0204                 // this color works well over the blurred/darkened background
0205                 labelColor: "white"
0206             }
0207         }
0208 
0209         // volume button
0210         MobileVolumeButton {
0211             id: volumeButton
0212             visible: musicWidget.isWidescreen
0213             muted: musicWidget.muted
0214             Layout.maximumHeight: parent.height
0215             Layout.preferredHeight: Math.floor(Kirigami.Units.gridUnit * 2.5)
0216             Layout.maximumWidth: height
0217             Layout.preferredWidth: height
0218         }
0219 
0220         FlatButtonWithToolTip {
0221             id: skipBackwardButton
0222             Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0223             Layout.maximumWidth: height
0224             Layout.preferredWidth: height
0225             enabled: skipBackwardEnabled
0226             text: i18nc("@action:button", "Skip Backward")
0227             onClicked: musicWidget.playPrevious()
0228             icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
0229             icon.width: Kirigami.Units.gridUnit
0230             icon.height: Kirigami.Units.gridUnit
0231             icon.color: "white"
0232             Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0233             Kirigami.Theme.inherit: false
0234         }
0235 
0236         FlatButtonWithToolTip {
0237             id: playPauseButton
0238             Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0239             Layout.maximumWidth: height
0240             Layout.preferredWidth: height
0241             enabled: playEnabled
0242             text: musicWidget.isPlaying ? i18nc("@action:button Pause any media that is playing", "Pause") : i18nc("@action:button Start playing media", "Play")
0243             onClicked: musicWidget.isPlaying ? musicWidget.pause() : musicWidget.play()
0244             icon.name: musicWidget.isPlaying ? "media-playback-pause" : "media-playback-start"
0245             icon.width: Kirigami.Units.gridUnit
0246             icon.height: Kirigami.Units.gridUnit
0247             icon.color: "white"
0248             Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0249             Kirigami.Theme.inherit: false
0250         }
0251 
0252         FlatButtonWithToolTip {
0253             id: skipForwardButton
0254             Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0255             Layout.maximumWidth: height
0256             Layout.preferredWidth: height
0257             enabled: skipForwardEnabled
0258             text: i18nc("@action:button", "Skip Forward")
0259             onClicked: musicWidget.playNext()
0260             icon.name: musicWidget.LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
0261             icon.width: Kirigami.Units.gridUnit
0262             icon.height: Kirigami.Units.gridUnit
0263             icon.color: "white"
0264             Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
0265             Kirigami.Theme.inherit: false
0266         }
0267 
0268         Item { implicitWidth: Math.floor(Kirigami.Units.smallSpacing / 2) }
0269     }
0270 
0271     Component.onCompleted: {
0272         for (const element of [
0273             skipForwardButton,
0274             skipBackwardButton,
0275             playPauseButton,
0276         ]) {
0277             ElisaApplication.installKeyEventFilter(element)
0278         }
0279     }
0280 }