[vlc-devel] [RFC 39/82] qt: port interface widgets to use the new player/playlist API
Pierre Lamot
pierre at videolabs.io
Fri Feb 1 14:01:43 CET 2019
---
.../gui/qt/components/interface_widgets.cpp | 77 ++++++++-----------
.../gui/qt/components/interface_widgets.hpp | 4 +-
2 files changed, 35 insertions(+), 46 deletions(-)
diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index 96d71109ea..8da7b6d20a 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -70,6 +70,7 @@
#include <assert.h>
#include <vlc_vout_window.h>
+#include <vlc_player.h>
/**********************************************************************
* Video Widget. A simple frame on which video is drawn
@@ -427,10 +428,10 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i )
CONNECT( fadeAnimation, valueChanged( const QVariant & ),
this, update() );
- CONNECT( THEMIM->getIM(), artChanged( QString ),
- this, updateArt( const QString& ) );
- CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
- this, titleUpdated( const QString & ) );
+ connect( THEMIM, QOverload<QString>::of(&PlayerControler::artChanged),
+ this, &BackgroundWidget::updateArt );
+ connect( THEMIM, &PlayerControler::nameChanged,
+ this, &BackgroundWidget::titleUpdated );
}
void BackgroundWidget::updateArt( const QString& url )
@@ -661,13 +662,12 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent )
speedControlMenu->addAction( widgetAction );
/* Change the SpeedRate in the Label */
- CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) );
+ connect( THEMIM, &PlayerControler::rateChanged, this, &SpeedLabel::setRate );
- DCONNECT( THEMIM, inputChanged( bool ),
- speedControl, activateOnState() );
+ connect( THEMIM, &PlayerControler::playingStateChanged, speedControl, &SpeedControlWidget::activateOnState );
setContentsMargins(4, 0, 4, 0);
- setRate( var_InheritFloat( THEPL, "rate" ) );
+ setRate( THEMIM->getRate() );
}
SpeedLabel::~SpeedLabel()
@@ -717,7 +717,8 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
speedSlider->setPageStep( 1 );
speedSlider->setTickInterval( 17 );
- CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );
+ connect( speedSlider, &QSlider::valueChanged, this, &SpeedControlWidget::updateRate );
+ connect( THEMIM, &PlayerControler::rateChanged, this, &SpeedControlWidget::updateControls);
QToolButton *normalSpeedButton = new QToolButton( this );
normalSpeedButton->setMaximumSize( QSize( 26, 16 ) );
@@ -725,49 +726,38 @@ SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i, QWidget *_parent )
normalSpeedButton->setText( "1x" );
normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );
- CONNECT( normalSpeedButton, clicked(), this, resetRate() );
+ connect( normalSpeedButton, &QToolButton::clicked, this, &SpeedControlWidget::resetRate );
QToolButton *slowerButton = new QToolButton( this );
slowerButton->setMaximumSize( QSize( 26, 16 ) );
slowerButton->setAutoRaise( true );
slowerButton->setToolTip( tooltipL[SLOWER_BUTTON] );
slowerButton->setIcon( QIcon( iconL[SLOWER_BUTTON] ) );
- CONNECT( slowerButton, clicked(), THEMIM->getIM(), slower() );
+ connect( slowerButton, &QToolButton::clicked, THEMIM, &PlayerControler::slower);
QToolButton *fasterButton = new QToolButton( this );
fasterButton->setMaximumSize( QSize( 26, 16 ) );
fasterButton->setAutoRaise( true );
fasterButton->setToolTip( tooltipL[FASTER_BUTTON] );
fasterButton->setIcon( QIcon( iconL[FASTER_BUTTON] ) );
- CONNECT( fasterButton, clicked(), THEMIM->getIM(), faster() );
-
-/* 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 ) ); */
+ connect( fasterButton, &QToolButton::clicked, THEMIM, &PlayerControler::faster );
QGridLayout* speedControlLayout = new QGridLayout( this );
speedControlLayout->addWidget( speedSlider, 0, 0, 1, 3 );
speedControlLayout->addWidget( slowerButton, 1, 0 );
speedControlLayout->addWidget( normalSpeedButton, 1, 1, 1, 1, Qt::AlignRight );
speedControlLayout->addWidget( fasterButton, 1, 2, 1, 1, Qt::AlignRight );
- //speedControlLayout->addWidget( spinBox );
speedControlLayout->setContentsMargins( 0, 0, 0, 0 );
speedControlLayout->setSpacing( 0 );
lastValue = 0;
- activateOnState();
+ activateOnState( THEMIM->getPlayingState() );
}
-void SpeedControlWidget::activateOnState()
+void SpeedControlWidget::activateOnState( PlayerControler::PlayingState state )
{
- speedSlider->setEnabled( THEMIM->getIM()->hasInput() );
- //spinBox->setEnabled( THEMIM->getIM()->hasInput() );
+ speedSlider->setEnabled( state == PlayerControler::PLAYING_STATE_PLAYING || state == PlayerControler::PLAYING_STATE_PAUSED );
}
void SpeedControlWidget::updateControls( float rate )
@@ -802,28 +792,27 @@ void SpeedControlWidget::updateRate( int sliderValue )
lastValue = sliderValue;
double speed = pow( 2, (double)sliderValue / 17 );
- int rate = INPUT_RATE_DEFAULT / speed;
- THEMIM->getIM()->setRate(rate);
+ THEMIM->setRate(speed);
//spinBox->setValue( var_InheritFloat( THEPL, "rate" ) );
}
void SpeedControlWidget::updateSpinBoxRate( double r )
{
- var_SetFloat( THEPL, "rate", r );
+ THEMIM->setRate(r);
}
void SpeedControlWidget::resetRate()
{
- THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
+ THEMIM->normalRate();
}
CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
: QLabel( parent ), p_intf( _p_i ), p_item( NULL )
{
setContextMenuPolicy( Qt::ActionsContextMenu );
- CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
- this, showArtUpdate( input_item_t * ) );
+ connect( THEMIM, QOverload<QString>::of(&PlayerControler::artChanged),
+ this, QOverload<const QString&>::of(&CoverArtLabel::showArtUpdate) );
setMinimumHeight( 128 );
setMinimumWidth( 128 );
@@ -838,7 +827,7 @@ CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
CONNECT( action, triggered(), this, setArtFromFile() );
addAction( action );
- p_item = THEMIM->currentInputItem();
+ p_item = THEMIM->getInput();
if( p_item )
{
input_item_Hold( p_item );
@@ -886,13 +875,13 @@ void CoverArtLabel::showArtUpdate( input_item_t *_p_item )
return;
QString url;
- if ( _p_item ) url = THEMIM->getIM()->decodeArtURL( _p_item );
+ if ( _p_item ) url = THEMIM->decodeArtURL( _p_item );
showArtUpdate( url );
}
void CoverArtLabel::askForUpdate()
{
- THEMIM->getIM()->requestArtUpdate( p_item, true );
+ THEMIM->requestArtUpdate( p_item, true );
}
void CoverArtLabel::setArtFromFile()
@@ -906,7 +895,7 @@ void CoverArtLabel::setArtFromFile()
if( fileUrl.isEmpty() )
return;
- THEMIM->getIM()->setArt( p_item, fileUrl.toString() );
+ THEMIM->setArt( p_item, fileUrl.toString() );
}
void CoverArtLabel::clear()
@@ -947,17 +936,17 @@ TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
}
setAlignment( Qt::AlignRight | Qt::AlignVCenter );
- CONNECT( THEMIM->getIM(), seekRequested( float ),
- this, setDisplayPosition( float ) );
+ connect( THEMIM, &PlayerControler::seekRequested,
+ this, QOverload<float>::of(&TimeLabel::setDisplayPosition) );
- CONNECT( THEMIM->getIM(), positionUpdated( float, vlc_tick_t, int ),
- this, setDisplayPosition( float, vlc_tick_t, int ) );
+ connect( THEMIM, &PlayerControler::positionUpdated,
+ this, QOverload<float , vlc_tick_t, int>::of(&TimeLabel::setDisplayPosition) );
- connect( this, SIGNAL( broadcastRemainingTime( bool ) ),
- THEMIM->getIM(), SIGNAL( remainingTimeChanged( bool ) ) );
+ connect( this, &TimeLabel::broadcastRemainingTime,
+ THEMIM, &PlayerControler::remainingTimeChanged );
- CONNECT( THEMIM->getIM(), remainingTimeChanged( bool ),
- this, setRemainingTime( bool ) );
+ connect( THEMIM, &PlayerControler::remainingTimeChanged,
+ this, &TimeLabel::setRemainingTime );
setStyleSheet( "QLabel { padding-left: 4px; padding-right: 4px; }" );
}
diff --git a/modules/gui/qt/components/interface_widgets.hpp b/modules/gui/qt/components/interface_widgets.hpp
index 0d5161b025..f451700b81 100644
--- a/modules/gui/qt/components/interface_widgets.hpp
+++ b/modules/gui/qt/components/interface_widgets.hpp
@@ -30,7 +30,7 @@
#endif
#include "main_interface.hpp" /* Interface integration */
-#include "input_manager.hpp" /* Speed control */
+#include "components/player_controler.hpp" /* Speed control */
#include "components/controller.hpp"
#include "components/controller_widget.hpp"
@@ -258,7 +258,7 @@ private:
int lastValue;
public slots:
- void activateOnState();
+ void activateOnState(PlayerControler::PlayingState state);
private slots:
void updateRate( int );
--
2.19.1
More information about the vlc-devel
mailing list