~ahayzen/music-app/convergence-tabs-with-sidebar-01

« back to all changes in this revision

Viewing changes to app/components/MusicRow.qml

  • Committer: Tarmac
  • Author(s): Andrew Hayzen
  • Date: 2016-01-11 16:45:56 UTC
  • mfrom: (960.1.5 fix-1526247-use-layouts)
  • Revision ID: tarmac-20160111164556-22tln8e6t66gz728
* Use ListItemLayout for listitems to improve performance and match design guidelines. Fixes: https://bugs.launchpad.net/bugs/1480269, https://bugs.launchpad.net/bugs/1526247.

Approved by Jenkins Bot, Victor Thompson.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013, 2014, 2015
3
 
 *      Andrew Hayzen <ahayzen@gmail.com>
4
 
 *      Nekhelesh Ramananthan <krnekhelesh@gmail.com>
5
 
 *      Victor Thompson <victor.thompson@gmail.com>
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; version 3.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
import QtQuick 2.4
21
 
import Ubuntu.Components 1.3
22
 
 
23
 
 
24
 
Row {
25
 
    height: units.gu(7)
26
 
 
27
 
    property alias column: columnComponent.sourceComponent
28
 
    property real coverSize: styleMusic.common.albumSize
29
 
    property var imageSource
30
 
 
31
 
    spacing: units.gu(2)
32
 
 
33
 
    Image {
34
 
        id: image
35
 
        anchors {
36
 
            verticalCenter: parent.verticalCenter
37
 
        }
38
 
        asynchronous: true
39
 
        fillMode: Image.PreserveAspectCrop
40
 
        height: width
41
 
        source: imageSource !== undefined && imageSource !== ""
42
 
                ? (imageSource.art !== undefined
43
 
                   ? imageSource.art
44
 
                   : "image://albumart/artist=" + imageSource.author + "&album=" + imageSource.album)
45
 
                : ""
46
 
        sourceSize.height: height
47
 
        sourceSize.width: width
48
 
        width: units.gu(6)
49
 
 
50
 
        onStatusChanged: {
51
 
            if (status === Image.Error) {
52
 
                source = Qt.resolvedUrl("../graphics/music-app-cover@30.png")
53
 
            }
54
 
        }
55
 
        visible: imageSource !== undefined
56
 
    }
57
 
 
58
 
    Loader {
59
 
        id: columnComponent
60
 
        anchors {
61
 
            verticalCenter: parent.verticalCenter
62
 
        }
63
 
        width: imageSource === undefined ? parent.width - parent.spacing
64
 
                                         : parent.width - image.width - parent.spacing
65
 
 
66
 
        onSourceComponentChanged: {
67
 
            for (var i=0; i < item.children.length; i++) {
68
 
                item.children[i].elide = Text.ElideRight
69
 
                item.children[i].height = units.gu(2)
70
 
                item.children[i].maximumLineCount = 1
71
 
                item.children[i].wrapMode = Text.NoWrap
72
 
                item.children[i].verticalAlignment = Text.AlignVCenter
73
 
 
74
 
                // binds to width so it is updated when screen size changes
75
 
                item.children[i].width = Qt.binding(function () { return width; })
76
 
            }
77
 
        }
78
 
    }
79
 
}