2017-05-08 14:35:15 -04:00
|
|
|
/*
|
|
|
|
* RetroShare Android QML App
|
|
|
|
* Copyright (C) 2017 Gioacchino Mazzurco <gio@eigenlab.org>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import "." //Needed for ClipboardWrapper singleton
|
2017-06-12 09:44:50 -04:00
|
|
|
import "./components"
|
2017-05-08 14:35:15 -04:00
|
|
|
import "URI.js" as UriJs
|
|
|
|
|
|
|
|
Item
|
|
|
|
{
|
|
|
|
id: cntDt
|
|
|
|
property var md
|
|
|
|
property bool is_contact: cntDt.md.is_contact
|
2017-07-09 11:04:31 -04:00
|
|
|
property bool isOwn: cntDt.md.own
|
|
|
|
|
2017-07-10 13:50:11 -04:00
|
|
|
Button
|
2017-07-09 11:04:31 -04:00
|
|
|
{
|
2017-07-18 12:16:51 -04:00
|
|
|
id: avatarPicker
|
2017-07-09 11:04:31 -04:00
|
|
|
|
2017-07-18 12:16:51 -04:00
|
|
|
text: "Change your Avatar"
|
2017-07-09 11:04:31 -04:00
|
|
|
visible: isOwn
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2017-07-18 12:16:51 -04:00
|
|
|
|
2017-07-11 12:56:38 -04:00
|
|
|
onClicked:
|
|
|
|
{
|
|
|
|
fileChooser.open()
|
|
|
|
}
|
|
|
|
CustomFileChooser
|
|
|
|
{
|
|
|
|
id: fileChooser
|
2017-07-11 13:17:47 -04:00
|
|
|
onResultFileChanged:
|
|
|
|
{
|
|
|
|
console.log("Result file changed! " , resultFile)
|
2017-07-11 12:56:38 -04:00
|
|
|
|
2017-07-18 10:25:38 -04:00
|
|
|
var base64Image = androidImagePicker.imageToBase64(resultFile)
|
|
|
|
|
2017-07-18 10:36:54 -04:00
|
|
|
rsApi.request("/identity/set_avatar", JSON.stringify({"gxs_id": cntDt.md.gxs_id, "avatar": base64Image }),
|
2017-07-18 13:26:31 -04:00
|
|
|
function (par)
|
|
|
|
{
|
|
|
|
var jP = JSON.parse(par.response)
|
|
|
|
if (jP.returncode === "ok")
|
|
|
|
{
|
|
|
|
console.log("Avatar changed! ")
|
|
|
|
topFace.getDetails()
|
|
|
|
}
|
|
|
|
})
|
2017-07-18 10:25:38 -04:00
|
|
|
}
|
2017-07-10 13:50:11 -04:00
|
|
|
}
|
2017-07-09 11:04:31 -04:00
|
|
|
}
|
2017-05-08 14:35:15 -04:00
|
|
|
|
2017-07-12 10:48:26 -04:00
|
|
|
|
2017-06-20 11:16:27 -04:00
|
|
|
AvatarOrColorHash
|
2017-05-08 14:35:15 -04:00
|
|
|
{
|
2017-06-20 09:35:05 -04:00
|
|
|
id: topFace
|
|
|
|
|
2017-06-20 11:16:27 -04:00
|
|
|
gxs_id: cntDt.md.gxs_id
|
2017-05-08 14:35:15 -04:00
|
|
|
|
2017-07-18 12:16:51 -04:00
|
|
|
anchors.top: (isOwn)? avatarPicker.bottom : parent.top
|
2017-05-08 14:35:15 -04:00
|
|
|
anchors.topMargin: 6
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Column
|
|
|
|
{
|
2017-06-20 09:35:05 -04:00
|
|
|
anchors.top: topFace.bottom
|
2017-05-08 14:35:15 -04:00
|
|
|
anchors.topMargin: 6
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
spacing: 6
|
|
|
|
|
|
|
|
Row
|
|
|
|
{
|
|
|
|
height: 50
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
spacing: 6
|
|
|
|
|
2017-06-20 11:16:27 -04:00
|
|
|
ColorHash
|
|
|
|
{
|
|
|
|
hash: cntDt.md.gxs_id
|
|
|
|
height: parent.height - 10
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2017-05-08 14:35:15 -04:00
|
|
|
Text
|
|
|
|
{
|
|
|
|
text: cntDt.md.name
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Image
|
|
|
|
{
|
|
|
|
source: cntDt.is_contact ?
|
2017-07-19 08:45:19 -04:00
|
|
|
"qrc:/icons/rating.svg" :
|
|
|
|
"qrc:/icons/rating-unrated.svg"
|
|
|
|
height: parent.height -4
|
2017-05-08 14:35:15 -04:00
|
|
|
fillMode: Image.PreserveAspectFit
|
2017-07-19 08:45:19 -04:00
|
|
|
sourceSize.height: height
|
2017-05-08 14:35:15 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
MouseArea
|
|
|
|
{
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onClicked:
|
|
|
|
{
|
|
|
|
var jDt = JSON.stringify({gxs_id: cntDt.md.gxs_id})
|
|
|
|
if(cntDt.is_contact)
|
|
|
|
rsApi.request("/identity/remove_contact", jDt, tgCt)
|
|
|
|
else rsApi.request("/identity/add_contact", jDt, tgCt)
|
|
|
|
}
|
|
|
|
|
|
|
|
function tgCt() { cntDt.is_contact = !cntDt.is_contact }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
text: "<pre>"+cntDt.md.gxs_id+"</pre>"
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Text
|
|
|
|
{
|
|
|
|
visible: cntDt.md.pgp_linked
|
|
|
|
text: qsTr("Owned by: %1").arg(cntDt.md.pgp_id)
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row
|
|
|
|
{
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
spacing: 6
|
|
|
|
|
|
|
|
Button
|
|
|
|
{
|
|
|
|
text: qsTr("Contact full link")
|
|
|
|
onClicked:
|
|
|
|
{
|
|
|
|
rsApi.request(
|
|
|
|
"/identity/export_key",
|
|
|
|
JSON.stringify({ gxs_id: cntDt.md.gxs_id }),
|
|
|
|
function(par)
|
|
|
|
{
|
|
|
|
var jD = JSON.parse(par.response).data
|
2017-07-04 10:27:12 -04:00
|
|
|
var contactUrl = (
|
2017-05-08 14:35:15 -04:00
|
|
|
"retroshare://" +
|
|
|
|
"identity?gxsid=" +
|
|
|
|
cntDt.md.gxs_id +
|
|
|
|
"&name=" +
|
|
|
|
UriJs.URI.encode(cntDt.md.name) +
|
|
|
|
"&groupdata=" +
|
2017-07-04 10:27:12 -04:00
|
|
|
UriJs.URI.encode(jD.radix) )
|
|
|
|
ClipboardWrapper.postToClipBoard(contactUrl)
|
2017-05-08 14:35:15 -04:00
|
|
|
linkCopiedPopup.itemName = cntDt.md.name
|
|
|
|
linkCopiedPopup.visible = true
|
2017-07-04 10:27:12 -04:00
|
|
|
platformGW.shareUrl(contactUrl);
|
2017-05-08 14:35:15 -04:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button
|
|
|
|
{
|
|
|
|
text: qsTr("Contact short link")
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|