Warning, /maui/communicator/src/views/contacts/ContactPage.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.10
0002 import QtQuick.Controls 2.10
0003 import QtQuick.Layouts 1.3
0004 import QtGraphicalEffects 1.0
0005
0006 import org.mauikit.controls 1.3 as Maui
0007
0008 Maui.PopupPage
0009 {
0010 id: control
0011 autoClose: false
0012
0013 maxWidth: 500
0014 maxHeight: 800
0015
0016 property var contact : ({})
0017
0018 property bool editing : Object.keys(contact).length === 0
0019
0020 signal contactEdited(var contact)
0021 signal editCanceled()
0022
0023 actionBar.visible: control.editing
0024
0025 filling: !isWide
0026
0027 page.footBar.visible: control.editing
0028 page.headBar.visible: true
0029
0030 Maui.Theme.colorSet: Maui.Theme.Window
0031 Maui.Theme.inherit: false
0032
0033 headBar.background: null
0034
0035 headBar.rightContent: [
0036 ToolButton
0037 {
0038 icon.name: "draw-star"
0039 text: i18n("Fav")
0040 checked: contact.fav == "1"
0041 checkable: false
0042 // Maui.Theme.textColor: checked ? "#FFD700" : Maui.Theme.textColor
0043 // Maui.Theme.backgroundColor: checked ? "#FFD700" : Maui.Theme.textColor
0044 onClicked:
0045 {
0046 contact["fav"] = contact.fav == "1" ? "0" : "1"
0047 list.update(contact, listModel.mappedToSource(_contactsPage.currentIndex))
0048 control.contact = contact;
0049 _favsView.list.refresh()
0050 }
0051 },
0052
0053 Maui.ToolButtonMenu
0054 {
0055 icon.name: "overflow-menu"
0056 MenuItem
0057 {
0058 icon.name: "document-edit"
0059 text: i18n("Edit")
0060 onTriggered: control.editing = !control.editing
0061 }
0062
0063 MenuItem
0064 {
0065 text: i18n("Delete")
0066 icon.name: "user-trash"
0067 icon.color: Maui.Theme.negativeTextColor
0068 onTriggered: _removeDialog.open()
0069 }
0070 }
0071 ]
0072
0073
0074 actions: [
0075 Action
0076 {
0077 text: i18n("Save")
0078 onTriggered:
0079 {
0080 var contact = control.contact
0081 contact.n = _nameField.text
0082 contact.tel =_telField.text
0083 contact.email = _emailField.text
0084 contact.org = _orgField.text
0085 // adr: _adrField.text,
0086 contact.photo = control.contact.photo
0087 contact.account = Maui.Handy.isAndroid ? _accountsCombobox.model[_accountsCombobox.currentIndex] :({})
0088
0089 control.contactEdited(contact)
0090 control.contact = contact
0091 control.editing = false
0092 }
0093 },
0094 Action
0095 {
0096 text: i18n("Cancel")
0097 onTriggered:
0098 {
0099 control.editing = false
0100 editCanceled()
0101 }
0102 }
0103 ]
0104
0105 Maui.InfoDialog
0106 {
0107 id: _removeDialog
0108
0109 title: i18n("Remove contact...")
0110 message: i18n("Are you sure you want to remove this contact? This action can not be undone.")
0111
0112 standardButtons: Dialog.Yes | Dialog.No
0113
0114 onRejected: close()
0115 onAccepted:
0116 {
0117 list.remove(listModel.mappedToSource(_contactsPage.currentIndex))
0118 close()
0119 }
0120 }
0121
0122
0123
0124 Item
0125 {
0126 id: _contactPic
0127 Layout.fillWidth: true
0128 Layout.preferredHeight: 160
0129
0130 Rectangle
0131 {
0132 id: _contactPhotoColor
0133 height: Maui.Style.iconSizes.huge * 1.5
0134 width: height
0135 anchors.centerIn: parent
0136 radius: Maui.Style.radiusV
0137 color: Qt.rgba(Math.random(),Math.random(),Math.random(),1);
0138
0139 MouseArea
0140 {
0141 visible: control.editing
0142 anchors.fill: parent
0143 onClicked:
0144 {
0145 _dialogLoader.sourceComponent = _fileDialogComponent
0146
0147 dialog.show(function(paths)
0148 {
0149 console.log("selected image", paths)
0150 contact.photo = paths[0]
0151 _contactPicLoader.sourceComponent = _imgComponent
0152 _contactPicLoader.item.source = contact.photo
0153 })
0154 }
0155 }
0156
0157 Loader
0158 {
0159 id: _contactPicLoader
0160 asynchronous: true
0161 anchors.fill: parent
0162 sourceComponent: contact.photo ? _imgComponent : _iconComponent
0163 }
0164
0165 Component
0166 {
0167 id: _imgComponent
0168
0169 Image
0170 {
0171 id: _img
0172
0173 sourceSize.width: parent.width
0174 sourceSize.height: parent.height
0175
0176 fillMode: Image.PreserveAspectCrop
0177 cache: true
0178 antialiasing: true
0179 smooth: true
0180 asynchronous: true
0181
0182 source: "image://contact/"+ contact.id
0183
0184 layer.enabled: true
0185 layer.effect: OpacityMask
0186 {
0187 maskSource: Item
0188 {
0189 width: _img.width
0190 height: _img.height
0191
0192 Rectangle
0193 {
0194 anchors.centerIn: parent
0195 width: _img.width
0196 height: _img.height
0197 radius: Maui.Style.radiusV
0198 }
0199 }
0200 }
0201 }
0202 }
0203
0204 Component
0205 {
0206 id: _iconComponent
0207
0208 // Maui.ToolButton
0209 // {
0210 // iconName: "view-media-artist"
0211 // size: iconSizes.big
0212 // iconColor: "white"
0213 // }
0214
0215 Label
0216 {
0217 anchors.fill: parent
0218 horizontalAlignment: Qt.AlignHCenter
0219 verticalAlignment: Qt.AlignVCenter
0220
0221 color: "white"
0222 font.pointSize: Maui.Style.fontSizes.huge * 1.5
0223 font.bold: true
0224 font.weight: Font.Bold
0225 text: contact.n ? contact.n[0] : "+"
0226 }
0227 }
0228
0229 }
0230 }
0231
0232
0233 ContactField
0234 {
0235 visible: contact.account || control.editing
0236 editing: control.editing
0237
0238 Layout.maximumWidth: 500
0239 Layout.minimumWidth: 100
0240 Layout.alignment: Qt.AlignHCenter
0241 Layout.fillWidth: true
0242 label1.text: i18n("Account")
0243 label2.text: contact.account || ""
0244
0245 iconSource: "password-show-on"
0246
0247 content: ComboBox
0248 {
0249 id: _accountsCombobox
0250 visible: control.editing
0251 textRole: "account"
0252 popup.z: control.z +1
0253 width: parent.width
0254 }
0255 }
0256
0257 ContactField
0258 {
0259 visible: contact.n || control.editing
0260 editing: control.editing
0261
0262 Layout.maximumWidth: 500
0263 Layout.minimumWidth: 100
0264 Layout.alignment: Qt.AlignHCenter
0265 Layout.fillWidth: true
0266 label1.text: i18n("Name")
0267 label2.text: contact.n || ""
0268
0269 iconSource: "im-user"
0270
0271 content: TextField
0272 {
0273 id: _nameField
0274 visible: control.editing
0275 Layout.fillWidth: true
0276 text: contact.n || ""
0277 }
0278 }
0279
0280 ContactField
0281 {
0282 visible: contact.tel || control.editing
0283
0284 editing: control.editing
0285 Layout.maximumWidth: 500
0286 Layout.minimumWidth: 100
0287 Layout.alignment: Qt.AlignHCenter
0288 Layout.fillWidth: true
0289
0290 label1.text: i18n("Phone")
0291 label2.text: contact.tel || ""
0292 iconSource: "call-start"
0293
0294 content: TextField
0295 {
0296 visible: control.editing
0297 id: _telField
0298 Layout.fillWidth: true
0299 text: contact.tel || ""
0300 }
0301
0302 Action
0303 {
0304 icon.name: "message-new"
0305 text: i18n("Message")
0306 icon.color: Maui.Theme.textColor
0307 onTriggered:
0308 {
0309 _dialogLoader.sourceComponent = _messageComposerComponent
0310 dialog.contact = control.contact
0311 dialog.open()
0312 }
0313 }
0314
0315 Action
0316 {
0317 enabled: Maui.Handy.isMobile
0318 icon.name: "call-start"
0319 text: i18n("Call")
0320 icon.color: Maui.Theme.textColor
0321
0322 onTriggered:
0323 {
0324 _communicator.call(control.contact.tel)
0325 }
0326 }
0327
0328 Action
0329 {
0330 icon.name: "edit-copy"
0331 text: i18n("Copy")
0332 icon.color: Maui.Theme.textColor
0333 onTriggered:
0334 {
0335 Maui.Handy.copyTextToClipboard(control.contact.tel)
0336 }
0337 }
0338 }
0339
0340 ContactField
0341 {
0342 visible: contact.email || control.editing
0343 editing: control.editing
0344
0345 Layout.maximumWidth: 500
0346 Layout.minimumWidth: 100
0347 Layout.alignment: Qt.AlignHCenter
0348 Layout.fillWidth: true
0349
0350 label1.text: i18n("Email")
0351 label2.text: contact.email || ""
0352 iconSource: "mail-message"
0353
0354 content: TextField
0355 {
0356 id: _emailField
0357 visible: control.editing
0358 Layout.fillWidth: true
0359 text: contact.email || ""
0360 }
0361
0362 Action
0363 {
0364 icon.name: "message-new"
0365 text: i18n("Message")
0366 icon.color: Maui.Theme.textColor
0367 onTriggered:
0368 {
0369 _dialogLoader.sourceComponent = _messageComposerComponent
0370 dialog.contact = control.contact
0371 dialog.open()
0372 }
0373 }
0374
0375 Action
0376 {
0377 icon.name: "edit-copy"
0378 text: i18n("Copy")
0379 icon.color: Maui.Theme.textColor
0380 onTriggered:
0381 {
0382 Maui.Handy.copyTextToClipboard(control.contact.tel)
0383 }
0384 }
0385 }
0386
0387
0388 ContactField
0389 {
0390 visible: contact.org || control.editing
0391 editing: control.editing
0392
0393 Layout.maximumWidth: 500
0394 Layout.minimumWidth: 100
0395 Layout.alignment: Qt.AlignHCenter
0396 Layout.fillWidth: true
0397 label1.text: i18n("Organization")
0398 label2.text: contact.org || ""
0399
0400 iconSource: "roll"
0401
0402 content: TextField
0403 {
0404 id: _orgField
0405 visible: control.editing
0406 Layout.fillWidth: true
0407 text: contact.org || ""
0408 }
0409 }
0410
0411 ContactField
0412 {
0413 visible: contact.title || control.editing
0414 editing: control.editing
0415
0416 Layout.maximumWidth: 500
0417 Layout.minimumWidth: 100
0418 Layout.alignment: Qt.AlignHCenter
0419 Layout.fillWidth: true
0420 label1.text: i18n("Title")
0421 label2.text: contact.title || ""
0422
0423 iconSource: "actor"
0424
0425 content: TextField
0426 {
0427 visible: control.editing
0428 Layout.fillWidth: true
0429 text: contact.title || ""
0430 }
0431 }
0432
0433 function clear()
0434 {
0435 _nameField.clear()
0436 _telField.clear()
0437 _emailField.clear()
0438 _orgField.clear()
0439 // _adrField.clear()
0440 // _img.source = ""
0441 _contactPicLoader.sourceComponent = _iconComponent
0442 control.close()
0443
0444 }
0445
0446 Component.onCompleted:
0447 {
0448 var androidAccounts = _contacsView.list.getAccounts();
0449 _accountsCombobox.model = androidAccounts;
0450 }
0451
0452 onClosed:
0453 {
0454 control.contact = ({})
0455 _dialogLoader.sourceComponent = null
0456 }
0457 }