1/*
2 * Copyright (C) 2017
3 *      Jean-Luc Barriere <jlbarriere68@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18import QtQuick 2.9
19import QtQuick.Controls 2.2
20
21Item {
22    anchors {
23        left: parent.left
24        right: parent.right
25    }
26
27    property alias titleColumn: titleColumnLoader.sourceComponent
28    property alias coverSources: coversImage.covers
29    property alias coverFlow: coversImage.flowModel
30    property alias noCover: coversImage.noCover
31    property alias rightColumn: rightColumnLoader.sourceComponent
32    property alias firstSource: coversImage.firstSource
33    property bool isFavorite: false
34    readonly property bool wideView: width > mainView.wideSongView
35    readonly property real contentHeight: {
36        titleColumnLoader.item.height + rightColumnLoader.item.height +
37             coversImage.anchors.topMargin + coversImage.anchors.bottomMargin
38    }
39
40    CoverGrid {
41        id: coversImage
42        anchors {
43            left: parent.left
44            top: parent.top
45            margins: units.gu(1)
46        }
47        size: wideView ? titleColumnLoader.item.height + rightColumnLoader.item.height : rightColumnLoader.item.height
48
49        Behavior on size {
50            NumberAnimation { }
51        }
52    }
53
54    /* Show starred */
55    Icon {
56        id: starred
57        anchors {
58            bottom: coversImage.bottom
59            right: coversImage.right
60        }
61        height: isFavorite ? (coversImage.size * 0.40) : 0
62        width: height
63        enabled: isFavorite
64        source: "qrc:/images/starred.svg"
65        color: styleMusic.card.foregroundColor
66    }
67
68    Loader {
69        id: rightColumnLoader
70        anchors {
71            bottom: coversImage.bottom
72            left: coversImage.right
73            leftMargin: units.gu(2)
74        }
75    }
76
77    Loader {
78        id: titleColumnLoader
79        anchors {
80            left: parent.width > mainView.wideSongView ? coversImage.right : coversImage.left
81            leftMargin: parent.width > mainView.wideSongView ? units.gu(2) : units.gu(0)
82            right: parent.right
83            rightMargin: parent.width > mainView.wideSongView ? units.gu(0) : units.gu(2)
84            top: parent.width > mainView.wideSongView ? coversImage.top : coversImage.bottom
85            topMargin: parent.width > mainView.wideSongView ? units.gu(0) : units.gu(1)
86        }
87    }
88}
89