~mzanetti/unity8/launcher-follow-unity-api

« back to all changes in this revision

Viewing changes to Dash/People/Delegate.qml

  • Committer: Michael Zanetti
  • Date: 2013-06-26 09:26:51 UTC
  • mfrom: (22.1.24 unity)
  • Revision ID: michael.zanetti@canonical.com-20130626092651-ku85xmvlt2pjgypx
merge trunk

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
 
import "../../Components"
20
 
import "../../Components/Time.js" as Time
21
 
 
22
 
Item {
23
 
    id: peopleView
24
 
 
25
 
    property var dataModel
26
 
 
27
 
    property int __spacing: units.gu(1)
28
 
 
29
 
    /* Select what is shown in the subtitle
30
 
       data: phone number or email address
31
 
       status: social media presence status
32
 
    */
33
 
    property string subtitleType: "data"
34
 
    height: subtitleType == "data" && detailsLabel.lineCount < 2 ? units.gu(10) : units.gu(11.5)
35
 
 
36
 
    Row {
37
 
        id: row
38
 
        anchors {
39
 
            left: parent.left
40
 
            right: parent.right
41
 
            leftMargin: units.gu(2)
42
 
            rightMargin: units.gu(4)
43
 
            top: parent.top
44
 
            topMargin: units.gu(2)
45
 
        }
46
 
        spacing: __spacing
47
 
 
48
 
        UbuntuShape {
49
 
            id: avatar
50
 
            anchors { top: parent.top }
51
 
            width: units.gu(6)
52
 
            height: units.gu(6)
53
 
            image: Image {
54
 
                width: units.gu(6)
55
 
                source: peopleView.dataModel.avatar
56
 
                sourceSize { width: avatar.width; height: avatar.height }
57
 
                fillMode: Image.PreserveAspectCrop
58
 
                smooth: true
59
 
                asynchronous: true
60
 
                cache: false
61
 
            }
62
 
        }
63
 
 
64
 
        Grid {
65
 
            spacing: units.gu(0.5)
66
 
            width: parent.width - x
67
 
            columns: 2
68
 
 
69
 
            Item {
70
 
                height: units.gu(2)
71
 
                width: units.gu(2)
72
 
 
73
 
                Image {
74
 
                    id: statusImage
75
 
                    source: peopleView.dataModel.statusIcon
76
 
                    width: units.gu(1.5)
77
 
                    height: units.gu(1.5)
78
 
                    fillMode: Image.PreserveAspectFit
79
 
                    smooth: true
80
 
                    anchors.verticalCenter: parent.verticalCenter
81
 
                }
82
 
            }
83
 
 
84
 
            Label {
85
 
                id: nameLabel
86
 
                elide: Text.ElideRight
87
 
                text: peopleView.dataModel.name
88
 
                color: "#f3f3e7"
89
 
                style: Text.Raised
90
 
                styleColor: "black"
91
 
                font.weight: Font.DemiBold;
92
 
                opacity: 0.9;
93
 
            }
94
 
 
95
 
            Image {
96
 
                source: switch(peopleView.subtitleType) {
97
 
                        case "data":
98
 
                            return peopleView.dataModel.remoteSourceIcon;
99
 
                        case "status":
100
 
                            return peopleView.dataModel.recent ? peopleView.dataModel.recentIcon : "";
101
 
                        }
102
 
 
103
 
                width: units.gu(1.5)
104
 
                height: units.gu(1.5)
105
 
                fillMode: Image.PreserveAspectFit
106
 
                smooth: true
107
 
            }
108
 
 
109
 
            Label {
110
 
                id: detailsLabel
111
 
                width: parent.width - x
112
 
                elide: Text.ElideRight
113
 
                text: switch (peopleView.subtitleType) {
114
 
                    case "data":
115
 
                        if (peopleView.dataModel.phones && peopleView.dataModel.phones.count > 0) {
116
 
                            return peopleView.dataModel.phones.get(0).number;
117
 
                        } else if (peopleView.dataModel.emails && peopleView.dataModel.emails.count > 0) {
118
 
                            return peopleView.dataModel.emails.get(0).address;
119
 
                        }
120
 
                        return "";
121
 
                    case "status":
122
 
                        return peopleView.dataModel.status;
123
 
                     }
124
 
                color: "#f3f3e7"
125
 
                style: Text.Raised
126
 
                styleColor: "black"
127
 
                opacity: 0.7;
128
 
                fontSize: "small";
129
 
                wrapMode: Text.WordWrap;
130
 
                maximumLineCount: 2;
131
 
            }
132
 
 
133
 
            Item {
134
 
                height: units.gu(2)
135
 
                width: units.gu(1.5)
136
 
 
137
 
                // Placeholder
138
 
            }
139
 
 
140
 
            Label {
141
 
                width: parent.width - x
142
 
                elide: Text.ElideRight
143
 
                text: switch (peopleView.subtitleType) {
144
 
                      case "data":
145
 
                          if (peopleView.dataModel.phones && peopleView.dataModel.phones.count > 0) {
146
 
                              return peopleView.dataModel.phones.get(0).type;
147
 
                          } else if (peopleView.dataModel.emails && peopleView.dataModel.emails.count > 0) {
148
 
                              return peopleView.dataModel.emails.get(0).type;
149
 
                          }
150
 
                          return "";
151
 
                      case "status":
152
 
                          if (peopleView.dataModel.recent) {
153
 
                              var time = Time.readableFromNow(peopleView.dataModel.recentTime);
154
 
                              return time ? time : peopleView.dataModel.recentTime;
155
 
                          } else {
156
 
                              return peopleView.dataModel.status
157
 
                          }
158
 
                      }
159
 
                color: "#8f8f88"
160
 
                style: Text.Raised
161
 
                styleColor: "black"
162
 
                opacity: 0.7;
163
 
                fontSize: "x-small";
164
 
            }
165
 
        }
166
 
    }
167
 
}