mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk qt) #3469 "Qt client should have desktop notification for added torrents" -- done.
This commit is contained in:
parent
d731848f21
commit
c4cac7ae8c
2 changed files with 26 additions and 6 deletions
28
qt/app.cc
28
qt/app.cc
|
@ -249,8 +249,29 @@ MyApp :: MyApp( int& argc, char ** argv ):
|
||||||
void
|
void
|
||||||
MyApp :: torrentsAdded( QSet<int> torrents )
|
MyApp :: torrentsAdded( QSet<int> torrents )
|
||||||
{
|
{
|
||||||
myAddedTorrents += torrents;
|
foreach( int id, torrents )
|
||||||
std::cerr << "added count is " << myAddedTorrents.size() << std::endl;
|
{
|
||||||
|
Torrent * tor = myModel->getTorrentFromId( id );
|
||||||
|
if( !tor->name().isEmpty( ) )
|
||||||
|
torrentChanged( id );
|
||||||
|
else // wait until the torrent's INFO fields are loaded
|
||||||
|
connect( tor, SIGNAL(torrentChanged(int)), this, SLOT(torrentChanged(int)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MyApp :: torrentChanged( int id )
|
||||||
|
{
|
||||||
|
Torrent * tor = myModel->getTorrentFromId( id );
|
||||||
|
|
||||||
|
if( tor && !tor->name().isEmpty() )
|
||||||
|
{
|
||||||
|
const int age_secs = tor->dateAdded().secsTo(QDateTime::currentDateTime());
|
||||||
|
if( age_secs < 30 )
|
||||||
|
notify( tr( "Torrent Added" ), tor->name( ) );
|
||||||
|
|
||||||
|
disconnect( tor, SIGNAL(torrentChanged(int)), this, SLOT(torrentChanged(int)) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -374,7 +395,7 @@ MyApp :: raise( )
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MyApp :: notify( const QString& title, const QString& body, int timeout_msec ) const
|
MyApp :: notify( const QString& title, const QString& body ) const
|
||||||
{
|
{
|
||||||
const QString dbusServiceName = "org.freedesktop.Notifications";
|
const QString dbusServiceName = "org.freedesktop.Notifications";
|
||||||
const QString dbusInterfaceName = "org.freedesktop.Notifications";
|
const QString dbusInterfaceName = "org.freedesktop.Notifications";
|
||||||
|
@ -439,6 +460,5 @@ main( int argc, char * argv[] )
|
||||||
|
|
||||||
tr_optind = 1;
|
tr_optind = 1;
|
||||||
MyApp app( argc, argv );
|
MyApp app( argc, argv );
|
||||||
app.notify( "hello world", "this is a test" );
|
|
||||||
return app.exec( );
|
return app.exec( );
|
||||||
}
|
}
|
||||||
|
|
4
qt/app.h
4
qt/app.h
|
@ -34,7 +34,7 @@ class MyApp: public QApplication
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void raise( );
|
void raise( );
|
||||||
bool notify( const QString& title, const QString& body, int timeout_msec=-1 ) const;
|
bool notify( const QString& title, const QString& body ) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Favicons favicons;
|
Favicons favicons;
|
||||||
|
@ -49,7 +49,6 @@ class MyApp: public QApplication
|
||||||
QTimer myStatsTimer;
|
QTimer myStatsTimer;
|
||||||
QTimer mySessionTimer;
|
QTimer mySessionTimer;
|
||||||
time_t myLastFullUpdateTime;
|
time_t myLastFullUpdateTime;
|
||||||
QSet<int> myAddedTorrents;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void consentGiven( );
|
void consentGiven( );
|
||||||
|
@ -57,6 +56,7 @@ class MyApp: public QApplication
|
||||||
void refreshPref( int key );
|
void refreshPref( int key );
|
||||||
void refreshTorrents( );
|
void refreshTorrents( );
|
||||||
void torrentsAdded( QSet<int> );
|
void torrentsAdded( QSet<int> );
|
||||||
|
void torrentChanged( int );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTorrent( const QString& );
|
void addTorrent( const QString& );
|
||||||
|
|
Loading…
Reference in a new issue