| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2017 Malte Veerman <[email protected]> * |
| 3 |
* * |
| 4 |
* This program is free software; you can redistribute it and/or modify it under * |
| 5 |
* the terms of the GNU General Public License as published by the Free Software * |
| 6 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 7 |
* version. * |
| 8 |
* * |
| 9 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 10 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 11 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 12 |
* * |
| 13 |
* You should have received a copy of the GNU General Public License along with * |
| 14 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 15 |
****************************************************************************************/ |
| 16 |
|
| 17 |
import QtQuick 2.15 |
| 18 |
import QtQuick.Controls 2.15 |
| 19 |
import QtQuick.Layouts 1.15 |
| 20 |
import org.kde.kirigami 2.14 as Kirigami |
| 21 |
import org.kde.amarok.qml 1.0 as AmarokQml |
| 22 |
import org.kde.amarok.currenttrack 1.0 |
| 23 |
|
| 24 |
AmarokQml.Applet { |
| 25 |
id: applet |
| 26 |
|
| 27 |
//album art |
| 28 |
Loader { |
| 29 |
id: cover |
| 30 |
|
| 31 |
height: parent.height |
| 32 |
width: height |
| 33 |
|
| 34 |
sourceComponent: CurrentTrackEngine.hasValidCover ? coverComponent : emptyComponent |
| 35 |
} |
| 36 |
|
| 37 |
ColumnLayout { |
| 38 |
anchors { |
| 39 |
left: cover.right |
| 40 |
leftMargin: applet.spacing |
| 41 |
right: parent.right |
| 42 |
top: parent.top |
| 43 |
bottom: parent.bottom |
| 44 |
} |
| 45 |
|
| 46 |
GridLayout { |
| 47 |
id: artistRatingGrid |
| 48 |
Layout.preferredWidth: parent.width |
| 49 |
Layout.fillWidth: true |
| 50 |
Layout.fillHeight: true |
| 51 |
Layout.alignment: Qt.AlignTop |
| 52 |
flow: parent.width < ( infoItem.Layout.minimumWidth + ratingItem.Layout.minimumWidth ) * 8 ? GridLayout.TopToBottom : GridLayout.LeftToRight |
| 53 |
|
| 54 |
InfoItem { |
| 55 |
id: infoItem |
| 56 |
|
| 57 |
width: ( artistRatingGrid.flow == GridLayout.TopToBottom ? parent.width : parent.width / 2 ) |
| 58 |
Layout.minimumWidth: 24 |
| 59 |
Layout.maximumWidth: parent.width |
| 60 |
Layout.fillHeight: true |
| 61 |
Layout.alignment: Qt.AlignLeft |
| 62 |
} |
| 63 |
AmarokQml.RatingItem { |
| 64 |
id: ratingItem |
| 65 |
|
| 66 |
Layout.preferredWidth: height * 6 |
| 67 |
Layout.preferredHeight: parent.height / 5 |
| 68 |
Layout.maximumHeight: parent.height / 5 |
| 69 |
Layout.minimumWidth: 24 |
| 70 |
Layout.maximumWidth: parent.width / ( artistRatingGrid.flow == GridLayout.TopToBottom ? 1 : 2 ) |
| 71 |
Layout.minimumHeight: 100 |
| 72 |
|
| 73 |
Layout.alignment: Qt.AlignTop | Qt.AlignRight |
| 74 |
rating: CurrentTrackEngine.rating |
| 75 |
onClicked: CurrentTrackEngine.rating = newRating |
| 76 |
} |
| 77 |
} |
| 78 |
StatsItem { |
| 79 |
id: statsItem |
| 80 |
|
| 81 |
Layout.fillWidth: true |
| 82 |
Layout.alignment: Qt.AlignBottom |
| 83 |
Layout.preferredHeight: parent.height / 5 |
| 84 |
} |
| 85 |
visible: CurrentTrackEngine.track !== "" |
| 86 |
} |
| 87 |
|
| 88 |
RowLayout { |
| 89 |
anchors { |
| 90 |
left: cover.right |
| 91 |
leftMargin: applet.spacing |
| 92 |
right: parent.right |
| 93 |
top: parent.top |
| 94 |
bottom: parent.bottom |
| 95 |
} |
| 96 |
Label { |
| 97 |
id: nothingPlaying |
| 98 |
font.bold: true |
| 99 |
color: Kirigami.Theme.textColor |
| 100 |
Layout.alignment: Qt.AlignCenter |
| 101 |
Layout.minimumWidth: parent.height / 3 |
| 102 |
text: i18n("No track playing") |
| 103 |
} |
| 104 |
Item { |
| 105 |
id: logoComponent |
| 106 |
Layout.minimumWidth: parent.height / 3 |
| 107 |
Layout.maximumWidth: parent.height |
| 108 |
Layout.fillHeight: true |
| 109 |
AmarokQml.PixmapItem { |
| 110 |
id: amarokLogo |
| 111 |
source: Svg.renderSvg(applet.imageUrl("amarok-currenttrack.svg"), |
| 112 |
"CurrentTrackLogo", |
| 113 |
512, |
| 114 |
512, |
| 115 |
"amarok_logo"); |
| 116 |
width: parent.width |
| 117 |
height: width |
| 118 |
anchors.centerIn: parent |
| 119 |
} |
| 120 |
} |
| 121 |
visible: CurrentTrackEngine.track === "" |
| 122 |
} |
| 123 |
|
| 124 |
Component { |
| 125 |
id: coverComponent |
| 126 |
|
| 127 |
Rectangle { |
| 128 |
id: cover |
| 129 |
|
| 130 |
color: "white" |
| 131 |
radius: Kirigami.Units.smallSpacing / 2 |
| 132 |
border.width: albumCoverMouse.containsMouse ? 3 : 1 |
| 133 |
border.color: albumCoverMouse.containsMouse ? Kirigami.Theme.highlightColor : applet.palette.light |
| 134 |
|
| 135 |
AmarokQml.PixmapItem { |
| 136 |
id: iconItem |
| 137 |
|
| 138 |
anchors.fill: parent |
| 139 |
anchors.margins: parent.radius |
| 140 |
source: CurrentTrackEngine.cover |
| 141 |
} |
| 142 |
MouseArea { |
| 143 |
id: albumCoverMouse |
| 144 |
anchors.fill: parent |
| 145 |
hoverEnabled: true |
| 146 |
onClicked: CurrentTrackEngine.displayCover() |
| 147 |
} |
| 148 |
} |
| 149 |
} |
| 150 |
Component { |
| 151 |
id: emptyComponent |
| 152 |
|
| 153 |
AmarokQml.PixmapItem { |
| 154 |
source: Svg.renderSvg(applet.imageUrl("amarok-currenttrack.svg"), |
| 155 |
"CurrentTrackAlbum", |
| 156 |
512, |
| 157 |
512, |
| 158 |
"album_old"); |
| 159 |
width: parent.width |
| 160 |
height: parent.height |
| 161 |
} |
| 162 |
} |
| 163 |
} |