[vlc-commits] Qt: Add an option to show system tray notifications when VLC is visible

Edward Wang git at videolan.org
Wed Feb 1 22:31:26 CET 2012


vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Feb  1 22:30:20 2012 +0100| [ecd1d62e8604359422780f53279ff08336fc5ed6] | committer: Jean-Baptiste Kempf

Qt: Add an option to show system tray notifications when VLC is visible

Close #5041

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ecd1d62e8604359422780f53279ff08336fc5ed6
---

 modules/gui/qt4/components/simple_preferences.cpp |    7 ++-
 modules/gui/qt4/main_interface.cpp                |    7 ++-
 modules/gui/qt4/main_interface.hpp                |    2 +-
 modules/gui/qt4/qt4.cpp                           |   14 ++++++-
 modules/gui/qt4/qt4.hpp                           |    6 +++
 modules/gui/qt4/ui/sprefs_interface.ui            |   44 +++++++++++----------
 6 files changed, 50 insertions(+), 30 deletions(-)

diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp
index e806d74..a7576d0 100644
--- a/modules/gui/qt4/components/simple_preferences.cpp
+++ b/modules/gui/qt4/components/simple_preferences.cpp
@@ -593,9 +593,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
 
             CONFIG_BOOL( "qt-fs-controller", fsController );
             CONFIG_BOOL( "qt-system-tray", systrayBox );
-            CONFIG_BOOL( "qt-notification", sysPop );
-            CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) );
-            ui.sysPop->setEnabled( ui.systrayBox->isChecked() );
+            CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
+                                                      notificationCombo );
+            CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
+            ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
 
             CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
             CONFIG_BOOL( "playlist-tree", treePlaylist );
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 3a44003..98011a6 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -121,7 +121,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" );
 
     /* Do we want anoying popups or not */
-    b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" );
+    i_notificationSetting = var_InheritInteger( p_intf, "qt-notification" );
 
     /* */
     b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
@@ -353,7 +353,7 @@ void MainInterface::recreateToolbars()
 
 void MainInterface::reloadPrefs()
 {
-    b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" );
+    i_notificationSetting = var_InheritInteger( p_intf, "qt-notification" );
     b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
 #ifdef WIN32
     p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" );
@@ -1137,7 +1137,8 @@ void MainInterface::updateSystrayTooltipName( const QString& name )
     else
     {
         sysTray->setToolTip( name );
-        if( b_notificationEnabled && ( isHidden() || isMinimized() ) )
+        if( ( i_notificationSetting == NOTIFICATION_ALWAYS ) ||
+            ( i_notificationSetting == NOTIFICATION_MINIMIZED && (isMinimized() || isHidden()) ) )
         {
             sysTray->showMessage( qtr( "VLC media player" ), name,
                     QSystemTrayIcon::NoIcon, 3000 );
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 1231d25..3567c4a 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -152,7 +152,7 @@ private:
     QMap<QWidget *, QSize> stackWidgetsSizes;
 
     /* Flags */
-    bool                 b_notificationEnabled; /// Systray Notifications
+    unsigned             i_notificationSetting; /// Systray Notifications
     bool                 b_autoresize;          ///< persistent resizable window
     bool                 b_videoEmbedded;       ///< Want an external Video Window
     bool                 b_videoFullScreen;     ///< --fullscreen
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index bbf4ae5..a2c6cc3 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -204,8 +204,18 @@ vlc_module_begin ()
             true,
 #endif
             SYSTRAY_TEXT, SYSTRAY_LONGTEXT, false)
-    add_bool( "qt-notification", true, NOTIFICATION_TEXT,
-              NOTIFICATION_LONGTEXT, false )
+
+    static const int i_notification_list[] =
+        { NOTIFICATION_NEVER, NOTIFICATION_MINIMIZED, NOTIFICATION_ALWAYS };
+
+    static const char *const psz_notification_list_text[] =
+        { N_("Never"), N_("When minimized"), N_("Always") };
+
+    add_integer( "qt-notification", NOTIFICATION_MINIMIZED,
+                 NOTIFICATION_TEXT,
+                 NOTIFICATION_LONGTEXT, false )
+            change_integer_list( i_notification_list, psz_notification_list_text )
+
     add_bool( "qt-start-minimized", false, MINIMIZED_TEXT,
               MINIMIZED_LONGTEXT, true)
     add_bool( "qt-pause-minimized", false, QT_PAUSE_MINIMIZED_TEXT,
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 3e904e8..a1cd027 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -49,6 +49,12 @@ enum {
     MsgEventType    = 300,
 };
 
+enum{
+    NOTIFICATION_NEVER = 0,
+    NOTIFICATION_MINIMIZED = 1,
+    NOTIFICATION_ALWAYS = 2,
+};
+
 class QVLCApp;
 class QMenu;
 class MainInterface;
diff --git a/modules/gui/qt4/ui/sprefs_interface.ui b/modules/gui/qt4/ui/sprefs_interface.ui
index dacf55a..ef24e36 100644
--- a/modules/gui/qt4/ui/sprefs_interface.ui
+++ b/modules/gui/qt4/ui/sprefs_interface.ui
@@ -8,7 +8,7 @@
     <x>0</x>
     <y>0</y>
     <width>734</width>
-    <height>623</height>
+    <height>687</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -36,6 +36,9 @@
       <string>Instances</string>
      </property>
      <layout class="QGridLayout" name="gridLayout_2">
+      <property name="verticalSpacing">
+       <number>0</number>
+      </property>
       <property name="leftMargin">
        <number>9</number>
       </property>
@@ -45,9 +48,6 @@
       <property name="bottomMargin">
        <number>9</number>
       </property>
-      <property name="verticalSpacing">
-       <number>0</number>
-      </property>
       <item row="0" column="0">
        <widget class="QCheckBox" name="OneInterfaceMode">
         <property name="text">
@@ -473,13 +473,6 @@
                </property>
               </widget>
              </item>
-             <item row="2" column="2" colspan="2">
-              <widget class="QCheckBox" name="resizingBox">
-               <property name="text">
-                <string>Resize interface to video size</string>
-               </property>
-              </widget>
-             </item>
              <item row="3" column="0" rowspan="2">
               <widget class="QCheckBox" name="systrayBox">
                <property name="text">
@@ -487,14 +480,7 @@
                </property>
               </widget>
              </item>
-             <item row="3" column="2" rowspan="2" colspan="2">
-              <widget class="QCheckBox" name="sysPop">
-               <property name="text">
-                <string>Systray popup when minimized</string>
-               </property>
-              </widget>
-             </item>
-             <item row="5" column="0">
+             <item row="6" column="0">
               <widget class="QLabel" name="stylesLabel">
                <property name="sizePolicy">
                 <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@@ -510,7 +496,7 @@
                </property>
               </widget>
              </item>
-             <item row="5" column="2" colspan="2">
+             <item row="6" column="2" colspan="2">
               <widget class="QComboBox" name="stylesCombo"/>
              </item>
              <item row="1" column="1">
@@ -539,6 +525,23 @@
                </property>
               </spacer>
              </item>
+             <item row="2" column="2" colspan="2">
+              <widget class="QCheckBox" name="resizingBox">
+               <property name="text">
+                <string>Resize interface to video size</string>
+               </property>
+              </widget>
+             </item>
+             <item row="5" column="0" colspan="2">
+              <widget class="QLabel" name="notificationComboLabel">
+               <property name="text">
+                <string>Show media change popup when</string>
+               </property>
+              </widget>
+             </item>
+             <item row="5" column="2" colspan="2">
+              <widget class="QComboBox" name="notificationCombo"/>
+             </item>
             </layout>
            </widget>
           </item>
@@ -688,7 +691,6 @@
   <tabstop>embedVideo</tabstop>
   <tabstop>resizingBox</tabstop>
   <tabstop>systrayBox</tabstop>
-  <tabstop>sysPop</tabstop>
   <tabstop>stylesCombo</tabstop>
   <tabstop>OneInterfaceMode</tabstop>
   <tabstop>EnqueueOneInterfaceMode</tabstop>



More information about the vlc-commits mailing list