[vlc-devel] [PATCH 1/3] Qt4: UI enhancements - Speed

Edward Wang edward.c.wang at compdigitec.com
Sun Jan 1 20:04:57 CET 2012


---
 modules/gui/qt4/components/controller.cpp        |    3 ++
 modules/gui/qt4/components/controller.hpp        |    1 +
 modules/gui/qt4/components/interface_widgets.cpp |   37 ++++++++++++++++++---
 modules/gui/qt4/components/interface_widgets.hpp |    6 ++-
 modules/gui/qt4/dialogs/toolbar.cpp              |    4 ++
 5 files changed, 43 insertions(+), 8 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..ccabd7c 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -348,6 +348,10 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
 
     DCONNECT( THEMIM, inputChanged( input_thread_t * ),
               speedControl, activateOnState() );
+
+    setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
+    setLineWidth( 1 );
+
     setRate( var_InheritFloat( p_intf, "rate" ) );
 }
 
@@ -383,15 +387,15 @@ 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( 200, 24 ) );
+    speedSlider->setOrientation( Qt::Horizontal );
+    speedSlider->setTickPosition( QSlider::TicksAbove );
 
     speedSlider->setRange( -34, 34 );
     speedSlider->setSingleStep( 1 );
@@ -408,11 +412,24 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
 
     CONNECT( normalSpeedButton, clicked(), this, resetRate() );
 
-    QVBoxLayout *speedControlLayout = new QVBoxLayout( this );
+    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 ) );
+
+    QVBoxLayout* speedControlLayout = new QVBoxLayout( this );
+    QHBoxLayout* hboxLayout = new QHBoxLayout();
+    hboxLayout->addWidget( spinBox );
+    hboxLayout->addWidget( normalSpeedButton );
     speedControlLayout->setContentsMargins( 4, 4, 4, 4 );
     speedControlLayout->setSpacing( 4 );
     speedControlLayout->addWidget( speedSlider );
-    speedControlLayout->addWidget( normalSpeedButton );
+    speedControlLayout->addLayout( hboxLayout );
+    speedControlLayout->setAlignment( hboxLayout, Qt::AlignHCenter );
 
     lastValue = 0;
 
@@ -422,6 +439,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 +464,7 @@ void SpeedControlWidget::updateControls( float rate )
     lastValue = sliderValue;
 
     speedSlider->setValue( sliderValue );
+    spinBox->setValue( rate );
 }
 
 void SpeedControlWidget::updateRate( int sliderValue )
@@ -457,6 +476,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;
-- 
1.7.5.4




More information about the vlc-devel mailing list