Warning, /plasma-mobile/plasma-phonebook/src/contents/ui/DetailPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2018 Fabian Riethmayer
0003  *   SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de>
0004  *
0005  *   SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 import QtQuick
0009 import QtQuick.Controls
0010 import QtQuick.Layouts
0011 import Qt5Compat.GraphicalEffects
0012 import org.kde.people as KPeople
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.phonebook
0015 import org.kde.kirigamiaddons.formcard as FormCard
0016 import org.kde.kirigamiaddons.components as Components
0017 
0018 import "components"
0019 
0020 FormCard.FormCardPage {
0021     id: page
0022 
0023     property string personUri
0024     property var addressee: ContactController.addresseeFromVCard(personData.person.contactCustomProperty("vcard"))
0025 
0026     title: personData.person.name
0027 
0028     function callNumber(number) {
0029         Qt.openUrlExternally("tel:" + number)
0030     }
0031 
0032     function sendSms(number) {
0033         Qt.openUrlExternally("sms:" + number)
0034     }
0035 
0036     data: [
0037         KPeople.PersonData {
0038             id: personData
0039             personUri: page.personUri
0040         },
0041 
0042         KPeople.PersonActions {
0043             id: personActions
0044             personUri: page.personUri
0045         },
0046 
0047         DoubleActionButton {
0048             parent: overlay
0049             x: page.width - width - margin
0050             y: page.height - height - pageStack.globalToolBar.preferredHeight - margin
0051             rightAction: Kirigami.Action {
0052                 text: i18n("Edit")
0053                 icon.name: "document-edit"
0054                 onTriggered: pageStack.pushDialogLayer(Qt.resolvedUrl("AddContactPage.qml"), {state: "update", person: personData.person, addressee: page.addressee})
0055             }
0056             leftAction: Kirigami.Action {
0057                 text: i18n("Delete contact")
0058                 icon.name: "delete"
0059                 onTriggered: {
0060                     removeDialog.open()
0061                 }
0062             }
0063         },
0064 
0065         Kirigami.Dialog {
0066             id: removeDialog
0067             standardButtons: Kirigami.Dialog.Yes | Kirigami.Dialog.Cancel
0068             title: i18n("Remove Contact")
0069             RowLayout {
0070                 Kirigami.Icon {
0071                     source: "dialog-warning"
0072                     Layout.margins: Kirigami.Units.largeSpacing
0073                 }
0074 
0075                 Label {
0076                     Layout.fillWidth: true
0077                     Layout.margins: Kirigami.Units.largeSpacing
0078                     text: i18n("Are you sure you want to delete <b>%1</b> from your Contacts?", personData.person.name)
0079                     wrapMode: Text.WordWrap
0080                 }
0081             }
0082             onRejected: {
0083                 close()
0084             }
0085             onAccepted: {
0086                 KPeople.PersonPluginManager.deleteContact(page.personUri)
0087                 pageStack.pop()
0088             }
0089         }
0090     ]
0091 
0092 
0093     Item {
0094         id: header
0095         height: 170
0096         Layout.fillWidth: true
0097 
0098         Item {
0099             anchors.fill: parent
0100 
0101             Rectangle {
0102                 anchors.fill: parent
0103                 color: avatar.color
0104                 opacity: 0.2
0105 
0106             }
0107             Image {
0108                 visible: personData.photoImageProviderUri
0109                 scale: 1.8
0110                 anchors.fill: parent
0111                 asynchronous: true
0112 
0113                 source: personData.photoImageProviderUri
0114                 fillMode: Image.PreserveAspectCrop
0115 
0116                 sourceSize.width: 512
0117                 sourceSize.height: 512
0118             }
0119 
0120             layer.enabled: true
0121             layer.effect: HueSaturation {
0122                 cached: true
0123 
0124                 saturation: 1.9
0125 
0126                 layer.enabled: true
0127                 layer.effect: FastBlur {
0128                     cached: true
0129                     radius: 100
0130                 }
0131             }
0132         }
0133 
0134         Rectangle {
0135             anchors.fill: parent
0136             gradient: Gradient {
0137                 GradientStop { position: -1.0; color: "transparent" }
0138                 GradientStop { position: 1.0; color: Kirigami.Theme.backgroundColor }
0139             }
0140         }
0141 
0142         RowLayout {
0143             anchors.fill: parent
0144             RowLayout {
0145                 Layout.maximumWidth: Kirigami.Units.gridUnit * 30
0146                 Layout.alignment: Qt.AlignHCenter
0147 
0148 
0149                 Kirigami.ShadowedRectangle {
0150                     color: Kirigami.Theme.backgroundColor
0151                     Layout.margins: 30
0152                     width: 120
0153                     height: width
0154                     radius: width/2
0155                     shadow.size: 15
0156                     shadow.xOffset: 5
0157                     shadow.yOffset: 5
0158                     shadow.color: Qt.rgba(0, 0, 0, 0.2)
0159 
0160                     Components.Avatar {
0161                         id: avatar
0162 
0163                         height: parent.height
0164                         width: height
0165 
0166                         source: personData.photoImageProviderUri
0167                         name: personData.person.name
0168                         imageMode: Components.Avatar.ImageMode.AdaptiveImageOrInitals
0169                     }
0170 
0171                 }
0172                 ColumnLayout {
0173                     Layout.leftMargin: 10
0174                     Layout.rightMargin: 10
0175                     Layout.fillWidth: true
0176 
0177                     Label {
0178                         Layout.fillWidth: true
0179                         text: personData.person.name
0180                         font.bold: true
0181                         font.pixelSize: 22
0182                         maximumLineCount: 2
0183                         wrapMode: Text.Wrap
0184                         elide: Text.ElideRight
0185 
0186                     }
0187                     Label {
0188                         Layout.fillWidth: true
0189                         text: personData.person.contactCustomProperty("phoneNumber") ? personData.person.contactCustomProperty("phoneNumber") : ""
0190                         elide: Qt.ElideRight
0191                         color: Kirigami.Theme.disabledTextColor
0192 
0193                     }
0194                 }
0195             }
0196         }
0197     }
0198 
0199     FormCard.FormCard {
0200         visible: phoneNumberRepeater.count !== 0
0201         Layout.topMargin: Kirigami.Units.largeSpacing
0202 
0203         Repeater {
0204             id: phoneNumberRepeater
0205             model: addressee.phoneNumbers
0206             delegate:FormCard.FormTextDelegate{
0207                 trailing:Row{
0208                     ToolButton {
0209                         text: i18n("Call")
0210                         icon.name: "call-start"
0211                         onClicked: page.callNumber(modelData.normalizedNumber)
0212                         display: AbstractButton.IconOnly
0213 
0214                     }
0215                     ToolButton {
0216                         text: i18n("Send SMS")
0217                         icon.name: "mail-message"
0218                         onClicked: page.sendSms(modelData.normalizedNumber)
0219                         display: AbstractButton.IconOnly
0220 
0221 
0222                     }
0223                 }
0224                 text: modelData.typeLabel
0225                 description: modelData.number
0226             }
0227         }
0228     }
0229 
0230     FormCard.FormCard {
0231         visible: emailRepeater.count !== 0
0232 
0233         Layout.topMargin: Kirigami.Units.largeSpacing
0234 
0235         Repeater{
0236             id: emailRepeater
0237             model: addressee.emails
0238             delegate: FormCard.FormTextDelegate {
0239                 trailing: Row {
0240                     ToolButton {
0241                         text: i18n("Send E-Mail")
0242                         icon.name: "mail-message"
0243                         onClicked: Qt.openUrlExternally("mailto:" + modelData.email)
0244                         display: AbstractButton.IconOnly
0245                     }
0246                 }
0247                 text: i18n("E-Mail")
0248                 description: modelData.email
0249             }
0250         }
0251     }
0252 
0253     FormCard.FormCard {
0254         visible: imppRepeater.count !== 0
0255         Layout.topMargin: Kirigami.Units.largeSpacing
0256 
0257         Repeater {
0258             id: imppRepeater
0259             model: addressee.impps
0260             delegate: FormCard.FormTextDelegate {
0261                 trailing:Row {
0262                     ToolButton {
0263                         text: i18n("Send Message")
0264                         icon.name: modelData.serviceIcon
0265                         onClicked: Qt.openUrlExternally(modelData.address)
0266                         display: AbstractButton.IconOnly
0267 
0268                     }
0269                 }
0270                 text: modelData.serviceLabel
0271                 description: modelData.address
0272             }
0273         }
0274     }
0275 
0276     FormCard.FormCard {
0277         visible: birthday.description !== ""
0278 
0279         FormCard.FormTextDelegate{
0280             id: birthday
0281             text: i18n("Birthday")
0282             description: {
0283                 // We do not always have the year
0284                 if (addressee.birthday.getFullYear() === 0) {
0285                     return Qt.formatDate(addressee.birthday, "dd.MM.")
0286                 } else {
0287                     return Qt.formatDate(addressee.birthday)
0288                 }
0289             }
0290         }
0291     }
0292 
0293     FormCard.FormCard {
0294         visible: addressee.note
0295         FormCard.FormTextDelegate{
0296             text: i18n("Note:")
0297             description: {
0298                 return addressee.note
0299             }
0300         }
0301     }
0302 
0303     //makes sure the last item isnt behind the actions
0304 
0305     Item {
0306         Layout.preferredHeight: 60
0307     }
0308 }