~ubuntu-branches/ubuntu/vivid/muon/vivid-proposed

« back to all changes in this revision

Viewing changes to discover/qml/ApplicationsGridDelegate.qml

Tags: upstream-1.3.65
ImportĀ upstreamĀ versionĀ 1.3.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import org.kde.plasma.components 0.1
 
2
import org.kde.qtextracomponents 0.1
 
3
import "navigation.js" as Navigation
 
4
import QtQuick 1.1
 
5
 
 
6
ListItem {
 
7
    id: delegateRoot
 
8
    clip: true
 
9
    width: parentItem.cellWidth
 
10
    height: parentItem.cellHeight
 
11
    property bool requireClick: false
 
12
    
 
13
    MouseArea {
 
14
        id: delegateArea
 
15
        anchors.fill: parent
 
16
        hoverEnabled: true
 
17
        property bool displayDescription: false
 
18
        onPositionChanged: if(!delegateRoot.requireClick) timer.restart()
 
19
        onExited: { if(!delegateRoot.requireClick) timer.stop(); displayDescription=false}
 
20
        Timer {
 
21
            id: timer
 
22
            interval: 200
 
23
            onTriggered: delegateArea.displayDescription=true
 
24
        }
 
25
        onClicked: {
 
26
            if(delegateRoot.requireClick && !displayDescription) {
 
27
                displayDescription=true
 
28
            } else
 
29
                Navigation.openApplication(application)
 
30
        }
 
31
    
 
32
        Flickable {
 
33
            id: delegateFlickable
 
34
            anchors.fill: parent
 
35
            contentHeight: delegateRoot.height*2
 
36
            interactive: false
 
37
            Behavior on contentY { NumberAnimation { duration: 200; easing.type: Easing.InQuad } }
 
38
            
 
39
            Image {
 
40
                id: screen
 
41
                anchors {
 
42
                    horizontalCenter: parent.horizontalCenter
 
43
                    top: parent.top
 
44
                    topMargin: 5
 
45
                }
 
46
                fillMode: Image.PreserveAspectFit
 
47
                source: model.application.thumbnailUrl
 
48
                width: parent.width; height: delegateRoot.height*0.7
 
49
                sourceSize {
 
50
                    width: screen.width
 
51
                    height: screen.height
 
52
                }
 
53
                cache: false
 
54
                asynchronous: true
 
55
                onStatusChanged:  {
 
56
                    if(status==Image.Error) {
 
57
                        sourceSize.width = height
 
58
                        sourceSize.height = height
 
59
                        source="image://icon/"+model.application.icon
 
60
                        smallIcon.visible = false
 
61
                    }
 
62
                }
 
63
            }
 
64
            QIconItem {
 
65
                id: smallIcon
 
66
                anchors {
 
67
                    right: screen.right
 
68
                }
 
69
                width: 48
 
70
                height: width
 
71
                icon: model.application.icon
 
72
                Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.InQuad } }
 
73
            }
 
74
            Label {
 
75
                anchors {
 
76
                    top: screen.bottom
 
77
                    left: parent.left
 
78
                    right: parent.right
 
79
                    leftMargin: 5
 
80
                }
 
81
                horizontalAlignment: Text.AlignHCenter
 
82
                elide: Text.ElideRight
 
83
                text: name
 
84
            }
 
85
            Loader {
 
86
                id: descriptionLoader
 
87
                anchors {
 
88
                    left: parent.left
 
89
                    right: parent.right
 
90
                    bottom: parent.bottom
 
91
                    top: parent.verticalCenter
 
92
                }
 
93
            }
 
94
        }
 
95
        onStateChanged: {
 
96
            if(state=="description")
 
97
                descriptionLoader.sourceComponent=extraInfoComponent
 
98
        }
 
99
        
 
100
        state: "screenshot"
 
101
        states: [
 
102
            State { name: "screenshot"
 
103
                when: !delegateArea.displayDescription
 
104
                PropertyChanges { target: smallIcon; y: 5+screen.height-height }
 
105
                PropertyChanges { target: delegateFlickable; contentY: 0 }
 
106
            },
 
107
            State { name: "description"
 
108
                when: delegateArea.displayDescription
 
109
                PropertyChanges { target: smallIcon; y: 5+delegateRoot.height }
 
110
                PropertyChanges { target: delegateFlickable; contentY: delegateRoot.height }
 
111
            }
 
112
        ]
 
113
    }
 
114
    
 
115
    Component {
 
116
        id: extraInfoComponent
 
117
        Item {
 
118
            Label {
 
119
                anchors {
 
120
                    left: parent.left
 
121
                    right: parent.right
 
122
                    top: parent.top
 
123
                    bottom: installButton.top
 
124
                    rightMargin: smallIcon.visible ? 48 : 0
 
125
                    topMargin: 5
 
126
                }
 
127
                verticalAlignment: Text.AlignVCenter
 
128
                horizontalAlignment: Text.AlignHCenter
 
129
                wrapMode: Text.WordWrap
 
130
                text: model.application.comment
 
131
            }
 
132
            InstallApplicationButton {
 
133
                id: installButton
 
134
                width: parent.width/3
 
135
                height: 30
 
136
                anchors {
 
137
                    bottom: parent.bottom
 
138
                    left: parent.left
 
139
                    bottomMargin: 20
 
140
                    margins: 10
 
141
                }
 
142
                
 
143
                application: model.application
 
144
                preferUpgrade: page.preferUpgrade
 
145
            }
 
146
            Item {
 
147
                anchors {
 
148
                    right: parent.right
 
149
                    left: installButton.right
 
150
                    verticalCenter: installButton.verticalCenter
 
151
                    margins: 10
 
152
                    topMargin: 20
 
153
                }
 
154
                height: Math.min(installButton.height, width/5)
 
155
                Rating {
 
156
                    anchors.fill: parent
 
157
                    rating: model.rating
 
158
                    visible: !model.application.canUpgrade && model.rating>=0
 
159
                }
 
160
                Button {
 
161
                    text: i18n("Upgrade")
 
162
                    visible: model.application.canUpgrade
 
163
                }
 
164
            }
 
165
        }
 
166
    }
 
167
}
 
 
b'\\ No newline at end of file'