Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
2b60288a
Commit
2b60288a
authored
May 02, 2007
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt4 - Systray Icon and menu to control VLC. Play/Pause Stop Previous Next Quit for now. Ref #294
parent
fda713ec
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
45 deletions
+112
-45
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.cpp
+26
-6
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/main_interface.hpp
+11
-0
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.cpp
+60
-36
modules/gui/qt4/menus.hpp
modules/gui/qt4/menus.hpp
+8
-3
modules/gui/qt4/qt4.cpp
modules/gui/qt4/qt4.cpp
+6
-0
modules/gui/qt4/res.qrc
modules/gui/qt4/res.qrc
+1
-0
No files found.
modules/gui/qt4/main_interface.cpp
View file @
2b60288a
...
...
@@ -38,6 +38,7 @@
#include <QStatusBar>
#include <QKeyEvent>
#include <QUrl>
#include <QSystemTrayIcon>
#include <assert.h>
#include <vlc_keys.h>
...
...
@@ -130,7 +131,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
this
,
setDisplay
(
float
,
int
,
int
)
);
CONNECT
(
THEMIM
->
getIM
(),
nameChanged
(
QString
),
this
,
setName
(
QString
)
);
CONNECT
(
THEMIM
->
getIM
(),
statusChanged
(
int
),
this
,
setStatus
(
int
)
);
CONNECT
(
THEMIM
->
getIM
(),
navigationChanged
(
int
),
this
,
setNavigation
(
int
)
);
CONNECT
(
THEMIM
->
getIM
(),
statusChanged
(
int
),
this
,
updateSystrayMenu
(
int
)
);
CONNECT
(
THEMIM
->
getIM
(),
navigationChanged
(
int
),
this
,
setNavigation
(
int
)
);
CONNECT
(
slider
,
sliderDragged
(
float
),
THEMIM
->
getIM
(),
sliderUpdate
(
float
)
);
...
...
@@ -146,21 +150,24 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
p_intf
->
b_interaction
=
VLC_TRUE
;
/* Register callback for the intf-popupmenu variable */
playlist_t
*
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_intf
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
playlist_t
*
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_intf
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
p_playlist
!=
NULL
)
{
var_AddCallback
(
p_playlist
,
"intf-popupmenu"
,
PopupMenuCB
,
p_intf
);
var_AddCallback
(
p_playlist
,
"intf-show"
,
IntfShowCB
,
p_intf
);
vlc_object_release
(
p_playlist
);
}
if
(
QSystemTrayIcon
::
isSystemTrayAvailable
()
&&
(
config_GetInt
(
p_intf
,
"qt-system-tray"
)
==
1
))
createSystrayMenu
();
}
MainInterface
::~
MainInterface
()
{
/* Unregister callback for the intf-popupmenu variable */
playlist_t
*
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_intf
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
playlist_t
*
p_playlist
=
(
playlist_t
*
)
vlc_object_find
(
p_intf
,
VLC_OBJECT_PLAYLIST
,
FIND_ANYWHERE
);
if
(
p_playlist
!=
NULL
)
{
var_DelCallback
(
p_playlist
,
"intf-popupmenu"
,
PopupMenuCB
,
p_intf
);
...
...
@@ -264,6 +271,19 @@ void MainInterface::handleMainUi( QSettings *settings )
setMinimumSize
(
PREF_W
,
addSize
.
height
()
);
}
void
MainInterface
::
createSystrayMenu
()
{
sysTray
=
new
QSystemTrayIcon
(
QIcon
(
QPixmap
(
":/vlc128.png"
)
)
);
systrayMenu
=
new
QMenu
(
qtr
(
"VLC media player"
),
this
);
QVLCMenu
::
updateSystrayMenu
(
this
,
p_intf
);
sysTray
->
show
();
}
void
MainInterface
::
updateSystrayMenu
(
int
status
)
{
QVLCMenu
::
updateSystrayMenu
(
this
,
p_intf
)
;
}
/**********************************************************************
* Handling of the components
**********************************************************************/
...
...
modules/gui/qt4/main_interface.hpp
View file @
2b60288a
...
...
@@ -30,6 +30,8 @@
#include "util/qvlcframe.hpp"
#include <QSize>
#include <QSystemTrayIcon>
#include <QMenu>
class
QSettings
;
class
QCloseEvent
;
...
...
@@ -44,6 +46,7 @@ class PlaylistWidget;
class
VolumeClickHandler
;
class
VisualSelector
;
class
ControlsWidget
;
class
QMenu
;
class
MainInterface
:
public
QVLCMW
{
...
...
@@ -57,6 +60,9 @@ public:
void
releaseVideo
(
void
*
);
int
controlVideo
(
void
*
p_window
,
int
i_query
,
va_list
args
);
void
setVLCWindowsTitle
(
QString
title
=
""
);
QSystemTrayIcon
*
getSysTray
()
{
return
sysTray
;
};
QMenu
*
getSysTrayMenu
()
{
return
systrayMenu
;
};
protected:
void
resizeEvent
(
QResizeEvent
*
);
void
dropEvent
(
QDropEvent
*
);
...
...
@@ -69,11 +75,15 @@ protected:
private:
QSettings
*
settings
;
QSize
mainSize
,
addSize
;
QSystemTrayIcon
*
sysTray
;
QMenu
*
systrayMenu
;
bool
need_components_update
;
void
calculateInterfaceSize
();
void
handleMainUi
(
QSettings
*
);
void
handleSystray
();
void
doComponentsUpdate
();
void
createSystrayMenu
();
/* Video */
VideoWidget
*
videoWidget
;
...
...
@@ -120,6 +130,7 @@ private slots:
void
visual
();
void
advanced
();
void
updateVolume
(
int
sliderVolume
);
void
updateSystrayMenu
(
int
);
};
...
...
modules/gui/qt4/menus.cpp
View file @
2b60288a
...
...
@@ -27,6 +27,7 @@
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
#include <QSystemTrayIcon>
#ifndef WIN32
# include <signal.h>
...
...
@@ -49,14 +50,14 @@ enum
static
QActionGroup
*
currentGroup
;
// Add static entries to menus
#define DP_SADD( text, help, icon, slot, shortcut ) \
#define DP_SADD(
menu,
text, help, icon, slot, shortcut ) \
{ \
if( strlen(icon) > 0 ) \
{ \
if( strlen(shortcut) > 0 ) \
{ \
menu->addAction( QIcon(icon), text, THEDP, SLOT( slot ), \
tr(shortcut) );\
q
tr(shortcut) );\
} \
else \
{ \
...
...
@@ -76,7 +77,7 @@ static QActionGroup *currentGroup;
} \
} \
}
#define MIM_SADD( text, help, icon, slot ) \
#define MIM_SADD(
menu,
text, help, icon, slot ) \
{ \
if( strlen(icon) > 0 ) \
{ \
...
...
@@ -196,18 +197,18 @@ void QVLCMenu::createMenuBar( MainInterface *mi, intf_thread_t *p_intf,
QMenu
*
QVLCMenu
::
FileMenu
()
{
QMenu
*
menu
=
new
QMenu
();
DP_SADD
(
qtr
(
"Open &File..."
),
""
,
""
,
openFileDialog
(),
"Ctrl+O"
);
DP_SADD
(
qtr
(
"Open &Disc..."
),
""
,
""
,
openDiscDialog
(),
"Ctrl+D"
);
DP_SADD
(
qtr
(
"Open &Network..."
),
""
,
""
,
openNetDialog
(),
"Ctrl+N"
);
DP_SADD
(
qtr
(
"Open &Capture Device..."
),
""
,
""
,
openCaptureDialog
(),
DP_SADD
(
menu
,
qtr
(
"Open &File..."
),
""
,
""
,
openFileDialog
(),
"Ctrl+O"
);
DP_SADD
(
menu
,
qtr
(
"Open &Disc..."
),
""
,
""
,
openDiscDialog
(),
"Ctrl+D"
);
DP_SADD
(
menu
,
qtr
(
"Open &Network..."
),
""
,
""
,
openNetDialog
(),
"Ctrl+N"
);
DP_SADD
(
menu
,
qtr
(
"Open &Capture Device..."
),
""
,
""
,
openCaptureDialog
(),
"Ctrl+C"
);
menu
->
addSeparator
();
DP_SADD
(
qtr
(
"&Streaming..."
),
""
,
""
,
openThenStreamingDialogs
(),
DP_SADD
(
menu
,
qtr
(
"&Streaming..."
),
""
,
""
,
openThenStreamingDialogs
(),
"Ctrl+S"
);
DP_SADD
(
qtr
(
"Conve&rt / Save..."
),
""
,
""
,
openThenTranscodingDialogs
(),
DP_SADD
(
menu
,
qtr
(
"Conve&rt / Save..."
),
""
,
""
,
openThenTranscodingDialogs
(),
"Ctrl+R"
);
menu
->
addSeparator
();
DP_SADD
(
qtr
(
"&Quit"
)
,
""
,
""
,
quit
(),
"Ctrl+Q"
);
DP_SADD
(
menu
,
qtr
(
"&Quit"
)
,
""
,
""
,
quit
(),
"Ctrl+Q"
);
return
menu
;
}
...
...
@@ -217,8 +218,8 @@ QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
menu
->
addMenu
(
SDMenu
(
p_intf
)
);
menu
->
addSeparator
();
DP_SADD
(
qtr
(
I_PL_LOAD
),
""
,
""
,
openPlaylist
(),
"Ctrl+L"
);
DP_SADD
(
qtr
(
I_PL_SAVE
),
""
,
""
,
savePlaylist
(),
"Ctrl+K"
);
DP_SADD
(
menu
,
qtr
(
I_PL_LOAD
),
""
,
""
,
openPlaylist
(),
"Ctrl+L"
);
DP_SADD
(
menu
,
qtr
(
I_PL_SAVE
),
""
,
""
,
savePlaylist
(),
"Ctrl+K"
);
menu
->
addSeparator
();
menu
->
addAction
(
qtr
(
"Undock from interface"
),
mi
,
SLOT
(
undockPlaylist
()
),
qtr
(
"Ctrl+U"
)
);
...
...
@@ -237,12 +238,12 @@ QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
menu
->
addMenu
(
intfmenu
);
menu
->
addSeparator
();
}
DP_SADD
(
qtr
(
I_MENU_MSG
),
""
,
""
,
messagesDialog
(),
"Ctrl+M"
);
DP_SADD
(
qtr
(
I_MENU_INFO
)
,
""
,
""
,
mediaInfoDialog
(),
"Ctrl+J"
);
DP_SADD
(
qtr
(
I_MENU_CODECINFO
)
,
""
,
""
,
mediaCodecDialog
(),
"Ctrl+I"
);
DP_SADD
(
qtr
(
I_MENU_GOTOTIME
),
""
,
""
,
gotoTimeDialog
(),
"Ctrl+T"
);
DP_SADD
(
qtr
(
I_MENU_BOOKMARK
),
""
,
""
,
bookmarksDialog
(),
"Ctrl+B"
);
DP_SADD
(
qtr
(
I_MENU_VLM
),
""
,
""
,
vlmDialog
(),
"Ctrl+V"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_MSG
),
""
,
""
,
messagesDialog
(),
"Ctrl+M"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_INFO
)
,
""
,
""
,
mediaInfoDialog
(),
"Ctrl+J"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_CODECINFO
)
,
""
,
""
,
mediaCodecDialog
(),
"Ctrl+I"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_GOTOTIME
),
""
,
""
,
gotoTimeDialog
(),
"Ctrl+T"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_BOOKMARK
),
""
,
""
,
bookmarksDialog
(),
"Ctrl+B"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_VLM
),
""
,
""
,
vlmDialog
(),
"Ctrl+V"
);
menu
->
addSeparator
();
if
(
mi
)
...
...
@@ -259,10 +260,10 @@ QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
#endif
menu
->
addAction
(
qtr
(
"Playlist"
),
mi
,
SLOT
(
playlist
()
)
);
}
DP_SADD
(
qtr
(
I_MENU_EXT
),
""
,
""
,
extendedDialog
(),
"Ctrl+E"
);
DP_SADD
(
qtr
(
"Hide Menus..."
),
""
,
""
,
hideMenus
(),
"Ctrl+H"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_EXT
),
""
,
""
,
extendedDialog
(),
"Ctrl+E"
);
DP_SADD
(
menu
,
qtr
(
"Hide Menus..."
),
""
,
""
,
hideMenus
(),
"Ctrl+H"
);
menu
->
addSeparator
();
DP_SADD
(
qtr
(
"Preferences"
),
""
,
""
,
prefsDialog
(),
"Ctrl+P"
);
DP_SADD
(
menu
,
qtr
(
"Preferences"
),
""
,
""
,
prefsDialog
(),
"Ctrl+P"
);
return
menu
;
}
...
...
@@ -398,15 +399,15 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
QMenu
*
QVLCMenu
::
HelpMenu
()
{
QMenu
*
menu
=
new
QMenu
();
DP_SADD
(
qtr
(
"Help"
)
,
""
,
""
,
helpDialog
(),
"F1"
);
DP_SADD
(
menu
,
qtr
(
"Help"
)
,
""
,
""
,
helpDialog
(),
"F1"
);
menu
->
addSeparator
();
DP_SADD
(
qtr
(
I_MENU_ABOUT
),
""
,
""
,
aboutDialog
(),
"Ctrl+F1"
);
DP_SADD
(
menu
,
qtr
(
I_MENU_ABOUT
),
""
,
""
,
aboutDialog
(),
"Ctrl+F1"
);
return
menu
;
}
/*****************************************************************************
* Popup menus
* Popup menus
*
*****************************************************************************/
#define POPUP_BOILERPLATE \
unsigned int i_last_separator = 0; \
...
...
@@ -422,22 +423,26 @@ QMenu *QVLCMenu::HelpMenu()
p_intf->p_sys->p_popup_menu = NULL; \
i_last_separator = 0;
#define POPUP_
STATIC_ENTRIES
\
#define POPUP_
PLAY_ENTRIES( menu )
\
vlc_value_t val; \
if( p_input ) \
{ \
var_Get( p_input, "state", &val ); \
if( val.i_int == PAUSE_S ) \
MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
MIM_SADD(
menu,
qtr("Play"), "", "", togglePlayPause() ) \
else \
MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
MIM_SADD(
menu,
qtr("Pause"), "", "", togglePlayPause() ) \
} \
else if( THEPL->items.i_size && THEPL->i_enabled ) \
MIM_SADD( qtr("Play"), "", "", togglePlayPause() );\
MIM_SADD( menu, qtr("Play"), "", "", togglePlayPause() ); \
\
MIM_SADD( menu, qtr("Stop"), "", "", stop() ); \
MIM_SADD( menu, qtr("Previous"), "", "", prev() ); \
MIM_SADD( menu, qtr("Next"), "", "", next() );
#define POPUP_STATIC_ENTRIES \
POPUP_PLAY_ENTRIES( menu ); \
\
MIM_SADD( qtr("Stop"), "", "", stop() ); \
MIM_SADD( qtr("Previous"), "", "", prev() ); \
MIM_SADD( qtr("Next"), "", "", next() ); \
menu->addSeparator(); \
QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
intfmenu->setTitle( qtr("Interfaces" ) ); \
...
...
@@ -460,7 +465,7 @@ QMenu *QVLCMenu::HelpMenu()
helpmenu->setTitle( qtr("Help") ); \
menu->addMenu( helpmenu ); \
\
DP_SADD( qtr("Quit"), "", "", quit() , "Ctrl+Q" );
DP_SADD(
menu,
qtr("Quit"), "", "", quit() , "Ctrl+Q" );
void
QVLCMenu
::
VideoPopupMenu
(
intf_thread_t
*
p_intf
)
{
...
...
@@ -582,9 +587,29 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
}
}
/************************************************************************
* Systray Menu *
************************************************************************/
void
QVLCMenu
::
updateSystrayMenu
(
MainInterface
*
mi
,
intf_thread_t
*
p_intf
)
{
POPUP_BOILERPLATE
;
QMenu
*
sysMenu
=
mi
->
getSysTrayMenu
();
sysMenu
->
clear
();
POPUP_PLAY_ENTRIES
(
sysMenu
);
sysMenu
->
addSeparator
();
/* FIXME DP_SADD( menu, qtr("&Hide/show") , "", "", quit(), "" );*/
DP_SADD
(
sysMenu
,
qtr
(
"&Quit"
)
,
""
,
""
,
quit
(),
""
);
mi
->
getSysTray
()
->
setContextMenu
(
sysMenu
);
}
#undef PUSH_VAR
#undef PUSH_SEPARATOR
/*************************************************************************
* Builders for automenus
*************************************************************************/
...
...
@@ -899,5 +924,4 @@ void QVLCMenu::DoAction( intf_thread_t *p_intf, QObject *data )
if
(
p_object
==
NULL
)
return
;
var_Set
(
p_object
,
itemData
->
psz_var
,
itemData
->
val
);
vlc_object_release
(
p_object
);
}
vlc_object_release
(
p_object
);}
modules/gui/qt4/menus.hpp
View file @
2b60288a
...
...
@@ -26,6 +26,7 @@
#include "qt4.hpp"
#include <QObject>
#include <vector>
#include <QSystemTrayIcon>
using
namespace
std
;
...
...
@@ -61,7 +62,8 @@ class QVLCMenu : public QObject
{
Q_OBJECT
;
public:
static
void
createMenuBar
(
MainInterface
*
mi
,
intf_thread_t
*
,
bool
,
bool
,
bool
);
static
void
createMenuBar
(
MainInterface
*
mi
,
intf_thread_t
*
,
bool
,
bool
,
bool
);
/* Menus */
static
QMenu
*
FileMenu
();
...
...
@@ -75,12 +77,16 @@ public:
static
QMenu
*
InterfacesMenu
(
intf_thread_t
*
p_intf
,
QMenu
*
);
static
QMenu
*
HelpMenu
();
/* Popups */
/* Popups
Menus
*/
static
void
AudioPopupMenu
(
intf_thread_t
*
);
static
void
VideoPopupMenu
(
intf_thread_t
*
);
static
void
MiscPopupMenu
(
intf_thread_t
*
);
static
void
PopupMenu
(
intf_thread_t
*
,
bool
);
/* Systray */
static
void
updateSystrayMenu
(
MainInterface
*
,
intf_thread_t
*
);
/* Actions */
static
void
DoAction
(
intf_thread_t
*
,
QObject
*
);
private:
/* Generic automenu methods */
...
...
@@ -92,7 +98,6 @@ private:
int
,
int
,
vlc_value_t
,
int
,
bool
c
=
false
);
static
void
CreateItem
(
QMenu
*
,
const
char
*
,
vlc_object_t
*
,
bool
);
static
int
CreateChoicesMenu
(
QMenu
*
,
const
char
*
,
vlc_object_t
*
,
bool
);
};
class
MenuFunc
:
public
QObject
...
...
modules/gui/qt4/qt4.cpp
View file @
2b60288a
...
...
@@ -48,6 +48,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
"preferences when opening the preferences " \
"dialog.")
#define SYSTRAY_TEXT N_("Show a systray icon to control")
#define SYSTRAY_LONGTEXT N_("Show in the taskbar, a systray icon" \
"in order to control VLC for basic actions")
vlc_module_begin
();
set_shortname
(
(
char
*
)
"Qt"
);
set_description
(
(
char
*
)
_
(
"Qt interface"
)
);
...
...
@@ -66,6 +70,8 @@ vlc_module_begin();
VLC_TRUE
);
add_bool
(
"qt-advanced-pref"
,
VLC_FALSE
,
NULL
,
ADVANCED_PREFS_TEXT
,
ADVANCED_PREFS_LONGTEXT
,
VLC_FALSE
);
add_bool
(
"qt-system-tray"
,
VLC_TRUE
,
NULL
,
SYSTRAY_TEXT
,
SYSTRAY_LONGTEXT
,
VLC_FALSE
);
set_callbacks
(
OpenDialogs
,
Close
);
vlc_module_end
();
...
...
modules/gui/qt4/res.qrc
View file @
2b60288a
...
...
@@ -9,6 +9,7 @@
<file>
pixmaps/volume-high.png
</file>
<file>
pixmaps/go-next.png
</file>
<file
alias=
"vlc128.png"
>
../../../share/vlc128x128.png
</file>
<file
alias=
"vlc48.png"
>
../../../share/vlc48x48.png
</file>
<file
alias=
"noart.png"
>
pixmaps/noart.png
</file>
<file>
pixmaps/playlist_icon.png
</file>
<file>
pixmaps/spref_cone_Audio_64.png
</file>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment