[vlc-commits] Qt4: allow speedlabel in toolbars
Edward Wang
git at videolan.org
Tue Jan 3 19:16:25 CET 2012
vlc | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sun Jan 1 14:04:57 2012 -0500| [18120e5ae23e61a7172dec0321d386e0d877702e] | committer: Jean-Baptiste Kempf
Qt4: allow speedlabel in toolbars
Modified-by: Jean-Baptiste Kempf <jb at videolan.org>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=18120e5ae23e61a7172dec0321d386e0d877702e
---
modules/gui/qt4/components/controller.cpp | 3 +
modules/gui/qt4/components/controller.hpp | 1 +
modules/gui/qt4/components/interface_widgets.cpp | 45 ++++++++++++++++------
modules/gui/qt4/components/interface_widgets.hpp | 6 ++-
modules/gui/qt4/dialogs/toolbar.cpp | 4 ++
5 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index 22d3792..d1fad22 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -468,6 +468,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
case ASPECT_RATIO_COMBOBOX:
widget = new AspectRatioComboBox( p_intf );
break;
+ case SPEED_LABEL:
+ widget = new SpeedLabel( p_intf, this );
+ break;
default:
msg_Warn( p_intf, "This should not happen %i", button );
break;
diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
index 96d53c0..8052c75 100644
--- a/modules/gui/qt4/components/controller.hpp
+++ b/modules/gui/qt4/components/controller.hpp
@@ -100,6 +100,7 @@ typedef enum buttonType_e
ADVANCED_CONTROLLER,
PLAYBACK_BUTTONS,
ASPECT_RATIO_COMBOBOX,
+ SPEED_LABEL,
SPECIAL_MAX,
WIDGET_SPACER = 0x40,
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index e384092..2fabfa3 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -343,11 +343,15 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
widgetAction->setDefaultWidget( speedControl );
speedControlMenu->addAction( widgetAction );
- /* Change the SpeedRate in the Status Bar */
+ /* Change the SpeedRate in the Label */
CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) );
DCONNECT( THEMIM, inputChanged( input_thread_t * ),
speedControl, activateOnState() );
+
+ setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
+ setLineWidth( 1 );
+
setRate( var_InheritFloat( p_intf, "rate" ) );
}
@@ -364,7 +368,7 @@ SpeedLabel::~SpeedLabel()
void SpeedLabel::showSpeedMenu( QPoint pos )
{
speedControlMenu->exec( QCursor::pos() - pos
- + QPoint( 0, height() ) );
+ + QPoint( -70 + width()/2, height() ) );
}
void SpeedLabel::setRate( float rate )
@@ -383,15 +387,14 @@ void SpeedLabel::setRate( float rate )
SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
: QFrame( _parent ), p_intf( _p_i )
{
- QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
+ QSizePolicy sizePolicy( QSizePolicy::Fixed, QSizePolicy::Maximum );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
speedSlider = new QSlider( this );
speedSlider->setSizePolicy( sizePolicy );
- speedSlider->setMaximumSize( QSize( 80, 200 ) );
- speedSlider->setOrientation( Qt::Vertical );
- speedSlider->setTickPosition( QSlider::TicksRight );
+ speedSlider->setMinimumSize( QSize( 140, 20 ) );
+ speedSlider->setOrientation( Qt::Horizontal );
speedSlider->setRange( -34, 34 );
speedSlider->setSingleStep( 1 );
@@ -401,18 +404,28 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
QToolButton *normalSpeedButton = new QToolButton( this );
- normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );
+ normalSpeedButton->setMaximumSize( QSize( 26, 16 ) );
normalSpeedButton->setAutoRaise( true );
normalSpeedButton->setText( "1x" );
normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
CONNECT( normalSpeedButton, clicked(), this, resetRate() );
- QVBoxLayout *speedControlLayout = new QVBoxLayout( this );
- speedControlLayout->setContentsMargins( 4, 4, 4, 4 );
- speedControlLayout->setSpacing( 4 );
- speedControlLayout->addWidget( speedSlider );
- speedControlLayout->addWidget( normalSpeedButton );
+/* spinBox = new QDoubleSpinBox();
+ spinBox->setDecimals( 2 );
+ spinBox->setMaximum( 32 );
+ spinBox->setMinimum( 0.03F );
+ spinBox->setSingleStep( 0.10F );
+ spinBox->setAlignment( Qt::AlignRight );
+
+ CONNECT( spinBox, valueChanged( double ), this, updateSpinBoxRate( double ) ); */
+
+ QGridLayout* speedControlLayout = new QGridLayout( this );
+ speedControlLayout->addWidget( speedSlider, 0, 0, 1, 3 );
+ speedControlLayout->addWidget( normalSpeedButton, 1, 1 );
+ //speedControlLayout->addWidget( spinBox );
+ speedControlLayout->setContentsMargins( 0, 0, 0, 0 );
+ speedControlLayout->setSpacing( 0 );
lastValue = 0;
@@ -422,6 +435,7 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
void SpeedControlWidget::activateOnState()
{
speedSlider->setEnabled( THEMIM->getIM()->hasInput() );
+ //spinBox->setEnabled( THEMIM->getIM()->hasInput() );
}
void SpeedControlWidget::updateControls( float rate )
@@ -446,6 +460,7 @@ void SpeedControlWidget::updateControls( float rate )
lastValue = sliderValue;
speedSlider->setValue( sliderValue );
+ //spinBox->setValue( rate );
}
void SpeedControlWidget::updateRate( int sliderValue )
@@ -457,6 +472,12 @@ void SpeedControlWidget::updateRate( int sliderValue )
int rate = INPUT_RATE_DEFAULT / speed;
THEMIM->getIM()->setRate(rate);
+ //spinBox->setValue( var_InheritFloat( THEPL, "rate" ) );
+}
+
+void SpeedControlWidget::updateSpinBoxRate( double r )
+{
+ var_SetFloat( THEPL, "rate", r );
}
void SpeedControlWidget::resetRate()
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index a2ce18f..5de9b32 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -188,8 +188,9 @@ public:
SpeedControlWidget( intf_thread_t *, QWidget * );
void updateControls( float );
private:
- intf_thread_t *p_intf;
- QSlider *speedSlider;
+ intf_thread_t* p_intf;
+ QSlider* speedSlider;
+ QDoubleSpinBox* spinBox;
int lastValue;
public slots:
@@ -197,6 +198,7 @@ public slots:
private slots:
void updateRate( int );
+ void updateSpinBoxRate( double );
void resetRate();
};
diff --git a/modules/gui/qt4/dialogs/toolbar.cpp b/modules/gui/qt4/dialogs/toolbar.cpp
index 43ebf09..ce5194b 100644
--- a/modules/gui/qt4/dialogs/toolbar.cpp
+++ b/modules/gui/qt4/dialogs/toolbar.cpp
@@ -449,6 +449,10 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
widget = new AspectRatioComboBox( p_intf );
widgetItem->setText( qtr("Aspect ratio selector") );
break;
+ case SPEED_LABEL:
+ widget = new SpeedLabel( p_intf, this );
+ widgetItem->setText( qtr("Speed selector") );
+ break;
default:
msg_Warn( p_intf, "This should not happen %i", i );
break;
More information about the vlc-commits
mailing list