From 0b82b73131836c8557f601d194fddc0db91786c0 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 13 May 2017 11:43:31 +0200 Subject: [PATCH] Qml app: fixed import/export of plain certificate Added TimedPopup that is a common use case so it is reusable without code duplication --- retroshare-qml-app/src/AddTrustedNode.qml | 37 ++++++++++++++++---- retroshare-qml-app/src/TimedPopup.qml | 41 +++++++++++++++++++++++ retroshare-qml-app/src/qml.qrc | 1 + 3 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 retroshare-qml-app/src/TimedPopup.qml diff --git a/retroshare-qml-app/src/AddTrustedNode.qml b/retroshare-qml-app/src/AddTrustedNode.qml index 14acd8a6d..823bc8e87 100644 --- a/retroshare-qml-app/src/AddTrustedNode.qml +++ b/retroshare-qml-app/src/AddTrustedNode.qml @@ -80,12 +80,21 @@ Item JSON.stringify({cert_string: cptext}), function(par) { - console.log("/peers/examine_cert/ CB", par) - var jData = JSON.parse(par.response).data + console.log("/peers/examine_cert/ CB", + par.response) + var resp = JSON.parse(par.response) + if(resp.returncode === "fail") + { + importErrorPop.text = resp.debug_msg + importErrorPop.open() + return + } + + var jData = resp.data stackView.push( "qrc:/TrustedNodeDetails.qml", { - nodeCert: otherKeyField.text, + nodeCert: cptext, pgpName: jData.name, pgpId: jData.pgp_id, locationName: jData.location, @@ -106,12 +115,26 @@ Item "/peers/self/certificate/", "", function(par) { - var jD = JSON.parse(par.response).data - ClipboardWrapper.postToClipBoard(jD.cert_string) - mainWindow.linkCopiedPopup.itemName=mainWindow.user_name - mainWindow.linkCopiedPopup.open() + var radix = JSON.parse(par.response).data.cert_string + var name = mainWindow.user_name + ClipboardWrapper.postToClipBoard(radix) + + linkCopiedPopup.itemName = name + linkCopiedPopup.open() }) } } } + + TimedPopup + { + id: importErrorPop + property alias text: popText.text + + Text + { + id: popText + anchors.fill: parent + } + } } diff --git a/retroshare-qml-app/src/TimedPopup.qml b/retroshare-qml-app/src/TimedPopup.qml new file mode 100644 index 000000000..0f5bc6e5e --- /dev/null +++ b/retroshare-qml-app/src/TimedPopup.qml @@ -0,0 +1,41 @@ +/* + * RetroShare Android QML App + * Copyright (C) 2017 Gioacchino Mazzurco + * + * 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 . + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 + +Popup +{ + property alias duration: timer.interval + + + id: popupRoot + visible: false + onVisibleChanged: if(visible) timer.start() + x: parent.x + parent.width/2 - width/2 + y: parent.y + parent.height/2 - height/2 + + + Timer + { + id: timer + interval: 1500 + onTriggered: popupRoot.close() + } +} + diff --git a/retroshare-qml-app/src/qml.qrc b/retroshare-qml-app/src/qml.qrc index 14dcd3971..3859fde54 100644 --- a/retroshare-qml-app/src/qml.qrc +++ b/retroshare-qml-app/src/qml.qrc @@ -28,5 +28,6 @@ ColorHash.qml icons/rating-unrated.png icons/rating.png + TimedPopup.qml