]> granicus.if.org Git - transmission/commitdiff
(qt) Qt client should have the option to play a sound when the download completes...
authorJordan Lee <jordan@transmissionbt.com>
Sun, 20 Jan 2013 23:57:09 +0000 (23:57 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sun, 20 Jan 2013 23:57:09 +0000 (23:57 +0000)
libtransmission/quark.c
libtransmission/quark.h
qt/app.cc
qt/prefs-dialog.cc
qt/prefs.cc
qt/prefs.h

index 4b3f84d3896884f212f28ad89bb170fe0b30c927..02837f4172044db053bcb69733057be9aae0698f 100644 (file)
@@ -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 },
index 5d88083faa3d8f2a70ea85aa69f1a46d3dc74e93..2ed0786100fb1b24ee83b545fcad8420230c41dc 100644 (file)
@@ -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,
index 3ecb2cefe0832a14401e8a4a3a9751b2e470bad5..b8dd62d16ab5bb0e29471e0b3f17ccccd6bdcba2 100644 (file)
--- a/qt/app.cc
+++ b/qt/app.cc
@@ -22,6 +22,7 @@
 #include <QIcon>
 #include <QLabel>
 #include <QLibraryInfo>
+#include <QProcess>
 #include <QRect>
 
 #include <libtransmission/transmission.h>
@@ -259,7 +260,7 @@ MyApp :: MyApp( int& argc, char ** argv ):
 void
 MyApp :: onTorrentsAdded( QSet<int> 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<int> 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)) );
     }
 }
 
index 122eb378f9ed98c86d0e6dd67460ce8600f69aff..e60d7c54030d51130a52818a25f8acb54081d07d 100644 (file)
@@ -299,9 +299,15 @@ PrefsDialog :: createDesktopTab( )
     HIG * hig = new HIG( this );
     hig->addSectionTitle( tr( "Desktop" ) );
 
-    hig->addWideControl( checkBoxNew( tr( "Show Transmission icon in the &notification 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 &notification 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;
index e3a030a063ac47a2025329eba589798ebe28b736..25f0583f30bb1c71d754a1ee1a05cc05d4648806 100644 (file)
@@ -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);
index 74df631a1c75ba049e5f9d796f27db9c21962318..663301e2b7660b7253113d99382a3b244be32946 100644 (file)
@@ -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 */