Changeset 12595


Ignore:
Timestamp:
Jul 26, 2011, 2:56:30 AM (10 years ago)
Author:
jordan
Message:

(trunk qt) add popup notification for when torrents finish downloading.

Location:
trunk/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/app.cc

    r12008 r12595  
    255255}
    256256
    257 /* these two functions are for popping up desktop notification
    258  * when new torrents are added */
     257/* these functions are for popping up desktop notifications */
     258
    259259void
    260260MyApp :: onTorrentsAdded( QSet<int> torrents )
     
    266266    {
    267267        Torrent * tor = myModel->getTorrentFromId( id );
    268         if( !tor->name().isEmpty( ) )
     268        std::cerr << "torrent added: " << qPrintable(tor->name()) << std::endl;
     269
     270        if( tor->name().isEmpty( ) ) // wait until the torrent's INFO fields are loaded
     271            connect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onNewTorrentChanged(int)) );
     272        else {
    269273            onNewTorrentChanged( id );
    270         else // wait until the torrent's INFO fields are loaded
    271             connect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onNewTorrentChanged(int)) );
    272     }
    273 }
     274            if( !tor->isSeed( ) )
     275                connect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) );
     276        }
     277    }
     278}
     279
     280void
     281MyApp :: onTorrentCompleted( int id )
     282{
     283    Torrent * tor = myModel->getTorrentFromId( id );
     284
     285    if( tor && !tor->name().isEmpty() )
     286    {
     287        notify( tr( "Torrent Completed" ), tor->name( ) );
     288
     289        disconnect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) );
     290    }
     291}
     292
    274293void
    275294MyApp :: onNewTorrentChanged( int id )
     
    284303
    285304        disconnect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onNewTorrentChanged(int)) );
    286     }
    287 }
     305
     306        if( !tor->isSeed( ) )
     307            connect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) );
     308    }
     309}
     310
     311/***
     312****
     313***/
    288314
    289315void
  • trunk/qt/app.h

    r11437 r12595  
    6262        void refreshTorrents( );
    6363        void onTorrentsAdded( QSet<int> );
     64        void onTorrentCompleted( int );
    6465        void onNewTorrentChanged( int );
    6566
  • trunk/qt/torrent.cc

    r12214 r12595  
    455455{
    456456    bool changed = false;
     457    const bool was_seed = isSeed( );
     458    const uint64_t old_verified_size = haveVerified( );
    457459
    458460    for( int  i=0; i<PROPERTY_COUNT; ++i )
     
    688690    if( changed )
    689691        emit torrentChanged( id( ) );
     692
     693    if( !was_seed && isSeed() && (old_verified_size>0) )
     694        emit torrentCompleted( id( ) );
    690695}
    691696
  • trunk/qt/torrent.h

    r11446 r12595  
    183183    signals:
    184184        void torrentChanged( int id );
     185        void torrentCompleted( int id );
    185186
    186187    private:
Note: See TracChangeset for help on using the changeset viewer.