[vlc-commits] Qt, controller: put all buttons in QHBoxLayouts

Jean-Baptiste Kempf git at videolan.org
Sun Apr 17 21:40:32 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Apr 17 21:38:39 2011 +0200| [77bcf64b01428690829d47d07c9213ab7b87c2fb] | committer: Jean-Baptiste Kempf

Qt, controller: put all buttons in QHBoxLayouts

This will be needed for special styling

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

 modules/gui/qt4/components/controller.cpp |   53 ++++++++++++++++++++++------
 modules/gui/qt4/components/controller.hpp |    3 +-
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index f3e4637..d390665 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -61,6 +61,7 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
 {
     p_intf = _p_i;
     advControls = NULL;
+    buttonGroupLayout = NULL;
 
     /* Main action provider */
     toolbarActionsMapper = new QSignalMapper( this );
@@ -111,7 +112,7 @@ void AbstractController::parseAndCreate( const QString& config,
         QStringList list2 = list.at( i ).split( "-" );
         if( list2.size() < 1 )
         {
-            msg_Warn( p_intf, "Parsing error. Report this" );
+            msg_Warn( p_intf, "Parsing error 1. Please, report this." );
             continue;
         }
 
@@ -120,7 +121,7 @@ void AbstractController::parseAndCreate( const QString& config,
         buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
         if( !ok )
         {
-            msg_Warn( p_intf, "Parsing error 0. Please report this" );
+            msg_Warn( p_intf, "Parsing error 2. Please report this." );
             continue;
         }
 
@@ -129,13 +130,19 @@ void AbstractController::parseAndCreate( const QString& config,
             i_option = list2.at( 1 ).toInt( &ok );
             if( !ok )
             {
-                msg_Warn( p_intf, "Parsing error 1. Please report this" );
+                msg_Warn( p_intf, "Parsing error 3. Please, report this." );
                 continue;
             }
         }
 
         createAndAddWidget( controlLayout, -1, i_type, i_option );
     }
+
+    if( buttonGroupLayout )
+    {
+        controlLayout->addLayout( buttonGroupLayout );
+        buttonGroupLayout = NULL;
+    }
 }
 
 void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
@@ -143,23 +150,45 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
                                              buttonType_e i_type,
                                              int i_option )
 {
+    VLC_UNUSED( i_index ); // i_index should only be required for edition
+
+    /* Close the current buttonGroup if we have a special widget or a spacer */
+    if( buttonGroupLayout && i_type > BUTTON_MAX )
+    {
+        controlLayout->addLayout( buttonGroupLayout );
+        buttonGroupLayout = NULL;
+    }
+
     /* Special case for SPACERS, who aren't QWidgets */
     if( i_type == WIDGET_SPACER )
     {
-        controlLayout->insertSpacing( i_index, 12 );
-        return;
+        controlLayout->addSpacing( 12 );
     }
-
-    if(  i_type == WIDGET_SPACER_EXTEND )
+    else if(  i_type == WIDGET_SPACER_EXTEND )
     {
-        controlLayout->insertStretch( i_index, 12 );
-        return;
+        controlLayout->addStretch( 12 );
     }
+    else
+    {
+        /* Create the widget */
+        QWidget *widg = createWidget( i_type, i_option );
+        if( !widg ) return;
 
-    QWidget *widg = createWidget( i_type, i_option );
-    if( !widg ) return;
+        /* Buttons */
+        if( i_type < BUTTON_MAX )
+        {
+            if( !buttonGroupLayout )
+            {
+                buttonGroupLayout = new QHBoxLayout;
 
-    controlLayout->insertWidget( i_index, widg );
+            }
+            buttonGroupLayout->addWidget( widg );
+        }
+        else /* Special widgets */
+        {
+            controlLayout->addWidget( widg );
+        }
+    }
 }
 
 
diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
index 15540d8..0edb09d 100644
--- a/modules/gui/qt4/components/controller.hpp
+++ b/modules/gui/qt4/components/controller.hpp
@@ -163,6 +163,8 @@ private:
     QFrame *discFrame();
     QFrame *telexFrame();
     void applyAttributes( QToolButton *, bool b_flat, bool b_big );
+
+    QHBoxLayout         *buttonGroupLayout;
 protected slots:
     virtual void setStatus( int );
 
@@ -197,7 +199,6 @@ public:
     /* p_intf, advanced control visible or not, blingbling or not */
     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
                     QWidget *_parent = 0 );
-    virtual ~ControlsWidget();
 
 protected:
     friend class MainInterface;



More information about the vlc-commits mailing list