[vlc-devel] [RFC 29/82] qt: port the control widgets to the new player/playlist API

Pierre Lamot pierre at videolabs.io
Fri Feb 1 14:01:33 CET 2019


---
 modules/gui/qt/components/controller.cpp      | 239 ++++++++----------
 modules/gui/qt/components/controller.hpp      |   9 +-
 .../gui/qt/components/controller_widget.cpp   | 105 ++++----
 .../gui/qt/components/controller_widget.hpp   |  34 ++-
 4 files changed, 194 insertions(+), 193 deletions(-)

diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index c26d7a3680..9e50e86278 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -34,13 +34,11 @@
 #include "util/buttons/RoundButton.hpp"
 
 #include "dialogs_provider.hpp"                     /* Opening Dialogs */
-#include "actions_manager.hpp"                             /* *_ACTION */
+#include "components/playlist/playlist_controler.hpp"
 
 #include "util/input_slider.hpp"                         /* SeekSlider */
 #include "util/customwidgets.hpp"                       /* qEventToKey */
 
-#include "adapters/seekpoints.hpp"
-
 #include <QToolButton>
 #include <QHBoxLayout>
 #include <QRegion>
@@ -56,6 +54,8 @@
  * TEH controls
  **********************************************************************/
 
+using namespace vlc::playlist;
+
 /******
  * This is an abstract Toolbar/Controller
  * This has helper to create any toolbar, any buttons and to manage the actions
@@ -68,31 +68,42 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
     advControls = NULL;
     buttonGroupLayout = NULL;
 
-    /* Main action provider */
-    toolbarActionsMapper = new QSignalMapper( this );
-    CONNECT( toolbarActionsMapper, mapped( int ),
-             ActionsManager::getInstance( p_intf  ), doAction( int ) );
-    CONNECT( THEMIM->getIM(), playingStatusChanged( int ), this, setStatus( int ) );
+    connect( THEMIM, &PlayerControler::playingStateChanged, this, &AbstractController::setStatus);
 
     setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
 }
 
 /* Reemit some signals on status Change to activate some buttons */
-void AbstractController::setStatus( int status )
+void AbstractController::setStatus( PlayerControler::PlayingState status )
 {
-    bool b_hasInput = THEMIM->getIM()->hasInput();
+    bool b_hasInput = THEMIM->hasInput();
     /* Activate the interface buttons according to the presence of the input */
     emit inputExists( b_hasInput );
 
-    emit inputPlaying( status == PLAYING_S );
+    emit inputPlaying( status == PlayerControler::PLAYING_STATE_PLAYING );
+
+    emit inputIsTrickPlayable( b_hasInput && THEMIM->isRewindable() );
+}
+
+void AbstractController::playAction()
+{
+    if( THEMPL->isEmpty() )
+        THEDP->openFileDialog();
+    else
+        THEMPL->togglePlayPause();
+}
+
+void AbstractController::playlistAction()
+{
+
+}
 
-    emit inputIsRecordable( b_hasInput &&
-                            var_GetBool( THEMIM->getInput(), "can-record" ) );
+void AbstractController::fullwidthAction()
+{
 
-    emit inputIsTrickPlayable( b_hasInput &&
-                            var_GetBool( THEMIM->getInput(), "can-rewind" ) );
 }
 
+
 /* Generic button setup */
 void AbstractController::setupButton( QAbstractButton *aButton )
 {
@@ -196,12 +207,6 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout_,
     }
 }
 
-
-#define CONNECT_MAP( a ) CONNECT( a, clicked(),  toolbarActionsMapper, map() )
-#define SET_MAPPING( a, b ) toolbarActionsMapper->setMapping( a , b )
-#define CONNECT_MAP_SET( a, b ) \
-    CONNECT_MAP( a ); \
-    SET_MAPPING( a, b );
 #define BUTTON_SET_BAR( a_button ) \
     a_button->setToolTip( qtr( tooltipL[button] ) ); \
     a_button->setIcon( QIcon( iconL[button] ) );
@@ -210,17 +215,17 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout_,
     button->setIcon( QIcon( ":/"#image ".svg" ) );
 
 #define ENABLE_ON_VIDEO( a ) \
-    CONNECT( THEMIM->getIM(), voutChanged( bool ), a, setEnabled( bool ) ); \
-    a->setEnabled( THEMIM->getIM()->hasVideo() ); /* TODO: is this necessary? when input is started before the interface? */
+    connect( THEMIM, &PlayerControler::hasVideoOutputChanged, a, &QToolButton::setEnabled ); \
+    a->setEnabled( THEMIM->hasVideoOutput() ); /* TODO: is this necessary? when input is started before the interface? */
 
 #define ENABLE_ON_INPUT( a ) \
-    CONNECT( this, inputExists( bool ), a, setEnabled( bool ) ); \
-    a->setEnabled( THEMIM->getIM()->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
+    connect( this, &AbstractController::inputExists, a, &QToolButton::setEnabled ); \
+    a->setEnabled( THEMIM->hasInput() ); /* TODO: is this necessary? when input is started before the interface? */
 
-#define NORMAL_BUTTON( name )                           \
+#define NORMAL_BUTTON( name, actionReceiver, actionSlot ) \
     QToolButton * name ## Button = new QToolButton;     \
     setupButton( name ## Button );                      \
-    CONNECT_MAP_SET( name ## Button, name ## _ACTION ); \
+    connect( name ## Button, &QToolButton::clicked, actionReceiver, actionSlot ); \
     BUTTON_SET_BAR( name ## Button );                   \
     widget = name ## Button;
 
@@ -238,40 +243,39 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         PlayButton *playButton = new PlayButton;
         setupButton( playButton );
         BUTTON_SET_BAR(  playButton );
-        CONNECT_MAP_SET( playButton, PLAY_ACTION );
-        CONNECT( this, inputPlaying( bool ),
-                 playButton, updateButtonIcons( bool ));
-        playButton->updateButtonIcons( THEMIM->getIM()->playingStatus() == PLAYING_S );
+        connect( playButton, &PlayButton::clicked, this, &AbstractController::playAction  );
+        connect( this, &AbstractController::inputPlaying, playButton, &PlayButton::updateButtonIcons );
+        playButton->updateButtonIcons( THEMIM->getPlayingState() == PlayerControler::PLAYING_STATE_PLAYING );
         widget = playButton;
         }
         break;
     case STOP_BUTTON:{
-        NORMAL_BUTTON( STOP );
+        NORMAL_BUTTON( STOP, THEMPL, &PlaylistControlerModel::stop );
         }
         break;
     case OPEN_BUTTON:{
-        NORMAL_BUTTON( OPEN );
+        NORMAL_BUTTON( OPEN, THEDP, QOverload<>::of(&DialogsProvider::openDialog));
         }
         break;
     case OPEN_SUB_BUTTON:{
-        NORMAL_BUTTON( OPEN_SUB );
+        NORMAL_BUTTON( OPEN_SUB, THEDP, &DialogsProvider::loadSubtitlesFile);
         }
         break;
     case PREVIOUS_BUTTON:{
-        NORMAL_BUTTON( PREVIOUS );
+        NORMAL_BUTTON( PREVIOUS, THEMPL, &PlaylistControlerModel::prev );
         }
         break;
     case NEXT_BUTTON: {
-        NORMAL_BUTTON( NEXT );
+        NORMAL_BUTTON( NEXT, THEMPL, &PlaylistControlerModel::next);
         }
         break;
     case SLOWER_BUTTON:{
-        NORMAL_BUTTON( SLOWER );
+        NORMAL_BUTTON( SLOWER, THEMIM, &PlayerControler::slower );
         ENABLE_ON_INPUT( SLOWERButton );
         }
         break;
     case FASTER_BUTTON:{
-        NORMAL_BUTTON( FASTER );
+        NORMAL_BUTTON( FASTER, THEMIM, &PlayerControler::faster );
         ENABLE_ON_INPUT( FASTERButton );
         }
         break;
@@ -279,8 +283,8 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         QToolButtonExt *but = new QToolButtonExt;
         setupButton( but );
         BUTTON_SET_BAR( but );
-        CONNECT( but, shortClicked(), THEMIM, prev() );
-        CONNECT( but, longClicked(), THEAM, skipBackward() );
+        connect( but, &QToolButtonExt::shortClicked, THEMPL, &PlaylistControlerModel::prev );
+        connect( but, &QToolButtonExt::longClicked, THEMIM, &PlayerControler::jumpBwd );
         widget = but;
         }
         break;
@@ -288,49 +292,48 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         QToolButtonExt *but = new QToolButtonExt;
         setupButton( but );
         BUTTON_SET_BAR( but );
-        CONNECT( but, shortClicked(), THEMIM, next() );
-        CONNECT( but, longClicked(), THEAM, skipForward() );
+        connect( but, &QToolButtonExt::shortClicked, THEMPL, &PlaylistControlerModel::next );
+        connect( but, &QToolButtonExt::longClicked, THEMIM, &PlayerControler::jumpFwd );
         widget = but;
         }
         break;
     case FRAME_BUTTON: {
-        NORMAL_BUTTON( FRAME );
+        NORMAL_BUTTON( FRAME, THEMIM, &PlayerControler::frameNext );
         ENABLE_ON_VIDEO( FRAMEButton );
         }
         break;
     case FULLSCREEN_BUTTON:
     case DEFULLSCREEN_BUTTON:
         {
-        NORMAL_BUTTON( FULLSCREEN );
+        NORMAL_BUTTON( FULLSCREEN, THEMIM, &PlayerControler::toggleFullscreen );
         ENABLE_ON_VIDEO( FULLSCREENButton );
         }
         break;
     case FULLWIDTH_BUTTON: {
-            NORMAL_BUTTON( FULLWIDTH );
+        NORMAL_BUTTON( FULLWIDTH,  this, &AbstractController::fullwidthAction );
         }
         break;
     case EXTENDED_BUTTON:{
-        NORMAL_BUTTON( EXTENDED );
+        NORMAL_BUTTON( EXTENDED, THEDP, &DialogsProvider::extendedDialog );
         }
         break;
     case PLAYLIST_BUTTON:{
-        NORMAL_BUTTON( PLAYLIST );
+        NORMAL_BUTTON( PLAYLIST, this, &AbstractController::playlistAction );
         }
         break;
     case SNAPSHOT_BUTTON:{
-        NORMAL_BUTTON( SNAPSHOT );
+        NORMAL_BUTTON( SNAPSHOT, THEMIM, &PlayerControler::snapshot );
         ENABLE_ON_VIDEO( SNAPSHOTButton );
         }
         break;
     case RECORD_BUTTON:{
         QToolButton *recordButton = new QToolButton;
         setupButton( recordButton );
-        CONNECT_MAP_SET( recordButton, RECORD_ACTION );
+        recordButton->setCheckable( true );
+        connect( recordButton, &QToolButton::toggled, THEMIM, &PlayerControler::setRecording );
+        connect( THEMIM, &PlayerControler::recordingChanged, recordButton, &QToolButton::setChecked );
         BUTTON_SET_BAR(  recordButton );
         ENABLE_ON_INPUT( recordButton );
-        recordButton->setCheckable( true );
-        CONNECT( THEMIM->getIM(), recordingStateChanged( bool ),
-                 recordButton, setChecked( bool ) );
         widget = recordButton;
         }
         break;
@@ -340,29 +343,25 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         ABButton->setShortcut( qtr("Shift+L") );
         BUTTON_SET_BAR( ABButton );
         ENABLE_ON_INPUT( ABButton );
-        CONNECT_MAP_SET( ABButton, ATOB_ACTION );
-        CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool),
-                 ABButton, updateButtonIcons( bool, bool ) );
+        connect( ABButton, &AtoB_Button::clicked, THEMIM, &PlayerControler::toggleABloopState );
+        connect( THEMIM, &PlayerControler::ABLoopStateChanged, ABButton, &AtoB_Button::updateButtonIcons );
         widget = ABButton;
         }
         break;
     case INPUT_SLIDER: {
         SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, NULL, !b_shiny );
-        SeekPoints *chapters = new SeekPoints( this, p_intf );
-        CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() );
-        slider->setChapters( chapters );
 
         /* Update the position when the IM has changed */
-        CONNECT( THEMIM->getIM(), positionUpdated( float, vlc_tick_t, int ),
-                slider, setPosition( float, vlc_tick_t, int ) );
+        connect( THEMIM, &PlayerControler::positionUpdated,
+                slider, &SeekSlider::setPosition );
         /* And update the IM, when the position has changed */
-        CONNECT( slider, sliderDragged( float ),
-                 THEMIM->getIM(), sliderUpdate( float ) );
-        CONNECT( THEMIM->getIM(), cachingChanged( float ),
-                 slider, updateBuffering( float ) );
+        connect( slider, &SeekSlider::sliderDragged,
+                 THEMIM, &PlayerControler::jumpToPos );
+        connect( THEMIM, &PlayerControler::bufferingChanged,
+                 slider, &SeekSlider::updateBuffering );
         /* Give hint to disable slider's interactivity when useless */
-        CONNECT( THEMIM->getIM(), inputCanSeek( bool ),
-                 slider, setSeekable( bool ) );
+        connect( THEMIM, &PlayerControler::seekableChanged,
+                 slider, &SeekSlider::setSeekable );
         widget = slider;
         }
         break;
@@ -408,36 +407,35 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
     case REVERSE_BUTTON:{
         QToolButton *reverseButton = new QToolButton;
         setupButton( reverseButton );
-        CONNECT_MAP_SET( reverseButton, REVERSE_ACTION );
+        connect( reverseButton, &QToolButton::clicked, THEMIM, &PlayerControler::reverse);
         BUTTON_SET_BAR(  reverseButton );
         reverseButton->setCheckable( true );
         /* You should, of COURSE change this to the correct event,
            when/if we have one, that tells us if trickplay is possible . */
-        CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) );
+        connect( this, &AbstractController::inputIsTrickPlayable, reverseButton, &QToolButton::setVisible );
         reverseButton->setVisible( false );
         widget = reverseButton;
         }
         break;
     case SKIP_BACK_BUTTON: {
-        NORMAL_BUTTON( SKIP_BACK );
+        NORMAL_BUTTON( SKIP_BACK, THEMIM, &PlayerControler::jumpBwd );
         ENABLE_ON_INPUT( SKIP_BACKButton );
         }
         break;
     case SKIP_FW_BUTTON: {
-        NORMAL_BUTTON( SKIP_FW );
+        NORMAL_BUTTON( SKIP_FW, THEMIM, &PlayerControler::jumpFwd  );
         ENABLE_ON_INPUT( SKIP_FWButton );
         }
         break;
     case QUIT_BUTTON: {
-        NORMAL_BUTTON( QUIT );
+        NORMAL_BUTTON( QUIT, THEDP, &DialogsProvider::quit );
         }
         break;
     case RANDOM_BUTTON: {
-        NORMAL_BUTTON( RANDOM );
+        NORMAL_BUTTON( RANDOM, THEMPL, &PlaylistControlerModel::toggleRandom );
         RANDOMButton->setCheckable( true );
-        RANDOMButton->setChecked( var_GetBool( THEPL, "random" ) );
-        CONNECT( THEMIM, randomChanged( bool ),
-                 RANDOMButton, setChecked( bool ) );
+        RANDOMButton->setChecked( THEMPL->isRandom() );
+        connect( THEMPL, &PlaylistControlerModel::randomChanged, RANDOMButton, &QToolButton::setChecked );
         }
         break;
     case LOOP_BUTTON:{
@@ -445,20 +443,14 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         setupButton( loopButton );
         loopButton->setToolTip( qtr( "Click to toggle between loop all, loop one and no loop") );
         loopButton->setCheckable( true );
-        {
-            int i_state = NORMAL;
-            if( var_GetBool( THEPL, "loop" ) )   i_state = REPEAT_ALL;
-            if( var_GetBool( THEPL, "repeat" ) ) i_state = REPEAT_ONE;
-            loopButton->updateButtonIcons( i_state );
-        }
-
-        CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateButtonIcons( int ) );
-        CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
+        loopButton->updateButtonIcons( THEMPL->getRepeatMode() );
+        connect( THEMPL, &PlaylistControlerModel::repeatModeChanged, loopButton, &LoopButton::updateButtonIcons );
+        connect( loopButton, &LoopButton::clicked, THEMPL, &PlaylistControlerModel::toggleRepeatMode );
         widget = loopButton;
         }
         break;
     case INFO_BUTTON: {
-        NORMAL_BUTTON( INFO );
+        NORMAL_BUTTON( INFO, THEDP, &DialogsProvider::mediaInfoDialog );
         }
         break;
     case PLAYBACK_BUTTONS:{
@@ -470,13 +462,13 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         layout->setBackwardButton( prev );
         layout->setForwardButton( next );
         layout->setRoundButton( play );
-        CONNECT_MAP_SET( prev, PREVIOUS_ACTION );
-        CONNECT_MAP_SET( next, NEXT_ACTION );
-        CONNECT_MAP_SET( play, PLAY_ACTION );
+        connect( prev, &BrowseButton::clicked, THEMPL, &PlaylistControlerModel::prev );
+        connect( next, &BrowseButton::clicked, THEMPL, &PlaylistControlerModel::next );
+        connect( play, &BrowseButton::clicked, this, &AbstractController::playAction );
         }
         break;
     case ASPECT_RATIO_COMBOBOX:
-        widget = new AspectRatioComboBox( p_intf );
+        widget = new AspectRatioComboBox( p_intf, THEMIM->getAspectRatio());
         widget->setMinimumHeight( 26 );
         break;
     case SPEED_LABEL:
@@ -570,17 +562,13 @@ QFrame *AbstractController::discFrame()
 
     /* Change the navigation button display when the IM
        navigation changes */
-    CONNECT( THEMIM->getIM(), chapterChanged( bool ),
-            chapFrame, setVisible( bool ) );
-    CONNECT( THEMIM->getIM(), titleChanged( bool ),
-            menuFrame, setVisible( bool ) );
+    connect( THEMIM, &PlayerControler::hasTitlesChanged, chapFrame, &QFrame::setVisible );
+    connect( THEMIM, &PlayerControler::hasMenuChanged, menuFrame, &QFrame::setVisible );
+
     /* Changes the IM navigation when triggered on the nav buttons */
-    CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
-            sectionPrev() );
-    CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
-            sectionNext() );
-    CONNECT( menuButton, clicked(), THEMIM->getIM(),
-            sectionMenu() );
+    connect( prevSectionButton, &QToolButton::clicked, THEMIM, &PlayerControler::sectionPrev );
+    connect( nextSectionButton, &QToolButton::clicked, THEMIM, &PlayerControler::sectionNext );
+    connect( menuButton, &QToolButton::clicked, THEMIM, &PlayerControler::sectionMenu );
 
     return discFrame;
 }
@@ -593,23 +581,20 @@ QFrame *AbstractController::telexFrame()
     QFrame *telexFrame = new QFrame( this );
     QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
     telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
-    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
-             telexFrame, setVisible( bool ) );
+    connect( THEMIM,  &PlayerControler::teletextAvailableChanged, telexFrame, &QFrame::setVisible );
 
     /* On/Off button */
     QToolButton *telexOn = new QToolButton;
     setupButton( telexOn );
     BUTTON_SET_BAR2( telexOn, toolbar/tv, qtr( "Teletext Activation" ) );
-    telexOn->setEnabled( false );
+    telexOn->setEnabled( true );
     telexOn->setCheckable( true );
 
     telexLayout->addWidget( telexOn );
 
     /* Teletext Activation and set */
-    CONNECT( telexOn, clicked( bool ),
-             THEMIM->getIM(), activateTeletext( bool ) );
-    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
-             telexOn, setEnabled( bool ) );
+    connect( telexOn, &QToolButton::clicked, THEMIM, &PlayerControler::enableTeletext );
+    connect( THEMIM, &PlayerControler::teletextEnabledChanged , telexOn, &QToolButton::setChecked );
 
     /* Transparency button */
     QToolButton *telexTransparent = new QToolButton;
@@ -621,10 +606,8 @@ QFrame *AbstractController::telexFrame()
     telexLayout->addWidget( telexTransparent );
 
     /* Transparency change and set */
-    CONNECT( telexTransparent, clicked( bool ),
-            THEMIM->getIM(), telexSetTransparency( bool ) );
-    CONNECT( THEMIM->getIM(), teletextTransparencyActivated( bool ),
-             telexTransparent, setChecked( bool ) );
+    connect( telexTransparent, &QToolButton::clicked, THEMIM, &PlayerControler::setTeletextTransparency );
+    connect( THEMIM, &PlayerControler::teletextTransparencyChanged, telexTransparent, &QToolButton::setChecked );
 
 
     /* Page setting */
@@ -665,10 +648,9 @@ QFrame *AbstractController::telexFrame()
     contextButton->setIcon( iconPixmap );\
     contextButton->setEnabled( false );\
     contextButtonMapper->setMapping( contextButton, key << 16 );\
-    CONNECT( contextButton, clicked(), contextButtonMapper, map() );\
-    CONNECT( contextButtonMapper, mapped( int ),\
-             THEMIM->getIM(), telexSetPage( int ) );\
-    CONNECT( THEMIM->getIM(), teletextActivated( bool ), contextButton, setEnabled( bool ) );\
+    connect( contextButton, &QToolButton::clicked, contextButtonMapper, QOverload<>::of(&QSignalMapper::map) );\
+    connect( contextButtonMapper, QOverload<int>::of(&QSignalMapper::mapped), THEMIM, &PlayerControler::setTeletextPage );\
+    connect( THEMIM, &PlayerControler::teletextEnabledChanged, contextButton, &QToolButton::setEnabled );\
     telexLayout->addWidget( contextButton )
 
     CREATE_CONTEXT_BUTTON("grey", 'i'); /* index */
@@ -680,19 +662,13 @@ QFrame *AbstractController::telexFrame()
 #undef CREATE_CONTEXT_BUTTON
 
     /* Page change and set */
-    CONNECT( telexPage, valueChanged( int ),
-            THEMIM->getIM(), telexSetPage( int ) );
-    CONNECT( THEMIM->getIM(), newTelexPageSet( int ),
-            telexPage, setValue( int ) );
-
-    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexPage, setEnabled( bool ) );
-    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexTransparent, setEnabled( bool ) );
-    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexOn, setChecked( bool ) );
+    connect( telexPage, QOverload<int>::of(&QSpinBox::valueChanged), THEMIM, &PlayerControler::setTeletextPage );
+    connect( THEMIM, &PlayerControler::teletextPageChanged, telexPage, &QSpinBox::setValue);
+
+    connect( THEMIM, &PlayerControler::teletextEnabledChanged, telexPage, &QSpinBox::setEnabled);
+    connect( THEMIM, &PlayerControler::teletextEnabledChanged, telexTransparent, &QSpinBox::setEnabled );
     return telexFrame;
 }
-#undef CONNECT_MAP
-#undef SET_MAPPING
-#undef CONNECT_MAP_SET
 #undef BUTTON_SET_BAR
 #undef BUTTON_SET_BAR2
 #undef ENABLE_ON_VIDEO
@@ -827,26 +803,24 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
     /* hiding timer */
     p_hideTimer = new QTimer( this );
     p_hideTimer->setSingleShot( true );
-    CONNECT( p_hideTimer, timeout(), this, hideFSC() );
+    connect( p_hideTimer, &QTimer::timeout, this, &FullscreenControllerWidget::hideFSC );
 
     /* slow hiding timer */
     p_slowHideTimer = new QTimer( this );
-    CONNECT( p_slowHideTimer, timeout(), this, slowHideFSC() );
+    connect( p_slowHideTimer, &QTimer::timeout, this, &FullscreenControllerWidget::slowHideFSC );
     f_opacity = var_InheritFloat( p_intf, "qt-fs-opacity" );
 
     i_sensitivity = var_InheritInteger( p_intf, "qt-fs-sensitivity" );
 
     vlc_mutex_init_recursive( &lock );
 
-    DCONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
-              this, setVoutList( vout_thread_t **, int ) );
+    connect( THEMIM, &PlayerControler::voutListChanged,
+              this, &FullscreenControllerWidget::setVoutList, Qt::DirectConnection );
 
     /* First Move */
     previousPosition = getSettings()->value( "FullScreen/pos" ).toPoint();
     screenRes = getSettings()->value( "FullScreen/screen" ).toRect();
     isWideFSC = getSettings()->value( "FullScreen/wide" ).toBool();
-
-    CONNECT( this, fullscreenChanged( bool ), THEMIM, changeFullscreen( bool ) );
 }
 
 FullscreenControllerWidget::~FullscreenControllerWidget()
@@ -1139,7 +1113,7 @@ int FullscreenControllerWidget::FullscreenChanged( vlc_object_t *obj,
     FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
 
     p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );
-    p_fs->emit fullscreenChanged( new_val.b_bool );
+    emit p_fs->fullscreenChanged( new_val.b_bool );
 
     return VLC_SUCCESS;
 }
@@ -1278,4 +1252,3 @@ void FullscreenControllerWidget::mouseChanged( vout_thread_t *, int i_mousex, in
         QApplication::postEvent( this, eHide );
     }
 }
-
diff --git a/modules/gui/qt/components/controller.hpp b/modules/gui/qt/components/controller.hpp
index 03ac9a3637..eb94f1ab9c 100644
--- a/modules/gui/qt/components/controller.hpp
+++ b/modules/gui/qt/components/controller.hpp
@@ -32,6 +32,7 @@
 #include <QFrame>
 #include <QString>
 #include <QSizeGrip>
+#include "components/player_controler.hpp"
 
 #define MAIN_TB1_DEFAULT "64;39;64;38;65"
 #define MAIN_TB2_DEFAULT "0-2;64;3;1;4;64;7;9;64;10;20;19;64-4;37;65;35-4"
@@ -156,7 +157,6 @@ public:
 protected:
     intf_thread_t       *p_intf;
 
-    QSignalMapper       *toolbarActionsMapper;
     QBoxLayout          *controlLayout;
     /* Change to BoxLayout if both dir are needed */
 
@@ -176,12 +176,15 @@ private:
 
     QHBoxLayout         *buttonGroupLayout;
 protected slots:
-    virtual void setStatus( int );
+    virtual void setStatus( PlayerControler::PlayingState );
+
+    void playAction();
+    void playlistAction();
+    void fullwidthAction();
 
 signals:
     void inputExists( bool ); /// This might be useful in the IM ?
     void inputPlaying( bool ); /// This might be useful in the IM ?
-    void inputIsRecordable( bool ); /// same ?
     void inputIsTrickPlayable( bool ); /// same ?
 };
 
diff --git a/modules/gui/qt/components/controller_widget.cpp b/modules/gui/qt/components/controller_widget.cpp
index 647c035d35..2ea9182280 100644
--- a/modules/gui/qt/components/controller_widget.cpp
+++ b/modules/gui/qt/components/controller_widget.cpp
@@ -27,9 +27,11 @@
 #include "controller_widget.hpp"
 #include "controller.hpp"
 
-#include "input_manager.hpp"         /* Get notification of Volume Change */
+#include "components/playlist/playlist_controler.hpp"
+#include "components/player_controler.hpp"         /* Get notification of Volume Change */
 #include "util/input_slider.hpp"     /* SoundSlider */
 #include "util/imagehelper.hpp"
+#include "vlc_player.h"
 
 #include <math.h>
 
@@ -41,6 +43,8 @@
 
 #define VOLUME_MAX 125
 
+using namespace vlc::playlist;
+
 SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
                           bool b_shiny, bool b_special )
                          : QWidget( _parent ), p_intf( _p_intf),
@@ -110,10 +114,11 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
         layout->addWidget( volumeSlider, 0, b_shiny? Qt::AlignBottom : Qt::AlignCenter );
 
     /* Set the volume from the config */
-    float volume = playlist_VolumeGet( THEPL );
+    float volume = THEMIM->getVolume();
+
     libUpdateVolume( (volume >= 0.f) ? volume : 1.f );
     /* Sync mute status */
-    if( playlist_MuteGet( THEPL ) > 0 )
+    if( THEMIM->isMuted() )
         updateMuteStatus( true );
 
     /* Volume control connection */
@@ -154,7 +159,7 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
 {
     /* Only if volume is set by user action on slider */
     setMuted( false );
-    playlist_VolumeSet( THEPL, i_sliderVolume / 100.f );
+    THEMIM->setVolume( i_sliderVolume / 100.f );
     refreshLabels();
 }
 
@@ -198,8 +203,7 @@ void SoundWidget::showVolumeMenu( QPoint pos )
 void SoundWidget::setMuted( bool mute )
 {
     b_is_muted = mute;
-    playlist_t *p_playlist = THEPL;
-    playlist_MuteSet( p_playlist, mute );
+    THEMIM->setMuted(mute);
 }
 
 bool SoundWidget::eventFilter( QObject *obj, QEvent *e )
@@ -236,74 +240,83 @@ void PlayButton::updateButtonIcons( bool b_playing )
                           : qtr( I_PLAY_TOOLTIP ) );
 }
 
-void AtoB_Button::updateButtonIcons( bool timeA, bool timeB )
+void AtoB_Button::updateButtonIcons( PlayerControler::ABLoopState state )
 {
-    if( !timeA && !timeB)
+    switch( state)
     {
+    case PlayerControler::ABLOOP_STATE_NONE:
         setIcon( QIcon( ":/toolbar/atob_nob.svg" ) );
         setToolTip( qtr( "Loop from point A to point B continuously\n"
                          "Click to set point A" ) );
-    }
-    else if( timeA && !timeB )
-    {
+        break;
+    case PlayerControler::ABLOOP_STATE_A:
         setIcon( QIcon( ":/toolbar/atob_noa.svg" ) );
         setToolTip( qtr( "Click to set point B" ) );
-    }
-    else if( timeA && timeB )
-    {
+        break;
+    case PlayerControler::ABLOOP_STATE_B:
         setIcon( QIcon( ":/toolbar/atob.svg" ) );
         setToolTip( qtr( "Stop the A to B loop" ) );
+        break;
     }
 }
 
-void LoopButton::updateButtonIcons( int value )
+void LoopButton::updateButtonIcons( PlaylistControlerModel::PlaybackRepeat value )
 {
-    setChecked( value != NORMAL );
-    setIcon( ( value == REPEAT_ONE ) ? QIcon( ":/buttons/playlist/repeat_one.svg" )
+    setChecked( value != PlaylistControlerModel::PLAYBACK_REPEAT_NONE );
+    setIcon( ( value == PlaylistControlerModel::PLAYBACK_REPEAT_CURRENT ) ? QIcon( ":/buttons/playlist/repeat_one.svg" )
                                      : QIcon( ":/buttons/playlist/repeat_all.svg" ) );
 }
 
-void AspectRatioComboBox::updateRatios()
+void AspectRatioComboBox::onRowInserted(const QModelIndex &, int first, int last)
 {
-    /* Clear the list before updating */
-    clear();
-    vlc_value_t *val_list;
-    char **text_list;
-    size_t count;
+    for (int i = first; i <= last; i++)
+    {
+        QModelIndex index = m_aspectRatioModel->index(i);
+        addItem(m_aspectRatioModel->data(index, Qt::DisplayRole).toString());
+        if (m_aspectRatioModel->data(index, Qt::CheckStateRole).toBool())
+            setCurrentIndex(i);
+    }
+}
+
+void AspectRatioComboBox::onRowRemoved(const QModelIndex &, int first, int last)
+{
+    for (int i = last; i >= first; i--)
+        removeItem(i);
+}
 
-    vout_thread_t* p_vout = THEMIM->getVout();
+void AspectRatioComboBox::onModelAboutToReset()
+{
+    clear();
+}
 
-    /* Disable if there is no vout */
-    if( p_vout == NULL )
+void AspectRatioComboBox::onModelReset()
+{
+    if (m_aspectRatioModel->rowCount() == 0)
     {
+        setEnabled(false);
         addItem( qtr("Aspect Ratio") );
-        setDisabled( true );
-        return;
     }
-
-    var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
-                &count, &val_list, &text_list );
-    for( size_t i = 0; i < count; i++ )
+    else
     {
-        addItem( qfu( text_list[i] ),
-                 QString( val_list[i].psz_string ) );
-        free(text_list[i]);
-        free(val_list[i].psz_string);
+        setEnabled(true);
+        for (int i = 0; i < m_aspectRatioModel->rowCount(); i++)
+            addItem(m_aspectRatioModel->data(m_aspectRatioModel->index(i), Qt::DisplayRole).toString());
     }
-    setEnabled( true );
-    free(text_list);
-    free(val_list);
-    vlc_object_release( p_vout );
 }
 
-void AspectRatioComboBox::updateAspectRatio( int x )
+void AspectRatioComboBox::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &)
 {
-    vout_thread_t* p_vout = THEMIM->getVout();
-    if( p_vout && x >= 0 )
+    for (int i = topLeft.row(); i <= bottomRight.row(); i++)
     {
-        var_SetString( p_vout, "aspect-ratio", qtu( itemData(x).toString() ) );
+        QModelIndex index=  m_aspectRatioModel->index(i);
+        setItemText(i, m_aspectRatioModel->data(index, Qt::DisplayRole).toString());
+        if (m_aspectRatioModel->data(index, Qt::CheckStateRole).toBool())
+            setCurrentIndex(i);
     }
-    if( p_vout )
-        vlc_object_release( p_vout );
 }
 
+void AspectRatioComboBox::updateAspectRatio( int x )
+{
+    QModelIndex index = m_aspectRatioModel->index(x);
+    m_aspectRatioModel->setData(index, true, Qt::CheckStateRole);
+}
diff --git a/modules/gui/qt/components/controller_widget.hpp b/modules/gui/qt/components/controller_widget.hpp
index 4ebd653f5c..6e9040ba76 100644
--- a/modules/gui/qt/components/controller_widget.hpp
+++ b/modules/gui/qt/components/controller_widget.hpp
@@ -28,7 +28,8 @@
 #endif
 
 #include "qt.hpp"
-#include "input_manager.hpp"
+#include "components/player_controler.hpp"
+#include "components/playlist/playlist_controler.hpp"
 
 #include <QWidget>
 #include <QToolButton>
@@ -57,35 +58,46 @@ class LoopButton : public QToolButton
 {
     Q_OBJECT
 public slots:
-    void updateButtonIcons( int );
+    void updateButtonIcons( vlc::playlist::PlaylistControlerModel::PlaybackRepeat );
 };
 
 class AtoB_Button : public QToolButton
 {
     Q_OBJECT
-private slots:
-    void updateButtonIcons( bool, bool );
+public slots:
+    void updateButtonIcons( PlayerControler::ABLoopState state );
 };
 
 class AspectRatioComboBox : public QComboBox
 {
     Q_OBJECT
 public:
-    AspectRatioComboBox( intf_thread_t* _p_intf ) : p_intf( _p_intf )
+    AspectRatioComboBox( intf_thread_t* _p_intf, QAbstractListModel* model )
+        : p_intf( _p_intf )
+        , m_aspectRatioModel(model)
     {
-        CONNECT( THEMIM->getIM(), voutChanged( bool ),
-                 this, updateRatios() );
-        CONNECT( this, currentIndexChanged( int ),
-                 this, updateAspectRatio( int ) );
-        updateRatios();
+        connect( model, &QAbstractListModel::rowsInserted, this, &AspectRatioComboBox::onRowInserted );
+        connect( model, &QAbstractListModel::rowsRemoved, this, &AspectRatioComboBox::onRowRemoved );
+        connect( model, &QAbstractListModel::modelAboutToBeReset, this, &AspectRatioComboBox::onModelAboutToReset);
+        connect( model, &QAbstractListModel::modelReset, this, &AspectRatioComboBox::onModelReset);
+        connect( model, &QAbstractListModel::dataChanged, this, &AspectRatioComboBox::onDataChanged);
+        connect( this,QOverload<int>::of(&AspectRatioComboBox::currentIndexChanged), this, &AspectRatioComboBox::updateAspectRatio );
+
+        onModelReset();
     }
 
 public slots:
-    void updateRatios();
+    void onRowInserted(const QModelIndex &parent, int first, int last);
+    void onRowRemoved(const QModelIndex &parent, int first, int last);
+    void onModelAboutToReset();
+    void onModelReset();
+    void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
+
     void updateAspectRatio( int );
 
 private:
     intf_thread_t* p_intf;
+    QAbstractListModel* m_aspectRatioModel;
 };
 
 class SoundWidget : public QWidget
-- 
2.19.1



More information about the vlc-devel mailing list