X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Finput_manager.cpp;h=ee16a914d36f1c4ac2ded11c6636a8eeb20400ad;hb=60e75ffe8f3643379916d86625203426854df5e5;hp=a41bb0b2048b8870ad71ac42fadf0e7703847390;hpb=4b44912ce0888ed40d35aa5d782cd17cbf7e9c6b;p=vlc diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp index a41bb0b204..ee16a914d3 100644 --- a/modules/gui/qt4/input_manager.cpp +++ b/modules/gui/qt4/input_manager.cpp @@ -39,6 +39,10 @@ static int ItemChanged( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ); static int PLItemChanged( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ); +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 * ); @@ -150,16 +154,12 @@ void InputManager::customEvent( QEvent *event ) int i_type = event->type(); IMEvent *ple = static_cast(event); + if( i_type == ItemChanged_Type ) + UpdateMeta( ple->p_item ); + if( !hasInput() ) return; -#ifndef NDEBUG - if( i_type != PositionUpdate_Type && - i_type != StatisticsUpdate_Type && - i_type != ItemChanged_Type ) - msg_Dbg( p_intf, "New Event: type %i", i_type ); -#endif - /* Actions */ switch( i_type ) { @@ -178,7 +178,6 @@ void InputManager::customEvent( QEvent *event ) UpdateArt(); /* Update duration of file */ } - UpdateMeta( ple->p_item->i_id ); break; case ItemStateChanged_Type: // TODO: Fusion with above state @@ -408,7 +407,7 @@ void InputManager::UpdateStatus() void InputManager::UpdateRate() { /* Update Rate */ - int i_new_rate = var_GetInteger( p_input, "rate"); + int i_new_rate = INPUT_RATE_DEFAULT / var_GetFloat( p_input, "rate" ); if( i_new_rate != i_rate ) { i_rate = i_new_rate; @@ -593,7 +592,11 @@ void InputManager::UpdateArt() char *psz_art = input_item_GetArtURL( input_GetItem( p_input ) ); if( psz_art && !strncmp( psz_art, "file://", 7 ) && decode_URI( psz_art + 7 ) ) - url = qfu( psz_art + 7); +#ifdef WIN32 + url = qfu( psz_art + 8 ); // Remove extra / starting on Win32. +#else + url = qfu( psz_art + 7 ); +#endif free( psz_art ); url = url.replace( "file://", "" ); @@ -610,9 +613,9 @@ inline void InputManager::UpdateStats() emit statisticsUpdated( input_GetItem( p_input ) ); } -inline void InputManager::UpdateMeta( int id ) +inline void InputManager::UpdateMeta( input_item_t *p_item ) { - emit metaChanged( id ); + emit metaChanged( p_item ); } inline void InputManager::UpdateMeta() @@ -666,8 +669,8 @@ void InputManager::sectionPrev() if( hasInput() ) { int i_type = var_Type( p_input, "next-chapter" ); - var_SetVoid( p_input, (i_type & VLC_VAR_TYPE) != 0 ? - "prev-chapter":"prev-title" ); + var_TriggerCallback( p_input, (i_type & VLC_VAR_TYPE) != 0 ? + "prev-chapter":"prev-title" ); } } @@ -676,8 +679,8 @@ void InputManager::sectionNext() if( hasInput() ) { int i_type = var_Type( p_input, "next-chapter" ); - var_SetVoid( p_input, (i_type & VLC_VAR_TYPE) != 0 ? - "next-chapter":"next-title" ); + var_TriggerCallback( p_input, (i_type & VLC_VAR_TYPE) != 0 ? + "next-chapter":"next-title" ); } } @@ -773,21 +776,21 @@ void InputManager::reverse() { if( hasInput() ) { - int i_rate = var_GetInteger( p_input, "rate" ); - var_SetInteger( p_input, "rate", -i_rate ); + float f_rate = var_GetFloat( p_input, "rate" ); + var_SetFloat( p_input, "rate", -f_rate ); } } void InputManager::slower() { if( hasInput() ) - var_SetVoid( p_input, "rate-slower" ); + var_TriggerCallback( p_input, "rate-slower" ); } void InputManager::faster() { if( hasInput() ) - var_SetVoid( p_input, "rate-faster" ); + var_TriggerCallback( p_input, "rate-faster" ); } void InputManager::littlefaster() @@ -803,13 +806,14 @@ void InputManager::littleslower() void InputManager::normalRate() { if( hasInput() ) - var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT ); + var_SetFloat( p_input, "rate", 1. ); } void InputManager::setRate( int new_rate ) { if( hasInput() ) - var_SetInteger( p_input, "rate", new_rate ); + var_SetFloat( p_input, "rate", + (float)INPUT_RATE_DEFAULT / (float)new_rate ); } void InputManager::jumpFwd() @@ -882,6 +886,8 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) var_AddCallback( THEPL, "item-change", ItemChanged, im ); var_AddCallback( THEPL, "item-current", PLItemChanged, this ); var_AddCallback( THEPL, "activity", PLItemChanged, this ); + var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this ); + var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this ); var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this ); @@ -919,6 +925,8 @@ MainInputManager::~MainInputManager() var_DelCallback( THEPL, "item-change", ItemChanged, im ); var_DelCallback( THEPL, "item-current", PLItemChanged, this ); + var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this ); + var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this ); } vout_thread_t* MainInputManager::getVout() @@ -934,14 +942,25 @@ aout_instance_t * MainInputManager::getAout() void MainInputManager::customEvent( QEvent *event ) { int type = event->type(); - if ( type != ItemChanged_Type && type != VolumeChanged_Type ) - return; + + PLEvent *plEv; // msg_Dbg( p_intf, "New MainIM Event of type: %i", type ); - if( type == VolumeChanged_Type ) + switch( type ) { + case VolumeChanged_Type: emit volumeChanged(); return; + case PLItemAppended_Type: + plEv = static_cast( event ); + emit playlistItemAppended( plEv->i_item, plEv->i_parent ); + return; + case PLItemRemoved_Type: + plEv = static_cast( event ); + emit playlistItemRemoved( plEv->i_item ); + return; + default: + if( type != ItemChanged_Type ) return; } /* Should be PLItemChanged Event */ @@ -1036,3 +1055,22 @@ static int VolumeChanged( vlc_object_t *p_this, const char *psz_var, return VLC_SUCCESS; } +static int PLItemAppended +( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data ) +{ + MainInputManager *mim = static_cast(data); + playlist_add_t *p_add = static_cast( cur.p_address ); + + PLEvent *event = new PLEvent( PLItemAppended_Type, p_add->i_item, p_add->i_node ); + QApplication::postEvent( mim, event ); + return VLC_SUCCESS; +} +static int PLItemRemoved +( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data ) +{ + MainInputManager *mim = static_cast(data); + + PLEvent *event = new PLEvent( PLItemRemoved_Type, cur.i_int, 0 ); + QApplication::postEvent( mim, event ); + return VLC_SUCCESS; +}