]> git.sesse.net Git - vlc/commitdiff
qt4 - Systray Menu - Add hide/show handling, open dialog, help menu, and some click...
authorJean-Baptiste Kempf <jb@videolan.org>
Wed, 2 May 2007 22:57:51 +0000 (22:57 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 2 May 2007 22:57:51 +0000 (22:57 +0000)
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.hpp

index 2a3694dc71cadbb806077013ba1057add5721170..acf626cbd53651f5f1c075db4831e5a1661d6a72 100644 (file)
@@ -129,11 +129,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
              slider, setPosition( float,int, int ) );
     CONNECT( THEMIM->getIM(), positionUpdated( 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,
              updateSystrayMenu( int ) );
-    CONNECT( THEMIM->getIM(), navigationChanged( int ), 
+    CONNECT( THEMIM->getIM(), navigationChanged( int ),
              this, setNavigation(int) );
     CONNECT( slider, sliderDragged( float ),
              THEMIM->getIM(), sliderUpdate( float ) );
@@ -273,10 +274,14 @@ void MainInterface::handleMainUi( QSettings *settings )
 
 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 );
-    QVLCMenu::updateSystrayMenu( this, p_intf );
+    systrayMenu->setIcon( iconVLC );
+    QVLCMenu::updateSystrayMenu( this, p_intf, true );
     sysTray->show();
+    CONNECT( sysTray, activated(  QSystemTrayIcon::ActivationReason ),
+            this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
 }
 
 void MainInterface::updateSystrayMenu( int status )
@@ -284,6 +289,20 @@ void MainInterface::updateSystrayMenu( int status )
     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
  **********************************************************************/
index 9ef47af394d724c505d4b973d043f29bc68a8484..9af6e125b837e186f80d7011f8c3ae8942cec41b 100644 (file)
@@ -131,6 +131,7 @@ private slots:
     void advanced();
     void updateVolume( int sliderVolume );
     void updateSystrayMenu( int );
+    void handleSystrayClick(  QSystemTrayIcon::ActivationReason );
 };
 
 
index e519e22ae752e7a7d74b05aacbc22f552e684721..cc248e8e4ac744a1573fcb46aff536cc9408bf60 100644 (file)
@@ -591,8 +591,8 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
  * 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;
     QMenu *sysMenu = mi->getSysTrayMenu();
@@ -600,7 +600,15 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, intf_thread_t *p_intf
     POPUP_PLAY_ENTRIES( sysMenu );
     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(), "" );
 
     mi->getSysTray()->setContextMenu( sysMenu );
index 2561b14fe39057a4fc8424786f3edf6312c5c383..666028b2bac0f17dcfd105464292ca910396154a 100644 (file)
@@ -84,7 +84,8 @@ public:
     static void PopupMenu( intf_thread_t *, bool );
 
     /* Systray */
-    static void updateSystrayMenu( MainInterface *,intf_thread_t  * );
+    static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
+                                   bool b_force_visible = false);
 
     /* Actions */
     static void DoAction( intf_thread_t *, QObject * );