From 4c13280feda48caf26a6ab197e7619214bedc969 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 18 May 2011 21:23:26 +0000 Subject: [PATCH] Show the RetroShare id of the peer and the signers of the key in ConfCertDialog as clickable links. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4212 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/RetroShareLink.cpp | 5 ++- .../src/gui/connect/ConfCertDialog.cpp | 40 ++++++------------- .../src/gui/connect/ConfCertDialog.h | 6 +-- .../src/gui/connect/ConfCertDialog.ui | 32 +++++++++++++-- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 78f014d58..82e1bd4cf 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -36,6 +36,7 @@ #include "msgs/MessageComposer.h" #include "util/misc.h" #include "common/PeerDefs.h" +#include "gui/connect/ConfCertDialog.h" #include #include @@ -431,6 +432,7 @@ QString RetroShareLink::title() const case TYPE_FILE: return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size())); case TYPE_PERSON: + return PeerDefs::rsidFromId(hash().toStdString()); case TYPE_FORUM: case TYPE_CHANNEL: case TYPE_SEARCH: @@ -693,6 +695,7 @@ bool RetroShareLink::process(int flag) } if (rsPeers->setAcceptToConnectGPGCertificate(hash().toStdString(), true)) { + ConfCertDialog::loadAll(); if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { QMessageBox mb(QObject::tr("Friend Request Confirmation"), QObject::tr("The friend has been added to your list."),QMessageBox::Information,QMessageBox::Ok,0,0); mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); @@ -814,7 +817,7 @@ bool RetroShareLink::process(int flag) #endif RsPeerDetails detail; if (rsPeers->getPeerDetails(hash().toStdString(), detail)) { - if (detail.accept_connection || detail.id == rsPeers->getOwnId()) { + if (detail.accept_connection || detail.id == rsPeers->getOwnId() || detail.id == rsPeers->getGPGOwnId()) { MessageComposer *msg = MessageComposer::newMsg(); msg->addRecipient(MessageComposer::TO, detail.id, false); if (subject().isEmpty() == false) { diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index fa1e205a5..c811f993d 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -36,6 +36,7 @@ #include "gui/help/browser/helpbrowser.h" #include "gui/common/PeerDefs.h" #include "gui/common/StatusDefs.h" +#include "gui/RetroShareLink.h" #ifndef MINIMAL_RSGUI #include "gui/MainWindow.h" @@ -74,7 +75,6 @@ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WFlag connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend())); connect(ui.signKeyButton, SIGNAL(clicked()), this, SLOT(signGPGKey())); connect(ui.trusthelpButton, SIGNAL(clicked()), this, SLOT(showHelpDialog())); - connect(ui.signers_listWidget, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( listWidgetContextMenuPopup( QPoint ) ) ); #ifndef MINIMAL_RSGUI MainWindow *w = MainWindow::getInstance(); @@ -138,7 +138,12 @@ void ConfCertDialog::load() ui.name->setText(QString::fromStdString(detail.name)); ui.peerid->setText(QString::fromStdString(detail.id)); - ui.rsid->setText(PeerDefs::rsid(detail)); + + RetroShareLink link; + link.createPerson(detail.id); + + ui.rsid->setText(link.toHtml()); + ui.rsid->setToolTip(link.title()); if (!detail.isOnlyGPGdetail) { @@ -302,13 +307,14 @@ void ConfCertDialog::load() } } - ui.signers_listWidget->clear() ; + QString text; for(std::list::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) { - RsPeerDetails signerDetail; - if (rsPeers->getGPGDetails(*it, signerDetail)) { - ui.signers_listWidget->addItem(QString::fromStdString(signerDetail.name) + " (" + QString::fromStdString(signerDetail.id) +")"); + link.createPerson(*it); + if (link.valid()) { + text += link.toHtml() + "
"; } } + ui.signers->setHtml(text); std::string invite = rsPeers->GetRetroshareInvite(detail.id) ; // this needs to be a SSL id @@ -434,25 +440,3 @@ void ConfCertDialog::showHelpDialog(const QString &topic) helpBrowser = new HelpBrowser(this); helpBrowser->showWindow(topic); } - -void ConfCertDialog::listWidgetContextMenuPopup(const QPoint &pos) -{ - QListWidgetItem *CurrentItem = ui.signers_listWidget->currentItem(); - if (!CurrentItem) - return; - - QMenu menu(this); - menu.addAction(tr("Copy Peer"), this, SLOT(copyToClipboard())); - menu.exec(QCursor::pos()); -} - -void ConfCertDialog::copyToClipboard( ) -{ - QListWidgetItem *CurrentItem = ui.signers_listWidget->currentItem(); - if (!CurrentItem) - return; - - QClipboard *cb = QApplication::clipboard(); - QString text = CurrentItem->text(); - cb->setText(text, QClipboard::Clipboard); -} diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.h b/retroshare-gui/src/gui/connect/ConfCertDialog.h index 9d9d6f358..5900a7b8d 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.h +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.h @@ -35,6 +35,7 @@ public: enum enumPage { PageDetails, PageTrust, PageCertificate }; static void showIt(const std::string& id, enumPage page); + static void loadAll(); signals: void configChanged(); @@ -47,12 +48,9 @@ private: static ConfCertDialog *instance(const std::string& peer_id); - static void loadAll(); void load(); private slots: - void listWidgetContextMenuPopup(const QPoint &pos); - void applyDialog(); void makeFriend(); void denyFriend(); @@ -62,8 +60,6 @@ private slots: /** Called when a child window requests the given help topic. */ void showHelpDialog(const QString &topic); - void copyToClipboard(); - private: std::string mId; diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.ui b/retroshare-gui/src/gui/connect/ConfCertDialog.ui index 640634c36..31b9f8e4e 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.ui +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.ui @@ -116,10 +116,34 @@ - + + + true + + + + 0 + 0 + + + + + 16777215 + 20 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + true + + true + @@ -468,9 +492,9 @@ - - - Qt::CustomContextMenu + + + true