Commit 35733acc authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: adapt menus to new Audio Device list

parent c957debc
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QApplication> #include <QApplication>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QSignalMapper>
#include <assert.h> #include <assert.h>
...@@ -999,6 +1000,10 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) ...@@ -999,6 +1000,10 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
p_input = playlist_CurrentInput( pl_Get(p_intf) ); p_input = playlist_CurrentInput( pl_Get(p_intf) );
if( p_input ) if( p_input )
emit inputChanged( p_input ); emit inputChanged( p_input );
/* Audio Menu */
menusAudioMapper = new QSignalMapper();
CONNECT( menusAudioMapper, mapped(QString), this, menusUpdateAudio( QString ) );
} }
MainInputManager::~MainInputManager() MainInputManager::~MainInputManager()
...@@ -1015,6 +1020,8 @@ MainInputManager::~MainInputManager() ...@@ -1015,6 +1020,8 @@ MainInputManager::~MainInputManager()
var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this ); var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this ); var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
delete menusAudioMapper;
} }
vout_thread_t* MainInputManager::getVout() vout_thread_t* MainInputManager::getVout()
...@@ -1218,6 +1225,12 @@ void MainInputManager::notifyMute( bool mute ) ...@@ -1218,6 +1225,12 @@ void MainInputManager::notifyMute( bool mute )
emit soundMuteChanged(mute); emit soundMuteChanged(mute);
} }
void MainInputManager::menusUpdateAudio( const QString& data )
{
aout_DeviceSet( getAout(), qtu(data) );
}
static int PLItemAppended static int PLItemAppended
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data ) ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{ {
...@@ -1231,6 +1244,7 @@ static int PLItemAppended ...@@ -1231,6 +1244,7 @@ static int PLItemAppended
QApplication::postEvent( mim, event ); QApplication::postEvent( mim, event );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int PLItemRemoved static int PLItemRemoved
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data ) ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{ {
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <QObject> #include <QObject>
#include <QEvent> #include <QEvent>
class QSignalMapper;
enum { NORMAL, /* loop: 0, repeat: 0 */ enum { NORMAL, /* loop: 0, repeat: 0 */
REPEAT_ONE,/* loop: 0, repeat: 1 */ REPEAT_ONE,/* loop: 0, repeat: 1 */
...@@ -253,6 +254,7 @@ class MainInputManager : public QObject, public Singleton<MainInputManager> ...@@ -253,6 +254,7 @@ class MainInputManager : public QObject, public Singleton<MainInputManager>
{ {
Q_OBJECT Q_OBJECT
friend class Singleton<MainInputManager>; friend class Singleton<MainInputManager>;
friend class VLCMenuBar;
public: public:
input_thread_t *getInput() { return p_input; } input_thread_t *getInput() { return p_input; }
...@@ -270,6 +272,9 @@ public: ...@@ -270,6 +272,9 @@ public:
void requestVoutUpdate() { return im->UpdateVout(); } void requestVoutUpdate() { return im->UpdateVout(); }
protected:
QSignalMapper *menusAudioMapper;
private: private:
MainInputManager( intf_thread_t * ); MainInputManager( intf_thread_t * );
virtual ~MainInputManager(); virtual ~MainInputManager();
...@@ -301,6 +306,7 @@ private slots: ...@@ -301,6 +306,7 @@ private slots:
void notifyRepeatLoop( bool ); void notifyRepeatLoop( bool );
void notifyVolume( float ); void notifyVolume( float );
void notifyMute( bool ); void notifyMute( bool );
void menusUpdateAudio( const QString& );
signals: signals:
void inputChanged( input_thread_t * ); void inputChanged( input_thread_t * );
......
...@@ -82,6 +82,7 @@ enum ...@@ -82,6 +82,7 @@ enum
static QActionGroup *currentGroup; static QActionGroup *currentGroup;
QMenu *VLCMenuBar::recentsMenu = NULL; QMenu *VLCMenuBar::recentsMenu = NULL;
QMenu *VLCMenuBar::audioDeviceMenu = NULL;
/** /**
* @brief Add static entries to DP in menus * @brief Add static entries to DP in menus
...@@ -255,7 +256,6 @@ static int AudioAutoMenuBuilder( audio_output_t *p_object, ...@@ -255,7 +256,6 @@ static int AudioAutoMenuBuilder( audio_output_t *p_object,
{ {
PUSH_INPUTVAR( "audio-es" ); PUSH_INPUTVAR( "audio-es" );
PUSH_VAR( "stereo-mode" ); PUSH_VAR( "stereo-mode" );
PUSH_VAR( "device" );
PUSH_VAR( "visual" ); PUSH_VAR( "visual" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -593,8 +593,8 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current ) ...@@ -593,8 +593,8 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
if( current->isEmpty() ) if( current->isEmpty() )
{ {
addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) ); addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
audioDeviceMenu = current->addMenu( qtr( "Audio &Device" ) );
addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) ); addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) );
addActionWithSubmenu( current, "device", qtr( "Audio &Device" ) );
current->addSeparator(); current->addSeparator();
addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) ); addActionWithSubmenu( current, "visual", qtr( "&Visualizations" ) );
...@@ -605,6 +605,7 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current ) ...@@ -605,6 +605,7 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
p_aout = THEMIM->getAout(); p_aout = THEMIM->getAout();
EnableStaticEntries( current, ( p_aout != NULL ) ); EnableStaticEntries( current, ( p_aout != NULL ) );
AudioAutoMenuBuilder( p_aout, p_input, objects, varnames ); AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
updateAudioDevice( p_intf, p_aout, audioDeviceMenu );
if( p_aout ) if( p_aout )
{ {
vlc_object_release( p_aout ); vlc_object_release( p_aout );
...@@ -1524,6 +1525,39 @@ void VLCMenuBar::DoAction( QObject *data ) ...@@ -1524,6 +1525,39 @@ void VLCMenuBar::DoAction( QObject *data )
var_Set( p_object, var, val ); var_Set( p_object, var, val );
} }
void VLCMenuBar::updateAudioDevice( intf_thread_t * p_intf, audio_output_t *p_aout, QMenu *current )
{
char **ids, **names;
char *selected;
if( !p_aout )
return;
current->clear();
int i_result = aout_DevicesList( p_aout, &ids, &names);
selected = aout_DeviceGet( p_aout );
QActionGroup *actionGroup = new QActionGroup(current);
QAction *action;
for( int i = 0; i < i_result; i++ )
{
action = new QAction( qfu( names[i] ), NULL );
action->setData( ids[i] );
action->setCheckable( true );
if( selected && !strcmp( ids[i], selected ) )
action->setChecked( true );
actionGroup->addAction( action );
current->addAction( action );
CONNECT(action, changed(), THEMIM->menusAudioMapper, map());
THEMIM->menusAudioMapper->setMapping(action, ids[i]);
free( ids[i] );
free( names[i] );
}
free( ids );
free( names );
}
void VLCMenuBar::updateRecents( intf_thread_t *p_intf ) void VLCMenuBar::updateRecents( intf_thread_t *p_intf )
{ {
if( recentsMenu ) if( recentsMenu )
......
...@@ -153,7 +153,9 @@ private: ...@@ -153,7 +153,9 @@ private:
static void EnableStaticEntries( QMenu *, bool ); static void EnableStaticEntries( QMenu *, bool );
/* recentMRL menu */ /* recentMRL menu */
static QMenu *recentsMenu; static QMenu *recentsMenu, *audioDeviceMenu;
static void updateAudioDevice( intf_thread_t *, audio_output_t *, QMenu* );
public slots: public slots:
static void updateRecents( intf_thread_t * ); static void updateRecents( intf_thread_t * );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment