(qt) #3255: Don't use filebrowser in remote sessions
This commit is contained in:
parent
b4cee64ec9
commit
832d055ab3
2
NEWS
2
NEWS
|
@ -26,6 +26,8 @@
|
|||
* 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
|
||||
|
|
|
@ -667,7 +667,7 @@ TrMainWindow :: openProperties( )
|
|||
void
|
||||
TrMainWindow :: setLocation( )
|
||||
{
|
||||
QDialog * d = new RelocateDialog( mySession, getSelectedTorrents(), this );
|
||||
QDialog * d = new RelocateDialog( mySession, myModel, getSelectedTorrents(), this );
|
||||
d->show( );
|
||||
}
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ void
|
|||
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;
|
||||
|
@ -1247,18 +1247,18 @@ TrMainWindow :: removeTorrents( const bool deleteFiles )
|
|||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFileIconProvider>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -42,6 +41,7 @@
|
|||
#include "prefs-dialog.h"
|
||||
#include "qticonloader.h"
|
||||
#include "session.h"
|
||||
#include "utils.h"
|
||||
|
||||
/***
|
||||
****
|
||||
|
@ -493,78 +493,51 @@ void
|
|||
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 *
|
||||
|
@ -603,7 +576,7 @@ PrefsDialog :: createTorrentsTab( )
|
|||
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)) );
|
||||
|
|
|
@ -51,13 +51,10 @@ class PrefsDialog: public QDialog
|
|||
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( );
|
||||
|
||||
|
@ -98,7 +95,7 @@ class PrefsDialog: public QDialog
|
|||
QLabel * myPortLabel;
|
||||
QPushButton * myPortButton;
|
||||
QPushButton * myWatchButton;
|
||||
QPushButton * myTorrentDoneScriptFilename;
|
||||
QPushButton * myTorrentDoneScriptButton;
|
||||
QCheckBox * myTorrentDoneScriptCheckbox;
|
||||
QCheckBox * myIncompleteCheckbox;
|
||||
QPushButton * myIncompleteButton;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <QApplication>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFileIconProvider>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
@ -26,8 +25,9 @@
|
|||
#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;
|
||||
|
||||
|
@ -48,11 +48,11 @@ RelocateDialog :: onFileSelected( const QString& path )
|
|||
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
|
||||
|
@ -61,9 +61,10 @@ RelocateDialog :: onMoveToggled( bool b )
|
|||
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 ) );
|
||||
|
@ -74,8 +75,18 @@ RelocateDialog :: RelocateDialog( Session& session, const QSet<int>& ids, QWidge
|
|||
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" ) );
|
||||
|
@ -98,4 +109,5 @@ RelocateDialog :: RelocateDialog( Session& session, const QSet<int>& ids, QWidge
|
|||
connect( buttons, SIGNAL(rejected()), this, SLOT(deleteLater()));
|
||||
connect( buttons, SIGNAL(accepted()), this, SLOT(onSetLocation()));
|
||||
layout->addWidget( buttons );
|
||||
QWidget::setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
}
|
||||
|
|
|
@ -20,17 +20,20 @@
|
|||
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;
|
||||
|
@ -42,7 +45,7 @@ class RelocateDialog: public QDialog
|
|||
void onMoveToggled( bool );
|
||||
|
||||
public:
|
||||
RelocateDialog( Session&, const QSet<int>& ids, QWidget * parent = 0 );
|
||||
RelocateDialog( Session&, TorrentModel&, const QSet<int>& ids, QWidget * parent = 0 );
|
||||
~RelocateDialog( ) { }
|
||||
};
|
||||
|
||||
|
|
20
qt/utils.cc
20
qt/utils.cc
|
@ -15,7 +15,9 @@
|
|||
#include <QApplication>
|
||||
#include <QDataStream>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QStyle>
|
||||
|
@ -26,6 +28,24 @@
|
|||
#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 )
|
||||
|
|
|
@ -27,7 +27,7 @@ class Utils: public QObject
|
|||
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 );
|
||||
|
|
Loading…
Reference in New Issue