[vlc-commits] Qt: improve title display
Jean-Baptiste Kempf
git at videolan.org
Sun Apr 24 01:12:23 CEST 2011
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Apr 24 01:12:00 2011 +0200| [7658d8e485ffeec59c921909ded95b6c0f294a63] | committer: Jean-Baptiste Kempf
Qt: improve title display
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7658d8e485ffeec59c921909ded95b6c0f294a63
---
modules/gui/qt4/input_manager.cpp | 20 ++++++-----
src/libvlc-module.c | 2 +-
src/text/strings.c | 65 ++++++++++++++++++-------------------
3 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 4cadb2f..6acb687 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -456,29 +456,31 @@ void InputManager::UpdateRate()
void InputManager::UpdateName()
{
/* Update text, name and nowplaying */
- QString text;
+ QString name;
/* Try to get the nowplaying */
char *format = var_InheritString( p_intf, "input-title-format" );
char *formated = str_format_meta( p_input, format );
- text = formated;
+ name = formated;
/* Free everything */
free( format );
free( formated );
/* If we have Nothing */
- if( text.isEmpty() )
+ if( name.isEmpty() )
{
- char *psz_name = input_item_GetURI( input_GetItem( p_input ) );
- text.sprintf( "%s", psz_name );
- text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 );
+ char *psz_name = make_path( input_item_GetURI( input_GetItem( p_input ) ) );
+ name = psz_name;
+ name = name.remove( 0, name.lastIndexOf( DIR_SEP ) + 1 );
free( psz_name );
}
- if( oldName != text )
+ name = name.trimmed();
+
+ if( oldName != name )
{
- emit nameChanged( text );
- oldName = text;
+ emit nameChanged( name );
+ oldName = name;
}
}
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index a666db7..a347e6a 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1958,7 +1958,7 @@ vlc_module_begin ()
add_integer( "input-timeshift-granularity", -1, INPUT_TIMESHIFT_GRANULARITY_TEXT,
INPUT_TIMESHIFT_GRANULARITY_LONGTEXT, true )
- add_string( "input-title-format", "$a - $t", INPUT_TITLE_FORMAT_TEXT, INPUT_TITLE_FORMAT_LONGTEXT, false );
+ add_string( "input-title-format", "$Z", INPUT_TITLE_FORMAT_TEXT, INPUT_TITLE_FORMAT_LONGTEXT, false );
/* Decoder options */
add_category_hint( N_("Decoders"), CODEC_CAT_LONGTEXT , true )
diff --git a/src/text/strings.c b/src/text/strings.c
index 829a142..48f6c71 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -618,11 +618,6 @@ static void format_duration (char *buf, size_t len, int64_t duration)
d += len; \
free( string ); \
} \
- else if( !b_empty_if_na ) \
- { \
- *(dst+d) = '-'; \
- d++; \
- } \
/* same than INSERT_STRING, except that string won't be freed */
#define INSERT_STRING_NO_FREE( string ) \
@@ -730,15 +725,15 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
}
break;
case 's':
- {
- char *lang = NULL;
- if( p_input )
- lang = var_GetNonEmptyString( p_input, "sub-language" );
- if( lang == NULL )
- lang = strdup( b_empty_if_na ? "" : "-" );
- INSERT_STRING( lang );
- break;
- }
+ {
+ char *lang = NULL;
+ if( p_input )
+ lang = var_GetNonEmptyString( p_input, "sub-language" );
+ if( lang == NULL )
+ lang = strdup( b_empty_if_na ? "" : "-" );
+ INSERT_STRING( lang );
+ break;
+ }
case 't':
if( p_item )
{
@@ -822,16 +817,16 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
}
break;
case 'O':
- {
- char *lang = NULL;
- if( p_input )
- lang = var_GetNonEmptyString( p_input,
- "audio-language" );
- if( lang == NULL )
- lang = strdup( b_empty_if_na ? "" : "-" );
- INSERT_STRING( lang );
- break;
- }
+ {
+ char *lang = NULL;
+ if( p_input )
+ lang = var_GetNonEmptyString( p_input,
+ "audio-language" );
+ if( lang == NULL )
+ lang = strdup( b_empty_if_na ? "" : "-" );
+ INSERT_STRING( lang );
+ break;
+ }
case 'P':
if( p_input )
{
@@ -871,7 +866,7 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
format_duration( buf, sizeof(buf), i_time );
}
else
- strcpy( buf, b_empty_if_na ? "" : "--:--:--" );
+ strcpy( buf, b_empty_if_na ? "" : "--:--:--" );
INSERT_STRING_NO_FREE( buf );
break;
case 'U':
@@ -881,12 +876,12 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
}
break;
case 'V':
- {
- audio_volume_t volume = aout_VolumeGet( p_object );
- snprintf( buf, 10, "%d", volume );
- INSERT_STRING_NO_FREE( buf );
- break;
- }
+ {
+ audio_volume_t volume = aout_VolumeGet( p_object );
+ snprintf( buf, 10, "%d", volume );
+ INSERT_STRING_NO_FREE( buf );
+ break;
+ }
case '_':
*(dst+d) = '\n';
d++;
@@ -897,8 +892,12 @@ char *str_format_meta( vlc_object_t *p_object, const char *string )
char *now_playing = input_item_GetNowPlaying( p_item );
if ( now_playing == NULL )
{
- INSERT_STRING( input_item_GetTitle( p_item ) );
- INSERT_STRING_NO_FREE( " - " );
+ char *temp = input_item_GetTitle( p_item );
+ if( !EMPTY_STR( temp ) )
+ {
+ INSERT_STRING( temp );
+ INSERT_STRING_NO_FREE( " - " );
+ }
INSERT_STRING( input_item_GetArtist( p_item ) );
}
else
More information about the vlc-commits
mailing list