mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added past RS links to post on channels, and additional check that the file is already shared
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4609 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b9dfa27c19
commit
ad04f62e80
@ -24,8 +24,10 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QMenu>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <gui/RetroShareLink.h>
|
||||||
#include "CreateChannelMsg.h"
|
#include "CreateChannelMsg.h"
|
||||||
#include "gui/feeds/SubFileItem.h"
|
#include "gui/feeds/SubFileItem.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
@ -51,6 +53,8 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
|
|||||||
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
|
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
|
||||||
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
|
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
|
||||||
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
|
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
|
||||||
|
connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
|
||||||
|
|
||||||
thumbNailCb->setVisible(false);
|
thumbNailCb->setVisible(false);
|
||||||
thumbNailCb->setEnabled(false);
|
thumbNailCb->setEnabled(false);
|
||||||
#ifdef CHANNELS_FRAME_CATCHER
|
#ifdef CHANNELS_FRAME_CATCHER
|
||||||
@ -65,6 +69,63 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
|
|||||||
newChannelMsg();
|
newChannelMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateChannelMsg::contextMenu(QPoint /*point*/)
|
||||||
|
{
|
||||||
|
QList<RetroShareLink> links ;
|
||||||
|
RSLinkClipboard::pasteLinks(links) ;
|
||||||
|
|
||||||
|
int n_file = 0 ;
|
||||||
|
|
||||||
|
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
|
||||||
|
if((*it).type() == RetroShareLink::TYPE_FILE)
|
||||||
|
n_file++ ;
|
||||||
|
|
||||||
|
QMenu contextMnu(this) ;
|
||||||
|
|
||||||
|
QAction *action ;
|
||||||
|
|
||||||
|
if(n_file > 1)
|
||||||
|
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Links"), this, SLOT(pasteLink()));
|
||||||
|
else
|
||||||
|
action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||||
|
|
||||||
|
action->setDisabled(n_file < 1) ;
|
||||||
|
contextMnu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateChannelMsg::pasteLink()
|
||||||
|
{
|
||||||
|
std::cerr << "Pasting links: " << std::endl;
|
||||||
|
|
||||||
|
QList<RetroShareLink> links,not_have ;
|
||||||
|
RSLinkClipboard::pasteLinks(links) ;
|
||||||
|
|
||||||
|
for(QList<RetroShareLink>::const_iterator it(links.begin());it!=links.end();++it)
|
||||||
|
if((*it).type() == RetroShareLink::TYPE_FILE)
|
||||||
|
{
|
||||||
|
// 0 - check that we actually have the file!
|
||||||
|
//
|
||||||
|
|
||||||
|
std::cerr << "Pasting " << (*it).toString().toStdString() << std::endl;
|
||||||
|
|
||||||
|
FileInfo info ;
|
||||||
|
if(rsFiles->alreadyHaveFile( (*it).hash().toStdString(),info ) )
|
||||||
|
addAttachment((*it).hash().toStdString(), (*it).name().toStdString(), (*it).size(), true, "") ;
|
||||||
|
else
|
||||||
|
not_have.push_back( *it ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!not_have.empty())
|
||||||
|
{
|
||||||
|
QString msg = tr("Channel security policy prevents you from posting files that you don't have. If you have these files, you need to share them before, or attach them explicitly:")+"<br/><br/>" ;
|
||||||
|
|
||||||
|
for(QList<RetroShareLink>::const_iterator it(not_have.begin());it!=not_have.end();++it)
|
||||||
|
msg += (*it).toString() + "<br/>" ;
|
||||||
|
|
||||||
|
QMessageBox::warning(NULL,tr("You can only post files that you do have"),msg) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CreateChannelMsg::~CreateChannelMsg(){
|
CreateChannelMsg::~CreateChannelMsg(){
|
||||||
|
|
||||||
#ifdef CHANNELS_FRAME_CATCHER
|
#ifdef CHANNELS_FRAME_CATCHER
|
||||||
|
@ -61,6 +61,8 @@ private slots:
|
|||||||
|
|
||||||
void cancelMsg();
|
void cancelMsg();
|
||||||
void sendMsg();
|
void sendMsg();
|
||||||
|
void pasteLink() ;
|
||||||
|
void contextMenu(QPoint) ;
|
||||||
|
|
||||||
void addThumbnail();
|
void addThumbnail();
|
||||||
void allowAutoMediaThumbNail(bool);
|
void allowAutoMediaThumbNail(bool);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>509</width>
|
<width>574</width>
|
||||||
<height>479</height>
|
<height>479</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -96,8 +96,17 @@ p, li { white-space: pre-wrap; }
|
|||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -343,8 +352,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>456</width>
|
<width>517</width>
|
||||||
<height>260</height>
|
<height>269</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@ -420,6 +429,7 @@ background: white;}</string>
|
|||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
<include location="../../../../../../../../.designer/images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user