Changeset 8323 for trunk/qt/app.cc


Ignore:
Timestamp:
May 3, 2009, 5:37:39 PM (13 years ago)
Author:
charles
Message:

(trunk qt) Remember between runs whether we were running a local or remote session. Add a gui dialog for switching sessions during runtime.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/app.cc

    r8233 r8323  
    2828#include "options.h"
    2929#include "prefs.h"
     30#include "session.h"
     31#include "session-dialog.h"
    3032#include "torrent-model.h"
    31 #include "session.h"
    3233#include "utils.h"
    3334#include "watchdir.h"
     
    4142        { 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
    4243        { 'm', "minimized",  "Start minimized in system tray", "m", 0, NULL },
    43         { 'p', "paused",  "Pause all torrents on sartup", "p", 0, NULL },
    44         { 'r', "remote",  "Remotely control a pre-existing session", "r", 1, "<URL>" },
    4544        { 'v', "version", "Show version number and exit", "v", 0, NULL },
    4645        { 0, NULL, NULL, NULL, 0, NULL }
     
    9796    // parse the command-line arguments
    9897    int c;
    99     bool paused = false;
    10098    bool minimized = false;
    10199    const char * optarg;
    102100    const char * configDir = 0;
    103     const char * url = 0;
    104101    while( ( c = tr_getopt( getUsage( ), argc, (const char**)argv, opts, &optarg ) ) ) {
    105102        switch( c ) {
    106103            case 'g': configDir = optarg; break;
    107104            case 'm': minimized = true; break;
    108             case 'p': paused = true; break;
    109             case 'r': url = optarg; break;
    110105            case 'v':        Utils::toStderr( QObject::tr( "transmission %1" ).arg( LONG_VERSION_STRING ) ); exit( 0 ); break;
    111106            case TR_OPT_ERR: Utils::toStderr( QObject::tr( "Invalid option" ) ); showUsage( ); break;
     
    118113        configDir = tr_getDefaultConfigDir( MY_NAME );
    119114
     115    // is this the first time we've run transmission?
     116    const bool firstTime = !QFile(QDir(configDir).absoluteFilePath("settings.json")).exists();
     117
    120118    myPrefs = new Prefs ( configDir );
    121     mySession = new Session( configDir, *myPrefs, url, paused );
     119    mySession = new Session( configDir, *myPrefs );
    122120    myModel = new TorrentModel( *myPrefs );
    123121    myWindow = new TrMainWindow( *mySession, *myPrefs, *myModel, minimized );
    124122    myWatchDir = new WatchDir( *myModel );
    125123
    126     /* when the session gets torrent info, update the model */
     124    // when the session gets torrent info, update the model
    127125    connect( mySession, SIGNAL(torrentsUpdated(tr_benc*,bool)), myModel, SLOT(updateTorrents(tr_benc*,bool)) );
    128126    connect( mySession, SIGNAL(torrentsUpdated(tr_benc*,bool)), myWindow, SLOT(refreshActionSensitivity()) );
    129127    connect( mySession, SIGNAL(torrentsRemoved(tr_benc*)), myModel, SLOT(removeTorrents(tr_benc*)) );
    130     /* when the model sees a torrent for the first time, ask the session for full info on it */
     128    // when the model sees a torrent for the first time, ask the session for full info on it
    131129    connect( myModel, SIGNAL(torrentsAdded(QSet<int>)), mySession, SLOT(initTorrents(QSet<int>)) );
    132130
     
    134132    mySession->refreshSessionStats( );
    135133
    136     /* when torrents are added to the watch directory, tell the session */
     134    // when torrents are added to the watch directory, tell the session
    137135    connect( myWatchDir, SIGNAL(torrentFileAdded(QString)), this, SLOT(addTorrent(QString)) );
    138136
    139     /* init from preferences */
     137    // init from preferences
    140138    QList<int> initKeys;
    141139    initKeys << Prefs::DIR_WATCH;
     
    163161
    164162    maybeUpdateBlocklist( );
     163
     164    if( !firstTime )
     165        mySession->restart( );
     166    else {
     167        QDialog * d = new SessionDialog( *mySession, *myPrefs, myWindow );
     168        d->show( );
     169    }
    165170}
    166171
Note: See TracChangeset for help on using the changeset viewer.