[vlc-devel] [PATCH 1/2] qt: add tray icon action customization
Niels Martignène
niels.martignene at gmail.com
Sun Jul 6 14:47:00 CEST 2014
Support the ability to customize mouse actions on tray icon, so that the left and middle clicks can be changed to do different things:
- Ignore
- Toggle main interface (default for left click)
- Play/Pause (default for middle click)
- Mute/Unmute
---
modules/gui/qt4/main_interface.cpp | 23 +++++++++++++++++++----
modules/gui/qt4/qt4.cpp | 29 +++++++++++++++++++++++++++++
modules/gui/qt4/qt4.hpp | 7 +++++++
3 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 43e5dcc..971c024 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -1161,20 +1161,35 @@ void MainInterface::hideUpdateSystrayMenu()
void MainInterface::handleSystrayClick(
QSystemTrayIcon::ActivationReason reason )
{
+ int action = SYSTRAY_CLICK_IGNORE;
+
switch( reason )
{
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::DoubleClick:
+ action = var_InheritInteger( p_intf, "qt-system-tray-click-left" );
+ break;
+ case QSystemTrayIcon::MiddleClick:
+ action = var_InheritInteger( p_intf, "qt-system-tray-click-middle" );
+ break;
+ default:
+ break;
+ }
+
+ switch( action )
+ {
+ case SYSTRAY_CLICK_TOGGLE_UI:
#ifdef Q_OS_MAC
VLCMenuBar::updateSystrayMenu( this, p_intf );
#else
toggleUpdateSystrayMenu();
#endif
break;
- case QSystemTrayIcon::MiddleClick:
- sysTray->showMessage( qtr( "VLC media player" ),
- qtr( "Control menu for the player" ),
- QSystemTrayIcon::Information, 3000 );
+ case SYSTRAY_CLICK_PLAY_PAUSE:
+ THEAM->play();
+ break;
+ case SYSTRAY_CLICK_TOGGLE_MUTE:
+ THEAM->toggleMuteAudio();
break;
default:
break;
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index a156366..ec60760 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -85,6 +85,16 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
"allowing you to control VLC media player " \
"for basic actions." )
+#define SYSTRAY_ACTIONS_TEXT N_("Systray actions")
+
+#define SYSTRAY_LEFT_CLICK_TEXT N_( "Left click" )
+#define SYSTRAY_LEFT_CLICK_LONGTEXT N_( "Action to execute for a left click on " \
+ " the system tray icon")
+
+#define SYSTRAY_MIDDLE_CLICK_TEXT N_( "Middle click" )
+#define SYSTRAY_MIDDLE_CLICK_LONGTEXT N_( "Action to execute for a middle click on " \
+ " the system tray icon")
+
#define MINIMIZED_TEXT N_( "Start VLC with only a systray icon" )
#define MINIMIZED_LONGTEXT N_( "VLC will start with just an icon in " \
"your taskbar" )
@@ -185,6 +195,14 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define FULLSCREEN_CONTROL_PIXELS N_( "Fullscreen controller mouse sensitivity" )
+static const int i_systray_click_list[] =
+ { SYSTRAY_CLICK_IGNORE, SYSTRAY_CLICK_TOGGLE_UI, SYSTRAY_CLICK_PLAY_PAUSE,
+ SYSTRAY_CLICK_TOGGLE_MUTE };
+
+static const char *const psz_systray_click_list_text[] =
+ { N_("Ignore"), N_("Toggle main interface"), N_("Play/pause"),
+ N_("Mute/unmute") };
+
static const int i_notification_list[] =
{ NOTIFICATION_NEVER, NOTIFICATION_MINIMIZED, NOTIFICATION_ALWAYS };
@@ -290,6 +308,17 @@ vlc_module_begin ()
add_obsolete_bool( "qt-volume-complete" ) /* Since 2.0.0 */
add_obsolete_integer( "qt-startvolume" ) /* Since 2.0.0 */
+ set_section( SYSTRAY_ACTIONS_TEXT, 0 )
+ add_integer( "qt-system-tray-click-left", SYSTRAY_CLICK_TOGGLE_UI,
+ SYSTRAY_LEFT_CLICK_TEXT,
+ SYSTRAY_LEFT_CLICK_LONGTEXT, false )
+ change_integer_list( i_systray_click_list, psz_systray_click_list_text )
+
+ add_integer( "qt-system-tray-click-middle", SYSTRAY_CLICK_PLAY_PAUSE,
+ SYSTRAY_MIDDLE_CLICK_TEXT,
+ SYSTRAY_MIDDLE_CLICK_LONGTEXT, false )
+ change_integer_list( i_systray_click_list, psz_systray_click_list_text )
+
cannot_unload_broken_library()
add_submodule ()
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 44d7db6..3fa5125 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -50,6 +50,13 @@ enum {
MsgEventTypeOffset = 300,
};
+enum {
+ SYSTRAY_CLICK_IGNORE = 0,
+ SYSTRAY_CLICK_TOGGLE_UI = 1,
+ SYSTRAY_CLICK_PLAY_PAUSE = 2,
+ SYSTRAY_CLICK_TOGGLE_MUTE = 3
+};
+
enum{
NOTIFICATION_NEVER = 0,
NOTIFICATION_MINIMIZED = 1,
--
2.0.1
More information about the vlc-devel
mailing list