Commit 4c2466aa authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

qt4 - Systray Menu - Add hide/show handling, open dialog, help menu, and some click handling.

parent 1f180231
...@@ -129,11 +129,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -129,11 +129,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
slider, setPosition( float,int, int ) ); slider, setPosition( float,int, int ) );
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ), CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplay( float, int, int ) ); this, setDisplay( float, int, int ) );
CONNECT( THEMIM->getIM(), nameChanged( QString ), this,setName( QString ) ); CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
setName( QString ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) ); CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
CONNECT( THEMIM->getIM(), statusChanged( int ), this, CONNECT( THEMIM->getIM(), statusChanged( int ), this,
updateSystrayMenu( int ) ); updateSystrayMenu( int ) );
CONNECT( THEMIM->getIM(), navigationChanged( int ), CONNECT( THEMIM->getIM(), navigationChanged( int ),
this, setNavigation(int) ); this, setNavigation(int) );
CONNECT( slider, sliderDragged( float ), CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) ); THEMIM->getIM(), sliderUpdate( float ) );
...@@ -273,10 +274,14 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -273,10 +274,14 @@ void MainInterface::handleMainUi( QSettings *settings )
void MainInterface::createSystrayMenu() void MainInterface::createSystrayMenu()
{ {
sysTray = new QSystemTrayIcon( QIcon( QPixmap( ":/vlc128.png" ) ) ); QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
sysTray = new QSystemTrayIcon( iconVLC );
systrayMenu = new QMenu( qtr( "VLC media player" ), this ); systrayMenu = new QMenu( qtr( "VLC media player" ), this );
QVLCMenu::updateSystrayMenu( this, p_intf ); systrayMenu->setIcon( iconVLC );
QVLCMenu::updateSystrayMenu( this, p_intf, true );
sysTray->show(); sysTray->show();
CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
} }
void MainInterface::updateSystrayMenu( int status ) void MainInterface::updateSystrayMenu( int status )
...@@ -284,6 +289,20 @@ void MainInterface::updateSystrayMenu( int status ) ...@@ -284,6 +289,20 @@ void MainInterface::updateSystrayMenu( int status )
QVLCMenu::updateSystrayMenu( this, p_intf ) ; QVLCMenu::updateSystrayMenu( this, p_intf ) ;
} }
void MainInterface::handleSystrayClick( QSystemTrayIcon::ActivationReason reason )
{
switch( reason )
{
case QSystemTrayIcon::Trigger:
this->show(); break;
case QSystemTrayIcon::MiddleClick:
sysTray->showMessage( qtr( "VLC media player" ),
qtr( "Control menu for the player" ),
QSystemTrayIcon::Information, 4000 );
break;
}
}
/********************************************************************** /**********************************************************************
* Handling of the components * Handling of the components
**********************************************************************/ **********************************************************************/
......
...@@ -131,6 +131,7 @@ private slots: ...@@ -131,6 +131,7 @@ private slots:
void advanced(); void advanced();
void updateVolume( int sliderVolume ); void updateVolume( int sliderVolume );
void updateSystrayMenu( int ); void updateSystrayMenu( int );
void handleSystrayClick( QSystemTrayIcon::ActivationReason );
}; };
......
...@@ -591,8 +591,8 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show ) ...@@ -591,8 +591,8 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
* Systray Menu * * Systray Menu *
************************************************************************/ ************************************************************************/
void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf,
) bool b_force_visible )
{ {
POPUP_BOILERPLATE; POPUP_BOILERPLATE;
QMenu *sysMenu = mi->getSysTrayMenu(); QMenu *sysMenu = mi->getSysTrayMenu();
...@@ -600,7 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf ...@@ -600,7 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf
POPUP_PLAY_ENTRIES( sysMenu ); POPUP_PLAY_ENTRIES( sysMenu );
sysMenu->addSeparator(); sysMenu->addSeparator();
/* FIXME DP_SADD( menu, qtr("&Hide/show") , "", "", quit(), "" );*/ if( mi->isVisible() || b_force_visible )
{
sysMenu->addAction( qtr("Hide Interface"), mi, SLOT( hide() ) );
}
else
{
sysMenu->addAction( qtr("Show Interface"), mi, SLOT( show() ) );
}
DP_SADD( sysMenu, qtr("&Open" ), "", "", openFileDialog(), "" );
DP_SADD( sysMenu, qtr("&Quit") , "", "", quit(), "" ); DP_SADD( sysMenu, qtr("&Quit") , "", "", quit(), "" );
mi->getSysTray()->setContextMenu( sysMenu ); mi->getSysTray()->setContextMenu( sysMenu );
......
...@@ -84,7 +84,8 @@ public: ...@@ -84,7 +84,8 @@ public:
static void PopupMenu( intf_thread_t *, bool ); static void PopupMenu( intf_thread_t *, bool );
/* Systray */ /* Systray */
static void updateSystrayMenu( MainInterface *,intf_thread_t * ); static void updateSystrayMenu( MainInterface *,intf_thread_t *,
bool b_force_visible = false);
/* Actions */ /* Actions */
static void DoAction( intf_thread_t *, QObject * ); static void DoAction( intf_thread_t *, QObject * );
......
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