Commit 83ad48a4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: partly fix volume display

parent b092d34b
......@@ -109,7 +109,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
layout->addWidget( volumeSlider, 0, Qt::AlignBottom );
/* Set the volume from the config */
libUpdateVolume();
float volume = aout_VolumeGet( THEPL );
libUpdateVolume( (volume >= 0.f) ? volume : 1.f );
/* Sync mute status */
if( aout_MuteGet( THEPL ) > 0 )
updateMuteStatus( true );
......@@ -118,7 +119,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
volumeSlider->setTracking( true );
CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) );
CONNECT( THEMIM, volumeChanged( float ), this, libUpdateVolume( float ) );
CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
}
......@@ -152,19 +153,15 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
{
/* Only if volume is set by user action on slider */
setMuted( false );
playlist_t *p_playlist = pl_Get( p_intf );
aout_VolumeSet( p_playlist, i_sliderVolume / 100.f );
aout_VolumeSet( THEPL, i_sliderVolume / 100.f );
refreshLabels();
}
/* libvlc changed value event slot */
void SoundWidget::libUpdateVolume()
void SoundWidget::libUpdateVolume( float volume )
{
/* Audio part */
playlist_t *p_playlist = pl_Get( p_intf );
long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f);
if ( i_volume - volumeSlider->value() != 0 )
long i_volume = lroundf(volume * 100.f);
if( i_volume != volumeSlider->value() )
{
b_ignore_valuechanged = true;
volumeSlider->setValue( i_volume );
......
......@@ -117,7 +117,7 @@ private:
protected slots:
void userUpdateVolume( int );
void libUpdateVolume( void );
void libUpdateVolume( float );
void updateMuteStatus( bool );
void refreshLabels( void );
void showVolumeMenu( QPoint pos );
......
......@@ -51,8 +51,6 @@ static int PLItemAppended( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int PLItemRemoved( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int VolumeChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
......@@ -945,7 +943,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
: QObject(NULL), p_intf( _p_intf ),
random( VLC_OBJECT(THEPL), "random" ),
repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" ),
mute( VLC_OBJECT(THEPL), "mute" )
volume( VLC_OBJECT(THEPL), "volume" ), mute( VLC_OBJECT(THEPL), "mute" )
{
p_input = NULL;
im = new InputManager( this, p_intf );
......@@ -960,7 +958,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
var_AddCallback( THEPL, "volume", VolumeChanged, this );
volume.addCallback( this, SLOT(notifyVolume(int)) );
mute.addCallback( this, SLOT(notifyMute(bool)) );
/* Warn our embedded IM about input changes */
......@@ -986,8 +984,6 @@ MainInputManager::~MainInputManager()
vlc_object_release( p_input );
}
var_DelCallback( THEPL, "volume", VolumeChanged, this );
var_DelCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "item-change", ItemChanged, im );
var_DelCallback( THEPL, "leaf-to-parent", LeafToParent, this );
......@@ -1016,9 +1012,6 @@ void MainInputManager::customEvent( QEvent *event )
// msg_Dbg( p_intf, "New MainIM Event of type: %i", type );
switch( type )
{
case VolumeChanged_Type:
emit volumeChanged();
return;
case PLItemAppended_Type:
plEv = static_cast<PLEvent*>( event );
emit playlistItemAppended( plEv->i_item, plEv->i_parent );
......@@ -1224,16 +1217,9 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
void MainInputManager::notifyVolume( int volume )
{
VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval );
MainInputManager *mim = (MainInputManager*)param;
IMEvent *event = new IMEvent( VolumeChanged_Type );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
emit volumeChanged( volume / (float)AOUT_VOLUME_DEFAULT );
}
void MainInputManager::notifyMute( bool mute )
......
......@@ -38,14 +38,12 @@
#include <QObject>
#include <QEvent>
enum {
PositionUpdate_Type = QEvent::User + IMEventType + 1,
ItemChanged_Type,
ItemStateChanged_Type,
ItemTitleChanged_Type,
ItemRateChanged_Type,
VolumeChanged_Type,
ItemEsChanged_Type,
ItemTeletextChanged_Type,
InterfaceVoutUpdate_Type,
......@@ -276,6 +274,7 @@ private:
input_thread_t *p_input;
intf_thread_t *p_intf;
QVLCBool random, repeat, loop;
QVLCInteger volume;
QVLCBool mute;
public slots:
......@@ -293,11 +292,12 @@ public slots:
private slots:
void notifyRandom( bool );
void notifyRepeatLoop( bool );
void notifyVolume( int );
void notifyMute( bool );
signals:
void inputChanged( input_thread_t * );
void volumeChanged();
void soundMuteChanged(bool);
void volumeChanged( float );
void soundMuteChanged( bool );
void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId );
void playlistNotEmpty( bool );
......
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