diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 104f7af1d..f8f6f0383 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -25,6 +25,7 @@ #include "gui/notifyqt.h" #include "gui/msgs/MessageComposer.h" #include "gui/connect/ConnectFriendWizard.h" +#include "gui/connect/FriendRecommendDialog.h" #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include @@ -60,10 +61,14 @@ HomePage::HomePage(QWidget *parent) : QAction *SendAction = new QAction(QIcon(),tr("Send via Email"), this); connect(SendAction, SIGNAL(triggered()), this, SLOT(runEmailClient())); + QAction *RecAction = new QAction(QIcon(),tr("Recommend friends to each others"), this); + connect(RecAction, SIGNAL(triggered()), this, SLOT(recommendFriends())); + QMenu *menu = new QMenu(); menu->addAction(CopyAction); menu->addAction(SaveAction); menu->addAction(SendAction); + menu->addAction(RecAction); ui->shareButton->setMenu(menu); @@ -109,6 +114,11 @@ static void sendMail(QString sAddress, QString sSubject, QString sBody) QDesktopServices::openUrl (url); } +void HomePage::recommendFriends() +{ + FriendRecommendDialog::showIt() ; +} + void HomePage::runEmailClient() { sendMail("", tr("RetroShare Invite"), ui->userCertEdit->toPlainText()); diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index 74be89afd..a11980ac7 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -53,7 +53,8 @@ private slots: void runEmailClient(); void copyCert(); void saveCert(); - void addFriend(); + void recommendFriends(); + void addFriend(); private: Ui::HomePage *ui; diff --git a/retroshare-gui/src/gui/connect/FriendRecommendDialog.cpp b/retroshare-gui/src/gui/connect/FriendRecommendDialog.cpp new file mode 100644 index 000000000..d4140a939 --- /dev/null +++ b/retroshare-gui/src/gui/connect/FriendRecommendDialog.cpp @@ -0,0 +1,77 @@ +#include + +#include "FriendRecommendDialog.h" +#include "gui/msgs/MessageComposer.h" + +FriendRecommendDialog::FriendRecommendDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::FriendRecommendDialog) +{ + ui->setupUi(this) ; +} +FriendRecommendDialog::~FriendRecommendDialog() +{ +} + +void FriendRecommendDialog::load() +{ + ui->frec_recommendList->setHeaderText(tr("Recommend friends")); + ui->frec_recommendList->setModus(FriendSelectionWidget::MODUS_CHECK); + ui->frec_recommendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL); + ui->frec_recommendList->start(); + + ui->frec_toList->setHeaderText(tr("To")); + ui->frec_toList->setModus(FriendSelectionWidget::MODUS_CHECK); + ui->frec_toList->start(); + + ui->frec_messageEdit->setText(MessageComposer::recommendMessage()); +} + +void FriendRecommendDialog::showIt() +{ + FriendRecommendDialog *dialog = instance(); + + dialog->load(); + + dialog->show(); + dialog->raise(); + dialog->activateWindow(); +} + +FriendRecommendDialog *FriendRecommendDialog::instance() +{ + static FriendRecommendDialog *d = NULL ; + + if(d == NULL) + d = new FriendRecommendDialog(NULL); + + return d; +} + +void FriendRecommendDialog::accept() +{ + std::set recommendIds; + ui->frec_recommendList->selectedIds(recommendIds, false); + + if (recommendIds.empty()) { + QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend for recommendation."), QMessageBox::Ok, QMessageBox::Ok); + return ; + } + + std::set toIds; + ui->frec_toList->selectedIds(toIds, false); + + if (toIds.empty()) { + QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend as recipient."), QMessageBox::Ok, QMessageBox::Ok); + return ; + } + + std::set::iterator toId; + for (toId = toIds.begin(); toId != toIds.end(); ++toId) { + MessageComposer::recommendFriend(recommendIds, *toId, ui->frec_messageEdit->toHtml(), true); + } + + QDialog::accept() ; + + QMessageBox::information(NULL,tr("Recommendation messages sent!"),tr("A recommendation message was sent to each of the chosen friends!")) ; +} + diff --git a/retroshare-gui/src/gui/connect/FriendRecommendDialog.h b/retroshare-gui/src/gui/connect/FriendRecommendDialog.h new file mode 100644 index 000000000..c364e12eb --- /dev/null +++ b/retroshare-gui/src/gui/connect/FriendRecommendDialog.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "ui_FriendRecommendDialog.h" + +class FriendRecommendDialog: public QDialog +{ +public: + FriendRecommendDialog(QWidget *parent) ; + virtual ~FriendRecommendDialog() ; + + static void showIt(); + +private: + static FriendRecommendDialog *instance(); + + virtual void accept() ; + + void load(); + + Ui::FriendRecommendDialog *ui; +}; diff --git a/retroshare-gui/src/gui/connect/FriendRecommendDialog.ui b/retroshare-gui/src/gui/connect/FriendRecommendDialog.ui new file mode 100644 index 000000000..d91172f6f --- /dev/null +++ b/retroshare-gui/src/gui/connect/FriendRecommendDialog.ui @@ -0,0 +1,118 @@ + + + FriendRecommendDialog + + + + 0 + 0 + 1398 + 774 + + + + Dialog + + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + Message: + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + buttonBox + frec_label + frec_messageEdit + layoutWidget + frec_recommendList + + + + FriendSelectionWidget + QWidget +
gui/common/FriendSelectionWidget.h
+ 1 +
+
+ + + + buttonBox + accepted() + FriendRecommendDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + FriendRecommendDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 0a5601dfe..94949c38c 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -425,6 +425,7 @@ HEADERS += rshare.h \ gui/chat/ChatLobbyUserNotify.h \ gui/connect/ConfCertDialog.h \ gui/connect/PGPKeyDialog.h \ + gui/connect/FriendRecommendDialog.h \ gui/msgs/MessageInterface.h \ gui/msgs/MessageComposer.h \ gui/msgs/MessageWindow.h \ @@ -616,6 +617,7 @@ FORMS += gui/StartDialog.ui \ gui/connect/PGPKeyDialog.ui \ gui/connect/ConnectFriendWizard.ui \ gui/connect/ConnectProgressDialog.ui \ + gui/connect/FriendRecommendDialog.ui \ gui/msgs/MessageComposer.ui \ gui/msgs/MessageWindow.ui\ gui/msgs/MessageWidget.ui\ @@ -903,6 +905,7 @@ SOURCES += main.cpp \ gui/feeds/NewsFeedUserNotify.cpp \ gui/connect/ConnectFriendWizard.cpp \ gui/connect/ConnectProgressDialog.cpp \ + gui/connect/FriendRecommendDialog.cpp \ gui/groups/CreateGroup.cpp \ gui/GetStartedDialog.cpp \ gui/statistics/BandwidthGraphWindow.cpp \