diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 8d4414250..d3124a623 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -22,9 +22,12 @@ #include "HomePage.h" #include "ui_HomePage.h" +#include "retroshare/rsinit.h" + #include "gui/notifyqt.h" #include "gui/msgs/MessageComposer.h" #include "gui/connect/ConnectFriendWizard.h" +#include "gui/connect/ConfCertDialog.h" #include #include "gui/connect/FriendRecommendDialog.h" @@ -54,36 +57,32 @@ HomePage::HomePage(QWidget *parent) : connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(ui->LoadCertFileButton, SIGNAL(clicked()), this, SLOT(loadCert())); - QAction *CopyAction = new QAction(QIcon(),tr("Copy your Cert to Clipboard"), this); - connect(CopyAction, SIGNAL(triggered()), this, SLOT(copyCert())); - - QAction *SaveAction = new QAction(QIcon(),tr("Save your Cert into a File"), this); - connect(SaveAction, SIGNAL(triggered()), this, SLOT(saveCert())); - - QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this); - connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient())); - QAction *WebMailAction = new QAction(QIcon(),tr("Invite via WebMail"), this); connect(WebMailAction, SIGNAL(triggered()), this, SLOT(webMail())); QAction *RecAction = new QAction(QIcon(),tr("Recommend friends to each others"), this); connect(RecAction, SIGNAL(triggered()), this, SLOT(recommendFriends())); + QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this); + connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient())); + QMenu *menu = new QMenu(); - menu->addAction(CopyAction); - menu->addAction(SaveAction); menu->addAction(SendAction); menu->addAction(WebMailAction); menu->addAction(RecAction); ui->shareButton->setMenu(menu); + QObject::connect(ui->userCertEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(certContextMenu(QPoint))); + connect(ui->runStartWizard_PB,SIGNAL(clicked()), this,SLOT(runStartWizard())) ; connect(ui->openwebhelp,SIGNAL(clicked()), this,SLOT(openWebHelp())) ; ui->runStartWizard_PB->hide(); // until future rework ui->LoadCertFileButton->hide(); // duplicates functionality => not good. + mIncludeAllIPs = false; + int S = QFontMetricsF(font()).height(); QString help_str = tr( "

  Welcome to Retroshare!

\ @@ -99,6 +98,37 @@ HomePage::HomePage(QWidget *parent) : registerHelpButton(ui->helpButton,help_str,"HomePage") ; } +void HomePage::certContextMenu(QPoint point) +{ + QMenu menu(this) ; + + QAction *CopyAction = new QAction(QIcon(),tr("Copy your Cert to Clipboard"), this); + connect(CopyAction, SIGNAL(triggered()), this, SLOT(copyCert())); + + QAction *SaveAction = new QAction(QIcon(),tr("Save your Cert into a File"), this); + connect(SaveAction, SIGNAL(triggered()), this, SLOT(saveCert())); + + menu.addAction(CopyAction); + menu.addAction(SaveAction); + + if(!RsAccounts::isHiddenNode()) + { + QAction *includeIPsAct = new QAction(QIcon(), mIncludeAllIPs? tr("Include only current IP"):tr("Include all your known IPs"),this); + connect(includeIPsAct, SIGNAL(triggered()), this, SLOT(toggleIncludeAllIPs())); + includeIPsAct->setCheckable(true); + + menu.addAction(includeIPsAct); + } + + menu.exec(QCursor::pos()); +} + +void HomePage::toggleIncludeAllIPs() +{ + mIncludeAllIPs = !mIncludeAllIPs; + updateOwnCert(); +} + HomePage::~HomePage() { delete ui; @@ -106,9 +136,23 @@ HomePage::~HomePage() void HomePage::updateOwnCert() { - std::string invite = rsPeers->GetRetroshareInvite(false); + bool include_extra_locators = mIncludeAllIPs; + + RsPeerDetails detail; + + if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) + { + std::cerr << "(EE) Cannot retrieve information about own certificate. That is a real problem!!" << std::endl; + return ; + } + + std::string invite = rsPeers->GetRetroshareInvite(detail.id,false,include_extra_locators); ui->userCertEdit->setPlainText(QString::fromUtf8(invite.c_str())); + + QString description = ConfCertDialog::getCertificateDescription(detail,false,include_extra_locators); + + ui->userCertEdit->setToolTip(description); } static void sendMail(QString sAddress, QString sSubject, QString sBody) diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index 22937f821..8677bc832 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -48,6 +48,7 @@ public: virtual QString helpText() const { return ""; } //MainPage private slots: + void certContextMenu(QPoint); void updateOwnCert(); void runEmailClient(); void copyCert(); @@ -58,10 +59,12 @@ private slots: void runStartWizard() ; void openWebHelp() ; void recommendFriends(); + void toggleIncludeAllIPs(); private: Ui::HomePage *ui; + bool mIncludeAllIPs; }; diff --git a/retroshare-gui/src/gui/HomePage.ui b/retroshare-gui/src/gui/HomePage.ui index a83856c1f..da8d7b25d 100644 --- a/retroshare-gui/src/gui/HomePage.ui +++ b/retroshare-gui/src/gui/HomePage.ui @@ -25,6 +25,41 @@ 2 + + + + + 0 + 0 + + + + + 11 + + + + The text below is your own Retroshare certificate. Send it to your friends + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + ... + + + + :/icons/help_64.png:/icons/help_64.png + + + true + + + @@ -32,6 +67,9 @@ Courier New + + Qt::CustomContextMenu + @@ -84,41 +122,6 @@ - - - - ... - - - - :/icons/help_64.png:/icons/help_64.png - - - true - - - - - - - - 0 - 0 - - - - - 11 - - - - The text below is your own Retroshare certificate. Send it to your friends - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index 3c873fdca..c6c86a0b1 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -270,34 +270,9 @@ void ConfCertDialog::loadInvitePage() // ui.userCertificateText_2->setFont(font); // ui.userCertificateText_2->setText(QString::fromUtf8(pgp_key.c_str())); - std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id + std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id - QString infotext ; - - //infotext += tr("

Use this certificate to make new friends. Send it by email, or give it hand to hand.

") ; - infotext += tr("

This certificate contains:") ; - infotext += "