* Show file sizes in the file tree
* Added a confirm dialog when removing torrents
* Properties and torrent options no longer jump around while editing
+ * Allow setting locations for remote sessions
+ * Miscellaneous UI fixes
==== Daemon ====
* Let users specify a script to be invoked when a torrent finishes downloading
* Better support for adding per-torrent settings when adding a new torrent
void
TrMainWindow :: setLocation( )
{
- QDialog * d = new RelocateDialog( mySession, getSelectedTorrents(), this );
+ QDialog * d = new RelocateDialog( mySession, myModel, getSelectedTorrents(), this );
d->show( );
}
TrMainWindow :: removeTorrents( const bool deleteFiles )
{
QSet<int> ids;
- QMessageBox msgBox( this );
+ QMessageBox * msgBox = new QMessageBox( this );
QString primary_text, secondary_text;
int incomplete = 0;
int connected = 0;
}
}
- msgBox.setWindowTitle( QString(" ") );
- msgBox.setText( QString( "<big><b>%1</big></b>" ).arg( primary_text ) );
- msgBox.setInformativeText( secondary_text );
- msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
- msgBox.setDefaultButton( QMessageBox::Cancel );
- msgBox.setIcon( QMessageBox::Question );
+ msgBox->setWindowTitle( QString(" ") );
+ msgBox->setText( QString( "<big><b>%1</big></b>" ).arg( primary_text ) );
+ msgBox->setInformativeText( secondary_text );
+ msgBox->setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
+ msgBox->setDefaultButton( QMessageBox::Cancel );
+ msgBox->setIcon( QMessageBox::Question );
/* hack needed to keep the dialog from being too narrow */
- QGridLayout* layout = (QGridLayout*)msgBox.layout();
+ QGridLayout* layout = (QGridLayout*)msgBox->layout();
QSpacerItem* spacer = new QSpacerItem( 450, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
layout->addItem( spacer, layout->rowCount(), 0, 1, layout->columnCount() );
- if( msgBox.exec() == QMessageBox::Ok )
+ if( msgBox->exec() == QMessageBox::Ok )
mySession.removeTorrents( ids, deleteFiles );
}
#include <QCoreApplication>
#include <QDialogButtonBox>
#include <QDoubleSpinBox>
-#include <QFileDialog>
#include <QFileIconProvider>
#include <QFileInfo>
#include <QHBoxLayout>
#include "prefs-dialog.h"
#include "qticonloader.h"
#include "session.h"
+#include "utils.h"
/***
****
PrefsDialog :: onScriptClicked( void )
{
const QString title = tr( "Select \"Torrent Done\" Script" );
- const QString path = myPrefs.getString( Prefs::SCRIPT_TORRENT_DONE_FILENAME );
- QFileDialog * d = new QFileDialog( this, title, path );
- d->setFileMode( QFileDialog::ExistingFiles );
- connect( d, SIGNAL(filesSelected(const QStringList&)),
- this, SLOT(onScriptSelected(const QStringList&)) );
- d->show( );
-}
+ const QString myPath = myPrefs.getString( Prefs::SCRIPT_TORRENT_DONE_FILENAME );
+ const QString path = Utils::remoteFileChooser( this, title, myPath, false, mySession.isServer() );
-void
-PrefsDialog :: onScriptSelected( const QStringList& list )
-{
- if( list.size() == 1 )
- myPrefs.set( Prefs::Prefs::SCRIPT_TORRENT_DONE_FILENAME, list.first( ) );
+ if( !path.isEmpty() )
+ onLocationSelected( path, Prefs::SCRIPT_TORRENT_DONE_FILENAME );
}
-
void
PrefsDialog :: onIncompleteClicked( void )
{
const QString title = tr( "Select Incomplete Directory" );
- const QString path = myPrefs.getString( Prefs::INCOMPLETE_DIR );
- QFileDialog * d = new QFileDialog( this, title, path );
- d->setFileMode( QFileDialog::Directory );
- connect( d, SIGNAL(filesSelected(const QStringList&)),
- this, SLOT(onIncompleteSelected(const QStringList&)) );
- d->show( );
-}
+ const QString myPath = myPrefs.getString( Prefs::INCOMPLETE_DIR );
+ const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
-void
-PrefsDialog :: onIncompleteSelected( const QStringList& list )
-{
- if( list.size() == 1 )
- myPrefs.set( Prefs::INCOMPLETE_DIR, list.first( ) );
+ if( !path.isEmpty() )
+ onLocationSelected( path, Prefs::INCOMPLETE_DIR );
}
-
void
PrefsDialog :: onWatchClicked( void )
{
const QString title = tr( "Select Watch Directory" );
- const QString path = myPrefs.getString( Prefs::DIR_WATCH );
- QFileDialog * d = new QFileDialog( this, title, path );
- d->setFileMode( QFileDialog::Directory );
- connect( d, SIGNAL(filesSelected(const QStringList&)),
- this, SLOT(onWatchSelected(const QStringList&)) );
- d->show( );
-}
+ const QString myPath = myPrefs.getString( Prefs::DIR_WATCH );
+ const QString path = Utils::remoteFileChooser( this, title, myPath, true, true );
-void
-PrefsDialog :: onWatchSelected( const QStringList& list )
-{
- if( list.size() == 1 )
- myPrefs.set( Prefs::DIR_WATCH, list.first( ) );
+ if( !path.isEmpty() )
+ onLocationSelected( path, Prefs::DIR_WATCH );
}
void
PrefsDialog :: onDestinationClicked( void )
{
const QString title = tr( "Select Destination" );
- const QString path = myPrefs.getString( Prefs::DOWNLOAD_DIR );
- QFileDialog * d = new QFileDialog( this, title, path );
- d->setFileMode( QFileDialog::Directory );
- connect( d, SIGNAL(filesSelected(const QStringList&)),
- this, SLOT(onDestinationSelected(const QStringList&)) );
- d->show( );
+ const QString myPath = myPrefs.getString( Prefs::DOWNLOAD_DIR );
+ const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
+
+ if( !path.isEmpty() )
+ onLocationSelected( path, Prefs::DOWNLOAD_DIR );
}
void
-PrefsDialog :: onDestinationSelected( const QStringList& list )
+PrefsDialog :: onLocationSelected( const QString& path, int key )
{
- if( list.size() == 1 )
- myPrefs.set( Prefs::DOWNLOAD_DIR, list.first( ) );
+ myPrefs.set( key, path );
+ updatePref( key );
}
QWidget *
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), b );
l = myTorrentDoneScriptCheckbox = checkBoxNew( tr( "Call scrip&t when torrent is completed" ), Prefs::SCRIPT_TORRENT_DONE_ENABLED );
- b = myTorrentDoneScriptFilename = new QPushButton;
+ b = myTorrentDoneScriptButton = new QPushButton;
b->setIcon( filePixmap );
b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
connect( b, SIGNAL(clicked(bool)), this, SLOT(onScriptClicked(void)) );
void altSpeedDaysEdited( int );
void sessionUpdated( );
void onWatchClicked( );
- void onWatchSelected( const QStringList& );
void onScriptClicked( );
- void onScriptSelected( const QStringList& );
void onIncompleteClicked( );
- void onIncompleteSelected( const QStringList& );
void onDestinationClicked( );
- void onDestinationSelected( const QStringList& );
+ void onLocationSelected( const QString&, int key );
void onPortTested( bool );
void onPortTest( );
QLabel * myPortLabel;
QPushButton * myPortButton;
QPushButton * myWatchButton;
- QPushButton * myTorrentDoneScriptFilename;
+ QPushButton * myTorrentDoneScriptButton;
QCheckBox * myTorrentDoneScriptCheckbox;
QCheckBox * myIncompleteCheckbox;
QPushButton * myIncompleteButton;
#include <QApplication>
#include <QDialogButtonBox>
#include <QDir>
-#include <QFileDialog>
#include <QFileIconProvider>
#include <QLabel>
#include <QPushButton>
#include "hig.h"
#include "relocate.h"
#include "session.h"
-
-QString RelocateDialog :: myPath;
+#include "torrent.h"
+#include "torrent-model.h"
+#include "utils.h"
bool RelocateDialog :: myMoveFlag = true;
void
RelocateDialog :: onDirButtonClicked( )
{
- QFileDialog * d = new QFileDialog( this );
- d->setFileMode( QFileDialog::Directory );
- d->selectFile( myPath );
- d->show( );
- connect( d, SIGNAL(fileSelected(const QString&)), this, SLOT(onFileSelected(const QString&)));
+ const QString title = tr( "Select Location" );
+ const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
+
+ if( !path.isEmpty() )
+ onFileSelected( path );
}
void
myMoveFlag = b;
}
-RelocateDialog :: RelocateDialog( Session& session, const QSet<int>& ids, QWidget * parent ):
+RelocateDialog :: RelocateDialog( Session& session, TorrentModel& model, const QSet<int>& ids, QWidget * parent ):
QDialog( parent ),
mySession( session ),
+ myModel( model ),
myIds( ids )
{
const int iconSize( style( )->pixelMetric( QStyle :: PM_SmallIconSize ) );
QRadioButton * find_rb;
setWindowTitle( tr( "Set Torrent Location" ) );
- if( myPath.isEmpty( ) )
- myPath = QDir::homePath( );
+ foreach( int id, myIds ) {
+ const Torrent * tor = myModel.getTorrentFromId( id );
+ if( myPath.isEmpty() )
+ myPath = tor->getPath();
+ else if( myPath != tor->getPath() )
+ {
+ if( mySession.isServer() )
+ myPath = QDir::homePath( );
+ else
+ myPath = QString( "/" );
+ }
+ }
HIG * hig = new HIG( );
hig->addSectionTitle( tr( "Set Location" ) );
connect( buttons, SIGNAL(rejected()), this, SLOT(deleteLater()));
connect( buttons, SIGNAL(accepted()), this, SLOT(onSetLocation()));
layout->addWidget( buttons );
+ QWidget::setAttribute( Qt::WA_DeleteOnClose, true );
}
class QPushButton;
class QRadioButton;
class Session;
+class Torrent;
+class TorrentModel;
class RelocateDialog: public QDialog
{
Q_OBJECT
private:
- static QString myPath;
+ QString myPath;
static bool myMoveFlag;
private:
Session & mySession;
+ TorrentModel& myModel;
QSet<int> myIds;
QPushButton * myDirButton;
QRadioButton * myMoveRadio;
void onMoveToggled( bool );
public:
- RelocateDialog( Session&, const QSet<int>& ids, QWidget * parent = 0 );
+ RelocateDialog( Session&, TorrentModel&, const QSet<int>& ids, QWidget * parent = 0 );
~RelocateDialog( ) { }
};
#include <QApplication>
#include <QDataStream>
#include <QFile>
+#include <QFileDialog>
#include <QFileInfo>
+#include <QInputDialog>
#include <QObject>
#include <QSet>
#include <QStyle>
#include "qticonloader.h"
#include "utils.h"
+QString
+Utils :: remoteFileChooser( QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local )
+{
+ QString path;
+
+ if( local )
+ {
+ if( dir )
+ path = QFileDialog::getExistingDirectory( parent, title, myPath );
+ else
+ path = QFileDialog::getOpenFileName( parent, title, myPath );
+ }
+ else
+ path = QInputDialog::getText( parent, title, tr( "Enter a location:" ), QLineEdit::Normal, myPath, NULL );
+
+ return path;
+}
+
#define KILOBYTE_FACTOR 1024.0
#define MEGABYTE_FACTOR ( 1024.0 * 1024.0 )
#define GIGABYTE_FACTOR ( 1024.0 * 1024.0 * 1024.0 )
Utils( ) { }
virtual ~Utils( ) { }
public:
-
+ static QString remoteFileChooser( QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local );
static QString sizeToString( double size );
static QString speedToString( const Speed& speed );
static QString ratioToString( double ratio );