Commit ecd1d62e authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

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

Close #5041
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 366d3dad
...@@ -593,9 +593,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -593,9 +593,10 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
CONFIG_BOOL( "qt-fs-controller", fsController ); CONFIG_BOOL( "qt-fs-controller", fsController );
CONFIG_BOOL( "qt-system-tray", systrayBox ); CONFIG_BOOL( "qt-system-tray", systrayBox );
CONFIG_BOOL( "qt-notification", sysPop ); CONFIG_GENERIC( "qt-notification", IntegerList, ui.notificationComboLabel,
CONNECT( ui.systrayBox, toggled( bool ), ui.sysPop, setEnabled( bool ) ); notificationCombo );
ui.sysPop->setEnabled( ui.systrayBox->isChecked() ); CONNECT( ui.systrayBox, toggled( bool ), ui.notificationCombo, setEnabled( bool ) );
ui.notificationCombo->setEnabled( ui.systrayBox->isChecked() );
CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox ); CONFIG_BOOL( "qt-pause-minimized", pauseMinimizedBox );
CONFIG_BOOL( "playlist-tree", treePlaylist ); CONFIG_BOOL( "playlist-tree", treePlaylist );
......
...@@ -121,7 +121,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -121,7 +121,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" ); b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" );
/* Do we want anoying popups or not */ /* 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" ); b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
...@@ -353,7 +353,7 @@ void MainInterface::recreateToolbars() ...@@ -353,7 +353,7 @@ void MainInterface::recreateToolbars()
void MainInterface::reloadPrefs() 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" ); b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
#ifdef WIN32 #ifdef WIN32
p_intf->p_sys->disable_volume_keys = var_InheritBool( p_intf, "qt-disable-volume-keys" ); 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 ) ...@@ -1137,7 +1137,8 @@ void MainInterface::updateSystrayTooltipName( const QString& name )
else else
{ {
sysTray->setToolTip( name ); 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, sysTray->showMessage( qtr( "VLC media player" ), name,
QSystemTrayIcon::NoIcon, 3000 ); QSystemTrayIcon::NoIcon, 3000 );
......
...@@ -152,7 +152,7 @@ private: ...@@ -152,7 +152,7 @@ private:
QMap<QWidget *, QSize> stackWidgetsSizes; QMap<QWidget *, QSize> stackWidgetsSizes;
/* Flags */ /* Flags */
bool b_notificationEnabled; /// Systray Notifications unsigned i_notificationSetting; /// Systray Notifications
bool b_autoresize; ///< persistent resizable window bool b_autoresize; ///< persistent resizable window
bool b_videoEmbedded; ///< Want an external Video Window bool b_videoEmbedded; ///< Want an external Video Window
bool b_videoFullScreen; ///< --fullscreen bool b_videoFullScreen; ///< --fullscreen
......
...@@ -204,8 +204,18 @@ vlc_module_begin () ...@@ -204,8 +204,18 @@ vlc_module_begin ()
true, true,
#endif #endif
SYSTRAY_TEXT, SYSTRAY_LONGTEXT, false) SYSTRAY_TEXT, SYSTRAY_LONGTEXT, false)
add_bool( "qt-notification", true, NOTIFICATION_TEXT,
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 ) NOTIFICATION_LONGTEXT, false )
change_integer_list( i_notification_list, psz_notification_list_text )
add_bool( "qt-start-minimized", false, MINIMIZED_TEXT, add_bool( "qt-start-minimized", false, MINIMIZED_TEXT,
MINIMIZED_LONGTEXT, true) MINIMIZED_LONGTEXT, true)
add_bool( "qt-pause-minimized", false, QT_PAUSE_MINIMIZED_TEXT, add_bool( "qt-pause-minimized", false, QT_PAUSE_MINIMIZED_TEXT,
......
...@@ -49,6 +49,12 @@ enum { ...@@ -49,6 +49,12 @@ enum {
MsgEventType = 300, MsgEventType = 300,
}; };
enum{
NOTIFICATION_NEVER = 0,
NOTIFICATION_MINIMIZED = 1,
NOTIFICATION_ALWAYS = 2,
};
class QVLCApp; class QVLCApp;
class QMenu; class QMenu;
class MainInterface; class MainInterface;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>734</width> <width>734</width>
<height>623</height> <height>687</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
<string>Instances</string> <string>Instances</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>0</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
...@@ -45,9 +48,6 @@ ...@@ -45,9 +48,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="OneInterfaceMode"> <widget class="QCheckBox" name="OneInterfaceMode">
<property name="text"> <property name="text">
...@@ -473,13 +473,6 @@ ...@@ -473,13 +473,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="3" column="0" rowspan="2">
<widget class="QCheckBox" name="systrayBox"> <widget class="QCheckBox" name="systrayBox">
<property name="text"> <property name="text">
...@@ -487,14 +480,7 @@ ...@@ -487,14 +480,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2" rowspan="2" colspan="2"> <item row="6" column="0">
<widget class="QCheckBox" name="sysPop">
<property name="text">
<string>Systray popup when minimized</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="stylesLabel"> <widget class="QLabel" name="stylesLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
...@@ -510,7 +496,7 @@ ...@@ -510,7 +496,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2" colspan="2"> <item row="6" column="2" colspan="2">
<widget class="QComboBox" name="stylesCombo"/> <widget class="QComboBox" name="stylesCombo"/>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
...@@ -539,6 +525,23 @@ ...@@ -539,6 +525,23 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</widget> </widget>
</item> </item>
...@@ -688,7 +691,6 @@ ...@@ -688,7 +691,6 @@
<tabstop>embedVideo</tabstop> <tabstop>embedVideo</tabstop>
<tabstop>resizingBox</tabstop> <tabstop>resizingBox</tabstop>
<tabstop>systrayBox</tabstop> <tabstop>systrayBox</tabstop>
<tabstop>sysPop</tabstop>
<tabstop>stylesCombo</tabstop> <tabstop>stylesCombo</tabstop>
<tabstop>OneInterfaceMode</tabstop> <tabstop>OneInterfaceMode</tabstop>
<tabstop>EnqueueOneInterfaceMode</tabstop> <tabstop>EnqueueOneInterfaceMode</tabstop>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment