From a7af0516e7f4b0354df01d06173576dadf7007fc Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 28 Aug 2013 15:37:11 +0000 Subject: [PATCH] Added "Send Message" functionality to NetworkDialog, to send a distant message to a known peer. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6633 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkDialog.cpp | 30 +++++++++++++++++++++++- retroshare-gui/src/gui/NetworkDialog.h | 1 + retroshare-gui/src/gui/NetworkDialog.ui | 11 ++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 0fed23748..a0ac14763 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -33,6 +33,7 @@ #include "common/vmessagebox.h" #include "common/RSTreeWidgetItem.h" #include +#include "gui/msgs/MessageComposer.h" #include "NetworkDialog.h" //#include "TrustView.h" #include "NetworkView.h" @@ -45,12 +46,13 @@ /* Images for context menu icons */ #define IMAGE_LOADCERT ":/images/loadcert16.png" -#define IMAGE_PEERDETAILS ":/images/peerdetails_16x16.png" +#define IMAGE_PEERDETAILS ":/images/info16.png" #define IMAGE_AUTH ":/images/encrypted16.png" #define IMAGE_CLEAN_UNUSED ":/images/deletemail24.png" #define IMAGE_MAKEFRIEND ":/images/user/add_user16.png" #define IMAGE_EXPORT ":/images/exportpeers_16x16.png" #define IMAGE_COPYLINK ":/images/copyrslink.png" +#define IMAGE_MESSAGE ":/images/mail_new.png" /* Images for Status icons */ #define IMAGE_AUTHED ":/images/accepted16.png" @@ -199,6 +201,7 @@ void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ ) contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export my certificate..."), this, SLOT(on_actionExportKey_activated())); contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails())); + contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage())); contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink())); contextMnu->addSeparator() ; contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys())); @@ -328,6 +331,31 @@ void NetworkDialog::copyLink() RSLinkClipboard::copyLinks(urls); } +void NetworkDialog::sendDistantMessage() +{ + QTreeWidgetItem *wi = getCurrentNeighbour(); + if (wi == NULL) { + return; + } + + MessageComposer *nMsgDialog = MessageComposer::newMsg(); + if (nMsgDialog == NULL) { + return; + } + + std::string hash ; + std::string mGpgId = wi->text(COLUMN_PEERID).toStdString() ; + + if(rsMsgs->getDistantMessageHash(mGpgId,hash)) + { + nMsgDialog->addRecipient(MessageComposer::TO, hash, mGpgId); + nMsgDialog->show(); + nMsgDialog->activateWindow(); + } + + /* window will destroy itself! */ +} + void NetworkDialog::updateDisplay() { insertConnect() ; diff --git a/retroshare-gui/src/gui/NetworkDialog.h b/retroshare-gui/src/gui/NetworkDialog.h index 0f1ba5f33..6df54f063 100644 --- a/retroshare-gui/src/gui/NetworkDialog.h +++ b/retroshare-gui/src/gui/NetworkDialog.h @@ -72,6 +72,7 @@ private slots: void deleteCert() ; void peerdetails(); void copyLink(); + void sendDistantMessage(); /** Create the context popup menu and it's submenus */ void connectTreeWidgetCostumPopupMenu( QPoint point ); //void unvalidGPGKeyWidgetCostumPopupMenu( QPoint point ); diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui index cc855b2e9..52f9a8775 100644 --- a/retroshare-gui/src/gui/NetworkDialog.ui +++ b/retroshare-gui/src/gui/NetworkDialog.ui @@ -10,8 +10,8 @@ 567 - - + + @@ -43,7 +43,7 @@ - + Qt::Vertical @@ -102,6 +102,11 @@ + + + + + Name