[vlc-commits] [Git][videolan/vlc][master] qt: remove AudioDevice menu specific code

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Oct 15 04:42:45 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
caf31863 by Pierre Lamot at 2024-10-15T04:27:46+00:00
qt: remove AudioDevice menu specific code

Audio devices are exposed as a QAbstractListModel in the player and provide all
the necessary functionnality from there. We can use this directly to create the menu

- - - - -


4 changed files:

- modules/gui/qt/menus/menus.cpp
- modules/gui/qt/menus/menus.hpp
- modules/gui/qt/player/player_controller.cpp
- modules/gui/qt/player/player_controller.hpp


Changes:

=====================================
modules/gui/qt/menus/menus.cpp
=====================================
@@ -423,13 +423,7 @@ void VLCMenuBar::AudioMenu( qt_intf_t *p_intf, QMenu * current )
     {
         current->addMenu(new CheckableListMenu(qtr( "Audio &Track" ), THEMIM->getAudioTracks(), QActionGroup::ExclusionPolicy::ExclusiveOptional, current));
 
-        QAction *audioDeviceAction = new QAction( qtr( "&Audio Device" ), current );
-        QMenu *audioDeviceSubmenu = new QMenu( current );
-        audioDeviceAction->setMenu( audioDeviceSubmenu );
-        current->addAction( audioDeviceAction );
-        connect(audioDeviceSubmenu, &QMenu::aboutToShow, [=]() {
-            updateAudioDevice( p_intf, audioDeviceSubmenu );
-        });
+        current->addMenu(new CheckableListMenu(qtr( "&Audio Device" ), THEMIM->getAudioDevices(), QActionGroup::ExclusionPolicy::Exclusive, current));
 
         VLCVarChoiceModel *mix_mode = THEMIM->getAudioMixMode();
         if (mix_mode->rowCount() == 0)
@@ -879,50 +873,3 @@ QMenu* VLCMenuBar::PopupMenu( qt_intf_t *p_intf, bool show )
         menu->popup( QCursor::pos() );
     return menu;
 }
-
-
-/*****************************************************************************
- * Private methods.
- *****************************************************************************/
-
-void VLCMenuBar::updateAudioDevice( qt_intf_t * p_intf, QMenu *current )
-{
-    char **ids, **names;
-    char *selected;
-
-    if( !current )
-        return;
-
-    current->clear();
-    SharedAOut aout = THEMIM->getAout();
-    if (!aout)
-        return;
-
-    int i_result = aout_DevicesList( aout.get(), &ids, &names);
-    if( i_result < 0 )
-        return;
-
-    selected = aout_DeviceGet( aout.get() );
-
-    QActionGroup *actionGroup = new QActionGroup(current);
-    QAction *action;
-
-    for( int i = 0; i < i_result; i++ )
-    {
-        action = new QAction( qfue( names[i] ), actionGroup );
-        action->setData( qfu(ids[i]) );
-        action->setCheckable( true );
-        if( (selected && !strcmp( ids[i], selected ) ) ||
-            (selected == NULL && ids[i] && ids[i][0] == '\0' ) )
-            action->setChecked( true );
-        actionGroup->addAction( action );
-        current->addAction( action );
-        connect(action, &QAction::triggered, THEMIM->menusAudioMapper, QOverload<>::of(&QSignalMapper::map));
-        THEMIM->menusAudioMapper->setMapping(action, ids[i]);
-        free( ids[i] );
-        free( names[i] );
-    }
-    free( ids );
-    free( names );
-    free( selected );
-}


=====================================
modules/gui/qt/menus/menus.hpp
=====================================
@@ -105,10 +105,7 @@ public:
 
     static void VolumeEntries( qt_intf_t *p_intf, QMenu *current );
 
-    /* recentMRL menu */
     static RendererMenu *rendererMenu;
-
-    static void updateAudioDevice(qt_intf_t *, QMenu* );
 };
 
 #endif


=====================================
modules/gui/qt/player/player_controller.cpp
=====================================
@@ -1169,10 +1169,6 @@ PlayerController::PlayerController( qt_intf_t *_p_intf )
     : QObject(NULL)
     , d_ptr( new PlayerControllerPrivate(this, _p_intf) )
 {
-    /* Audio Menu */
-    menusAudioMapper = new QSignalMapper(this);
-    connect( menusAudioMapper, &QSignalMapper::mappedString,
-             this, &PlayerController::menusUpdateAudio );
     connect( &d_ptr->m_position_timer, &QTimer::timeout, this, &PlayerController::updatePositionFromTimer );
     connect( &d_ptr->m_time_timer, &QTimer::timeout, this, &PlayerController::updateTimeFromTimer );
 }
@@ -1744,14 +1740,6 @@ bool PlayerController::hasAudioVisualization() const
     return d->m_audioVisualization.hasCurrent();
 }
 
-
-void PlayerController::menusUpdateAudio( const QString& data )
-{
-    SharedAOut aout = getAout();
-    if( aout )
-        aout_DeviceSet( aout.get(), qtu(data) );
-}
-
 void PlayerController::updatePosition()
 {
     Q_D(PlayerController);


=====================================
modules/gui/qt/player/player_controller.hpp
=====================================
@@ -77,7 +77,6 @@ class PlayerControllerPrivate;
 class PlayerController : public QObject
 {
     Q_OBJECT
-    friend class VLCMenuBar;
 
 public:
     enum ABLoopState {
@@ -483,13 +482,9 @@ signals:
     // Program Event changes
     void epgChanged();
 
-private slots:
-    void menusUpdateAudio( const QString& );
-
 private:
     Q_DECLARE_PRIVATE(PlayerController)
     QScopedPointer<PlayerControllerPrivate> d_ptr;
-    QSignalMapper *menusAudioMapper; //used by VLCMenuBar
 };
 
 #endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/caf318633b4da208843cf1ea8aa2980764e7bc60

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/caf318633b4da208843cf1ea8aa2980764e7bc60
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list