Commit 511888ee authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Show OSD when drag-n-dropping subtitles

And when it was successfully added

Close #8395
parent da84acd0
......@@ -36,6 +36,7 @@
#include <vlc_epg.h>
#include <vlc_events.h>
#include <vlc_input_item.h>
#include <vlc_vout_osd.h>
#include <string.h>
......@@ -526,14 +527,6 @@ static inline input_state_e input_GetState( input_thread_t * p_input )
input_Control( p_input, INPUT_GET_STATE, &state );
return state;
}
/**
* It will add a new subtitle source to the input.
* Provided for convenience.
*/
static inline int input_AddSubtitle( input_thread_t *p_input, const char *psz_url, bool b_check_extension )
{
return input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
}
/**
* Return one of the video output (if any). If possible, you should use
......@@ -558,6 +551,28 @@ static inline vout_thread_t *input_GetVout( input_thread_t *p_input )
return p_vout;
}
/**
* It will add a new subtitle source to the input.
* Provided for convenience.
*/
static inline int input_AddSubtitleOSD( input_thread_t *p_input, const char *psz_url,
bool b_check_extension, bool b_osd )
{
int i_result = input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
if( i_result != VLC_SUCCESS || !b_osd )
return i_result;
vout_thread_t *p_vout = input_GetVout( p_input );
if( p_vout )
{
vout_OSDMessage(p_vout, SPU_DEFAULT_CHANNEL, _("Subtitle track added") );
vlc_object_release( (vlc_object_t *)p_vout );
}
return i_result;
}
#define input_AddSubtitle(a, b, c) input_AddSubtitleOSD(a, b, c, false)
/**
* Return the audio output (if any) associated with an input.
* @param p_input an input thread
......
......@@ -576,7 +576,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
BOOL b_returned = NO;
if (count == 1 && p_input) {
b_returned = input_AddSubtitle(p_input, [[o_values objectAtIndex:0] UTF8String], true);
b_returned = input_AddSubtitleOSD(p_input, [[o_values objectAtIndex:0] UTF8String], true, true);
vlc_object_release(p_input);
if (!b_returned)
return YES;
......
......@@ -1046,7 +1046,7 @@ static VLCMain *_o_sharedMainInstance = nil;
input_thread_t * p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
BOOL b_returned = NO;
b_returned = input_AddSubtitle(p_input, [[o_names objectAtIndex:0] UTF8String], true);
b_returned = input_AddSubtitleOSD(p_input, [[o_names objectAtIndex:0] UTF8String], true, true);
vlc_object_release(p_input);
if (!b_returned) {
free(psz_uri);
......
......@@ -1597,7 +1597,7 @@
BOOL b_returned = NO;
if (count == 1 && p_input) {
b_returned = input_AddSubtitle(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true);
b_returned = input_AddSubtitleOSD(p_input, vlc_path2uri([[o_values objectAtIndex:0] UTF8String], NULL), true, true);
vlc_object_release(p_input);
if (!b_returned)
return YES;
......
......@@ -781,8 +781,8 @@ void DialogsProvider::loadSubtitlesFile()
free( path2 );
foreach( const QString &qsFile, qsl )
{
if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
true ) )
if( input_AddSubtitleOSD( p_input, qtu( toNativeSeparators( qsFile ) ),
true, true ) )
msg_Warn( p_intf, "unable to load subtitles from '%s'",
qtu( qsFile ) );
}
......
......@@ -1276,9 +1276,9 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play, bool b_playli
/* D&D of a subtitles file, add it on the fly */
if( mimeData->urls().count() == 1 && THEMIM->getIM()->hasInput() )
{
if( !input_AddSubtitle( THEMIM->getInput(),
if( !input_AddSubtitleOSD( THEMIM->getInput(),
qtu( toNativeSeparators( mimeData->urls()[0].toLocalFile() ) ),
true ) )
true, true ) )
{
event->accept();
return;
......
......@@ -288,7 +288,7 @@ void TopWindow::processEvent( EvtDragDrop &rEvtDragDrop )
char* psz_file = make_path( it->c_str() );
if( psz_file )
{
is_subtitle = !input_AddSubtitle( pInput, psz_file, true );
is_subtitle = !input_AddSubtitleOSD( pInput, psz_file, true, true );
free( psz_file );
}
}
......
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