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,
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 );
......
......@@ -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 );
......
......@@ -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
......
......@@ -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,
......
......@@ -49,6 +49,12 @@ enum {
MsgEventType = 300,
};
enum{
NOTIFICATION_NEVER = 0,
NOTIFICATION_MINIMIZED = 1,
NOTIFICATION_ALWAYS = 2,
};
class QVLCApp;
class QMenu;
class MainInterface;
......
......@@ -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>
......
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