]> git.sesse.net Git - vlc/commitdiff
qt4 - Systray: - Repair the hide-and-never-show-back bug,
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 4 May 2007 00:04:11 +0000 (00:04 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 4 May 2007 00:04:11 +0000 (00:04 +0000)
               - Repair the quit-VLC-but-let-the-menu W32 bug,
               - add an option to start VLC minimized.

modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/menus.cpp
modules/gui/qt4/qt4.cpp

index acf626cbd53651f5f1c075db4831e5a1661d6a72..b1a690973da55746fa004c8e519305c10c0f75ea 100644 (file)
@@ -159,9 +159,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
         var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
         vlc_object_release( p_playlist );
     }
+    if( QSystemTrayIcon::isSystemTrayAvailable() &&
+                        ( config_GetInt( p_intf, "qt-start-mininimized") == 1))
+    {
+        hide();
+        createSystrayMenu();
+    }
     if( QSystemTrayIcon::isSystemTrayAvailable() &&
                               ( config_GetInt( p_intf, "qt-system-tray") == 1))
             createSystrayMenu();
+
 }
 
 MainInterface::~MainInterface()
@@ -275,7 +282,7 @@ void MainInterface::handleMainUi( QSettings *settings )
 void MainInterface::createSystrayMenu()
 {
     QIcon iconVLC =  QIcon( QPixmap( ":/vlc128.png" ) );
-    sysTray = new QSystemTrayIcon( iconVLC );
+    sysTray = new QSystemTrayIcon( iconVLC, this );
     systrayMenu = new QMenu( qtr( "VLC media player" ), this );
     systrayMenu->setIcon( iconVLC );
     QVLCMenu::updateSystrayMenu( this, p_intf, true );
@@ -289,15 +296,22 @@ void MainInterface::updateSystrayMenu( int status )
     QVLCMenu::updateSystrayMenu( this, p_intf ) ;
 }
 
+void MainInterface::toggleUpdateSystrayMenu()
+{
+    QVLCMenu::updateSystrayMenu( this, p_intf );
+    toggleVisible();
+}
+
 void MainInterface::handleSystrayClick( QSystemTrayIcon::ActivationReason reason )
 {
     switch( reason )
     {
         case QSystemTrayIcon::Trigger:
-            this->show(); break;
+            this->toggleVisible(); break;
         case QSystemTrayIcon::MiddleClick:
             sysTray->showMessage( qtr( "VLC media player" ),
-                    qtr( "Control menu for the player" ),
+                    qtr( "Control menu for the player" )
+                    + nameLabel->text() ,
                     QSystemTrayIcon::Information, 4000 );
             break;
     }
index 9af6e125b837e186f80d7011f8c3ae8942cec41b..dfd61a6996b41fe346c7b7726c84d9be71e45113 100644 (file)
@@ -117,6 +117,7 @@ private:
 public slots:
     void undockPlaylist();
     void playlist();
+    void toggleUpdateSystrayMenu();
 private slots:
     void setNavigation( int );
     void setStatus( int );
@@ -130,8 +131,8 @@ private slots:
     void visual();
     void advanced();
     void updateVolume( int sliderVolume );
-    void updateSystrayMenu( int );
     void handleSystrayClick(  QSystemTrayIcon::ActivationReason );
+    void updateSystrayMenu( int );
 };
 
 
index cc248e8e4ac744a1573fcb46aff536cc9408bf60..1d917748570d70aaa759cdfbbf96fabda7bd83c2 100644 (file)
@@ -600,13 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf,
     POPUP_PLAY_ENTRIES( sysMenu );
     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
     {
-        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("&Quit") , "", "", quit(), "" );
index 2fc4933b6c5dcd2fe2ff03333a5aba06bc11bc59..c86537117d53d2d166114fd7b83d9d3debd68dfe 100644 (file)
@@ -53,6 +53,10 @@ static void ShowDialog   ( intf_thread_t *, int, int, intf_dialog_args_t * );
                             "in order to control VLC media player" \
                             "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();
     set_shortname( (char *)"Qt" );
     set_description( (char*)_("Qt interface") );
@@ -73,6 +77,8 @@ vlc_module_begin();
                 ADVANCED_PREFS_LONGTEXT, VLC_FALSE );
         add_bool( "qt-system-tray", VLC_TRUE, NULL, SYSTRAY_TEXT,
                 SYSTRAY_LONGTEXT, VLC_FALSE);
+        add_bool( "qt-start-mininimized", VLC_FALSE, NULL, MINIMIZED_TEXT,
+                MINIMIZED_LONGTEXT, VLC_TRUE);
         set_callbacks( OpenDialogs, Close );
 vlc_module_end();