]> git.sesse.net Git - vlc/commitdiff
Qt: remove the HACK with the static QAction for minimalViewAction, and fix a few...
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 27 Feb 2009 19:28:55 +0000 (20:28 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 27 Feb 2009 19:30:09 +0000 (20:30 +0100)
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/menus.cpp

index f1d490e8d2237aefbd50d16cf7e48bcef7cf03b9..0af76201d2f66904f12210d5fef92cb44fe156f6 100644 (file)
@@ -257,7 +257,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* And switch to minimal view if needed
        Must be called after the show() */
     if( i_visualmode == QT_MINIMAL_MODE )
-        toggleMinimalView();
+        toggleMinimalView( true );
 
     /* Update the geometry : It is useful if you switch between
        qt-display-modes ?*/
@@ -803,7 +803,7 @@ void MainInterface::dockPlaylist( pl_dock_e i_pos )
 {
 }
 
-void MainInterface::toggleMinimalView()
+void MainInterface::toggleMinimalView( bool b_switch )
 {
     if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
         i_visualmode != QT_MINIMAL_MODE )
@@ -816,13 +816,13 @@ void MainInterface::toggleMinimalView()
         }
     }
 
-    TOGGLEV( menuBar() );
-    TOGGLEV( controls );
-    TOGGLEV( statusBar() );
-    TOGGLEV( inputC );
+    menuBar()->setVisible( !b_switch );
+    controls->setVisible( !b_switch );
+    statusBar()->setVisible( !b_switch );
+    inputC->setVisible( !b_switch );
     doComponentsUpdate();
 
-    QVLCMenu::minimalViewAction->setChecked( bgWasVisible );
+    emit minimalViewToggled( b_switch );
 }
 
 /* Video widget cannot do this synchronously as it runs in another thread */
@@ -855,6 +855,8 @@ void MainInterface::toggleAdvanced()
 /* Get the visibility status of the controls (hidden or not, advanced or not) */
 int MainInterface::getControlsVisibilityStatus()
 {
+    msg_Warn( p_intf, "%i", (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
+                            + CONTROLS_ADVANCED * controls->b_advancedVisible );
     return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )
                 + CONTROLS_ADVANCED * controls->b_advancedVisible );
 }
@@ -1126,7 +1128,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
     if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() == Qt::Key_H )
           && menuBar()->isHidden() )
     {
-        toggleMinimalView();
+        toggleMinimalView( false );
         e->accept();
     }
 
index df86b807e5ac2f56d289d5c5d86b59c6468aa409..b2c088e5208934be3b10af518fdebc00572d1860 100644 (file)
@@ -51,9 +51,9 @@ class QMenu;
 class QSize;
 
 enum {
-    CONTROLS_HIDDEN = 0x0,
     CONTROLS_VISIBLE = 0x1,
-    CONTROLS_ADVANCED = 0x2
+    CONTROLS_HIDDEN = 0x2,
+    CONTROLS_ADVANCED = 0x4,
 };
 
 typedef enum pl_dock_e {
@@ -153,7 +153,7 @@ private:
 public slots:
     void undockPlaylist();
     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
-    void toggleMinimalView();
+    void toggleMinimalView( bool );
     void togglePlaylist();
     void toggleUpdateSystrayMenu();
     void toggleAdvanced();
@@ -185,6 +185,7 @@ signals:
     void askVideoToToggle();
     void askBgWidgetToToggle();
     void askUpdate();
+    void minimalViewToggled( bool );
 };
 
 #endif
index 9b7dd945fd5907e6033451980a9be5a561de588a..65226dd054dfc422a16460a1c38dd5f46d1e840a 100644 (file)
@@ -75,7 +75,6 @@ static QActionGroup *currentGroup;
 
 /* HACK for minimalView to go around a Qt bug/feature
  * that doesn't update the QAction checked state when QMenu is hidden */
-QAction *QVLCMenu::minimalViewAction = NULL;
 QAction *QVLCMenu::fullscreenViewAction = NULL;
 
 QMenu *QVLCMenu::recentsMenu = NULL;
@@ -413,13 +412,14 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
     }
 
     /* Minimal View */
-    QAction *action = menu->addAction( qtr( "Mi&nimal View" ), mi,
-            SLOT( toggleMinimalView() ), qtr( "Ctrl+H" ) );
+    QAction *action = menu->addAction( qtr( "Mi&nimal View" ) );
+    action->setShortcut( qtr( "Ctrl+H" ) );
     action->setCheckable( true );
+    action->setChecked( !with_intf &&
+            (mi->getControlsVisibilityStatus() && CONTROLS_HIDDEN ) );
 
-    if( mi->getControlsVisibilityStatus() & CONTROLS_VISIBLE )
-        action->setChecked( true );
-    minimalViewAction = action; /* HACK for minimalView */
+    CONNECT( action, triggered( bool ), mi, toggleMinimalView( bool ) );
+    CONNECT( mi, minimalViewToggled( bool ), action, setChecked( bool ) );
 
     /* FullScreen View */
     action = menu->addAction( qtr( "&Fullscreen Interface" ), mi,