mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-09-27 11:51:00 -04:00
added choice for default auto-download directory per channel.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6376 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2986e81f7e
commit
c2fa746991
7 changed files with 280 additions and 11 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <QFile>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -29,6 +30,8 @@
|
|||
#include <set>
|
||||
#include <map>
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
||||
#include "ChannelFeed.h"
|
||||
|
||||
#include "feeds/ChanMsgItem.h"
|
||||
|
@ -197,6 +200,51 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ )
|
|||
contextMnu.addAction( shareKeyAct );
|
||||
}
|
||||
|
||||
if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
|
||||
{
|
||||
QMenu *directoryMenu = contextMnu.addMenu(QIcon(":/images/folderopen.png"),tr("Set destination directory")) ;
|
||||
|
||||
QAction *specifyDestinationDirectoryAct = new QAction(QIcon(":/images/filefind.png"), tr("Other..."), &contextMnu);
|
||||
directoryMenu->addAction(specifyDestinationDirectoryAct);
|
||||
|
||||
// Now get the list of existing directories.
|
||||
|
||||
std::list<SharedDirInfo> dirs ;
|
||||
rsFiles->getSharedDirectories(dirs) ;
|
||||
bool found = false ;
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it)
|
||||
{
|
||||
// check for existence of directory name
|
||||
QFile directory(QString::fromUtf8((*it).filename.c_str())) ;
|
||||
|
||||
if(!directory.exists()) continue ;
|
||||
if(!(directory.permissions() & QFile::WriteOwner)) continue ;
|
||||
|
||||
QAction *act ;
|
||||
|
||||
if(ci.destination_directory == (*it).filename)
|
||||
{
|
||||
act = new QAction(QIcon(":/images/start.png"),QString::fromUtf8((*it).virtualname.c_str()),directoryMenu) ;
|
||||
found = true ;
|
||||
}
|
||||
else
|
||||
act = new QAction(QString::fromUtf8((*it).virtualname.c_str()),directoryMenu) ;
|
||||
|
||||
act->setData(QString::fromUtf8((*it).filename.c_str())) ;
|
||||
connect(act,SIGNAL(triggered()),this,SLOT(setDestinationDirectory())) ;
|
||||
directoryMenu->addAction(act) ;
|
||||
}
|
||||
QAction *defaultDestinationDirectoryAct = new QAction(tr("[Default]"), &contextMnu);
|
||||
defaultDestinationDirectoryAct->setData(QString()) ;
|
||||
connect(defaultDestinationDirectoryAct,SIGNAL(triggered()),this,SLOT(setDestinationDirectory())) ;
|
||||
|
||||
directoryMenu->addAction(defaultDestinationDirectoryAct);
|
||||
|
||||
if(!found)
|
||||
defaultDestinationDirectoryAct->setIcon(QIcon(":/images/start.png")) ;
|
||||
}
|
||||
|
||||
if(ci.channelFlags & RS_DISTRIB_SUBSCRIBED)
|
||||
{
|
||||
contextMnu.addAction( unsubscribechannelAct );
|
||||
|
@ -220,6 +268,17 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ )
|
|||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
void ChannelFeed::setDestinationDirectory()
|
||||
{
|
||||
ChannelInfo ci;
|
||||
if (!rsChannels->getChannelInfo(mChannelId, ci))
|
||||
return;
|
||||
|
||||
std::string dest_dir(qobject_cast<QAction*>(sender())->data().toString().toUtf8().data()) ;
|
||||
|
||||
std::cerr << "Setting new directory " << dest_dir << " to channel " << mChannelId << std::endl;
|
||||
rsChannels->channelSetDestinationDirectory(mChannelId,dest_dir) ;
|
||||
}
|
||||
|
||||
void ChannelFeed::createChannel()
|
||||
{
|
||||
|
|
|
@ -79,6 +79,7 @@ private slots:
|
|||
void editChannelDetail();
|
||||
void shareKey();
|
||||
void copyChannelLink();
|
||||
void setDestinationDirectory();
|
||||
|
||||
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue