From f3750d0d6184adf1be6fd8fbaff9f831c85ee71e Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 2 Nov 2013 14:56:22 +0000 Subject: [PATCH] added copy-rs-link to SubFileItem (Patch from Phenom) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6887 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/feeds/SubFileItem.cpp | 28 +++++++++++++++----- retroshare-gui/src/gui/feeds/SubFileItem.h | 3 ++- retroshare-gui/src/gui/feeds/SubFileItem.ui | 26 ++++++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.cpp b/retroshare-gui/src/gui/feeds/SubFileItem.cpp index 8480d395f..47389ac6d 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.cpp +++ b/retroshare-gui/src/gui/feeds/SubFileItem.cpp @@ -29,6 +29,7 @@ #include #include #include "util/misc.h" +#include "gui/RetroShareLink.h" /**** @@ -98,6 +99,7 @@ void SubFileItem::Setup() connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) ); connect( cancelButton, SIGNAL( clicked( void ) ), this, SLOT( cancel ( void ) ) ); + connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) ); connect( saveButton, SIGNAL( clicked( void ) ), this, SLOT( save ( void ) ) ); /* once off check - if remote, check if we have it @@ -686,9 +688,23 @@ bool SubFileItem::isPlayable(bool &startable) return visible; } -void SubFileItem::mediatype() -{ - /* check if the file is not a media file and change text */ - playButton->setText(tr("Open")); - playButton->setToolTip(tr("Open File")); -} +void SubFileItem::mediatype() +{ + /* check if the file is not a media file and change text */ + playButton->setText(tr("Open")); + playButton->setToolTip(tr("Open File")); +} + +void SubFileItem::copyLink() +{ + if (mFileName.empty() || mFileHash.empty()) { + return; + } + + RetroShareLink link; + if (link.createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash))) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } +} diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.h b/retroshare-gui/src/gui/feeds/SubFileItem.h index a92e2a219..c15d731ca 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.h +++ b/retroshare-gui/src/gui/feeds/SubFileItem.h @@ -76,7 +76,8 @@ public: public slots: void download(); void play(); - void mediatype(); + void mediatype(); + void copyLink(); private slots: void toggle(); diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.ui b/retroshare-gui/src/gui/feeds/SubFileItem.ui index 005ee3332..e05b122b1 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.ui +++ b/retroshare-gui/src/gui/feeds/SubFileItem.ui @@ -159,6 +159,32 @@ + + + + + 0 + 0 + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Copy RetroShare Link + + + + :/images/copyrslink.png:/images/copyrslink.png + + +