| 1 |
/* |
| 2 |
* Copyright (C) 2012-2015 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.12 |
| 18 |
import QtGraphicalEffects 1.0 |
| 19 |
import QtContacts 5.0 |
| 20 |
import Lomiri.Components 1.3 |
| 21 |
|
| 22 |
import Lomiri.Contacts 0.1 |
| 23 |
import Lomiri.AddressBook.Base 0.1 |
| 24 |
|
| 25 |
ContactDetailBase { |
| 26 |
id: root |
| 27 |
|
| 28 |
property alias editable: favImage.enabled |
| 29 |
|
| 30 |
implicitHeight: units.gu(12) |
| 31 |
implicitWidth: parent.width |
| 32 |
activeFocusOnTab: false |
| 33 |
|
| 34 |
Connections { |
| 35 |
id: connections |
| 36 |
|
| 37 |
target: avatar.contactElement |
| 38 |
ignoreUnknownSignals: true |
| 39 |
function onContactChanged() { avatar.reload() } |
| 40 |
} |
| 41 |
|
| 42 |
Image { |
| 43 |
id: imageBg |
| 44 |
|
| 45 |
source: avatar.avatarUrl |
| 46 |
anchors.fill: parent |
| 47 |
fillMode: Image.PreserveAspectCrop |
| 48 |
visible: false |
| 49 |
asynchronous: true |
| 50 |
autoTransform: true |
| 51 |
|
| 52 |
OpacityMask { |
| 53 |
source: mask |
| 54 |
maskSource: imageBg |
| 55 |
} |
| 56 |
|
| 57 |
LinearGradient { |
| 58 |
id: mask |
| 59 |
anchors.fill: parent |
| 60 |
start: Qt.point(0, 0) |
| 61 |
end: Qt.point(imageBg.x + imageBg.width, 0) |
| 62 |
gradient: Gradient { |
| 63 |
GradientStop { position: 0.2; color: "transparent"} |
| 64 |
GradientStop { position: 1.0; color: theme.palette.normal.background } |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
FastBlur { |
| 71 |
anchors.fill: imageBg |
| 72 |
source: imageBg |
| 73 |
radius: 32 |
| 74 |
visible: avatar.avatarUrl !== avatar.fallbackAvatarUrl |
| 75 |
} |
| 76 |
|
| 77 |
ContactAvatar { |
| 78 |
id: avatar |
| 79 |
objectName: "contactAvatarDetail" |
| 80 |
|
| 81 |
contactElement: root.contact |
| 82 |
height: units.gu(8) |
| 83 |
width: height |
| 84 |
|
| 85 |
anchors { |
| 86 |
left: parent.left |
| 87 |
verticalCenter: parent.verticalCenter |
| 88 |
leftMargin: units.gu(2) |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
ActionButton { |
| 94 |
id: favImage |
| 95 |
objectName: "contactFavoriteDetail" |
| 96 |
|
| 97 |
iconName: root.contact && root.contact.favorite.favorite ? "starred" : "non-starred" |
| 98 |
height: units.gu(4) |
| 99 |
visible: root.editable || (root.contact && root.contact.favorite.favorite) |
| 100 |
iconSize: units.gu(3) |
| 101 |
width: height |
| 102 |
anchors { |
| 103 |
right: parent.right |
| 104 |
rightMargin: units.gu(2) |
| 105 |
verticalCenter: parent.verticalCenter |
| 106 |
} |
| 107 |
|
| 108 |
onClicked: { |
| 109 |
root.contact.favorite.favorite = !root.contact.favorite.favorite |
| 110 |
root.contact.save() |
| 111 |
} |
| 112 |
} |
| 113 |
} |