Changeset 10722


Ignore:
Timestamp:
Jun 4, 2010, 1:00:27 AM (12 years ago)
Author:
Longinus00
Message:

(qt) #3255: Don't use filebrowser in remote sessions

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r10709 r10722  
    2727  * Added a confirm dialog when removing torrents
    2828  * Properties and torrent options no longer jump around while editing
     29  * Allow setting locations for remote sessions
     30  * Miscellaneous UI fixes
    2931==== Daemon ====
    3032  * Let users specify a script to be invoked when a torrent finishes downloading
  • trunk/qt/mainwin.cc

    r10630 r10722  
    668668TrMainWindow :: setLocation( )
    669669{
    670     QDialog * d = new RelocateDialog( mySession, getSelectedTorrents(), this );
     670    QDialog * d = new RelocateDialog( mySession, myModel, getSelectedTorrents(), this );
    671671    d->show( );
    672672}
     
    11751175{
    11761176    QSet<int> ids;
    1177     QMessageBox msgBox( this );
     1177    QMessageBox * msgBox = new QMessageBox( this );
    11781178    QString primary_text, secondary_text;
    11791179    int incomplete = 0;
     
    12481248    }
    12491249
    1250     msgBox.setWindowTitle( QString(" ") );
    1251     msgBox.setText( QString( "<big><b>%1</big></b>" ).arg( primary_text ) );
    1252     msgBox.setInformativeText( secondary_text );
    1253     msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
    1254     msgBox.setDefaultButton( QMessageBox::Cancel );
    1255     msgBox.setIcon( QMessageBox::Question );
     1250    msgBox->setWindowTitle( QString(" ") );
     1251    msgBox->setText( QString( "<big><b>%1</big></b>" ).arg( primary_text ) );
     1252    msgBox->setInformativeText( secondary_text );
     1253    msgBox->setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
     1254    msgBox->setDefaultButton( QMessageBox::Cancel );
     1255    msgBox->setIcon( QMessageBox::Question );
    12561256    /* hack needed to keep the dialog from being too narrow */
    1257     QGridLayout* layout = (QGridLayout*)msgBox.layout();
     1257    QGridLayout* layout = (QGridLayout*)msgBox->layout();
    12581258    QSpacerItem* spacer = new QSpacerItem( 450, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
    12591259    layout->addItem( spacer, layout->rowCount(), 0, 1, layout->columnCount() );
    12601260
    1261     if( msgBox.exec() == QMessageBox::Ok )
     1261    if( msgBox->exec() == QMessageBox::Ok )
    12621262        mySession.removeTorrents( ids, deleteFiles );
    12631263}
  • trunk/qt/prefs-dialog.cc

    r10638 r10722  
    1919#include <QDialogButtonBox>
    2020#include <QDoubleSpinBox>
    21 #include <QFileDialog>
    2221#include <QFileIconProvider>
    2322#include <QFileInfo>
     
    4342#include "qticonloader.h"
    4443#include "session.h"
     44#include "utils.h"
    4545
    4646/***
     
    494494{
    495495    const QString title = tr( "Select \"Torrent Done\" Script" );
    496     const QString path = myPrefs.getString( Prefs::SCRIPT_TORRENT_DONE_FILENAME );
    497     QFileDialog * d = new QFileDialog( this, title, path );
    498     d->setFileMode( QFileDialog::ExistingFiles );
    499     connect( d, SIGNAL(filesSelected(const QStringList&)),
    500              this, SLOT(onScriptSelected(const QStringList&)) );
    501     d->show( );
    502 }
    503 
    504 void
    505 PrefsDialog :: onScriptSelected( const QStringList& list )
    506 {
    507     if( list.size() == 1 )
    508         myPrefs.set( Prefs::Prefs::SCRIPT_TORRENT_DONE_FILENAME, list.first( ) );
    509 }
    510 
     496    const QString myPath = myPrefs.getString( Prefs::SCRIPT_TORRENT_DONE_FILENAME );
     497    const QString path = Utils::remoteFileChooser( this, title, myPath, false, mySession.isServer() );
     498
     499    if( !path.isEmpty() )
     500        onLocationSelected( path, Prefs::SCRIPT_TORRENT_DONE_FILENAME );
     501}
    511502
    512503void
     
    514505{
    515506    const QString title = tr( "Select Incomplete Directory" );
    516     const QString path = myPrefs.getString( Prefs::INCOMPLETE_DIR );
    517     QFileDialog * d = new QFileDialog( this, title, path );
    518     d->setFileMode( QFileDialog::Directory );
    519     connect( d, SIGNAL(filesSelected(const QStringList&)),
    520              this, SLOT(onIncompleteSelected(const QStringList&)) );
    521     d->show( );
    522 }
    523 
    524 void
    525 PrefsDialog :: onIncompleteSelected( const QStringList& list )
    526 {
    527     if( list.size() == 1 )
    528         myPrefs.set( Prefs::INCOMPLETE_DIR, list.first( ) );
    529 }
    530 
     507    const QString myPath = myPrefs.getString( Prefs::INCOMPLETE_DIR );
     508    const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
     509
     510    if( !path.isEmpty() )
     511        onLocationSelected( path, Prefs::INCOMPLETE_DIR );
     512}
    531513
    532514void
     
    534516{
    535517    const QString title = tr( "Select Watch Directory" );
    536     const QString path = myPrefs.getString( Prefs::DIR_WATCH );
    537     QFileDialog * d = new QFileDialog( this, title, path );
    538     d->setFileMode( QFileDialog::Directory );
    539     connect( d, SIGNAL(filesSelected(const QStringList&)),
    540              this, SLOT(onWatchSelected(const QStringList&)) );
    541     d->show( );
    542 }
    543 
    544 void
    545 PrefsDialog :: onWatchSelected( const QStringList& list )
    546 {
    547     if( list.size() == 1 )
    548         myPrefs.set( Prefs::DIR_WATCH, list.first( ) );
     518    const QString myPath = myPrefs.getString( Prefs::DIR_WATCH );
     519    const QString path = Utils::remoteFileChooser( this, title, myPath, true, true );
     520
     521    if( !path.isEmpty() )
     522        onLocationSelected( path, Prefs::DIR_WATCH );
    549523}
    550524
     
    553527{
    554528    const QString title = tr( "Select Destination" );
    555     const QString path = myPrefs.getString( Prefs::DOWNLOAD_DIR );
    556     QFileDialog * d = new QFileDialog( this, title, path );
    557     d->setFileMode( QFileDialog::Directory );
    558     connect( d, SIGNAL(filesSelected(const QStringList&)),
    559              this, SLOT(onDestinationSelected(const QStringList&)) );
    560     d->show( );
    561 }
    562 
    563 void
    564 PrefsDialog :: onDestinationSelected( const QStringList& list )
    565 {
    566     if( list.size() == 1 )
    567         myPrefs.set( Prefs::DOWNLOAD_DIR, list.first( ) );
     529    const QString myPath = myPrefs.getString( Prefs::DOWNLOAD_DIR );
     530    const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
     531
     532    if( !path.isEmpty() )
     533        onLocationSelected( path, Prefs::DOWNLOAD_DIR );
     534}
     535
     536void
     537PrefsDialog :: onLocationSelected( const QString& path, int key )
     538{
     539    myPrefs.set( key, path );
     540    updatePref( key );
    568541}
    569542
     
    604577
    605578        l = myTorrentDoneScriptCheckbox = checkBoxNew( tr( "Call scrip&t when torrent is completed" ), Prefs::SCRIPT_TORRENT_DONE_ENABLED );
    606         b = myTorrentDoneScriptFilename = new QPushButton;
     579        b = myTorrentDoneScriptButton = new QPushButton;
    607580        b->setIcon( filePixmap );
    608581        b->setStyleSheet( "text-align: left; padding-left: 5; padding-right: 5" );
  • trunk/qt/prefs-dialog.h

    r10638 r10722  
    5252        void sessionUpdated( );
    5353        void onWatchClicked( );
    54         void onWatchSelected( const QStringList& );
    5554        void onScriptClicked( );
    56         void onScriptSelected( const QStringList& );
    5755        void onIncompleteClicked( );
    58         void onIncompleteSelected( const QStringList& );
    5956        void onDestinationClicked( );
    60         void onDestinationSelected( const QStringList& );
     57        void onLocationSelected( const QString&, int key );
    6158        void onPortTested( bool );
    6259        void onPortTest( );
     
    9996        QPushButton * myPortButton;
    10097        QPushButton * myWatchButton;
    101         QPushButton * myTorrentDoneScriptFilename;
     98        QPushButton * myTorrentDoneScriptButton;
    10299        QCheckBox * myTorrentDoneScriptCheckbox;
    103100        QCheckBox * myIncompleteCheckbox;
  • trunk/qt/relocate.cc

    r9868 r10722  
    1414#include <QDialogButtonBox>
    1515#include <QDir>
    16 #include <QFileDialog>
    1716#include <QFileIconProvider>
    1817#include <QLabel>
     
    2726#include "relocate.h"
    2827#include "session.h"
    29 
    30 QString RelocateDialog :: myPath;
     28#include "torrent.h"
     29#include "torrent-model.h"
     30#include "utils.h"
    3131
    3232bool RelocateDialog :: myMoveFlag = true;
     
    4949RelocateDialog :: onDirButtonClicked( )
    5050{
    51     QFileDialog * d = new QFileDialog( this );
    52     d->setFileMode( QFileDialog::Directory );
    53     d->selectFile( myPath );
    54     d->show( );
    55     connect( d, SIGNAL(fileSelected(const QString&)), this, SLOT(onFileSelected(const QString&)));
     51    const QString title = tr( "Select Location" );
     52    const QString path = Utils::remoteFileChooser( this, title, myPath, true, mySession.isServer() );
     53
     54    if( !path.isEmpty() )
     55        onFileSelected( path );
    5656}
    5757
     
    6262}
    6363
    64 RelocateDialog :: RelocateDialog( Session& session, const QSet<int>& ids, QWidget * parent ):
     64RelocateDialog :: RelocateDialog( Session& session, TorrentModel& model, const QSet<int>& ids, QWidget * parent ):
    6565    QDialog( parent ),
    6666    mySession( session ),
     67    myModel( model ),
    6768    myIds( ids )
    6869{
     
    7576    setWindowTitle( tr( "Set Torrent Location" ) );
    7677
    77     if( myPath.isEmpty( ) )
    78         myPath = QDir::homePath( );
     78    foreach( int id, myIds ) {
     79        const Torrent * tor = myModel.getTorrentFromId( id );
     80        if( myPath.isEmpty() )
     81            myPath = tor->getPath();
     82        else if( myPath != tor->getPath() )
     83        {
     84            if( mySession.isServer() )
     85                myPath = QDir::homePath( );
     86            else
     87                myPath = QString( "/" );
     88        }
     89    }
    7990
    8091    HIG * hig = new HIG( );
     
    99110    connect( buttons, SIGNAL(accepted()), this, SLOT(onSetLocation()));
    100111    layout->addWidget( buttons );
     112    QWidget::setAttribute( Qt::WA_DeleteOnClose, true );
    101113}
  • trunk/qt/relocate.h

    r9868 r10722  
    2121class QRadioButton;
    2222class Session;
     23class Torrent;
     24class TorrentModel;
    2325
    2426class RelocateDialog: public QDialog
     
    2729
    2830    private:
    29         static QString myPath;
     31        QString myPath;
    3032        static bool myMoveFlag;
    3133
    3234    private:
    3335        Session & mySession;
     36        TorrentModel& myModel;
    3437        QSet<int> myIds;
    3538        QPushButton * myDirButton;
     
    4346
    4447    public:
    45         RelocateDialog( Session&, const QSet<int>& ids, QWidget * parent = 0 );
     48        RelocateDialog( Session&, TorrentModel&, const QSet<int>& ids, QWidget * parent = 0 );
    4649        ~RelocateDialog( ) { }
    4750};
  • trunk/qt/utils.cc

    r10683 r10722  
    1616#include <QDataStream>
    1717#include <QFile>
     18#include <QFileDialog>
    1819#include <QFileInfo>
     20#include <QInputDialog>
    1921#include <QObject>
    2022#include <QSet>
     
    2628#include "qticonloader.h"
    2729#include "utils.h"
     30
     31QString
     32Utils :: remoteFileChooser( QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local )
     33{
     34    QString path;
     35
     36    if( local )
     37    {
     38        if( dir )
     39            path = QFileDialog::getExistingDirectory( parent, title, myPath );
     40        else
     41            path = QFileDialog::getOpenFileName( parent, title, myPath );
     42    }
     43    else
     44        path = QInputDialog::getText( parent, title, tr( "Enter a location:" ), QLineEdit::Normal, myPath, NULL );
     45
     46    return path;
     47}
    2848
    2949#define KILOBYTE_FACTOR 1024.0
  • trunk/qt/utils.h

    r10645 r10722  
    2828        virtual ~Utils( ) { }
    2929    public:
    30 
     30        static QString remoteFileChooser( QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local );
    3131        static QString sizeToString( double size );
    3232        static QString speedToString( const Speed& speed );
Note: See TracChangeset for help on using the changeset viewer.