From 6e87a8d31f9aaaba36b12a703cfcfcee606ec4b6 Mon Sep 17 00:00:00 2001 From: alexandrut Date: Mon, 17 Aug 2009 20:19:53 +0000 Subject: [PATCH] add links to cloud from shared files dialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1544 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/AddLinksDialog.cpp | 101 +++++++ retroshare-gui/src/gui/AddLinksDialog.h | 49 ++++ retroshare-gui/src/gui/AddLinksDialog.ui | 260 +++++++++++++++++++ retroshare-gui/src/gui/SharedFilesDialog.cpp | 64 +++-- retroshare-gui/src/gui/SharedFilesDialog.h | 25 +- 5 files changed, 471 insertions(+), 28 deletions(-) create mode 100644 retroshare-gui/src/gui/AddLinksDialog.cpp create mode 100644 retroshare-gui/src/gui/AddLinksDialog.h create mode 100644 retroshare-gui/src/gui/AddLinksDialog.ui diff --git a/retroshare-gui/src/gui/AddLinksDialog.cpp b/retroshare-gui/src/gui/AddLinksDialog.cpp new file mode 100644 index 000000000..b83b9508d --- /dev/null +++ b/retroshare-gui/src/gui/AddLinksDialog.cpp @@ -0,0 +1,101 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include "common/vmessagebox.h" + +#include "AddLinksDialog.h" +#include "rsiface/rsrank.h" + +/* Images for context menu icons */ +#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.png" +#define IMAGE_GREAT ":/images/filerating5.png" +#define IMAGE_GOOD ":/images/filerating4.png" +#define IMAGE_OK ":/images/filerating3.png" +#define IMAGE_SUX ":/images/filerating2.png" +#define IMAGE_BADLINK ":/images/filerating1.png" + +/** Constructor */ +AddLinksDialog::AddLinksDialog(QWidget *parent) +: QDialog(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + /* add button */ + connect(ui.addLinkButton, SIGNAL(clicked()), this, SLOT(addLinkComment())); + connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close())); + + /* Hide platform specific features */ +#ifdef Q_WS_WIN + +#endif +} + +int AddLinksDialog::IndexToScore(int index) +{ + if ((index == -1) || (index > 4)) + return 0; + int score = 2 - index; + return score; +} + +void AddLinksDialog::addLinkComment() +{ + /* get the title / link / comment */ + QString title = ui.titleLineEdit->text(); + QString link = ui.linkLineEdit->text(); + QString comment = ui.linkTextEdit->toPlainText(); + int32_t score = AddLinksDialog::IndexToScore(ui.scoreBox->currentIndex()); + + if ((link == "") || (title == "")) + { + QMessageBox::StandardButton sb = QMessageBox::warning(NULL, + "Add Link Failure", + "Missing Link and/or Title", + QMessageBox::Ok); + /* can't do anything */ + return; + } + + /* add it either way */ + if (ui.anonBox->isChecked()) + { + rsRanks->anonRankMsg("", link.toStdWString(), title.toStdWString()); + } + else + { + rsRanks->newRankMsg(link.toStdWString(), + title.toStdWString(), + comment.toStdWString(), score); + } + + close(); +} + +void AddLinksDialog::insertTitleText(std::string title) +{ + ui.titleLineEdit->setText(QString::fromStdString(title)); +} + +void AddLinksDialog::insertLinkText(std::string link) +{ + ui.linkLineEdit->setText(QString::fromStdString(link)); +} diff --git a/retroshare-gui/src/gui/AddLinksDialog.h b/retroshare-gui/src/gui/AddLinksDialog.h new file mode 100644 index 000000000..52a68060e --- /dev/null +++ b/retroshare-gui/src/gui/AddLinksDialog.h @@ -0,0 +1,49 @@ +/**************************************************************** + * RetroShare GUI is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _ADDLINKS_DIALOG_H +#define _ADDLINKS_DIALOG_H + +#include "ui_AddLinksDialog.h" + +class AddLinksDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default Constructor */ + AddLinksDialog(QWidget *parent = 0); + /** Default Destructor */ + + void insertTitleText(std::string title); + void insertLinkText(std::string link); + + static int IndexToScore(int index); + +public slots: + void addLinkComment(); + +private: + /** Qt Designer generated object */ + Ui::AddLinksDialog ui; +}; + +#endif diff --git a/retroshare-gui/src/gui/AddLinksDialog.ui b/retroshare-gui/src/gui/AddLinksDialog.ui new file mode 100644 index 000000000..30dab4468 --- /dev/null +++ b/retroshare-gui/src/gui/AddLinksDialog.ui @@ -0,0 +1,260 @@ + + + AddLinksDialog + + + + 0 + 0 + 568 + 429 + + + + Add Link + + + + :/images/rstray3.png:/images/rstray3.png + + + + + + + 16777215 + 32 + + + + + + + :/images/ktorrent32.png + + + + + + + Add a new Link + + + + + + + + + 12 + 75 + true + + + + Title: + + + + + + + + 12 + + + + + + + + + + + + + 12 + 75 + true + + + + Url: + + + + + + + + 12 + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 12 + + + + + + + + + 12 + 75 + true + + + + Score: + + + + + + + + +2 Great! + + + + :/images/filerating5.png:/images/filerating5.png + + + + + +1 Good + + + + :/images/filerating4.png:/images/filerating4.png + + + + + 0 Okay + + + + :/images/filerating3.png:/images/filerating3.png + + + + + -1 Sux + + + + :/images/filerating2.png:/images/filerating2.png + + + + + -2 Bad Link + + + + :/images/filerating1.png:/images/filerating1.png + + + + + + + + + 12 + 50 + false + + + + Add Anonymous Link + + + + + + + Qt::Horizontal + + + + 196 + 23 + + + + + + + + + + + Qt::Horizontal + + + + 375 + 20 + + + + + + + + + 12 + + + + Cancel + + + + + + + + 12 + + + + Add Link + + + false + + + true + + + + + + + + + + diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 292d63546..7dc1c957f 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -30,6 +30,7 @@ #include "util/RsAction.h" #include "msgs/ChanMsgDialog.h" #include "Preferences/rsharesettings.h" +#include "AddLinksDialog.h" #ifndef RETROSHARE_LINK_ANALYZER #include "RetroShareLinkAnalyzer.h" @@ -234,8 +235,6 @@ void SharedFilesDialog::downloadRemoteSelected() QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel(); model -> downloadSelected(qism->selectedIndexes()); - - } void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote) @@ -338,7 +337,30 @@ void SharedFilesDialog::sendLinkTo( /*std::string rsid*/ ) nMsgDialog->show(); } +void SharedFilesDialog::sendLinkToCloud() +{ + copyLinkLocal (); + AddLinksDialog *nAddLinksDialog = new AddLinksDialog(); + + nAddLinksDialog->insertTitleText("New File"); + nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString()); + + nAddLinksDialog->addLinkComment(); + nAddLinksDialog->close(); +} + +void SharedFilesDialog::addLinkToCloud() +{ + copyLinkLocal (); + + AddLinksDialog *nAddLinksDialog = new AddLinksDialog(this); + + nAddLinksDialog->insertTitleText("New File"); + nAddLinksDialog->insertLinkText(QApplication::clipboard()->text().toStdString()); + + nAddLinksDialog->show(); +} void SharedFilesDialog::playselectedfiles() { @@ -591,11 +613,17 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point ) } //#endif - copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this ); - connect( copylinklocalAct , SIGNAL( triggered() ), this, SLOT( copyLinkLocal() ) ); + copylinklocalAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this ); + 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*/ ) ) ); + sendlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link" ), this ); + connect( sendlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinkTo( /*std::string rsid*/ ) ) ); + + sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Link to Cloud" ), this ); + connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) ); + + addlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Add Link to Cloud" ), this ); + connect( addlinkCloudAct , SIGNAL( triggered() ), this, SLOT( addLinkToCloud( ) ) ); openfileAct = new QAction(QIcon(IMAGE_OPENFILE), tr("Open File"), this); connect(openfileAct, SIGNAL(triggered()), this, SLOT(openfile())); @@ -607,6 +635,8 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point ) contextMnu2.addAction( menuAction ); contextMnu2.addAction( copylinklocalAct); contextMnu2.addAction( sendlinkAct); + contextMnu2.addAction( sendlinkCloudAct); + contextMnu2.addAction( addlinkCloudAct); contextMnu2.addSeparator(); contextMnu2.addAction( openfileAct); contextMnu2.addAction( openfolderAct); @@ -704,14 +734,14 @@ void SharedFilesDialog::showFrame(bool show) if (show) { ui.localframe->setVisible(true); ui.remoteframe->setVisible(false); - + ui.localButton->setChecked(true); - + ui.remoteButton->setChecked(false); ui.splittedButton->setChecked(false); - + ui.labeltext->setText(tr("My Shared Files")); - } + } } void SharedFilesDialog::showFrameRemote(bool show) @@ -719,13 +749,13 @@ void SharedFilesDialog::showFrameRemote(bool show) if (show) { ui.remoteframe->setVisible(true); ui.localframe->setVisible(false); - + ui.remoteButton->setChecked(true); ui.localButton->setChecked(false); ui.splittedButton->setChecked(false); ui.labeltext->setText(tr("Friends Files")); - } + } } void SharedFilesDialog::showFrameSplitted(bool show) @@ -733,12 +763,12 @@ void SharedFilesDialog::showFrameSplitted(bool show) if (show) { ui.remoteframe->setVisible(true); ui.localframe->setVisible(true); - + ui.splittedButton->setChecked(true); - - ui.localButton->setChecked(false); + + ui.localButton->setChecked(false); ui.remoteButton->setChecked(false); - + ui.labeltext->setText(tr("Files")); - } + } } diff --git a/retroshare-gui/src/gui/SharedFilesDialog.h b/retroshare-gui/src/gui/SharedFilesDialog.h index ee37ed1a4..1362d0211 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.h +++ b/retroshare-gui/src/gui/SharedFilesDialog.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. ****************************************************************/ @@ -33,7 +33,7 @@ #include "rsiface/rstypes.h" #include "gui/RemoteDirModel.h" -class SharedFilesDialog : public MainPage +class SharedFilesDialog : public MainPage { Q_OBJECT @@ -55,9 +55,9 @@ private slots: /** Create the context popup menu and it's submenus */ void shareddirtreeviewCostumPopupMenu( QPoint point ); - + void sharedDirTreeWidgetContextMenu( QPoint point ); - + void downloadRemoteSelected(); // void addMsgRemoteSelected(); @@ -65,6 +65,8 @@ private slots: void copyLinkLocal(); void sendLinkTo(); void sendremoteLinkTo(); + void sendLinkToCloud(); + void addLinkToCloud(); void showFrame(bool show); void showFrameRemote(bool show); @@ -91,15 +93,15 @@ private: //slots.. Maybe it's not good... //** Define the popup menus for the Context menu */ //QMenu* contextMnu; - + //QMenu* contextMnu2; - + void copyLink (const QModelIndexList& lst, bool remote); - + /** Defines the actions for the context menu for QTreeView */ QAction* downloadAct; QAction* addMsgAct; - + /** Defines the actions for the context menu for QTreeWidget */ QAction* openfileAct; QAction* openfolderAct; @@ -107,8 +109,9 @@ private: QAction* copylinklocalAct; QAction* sendremotelinkAct; QAction* sendlinkAct; - - + QAction* sendlinkCloudAct; + QAction* addlinkCloudAct; + QTreeView *shareddirtreeview; QMovie *movie; @@ -121,7 +124,7 @@ private: QString currentCommand; QString currentFile; - + QAction* fileAssotiationAction(const QString fileName); };