Debian Codegraph @

src/imports/Lomiri/AddressBook/ContactView/ContactDetailUrlView.qml

raw
1 /*
2 * Copyright (C) 2020 UBports Foundation.
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.4
18 import Lomiri.Components 1.3
19 import QtContacts 5.0 as QtContacts
20
21 import Lomiri.AddressBook.Base 0.1
22
23
24 ContactDetailBase {
25 id: root
26
27 property string url : detail ? detail.url : ""
28
29 detailType: QtContacts.ContactDetail.Url
30
31 visible: implicitHeight > 0
32 implicitHeight:(url.length > 0) ? contents.implicitHeight : 0
33
34 Column {
35 id: contents
36 spacing: units.gu(1)
37 width: parent.width
38
39 ContactDetailTitle {
40 title: i18n.dtr("lomiri-addressbook-app", "Web address")
41 }
42
43 Rectangle {
44
45 anchors {
46 left: parent.left
47 right: parent.right
48 leftMargin: units.gu(2)
49 rightMargin: units.gu(2)
50 }
51 height: childrenRect.height
52 color: theme.palette.normal.background
53
54 Label {
55 id: label
56 anchors.left: parent.left
57 anchors.right: icon.left
58 height: units.gu(3)
59 fontSize: "medium"
60 text: root.url
61 elide: Label.ElideRight
62 }
63
64 Icon {
65 id: icon
66
67 anchors.right: parent.right
68 anchors.rightMargin: units.gu(1)
69 width: units.gu(2.5)
70 height: width
71 name: "external-link"
72 color: root.activeFocus ? theme.palette.normal.focus : theme.palette.normal.baseText
73 asynchronous: true
74 }
75 }
76 }
77
78 onClicked: {
79 Qt.openUrlExternally(root.url)
80 }
81 }