~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to Components/Tile.qml

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.0
 
18
import Ubuntu.Components 0.1
 
19
 
 
20
AbstractButton {
 
21
    id: root
 
22
    property alias source: image.source
 
23
    property alias fillMode: image.fillMode
 
24
    property alias horizontalAlignment: image.horizontalAlignment
 
25
    property alias verticalAlignment: image.verticalAlignment
 
26
    property alias text: label.text
 
27
    property int imageWidth
 
28
    property int imageHeight
 
29
 
 
30
    UbuntuShape {
 
31
        id: icon
 
32
        anchors {
 
33
            top: parent.top
 
34
            horizontalCenter: parent.horizontalCenter
 
35
        }
 
36
        radius: "medium"
 
37
        width: imageWidth
 
38
        height: imageHeight
 
39
        image: Image {
 
40
            id: image
 
41
            objectName: "image"
 
42
            sourceSize { width: icon.width; height: icon.height }
 
43
            asynchronous: true
 
44
            cache: false
 
45
        }
 
46
    }
 
47
 
 
48
    UbuntuShape {
 
49
        id: borderPressed
 
50
        objectName: "borderPressed"
 
51
 
 
52
        anchors.fill: icon
 
53
        radius: "medium"
 
54
        borderSource: ItemStyle.style.borderPressed
 
55
        opacity: root.pressed ? 1.0 : 0.0
 
56
        Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
 
57
    }
 
58
 
 
59
    Item {
 
60
        anchors {
 
61
            left: parent.left
 
62
            right: parent.right
 
63
            top: icon.bottom
 
64
        }
 
65
        height: units.gu(2)
 
66
 
 
67
        Label {
 
68
            id: label
 
69
            objectName: "label"
 
70
            anchors {
 
71
                baseline: parent.bottom
 
72
                left: parent.left
 
73
                right: parent.right
 
74
                leftMargin: units.gu(1)
 
75
                rightMargin: units.gu(1)
 
76
            }
 
77
 
 
78
            color: "#f3f3e7"
 
79
            opacity: 0.9
 
80
            style: Text.Raised
 
81
            styleColor: "black"
 
82
            fontSize: "small"
 
83
            elide: Text.ElideMiddle
 
84
            horizontalAlignment: Text.AlignHCenter
 
85
        }
 
86
    }
 
87
 
 
88
    GridView.onRemove: SequentialAnimation {
 
89
        PropertyAction { target: root; property: "GridView.delayRemove"; value: true }
 
90
        NumberAnimation { target: root; property: "opacity"; from: 1; to: 0; duration: 200; easing.type: Easing.InOutQuad }
 
91
        PropertyAction { target: root; property: "GridView.delayRemove"; value: false }
 
92
    }
 
93
}