Commit 77bcf64b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt, controller: put all buttons in QHBoxLayouts

This will be needed for special styling
parent 33b0d9dd
...@@ -61,6 +61,7 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent ) ...@@ -61,6 +61,7 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
{ {
p_intf = _p_i; p_intf = _p_i;
advControls = NULL; advControls = NULL;
buttonGroupLayout = NULL;
/* Main action provider */ /* Main action provider */
toolbarActionsMapper = new QSignalMapper( this ); toolbarActionsMapper = new QSignalMapper( this );
...@@ -111,7 +112,7 @@ void AbstractController::parseAndCreate( const QString& config, ...@@ -111,7 +112,7 @@ void AbstractController::parseAndCreate( const QString& config,
QStringList list2 = list.at( i ).split( "-" ); QStringList list2 = list.at( i ).split( "-" );
if( list2.size() < 1 ) if( list2.size() < 1 )
{ {
msg_Warn( p_intf, "Parsing error. Report this" ); msg_Warn( p_intf, "Parsing error 1. Please, report this." );
continue; continue;
} }
...@@ -120,7 +121,7 @@ void AbstractController::parseAndCreate( const QString& config, ...@@ -120,7 +121,7 @@ void AbstractController::parseAndCreate( const QString& config,
buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok ); buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
if( !ok ) if( !ok )
{ {
msg_Warn( p_intf, "Parsing error 0. Please report this" ); msg_Warn( p_intf, "Parsing error 2. Please report this." );
continue; continue;
} }
...@@ -129,13 +130,19 @@ void AbstractController::parseAndCreate( const QString& config, ...@@ -129,13 +130,19 @@ void AbstractController::parseAndCreate( const QString& config,
i_option = list2.at( 1 ).toInt( &ok ); i_option = list2.at( 1 ).toInt( &ok );
if( !ok ) if( !ok )
{ {
msg_Warn( p_intf, "Parsing error 1. Please report this" ); msg_Warn( p_intf, "Parsing error 3. Please, report this." );
continue; continue;
} }
} }
createAndAddWidget( controlLayout, -1, i_type, i_option ); createAndAddWidget( controlLayout, -1, i_type, i_option );
} }
if( buttonGroupLayout )
{
controlLayout->addLayout( buttonGroupLayout );
buttonGroupLayout = NULL;
}
} }
void AbstractController::createAndAddWidget( QBoxLayout *controlLayout, void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
...@@ -143,23 +150,45 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout, ...@@ -143,23 +150,45 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
buttonType_e i_type, buttonType_e i_type,
int i_option ) 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 */ /* Special case for SPACERS, who aren't QWidgets */
if( i_type == WIDGET_SPACER ) if( i_type == WIDGET_SPACER )
{ {
controlLayout->insertSpacing( i_index, 12 ); controlLayout->addSpacing( 12 );
return;
} }
else if( i_type == WIDGET_SPACER_EXTEND )
if( i_type == WIDGET_SPACER_EXTEND )
{ {
controlLayout->insertStretch( i_index, 12 ); controlLayout->addStretch( 12 );
return;
} }
else
{
/* Create the widget */
QWidget *widg = createWidget( i_type, i_option ); QWidget *widg = createWidget( i_type, i_option );
if( !widg ) return; if( !widg ) return;
controlLayout->insertWidget( i_index, widg ); /* Buttons */
if( i_type < BUTTON_MAX )
{
if( !buttonGroupLayout )
{
buttonGroupLayout = new QHBoxLayout;
}
buttonGroupLayout->addWidget( widg );
}
else /* Special widgets */
{
controlLayout->addWidget( widg );
}
}
} }
......
...@@ -163,6 +163,8 @@ private: ...@@ -163,6 +163,8 @@ private:
QFrame *discFrame(); QFrame *discFrame();
QFrame *telexFrame(); QFrame *telexFrame();
void applyAttributes( QToolButton *, bool b_flat, bool b_big ); void applyAttributes( QToolButton *, bool b_flat, bool b_big );
QHBoxLayout *buttonGroupLayout;
protected slots: protected slots:
virtual void setStatus( int ); virtual void setStatus( int );
...@@ -197,7 +199,6 @@ public: ...@@ -197,7 +199,6 @@ public:
/* p_intf, advanced control visible or not, blingbling or not */ /* p_intf, advanced control visible or not, blingbling or not */
ControlsWidget( intf_thread_t *_p_i, bool b_advControls, ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
QWidget *_parent = 0 ); QWidget *_parent = 0 );
virtual ~ControlsWidget();
protected: protected:
friend class MainInterface; friend class MainInterface;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment