From b42a7ebdc3f72fc98802e534f087516d670d1932 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 20 Jan 2013 23:57:09 +0000 Subject: [PATCH] (qt) Qt client should have the option to play a sound when the download completes, as the Mac and GTK+ clients do -- implemented. --- libtransmission/quark.c | 1 - libtransmission/quark.h | 1 - qt/app.cc | 15 ++++++++++----- qt/prefs-dialog.cc | 12 +++++++++--- qt/prefs.cc | 12 +++++++++--- qt/prefs.h | 5 ++++- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/libtransmission/quark.c b/libtransmission/quark.c index 4b3f84d38..02837f417 100644 --- a/libtransmission/quark.c +++ b/libtransmission/quark.c @@ -309,7 +309,6 @@ static const struct tr_key_struct my_static[] = { "session-count", 13 }, { "sessionCount", 12 }, { "show-backup-trackers", 20 }, - { "show-desktop-notification", 25 }, { "show-extra-peer-details", 23 }, { "show-filterbar", 14 }, { "show-notification-area-icon", 27 }, diff --git a/libtransmission/quark.h b/libtransmission/quark.h index 5d88083fa..2ed078610 100644 --- a/libtransmission/quark.h +++ b/libtransmission/quark.h @@ -319,7 +319,6 @@ enum TR_KEY_session_count, TR_KEY_sessionCount, TR_KEY_show_backup_trackers, - TR_KEY_show_desktop_notification, TR_KEY_show_extra_peer_details, TR_KEY_show_filterbar, TR_KEY_show_notification_area_icon, diff --git a/qt/app.cc b/qt/app.cc index 3ecb2cefe..b8dd62d16 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -259,7 +260,7 @@ MyApp :: MyApp( int& argc, char ** argv ): void MyApp :: onTorrentsAdded( QSet torrents ) { - if( !myPrefs->getBool( Prefs::SHOW_DESKTOP_NOTIFICATION ) ) + if( !myPrefs->getBool( Prefs::SHOW_NOTIFICATION_ON_ADD ) ) return; foreach( int id, torrents ) @@ -279,13 +280,17 @@ MyApp :: onTorrentsAdded( QSet torrents ) void MyApp :: onTorrentCompleted( int id ) { - Torrent * tor = myModel->getTorrentFromId( id ); + Torrent * tor = myModel->getTorrentFromId (id); - if( tor && !tor->name().isEmpty() ) + if (tor) { - notify( tr( "Torrent Completed" ), tor->name( ) ); + if (myPrefs->getBool (Prefs::SHOW_NOTIFICATION_ON_COMPLETE)) + notify (tr("Torrent Completed"), tor->name()); + + if (myPrefs->getBool (Prefs::COMPLETE_SOUND_ENABLED)) + QProcess::execute (myPrefs->getString(Prefs::COMPLETE_SOUND_COMMAND)); - disconnect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) ); + disconnect( tor, SIGNAL(torrentCompleted(int)), this, SLOT(onTorrentCompleted(int)) ); } } diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index 122eb378f..e60d7c540 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -299,9 +299,15 @@ PrefsDialog :: createDesktopTab( ) HIG * hig = new HIG( this ); hig->addSectionTitle( tr( "Desktop" ) ); - hig->addWideControl( checkBoxNew( tr( "Show Transmission icon in the ¬ification area" ), Prefs::SHOW_TRAY_ICON ) ); - hig->addWideControl( checkBoxNew( tr( "Start &minimized in notification area" ), Prefs::START_MINIMIZED ) ); - hig->addWideControl( checkBoxNew( tr( "Show &popup notifications" ), Prefs::SHOW_DESKTOP_NOTIFICATION ) ); + hig->addWideControl( checkBoxNew( tr( "Show Transmission icon in the ¬ification area" ), Prefs::SHOW_TRAY_ICON ) ); + hig->addWideControl( checkBoxNew( tr( "Start &minimized in notification area" ), Prefs::START_MINIMIZED ) ); + + hig->addSectionDivider( ); + hig->addSectionTitle( tr ("Notification") ); + + hig->addWideControl( checkBoxNew( tr( "Show a notification when torrents are a&dded" ), Prefs::SHOW_NOTIFICATION_ON_ADD ) ); + hig->addWideControl( checkBoxNew( tr( "Show a notification when torrents &finish" ), Prefs::SHOW_NOTIFICATION_ON_COMPLETE ) ); + hig->addWideControl( checkBoxNew( tr( "Play a &sound when torrents finish" ), Prefs::COMPLETE_SOUND_ENABLED ) ); hig->finish( ); return hig; diff --git a/qt/prefs.cc b/qt/prefs.cc index e3a030a06..25f0583f3 100644 --- a/qt/prefs.cc +++ b/qt/prefs.cc @@ -38,7 +38,8 @@ Prefs::PrefItem Prefs::myItems[] = { DIR_WATCH_ENABLED, TR_KEY_watch_dir_enabled, QVariant::Bool }, { SHOW_TRAY_ICON, TR_KEY_show_notification_area_icon, QVariant::Bool }, { START_MINIMIZED, TR_KEY_start_minimized, QVariant::Bool }, - { SHOW_DESKTOP_NOTIFICATION, TR_KEY_show_desktop_notification, QVariant::Bool }, + { SHOW_NOTIFICATION_ON_ADD, TR_KEY_torrent_added_notification_enabled, QVariant::Bool }, + { SHOW_NOTIFICATION_ON_COMPLETE, TR_KEY_torrent_complete_notification_enabled, QVariant::Bool }, { ASKQUIT, TR_KEY_prompt_before_exit, QVariant::Bool }, { SORT_MODE, TR_KEY_sort_mode, TrTypes::SortModeType }, { SORT_REVERSED, TR_KEY_sort_reversed, QVariant::Bool }, @@ -65,6 +66,8 @@ Prefs::PrefItem Prefs::myItems[] = { SESSION_REMOTE_AUTH, TR_KEY_remote_session_requres_authentication, QVariant::Bool }, { SESSION_REMOTE_USERNAME, TR_KEY_remote_session_username, QVariant::String }, { SESSION_REMOTE_PASSWORD, TR_KEY_remote_session_password, QVariant::String }, + { COMPLETE_SOUND_COMMAND, TR_KEY_torrent_complete_sound_command, QVariant::String }, + { COMPLETE_SOUND_ENABLED, TR_KEY_torrent_complete_sound_enabled, QVariant::Bool }, { USER_HAS_GIVEN_INFORMED_CONSENT, TR_KEY_user_has_given_informed_consent, QVariant::Bool }, /* libtransmission settings */ @@ -275,7 +278,7 @@ Prefs :: ~Prefs () void Prefs :: initDefaults (tr_variant * d) { - tr_variantDictReserve (d, 35); + tr_variantDictReserve (d, 38); tr_variantDictAddBool (d, TR_KEY_blocklist_updates_enabled, true); tr_variantDictAddBool (d, TR_KEY_compact_view, false); tr_variantDictAddBool (d, TR_KEY_inhibit_desktop_hibernation, false); @@ -283,7 +286,6 @@ Prefs :: initDefaults (tr_variant * d) tr_variantDictAddBool (d, TR_KEY_remote_session_enabled, false); tr_variantDictAddBool (d, TR_KEY_remote_session_requres_authentication, false); tr_variantDictAddBool (d, TR_KEY_show_backup_trackers, false); - tr_variantDictAddBool (d, TR_KEY_show_desktop_notification, true); tr_variantDictAddBool (d, TR_KEY_show_extra_peer_details, false), tr_variantDictAddBool (d, TR_KEY_show_filterbar, true); tr_variantDictAddBool (d, TR_KEY_show_notification_area_icon, false); @@ -293,6 +295,10 @@ Prefs :: initDefaults (tr_variant * d) tr_variantDictAddBool (d, TR_KEY_show_toolbar, true); tr_variantDictAddBool (d, TR_KEY_show_tracker_scrapes, false); tr_variantDictAddBool (d, TR_KEY_sort_reversed, false); + tr_variantDictAddBool (d, TR_KEY_torrent_added_notification_enabled, true); + tr_variantDictAddBool (d, TR_KEY_torrent_complete_notification_enabled, true); + tr_variantDictAddStr (d, TR_KEY_torrent_complete_sound_command, "canberra-gtk-play -i complete-download -d 'transmission torrent downloaded'"); + tr_variantDictAddBool (d, TR_KEY_torrent_complete_sound_enabled, true); tr_variantDictAddBool (d, TR_KEY_user_has_given_informed_consent, false); tr_variantDictAddBool (d, TR_KEY_watch_dir_enabled, false); tr_variantDictAddInt (d, TR_KEY_blocklist_date, 0); diff --git a/qt/prefs.h b/qt/prefs.h index 74df631a1..663301e2b 100644 --- a/qt/prefs.h +++ b/qt/prefs.h @@ -44,7 +44,8 @@ class Prefs: public QObject DIR_WATCH_ENABLED, SHOW_TRAY_ICON, START_MINIMIZED, - SHOW_DESKTOP_NOTIFICATION, + SHOW_NOTIFICATION_ON_ADD, + SHOW_NOTIFICATION_ON_COMPLETE, ASKQUIT, SORT_MODE, SORT_REVERSED, @@ -71,6 +72,8 @@ class Prefs: public QObject SESSION_REMOTE_AUTH, SESSION_REMOTE_USERNAME, SESSION_REMOTE_PASSWORD, + COMPLETE_SOUND_COMMAND, + COMPLETE_SOUND_ENABLED, USER_HAS_GIVEN_INFORMED_CONSENT, /* core prefs */ -- 2.40.0