From 84447a63046d9bf3929cae296ecebc6c1e2345e8 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 16 Jan 2010 18:03:35 +0000 Subject: [PATCH] Added to Send RetroShare link as html format for Messages Added to can download from Messages when clicked on link. Added when start connection attempt then change icon on location. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2056 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MessagesDialog.cpp | 57 ++++++++++++++++++- retroshare-gui/src/gui/MessagesDialog.h | 2 + retroshare-gui/src/gui/PeersDialog.cpp | 11 +++- retroshare-gui/src/gui/SharedFilesDialog.cpp | 26 ++++++++- retroshare-gui/src/gui/SharedFilesDialog.h | 2 + retroshare-gui/src/gui/images.qrc | 1 + retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp | 6 ++ retroshare-gui/src/gui/msgs/ChanMsgDialog.h | 1 + 8 files changed, 103 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index c875815a0..a3b8683fe 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -75,13 +75,14 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect(ui.replyallmessageButton, SIGNAL(clicked()), this, SLOT(replyallmessage())); connect(ui.forwardmessageButton, SIGNAL(clicked()), this, SLOT(forwardmessage())); - //connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print())); connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview())); connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview())); connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getcurrentrecommended())); + connect( ui.msgText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &))); + mCurrCertId = ""; mCurrMsgId = ""; @@ -903,3 +904,57 @@ void MessagesDialog::printpreview() preview->show(); } +void MessagesDialog::anchorClicked (const QUrl& link ) +{ + #ifdef FORUM_DEBUG + std::cerr << "MessagesDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; + #endif + + if (link.scheme() == "retroshare") + { + QStringList L = link.toString().split("|") ; + + std::string fileName = L.at(1).toStdString() ; + uint64_t fileSize = L.at(2).toULongLong(); + std::string fileHash = L.at(3).toStdString() ; + +#ifdef FORUM_DEBUG + std::cerr << "MessagesDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl; +#endif + + if (fileName != "" && fileHash != "") + { + std::list srcIds; + + if(rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) + { + QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.exec(); + } + else + { + QMessageBox mb(tr("File Request canceled"), tr("The file has not been added to your download list, because you already have it."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.exec(); + } + } + else + { + QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.exec(); + } + } + else if (link.scheme() == "http") + { + QDesktopServices::openUrl(link); + } + else if (link.scheme() == "") + { + //it's probably a web adress, let's add http:// at the beginning of the link + QString newAddress = link.toString(); + newAddress.prepend("http://"); + QDesktopServices::openUrl(QUrl(newAddress)); + } +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/MessagesDialog.h b/retroshare-gui/src/gui/MessagesDialog.h index 5be95e1d6..985ec24ed 100644 --- a/retroshare-gui/src/gui/MessagesDialog.h +++ b/retroshare-gui/src/gui/MessagesDialog.h @@ -60,6 +60,8 @@ private slots: void removemessage(); + void anchorClicked (const QUrl &); + void getcurrentrecommended(); // void getallrecommended(); diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index e6a654369..d6e3beeea 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -398,8 +398,17 @@ void PeersDialog::insertPeers() sslItem -> setToolTip( 0, tr("location : ") + QString::fromStdString(sslDetail.location)); } - /* not displayed, used to find back the item */ + /* not displayed, used to find back the item */ sslItem -> setText(1, QString::fromStdString(sslDetail.autoconnect)); + + if (sslDetail.autoconnect !="Offline") + { + sslItem -> setIcon(0, (QIcon(":/images/connect_creating.png"))); + } + else + { + sslItem -> setIcon(0, (QIcon(":/images/connect_no.png"))); + } /* change color and icon */ int i; diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 2de8f19d0..ceb565651 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -341,6 +341,26 @@ void SharedFilesDialog::sendLinkTo( /*std::string rsid*/ ) nMsgDialog->show(); } +void SharedFilesDialog::sendHtmlLinkTo( ) +{ + copyLinkLocal (); + + /* create a message */ + ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true); + + + /* fill it in + * files are receommended already + * just need to set peers + */ + std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl; + nMsgDialog->newMsg(); + nMsgDialog->insertTitleText("RetroShare Link"); + nMsgDialog->insertHtmlText(QApplication::clipboard()->text().toStdString()); + + nMsgDialog->show(); +} + void SharedFilesDialog::sendLinkToCloud() { copyLinkLocal (); @@ -615,7 +635,10 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point ) connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) ); sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this ); - connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) ); + connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( ) ) ); + + sendhtmllinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link (html)" ), this ); + connect( sendhtmllinkAct , SIGNAL( triggered() ), this, SLOT( sendHtmlLinkTo( ) ) ); sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link to Cloud" ), this ); connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) ); @@ -636,6 +659,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point ) contextMnu2.addSeparator(); contextMnu2.addAction( copylinklocalAct); contextMnu2.addAction( sendlinkAct); + contextMnu2.addAction( sendhtmllinkAct); contextMnu2.addSeparator(); contextMnu2.addAction( sendlinkCloudAct); contextMnu2.addAction( addlinkCloudAct); diff --git a/retroshare-gui/src/gui/SharedFilesDialog.h b/retroshare-gui/src/gui/SharedFilesDialog.h index 066a5f008..842191443 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/SharedFilesDialog.h @@ -65,6 +65,7 @@ private slots: void copyLinkLocal(); void sendLinkTo(); void sendremoteLinkTo(); + void sendHtmlLinkTo(); void sendLinkToCloud(); void addLinkToCloud(); @@ -109,6 +110,7 @@ private: QAction* copylinklocalAct; QAction* sendremotelinkAct; QAction* sendlinkAct; + QAction* sendhtmllinkAct; QAction* sendlinkCloudAct; QAction* addlinkCloudAct; diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index 54d42f2be..1124ba7ed 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -14,6 +14,7 @@ images/btn_27_hover.png images/connect_established.png images/connect_creating.png + images/connect_no.png images/feedback_arrow.png images/feedback_arrow_hover.png images/feedback-bar-background.png diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp index 99484a4ef..eee376821 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.cpp @@ -215,6 +215,7 @@ ChanMsgDialog::ChanMsgDialog(bool msg, QWidget *parent, Qt::WFlags flags) _smheader->resizeSection ( 3, 220 ); _smheader->resizeSection ( 4, 10 ); + /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -533,6 +534,11 @@ void ChanMsgDialog::insertMsgText(std::string msg) ui.msgText->setText(QString::fromStdString(msg)); } +void ChanMsgDialog::insertHtmlText(std::string msg) +{ + ui.msgText->setHtml(QString(" ") ) + QString::fromStdString(std::string(msg)) + "") ; +} + void ChanMsgDialog::sendMessage() { diff --git a/retroshare-gui/src/gui/msgs/ChanMsgDialog.h b/retroshare-gui/src/gui/msgs/ChanMsgDialog.h index 1834b3f61..fcee68088 100644 --- a/retroshare-gui/src/gui/msgs/ChanMsgDialog.h +++ b/retroshare-gui/src/gui/msgs/ChanMsgDialog.h @@ -56,6 +56,7 @@ void insertFileList(const std::list&); /* for Both */ void insertTitleText(std::string title); void insertPastedText(std::string msg) ; void insertForwardPastedText(std::string msg); +void insertHtmlText(std::string msg); void insertMsgText(std::string msg); void addRecipient(std::string id) ; void Create_New_Image_Tag( const QString urlremoteorlocal );