(trunk qt) #4235 "allow transmission-qt to specify download dir for remote sessions" -- patch added from taem

This commit is contained in:
Jordan Lee 2012-07-09 23:18:40 +00:00
parent 1d1017534b
commit b72c58e34f
2 changed files with 22 additions and 7 deletions

View File

@ -29,6 +29,7 @@
#include <QSet>
#include <QVBoxLayout>
#include <QWidget>
#include <QLineEdit>
#include <libtransmission/transmission.h>
#include <libtransmission/bencode.h>
@ -110,14 +111,15 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
l->setBuddy( p );
connect( p, SIGNAL(clicked(bool)), this, SLOT(onFilenameClicked()));
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon( QFileIconProvider::Folder );
const QPixmap folderPixmap = folderIcon.pixmap( iconSize );
l = new QLabel( tr( "&Destination folder:" ) );
layout->addWidget( l, ++row, 0, Qt::AlignLeft );
if( session.isLocal( ) )
{
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon( QFileIconProvider::Folder );
const QPixmap folderPixmap = folderIcon.pixmap( iconSize );
l = new QLabel( tr( "&Destination folder:" ) );
layout->addWidget( l, ++row, 0, Qt::AlignLeft );
myDestination.setPath( prefs.getString( Prefs :: DOWNLOAD_DIR ) );
p = myDestinationButton = new QPushButton;
p->setIcon( folderPixmap );
@ -127,6 +129,13 @@ Options :: Options( Session& session, const Prefs& prefs, const AddData& addme,
l->setBuddy( p );
connect( p, SIGNAL(clicked(bool)), this, SLOT(onDestinationClicked()));
}
else
{
QLineEdit * e = myDestinationEdit = new QLineEdit;
e->setText( prefs.getString( Prefs :: DOWNLOAD_DIR ) );
layout->addWidget( e, row, 1 );
l->setBuddy( e );
}
myTree = new FileTreeView;
layout->addWidget( myTree, ++row, 0, 1, 2 );
@ -319,10 +328,14 @@ Options :: onAccepted( )
tr_bencDictAddStr( &top, "method", "torrent-add" );
tr_bencDictAddInt( &top, "tag", tag );
tr_benc * args( tr_bencDictAddDict( &top, "arguments", 10 ) );
QString downloadDir;
// "download-dir"
if( myDestinationButton )
tr_bencDictAddStr( args, "download-dir", myDestination.absolutePath().toUtf8().constData() );
downloadDir = myDestination.absolutePath();
else
downloadDir = myDestinationEdit->text();
tr_bencDictAddStr( args, "download-dir", downloadDir.toUtf8().constData() );
// "metainfo"
switch( myAdd.type )

View File

@ -27,6 +27,7 @@
#include <QCryptographicHash>
#include <QFile>
#include <QTimer>
#include <QLineEdit>
#include "add-data.h" // AddData
#include "file-tree.h" // FileList
@ -82,6 +83,7 @@ class Options: public QDialog
QComboBox * myPriorityCombo;
QPushButton * myFileButton;
QPushButton * myDestinationButton;
QLineEdit * myDestinationEdit;
QPushButton * myVerifyButton;
QVector<int> myPriorities;
QVector<bool> myWanted;