[vlc-devel] commit: Qt: remove the HACK with the static QAction for minimalViewAction, and fix a few minimalVIew issues. (Jean-Baptiste Kempf )

git version control git at videolan.org
Fri Feb 27 20:31:17 CET 2009


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Feb 27 20:28:55 2009 +0100| [916aa463af5260cac06cce80c1c84b3b6be5f331] | committer: Jean-Baptiste Kempf 

Qt: remove the HACK with the static QAction for minimalViewAction, and fix a few minimalVIew issues.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=916aa463af5260cac06cce80c1c84b3b6be5f331
---

 modules/gui/qt4/main_interface.cpp |   18 ++++++++++--------
 modules/gui/qt4/main_interface.hpp |    7 ++++---
 modules/gui/qt4/menus.cpp          |   12 ++++++------
 3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index f1d490e..0af7620 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -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();
     }
 
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index df86b80..b2c088e 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -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
diff --git a/modules/gui/qt4/menus.cpp b/modules/gui/qt4/menus.cpp
index 9b7dd94..65226dd 100644
--- a/modules/gui/qt4/menus.cpp
+++ b/modules/gui/qt4/menus.cpp
@@ -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,




More information about the vlc-devel mailing list