Commit cd669541 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

qt4 - Systray: - Repair the hide-and-never-show-back bug,

               - Repair the quit-VLC-but-let-the-menu W32 bug,
               - add an option to start VLC minimized.
parent 12dcce3f
...@@ -159,9 +159,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -159,9 +159,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf ); var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
if( QSystemTrayIcon::isSystemTrayAvailable() &&
( config_GetInt( p_intf, "qt-start-mininimized") == 1))
{
hide();
createSystrayMenu();
}
if( QSystemTrayIcon::isSystemTrayAvailable() && if( QSystemTrayIcon::isSystemTrayAvailable() &&
( config_GetInt( p_intf, "qt-system-tray") == 1)) ( config_GetInt( p_intf, "qt-system-tray") == 1))
createSystrayMenu(); createSystrayMenu();
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
...@@ -275,7 +282,7 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -275,7 +282,7 @@ void MainInterface::handleMainUi( QSettings *settings )
void MainInterface::createSystrayMenu() void MainInterface::createSystrayMenu()
{ {
QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) ); QIcon iconVLC = QIcon( QPixmap( ":/vlc128.png" ) );
sysTray = new QSystemTrayIcon( iconVLC ); sysTray = new QSystemTrayIcon( iconVLC, this );
systrayMenu = new QMenu( qtr( "VLC media player" ), this ); systrayMenu = new QMenu( qtr( "VLC media player" ), this );
systrayMenu->setIcon( iconVLC ); systrayMenu->setIcon( iconVLC );
QVLCMenu::updateSystrayMenu( this, p_intf, true ); QVLCMenu::updateSystrayMenu( this, p_intf, true );
...@@ -289,15 +296,22 @@ void MainInterface::updateSystrayMenu( int status ) ...@@ -289,15 +296,22 @@ void MainInterface::updateSystrayMenu( int status )
QVLCMenu::updateSystrayMenu( this, p_intf ) ; QVLCMenu::updateSystrayMenu( this, p_intf ) ;
} }
void MainInterface::toggleUpdateSystrayMenu()
{
QVLCMenu::updateSystrayMenu( this, p_intf );
toggleVisible();
}
void MainInterface::handleSystrayClick( QSystemTrayIcon::ActivationReason reason ) void MainInterface::handleSystrayClick( QSystemTrayIcon::ActivationReason reason )
{ {
switch( reason ) switch( reason )
{ {
case QSystemTrayIcon::Trigger: case QSystemTrayIcon::Trigger:
this->show(); break; this->toggleVisible(); break;
case QSystemTrayIcon::MiddleClick: case QSystemTrayIcon::MiddleClick:
sysTray->showMessage( qtr( "VLC media player" ), sysTray->showMessage( qtr( "VLC media player" ),
qtr( "Control menu for the player" ), qtr( "Control menu for the player" )
+ nameLabel->text() ,
QSystemTrayIcon::Information, 4000 ); QSystemTrayIcon::Information, 4000 );
break; break;
} }
......
...@@ -117,6 +117,7 @@ private: ...@@ -117,6 +117,7 @@ private:
public slots: public slots:
void undockPlaylist(); void undockPlaylist();
void playlist(); void playlist();
void toggleUpdateSystrayMenu();
private slots: private slots:
void setNavigation( int ); void setNavigation( int );
void setStatus( int ); void setStatus( int );
...@@ -130,8 +131,8 @@ private slots: ...@@ -130,8 +131,8 @@ private slots:
void visual(); void visual();
void advanced(); void advanced();
void updateVolume( int sliderVolume ); void updateVolume( int sliderVolume );
void updateSystrayMenu( int );
void handleSystrayClick( QSystemTrayIcon::ActivationReason ); void handleSystrayClick( QSystemTrayIcon::ActivationReason );
void updateSystrayMenu( int );
}; };
......
...@@ -600,13 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf, ...@@ -600,13 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf,
POPUP_PLAY_ENTRIES( sysMenu ); POPUP_PLAY_ENTRIES( sysMenu );
sysMenu->addSeparator(); sysMenu->addSeparator();
if( mi->isVisible() || b_force_visible ) if( !mi->isVisible() || b_force_visible )
{ {
sysMenu->addAction( qtr("Hide Interface"), mi, SLOT( hide() ) ); sysMenu->addAction( qtr("Hide Interface"), mi,
SLOT( toggleUpdateSystrayMenu() ) );
} }
else else
{ {
sysMenu->addAction( qtr("Show Interface"), mi, SLOT( show() ) ); sysMenu->addAction( qtr("Show Interface"), mi,
SLOT( toggleUpdateSystrayMenu() ) );
} }
DP_SADD( sysMenu, qtr("&Open" ), "", "", openFileDialog(), "" ); DP_SADD( sysMenu, qtr("&Open" ), "", "", openFileDialog(), "" );
DP_SADD( sysMenu, qtr("&Quit") , "", "", quit(), "" ); DP_SADD( sysMenu, qtr("&Quit") , "", "", quit(), "" );
......
...@@ -53,6 +53,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); ...@@ -53,6 +53,10 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
"in order to control VLC media player" \ "in order to control VLC media player" \
"for basic actions") "for basic actions")
#define MINIMIZED_TEXT N_("Start VLC only with a systray icon")
#define MINIMIZED_LONGTEXT N_("When you launch VLC with that option" \
"VLC will start just with an icon in" \
"your taskbar")
vlc_module_begin(); vlc_module_begin();
set_shortname( (char *)"Qt" ); set_shortname( (char *)"Qt" );
set_description( (char*)_("Qt interface") ); set_description( (char*)_("Qt interface") );
...@@ -73,6 +77,8 @@ vlc_module_begin(); ...@@ -73,6 +77,8 @@ vlc_module_begin();
ADVANCED_PREFS_LONGTEXT, VLC_FALSE ); ADVANCED_PREFS_LONGTEXT, VLC_FALSE );
add_bool( "qt-system-tray", VLC_TRUE, NULL, SYSTRAY_TEXT, add_bool( "qt-system-tray", VLC_TRUE, NULL, SYSTRAY_TEXT,
SYSTRAY_LONGTEXT, VLC_FALSE); SYSTRAY_LONGTEXT, VLC_FALSE);
add_bool( "qt-start-mininimized", VLC_FALSE, NULL, MINIMIZED_TEXT,
MINIMIZED_LONGTEXT, VLC_TRUE);
set_callbacks( OpenDialogs, Close ); set_callbacks( OpenDialogs, Close );
vlc_module_end(); vlc_module_end();
......
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