X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fcomponents%2Finfopanels.cpp;h=57a738a5e68fdb5642ff2d96bd6bbe0a1a3580ae;hb=6ee1e193fd896ab9a4729fde14f009d9ce629815;hp=40c6e365dbc71a855828d3771080aa8d2d77b5b1;hpb=88cc4a8a113f9eb1f6ba4992c51d66d12688ca58;p=vlc diff --git a/modules/gui/qt4/components/infopanels.cpp b/modules/gui/qt4/components/infopanels.cpp index 40c6e365db..57a738a5e6 100644 --- a/modules/gui/qt4/components/infopanels.cpp +++ b/modules/gui/qt4/components/infopanels.cpp @@ -49,16 +49,17 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) : QWidget( parent ), p_intf( _p_intf ) { - QGridLayout *l = new QGridLayout( this ); + QGridLayout *metaLayout = new QGridLayout( this ); + int line = 0; /* Counter for GridLayout */ p_input = NULL; #define ADD_META( string, widget ) { \ - l->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ + metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ widget = new QLineEdit; \ - l->addWidget( widget, line, 1, 1, 9 ); \ + metaLayout->addWidget( widget, line, 1, 1, 9 ); \ line++; } - + /* Title, artist and album*/ ADD_META( VLC_META_TITLE, title_text ); /* OK */ ADD_META( VLC_META_ARTIST, artist_text ); /* OK */ @@ -67,36 +68,35 @@ MetaPanel::MetaPanel( QWidget *parent, /* Genre Name */ /* FIXME List id3genres.h is not includable yet ? */ genre_text = new QLineEdit; - l->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 ); - l->addWidget( genre_text, line, 1, 1, 6 ); - - /* Date (Should be in years) */ - date_text = new QSpinBox; setSpinBounds( date_text ); - l->addWidget( new QLabel( qtr( VLC_META_DATE ) + " :" ), line, 7 ); - l->addWidget( date_text, line, 8, 1, 2 ); - line++; - - /* Number and Rating */ - l->addWidget( new QLabel( qtr( "Track number/Position" ) + " :" ), - line, 0 ); - seqnum_text = new QSpinBox; setSpinBounds( seqnum_text ); - l->addWidget( seqnum_text, line, 1, 1, 4 ); - - l->addWidget( new QLabel( qtr( VLC_META_RATING ) + " :" ), line, 5 ); - rating_text = new QSpinBox; setSpinBounds( rating_text) ; - l->addWidget( rating_text, line, 6, 1, 4 ); + metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 ); + metaLayout->addWidget( genre_text, line, 1, 1, 4 ); + + /* Number - on the same line */ + metaLayout->addWidget( new QLabel( qtr( "Track Number" ) + " :" ), + line, 5, 1, 2 ); + seqnum_text = new QLineEdit; + seqnum_text->setInputMask("0000"); + seqnum_text->setAlignment( Qt::AlignRight ); + metaLayout->addWidget( seqnum_text, line, 7, 1, 3 ); line++; - /* Now Playing ? */ - ADD_META( VLC_META_NOW_PLAYING, nowplaying_text ); - - /* Language and settings */ - l->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 0 ); + /* Date (Should be in years) */ + date_text = new QLineEdit; + date_text->setInputMask("0000"); + date_text->setAlignment( Qt::AlignRight ); + metaLayout->addWidget( new QLabel( qtr( VLC_META_DATE ) + " :" ), line, 0 ); + metaLayout->addWidget( date_text, line, 1, 1, 3 ); + + /* Rating - on the same line */ + metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) + " :" ), line, 4, 1, 2 ); + rating_text = new QSpinBox; setSpinBounds( rating_text ); + metaLayout->addWidget( rating_text, line, 6, 1, 1 ); + + /* Language on the same line */ + metaLayout->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 7, 1, 2 ); language_text = new QLineEdit; - l->addWidget( language_text, line, 1, 1, 4 ); - l->addWidget( new QLabel( qtr( VLC_META_SETTING ) + " :" ), line, 5 ); - setting_text = new QLineEdit; - l->addWidget( setting_text, line, 6, 1, 4 ); + language_text->setReadOnly( true ); + metaLayout->addWidget( language_text, line, 9, 1, 1 ); line++; /* ART_URL */ @@ -107,120 +107,61 @@ MetaPanel::MetaPanel( QWidget *parent, art_cover->setMaximumWidth( 128 ); art_cover->setScaledContents( true ); art_cover->setPixmap( QPixmap( ":/noart.png" ) ); - l->addWidget( art_cover, line, 8, 4, 2 ); + metaLayout->addWidget( art_cover, line, 8, 4, 2 ); + +/* Settings is unused */ +/* l->addWidget( new QLabel( qtr( VLC_META_SETTING ) + " :" ), line, 5 ); + setting_text = new QLineEdit; + l->addWidget( setting_text, line, 6, 1, 4 ); */ +/* Less used metadata */ #define ADD_META_2( string, widget ) { \ - l->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ + metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ widget = new QLineEdit; \ - l->addWidget( widget, line, 1, 1, 7 ); \ + metaLayout->addWidget( widget, line, 1, 1, 7 ); \ line++; } - - ADD_META_2( VLC_META_COPYRIGHT, copyright_text ); + + /* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */ + ADD_META_2( VLC_META_NOW_PLAYING, nowplaying_text ); + nowplaying_text->setReadOnly( true ); ADD_META_2( VLC_META_PUBLISHER, publisher_text ); + ADD_META_2( VLC_META_COPYRIGHT, copyright_text ); + ADD_META_2( "Comments", description_text ); - ADD_META_2( VLC_META_ENCODED_BY, publisher_text ); - ADD_META_2( VLC_META_DESCRIPTION, description_text ); +/* useless metadata */ + //ADD_META_2( VLC_META_ENCODED_BY, encodedby_text ); /* ADD_META( TRACKID ) Useless ? */ /* ADD_URI - DO not show it, done outside */ #undef ADD_META #undef ADD_META_2 - - CONNECT( title_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( description_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( artist_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( collection_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( genre_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( description_text, textEdited( QString ), this, editMeta( QString ) ); - CONNECT( date_text, valueChanged( QString ), this, editMeta( QString ) ); - CONNECT( seqnum_text, valueChanged( QString ), this, editMeta( QString ) ); - CONNECT( rating_text, valueChanged( QString ), this, editMeta( QString ) ); - in_edit = false; + CONNECT( title_text, textEdited( QString ), this, enterEditMode() ); + CONNECT( artist_text, textEdited( QString ), this, enterEditMode() ); + CONNECT( collection_text, textEdited( QString ), this, enterEditMode() ); + CONNECT( genre_text, textEdited( QString ), this, enterEditMode() ); + CONNECT( seqnum_text, textEdited( QString ), this, enterEditMode() ); + + CONNECT( date_text, textEdited( QString ), this, enterEditMode() ); + CONNECT( description_text, textEdited( QString ), this, enterEditMode() ); +/* CONNECT( rating_text, valueChanged( QString ), this, enterEditMode( QString ) );*/ + + /* We are not yet in Edit Mode */ + b_inEditMode = false; } MetaPanel::~MetaPanel(){} -/** - * Save the MetaData, triggered by parent->save Button - **/ -void MetaPanel::saveMeta() -{ - playlist_t *p_playlist; - char psz[5]; - - meta_export_t p_export; - p_export.p_item = p_input; - - if( p_input == NULL ) - return; - - /* we can write meta data only in a file */ - if( ( p_input->i_type == ITEM_TYPE_AFILE ) || \ - ( p_input->i_type == ITEM_TYPE_VFILE ) ) - /* some audio files are detected as video files */ - { - char *psz_uri = p_input->psz_uri; - if( !strncmp( psz_uri, "file://", 7 ) ) - psz_uri += 7; /* strlen("file://") = 7 */ - - p_export.psz_file = strndup( psz_uri, PATH_MAX ); - } - else - return; - - /* now we read the modified meta data */ - input_item_SetArtist( p_input, qtu( artist_text->text() ) ); - input_item_SetAlbum( p_input, qtu( collection_text->text() ) ); - input_item_SetGenre( p_input, qtu( genre_text->text() ) ); - - snprintf( psz, sizeof(psz), "%d", date_text->value() ); - input_item_SetDate( p_input, psz ); - - snprintf( psz, sizeof(psz), "%d", seqnum_text->value() ); - input_item_SetTrackNum( p_input, psz ); - - input_item_SetTitle( p_input, qtu( title_text->text() ) ); - - p_playlist = pl_Yield( p_intf ); - - PL_LOCK; - p_playlist->p_private = &p_export; - - module_t *p_mod = module_Need( p_playlist, "meta writer", NULL, 0 ); - if( p_mod ) - module_Unneed( p_playlist, p_mod ); - PL_UNLOCK; - pl_Release( p_playlist ); - in_edit = false; -} - -void MetaPanel::editMeta( QString edit ) -{ - in_edit = true; - emit editing(); -} - -void MetaPanel::setEdit( bool editing ) -{ - in_edit = editing; -} - -void MetaPanel::setInput( input_item_t *input ) -{ - if( in_edit ) return; - - p_input = input; -} - /** * Update all the MetaData and art on an "item-changed" event **/ void MetaPanel::update( input_item_t *p_item ) { - if( in_edit ) return; - char *psz_meta; + /* Don't update if you are in edit mode */ + if( b_inEditMode ) return; + + char *psz_meta; #define UPDATE_META( meta, widget ) { \ psz_meta = input_item_Get##meta( p_item ); \ if( !EMPTY_STR( psz_meta ) ) \ @@ -235,23 +176,31 @@ void MetaPanel::update( input_item_t *p_item ) widget->setValue( atoi( psz_meta ) ); } \ free( psz_meta ); - /* Name / Title */ psz_meta = input_item_GetTitle( p_item ); + char *psz_name = input_item_GetName( p_item ); if( !EMPTY_STR( psz_meta ) ) title_text->setText( qfu( psz_meta ) ); - else if( !EMPTY_STR( p_item->psz_name ) ) - title_text->setText( qfu( p_item->psz_name ) ); + else if( !EMPTY_STR( psz_name ) ) + title_text->setText( qfu( psz_name ) ); else title_text->setText( "" ); free( psz_meta ); + free( psz_name ); /* URL / URI */ psz_meta = input_item_GetURL( p_item ); if( !EMPTY_STR( psz_meta ) ) + { emit uriSet( QString( psz_meta ) ); - else if( !EMPTY_STR( p_item->psz_uri ) ) - emit uriSet( QString( p_item->psz_uri ) ); - free( psz_meta ); + free( psz_meta ); + } + else + { + free( psz_meta ); + psz_meta = input_item_GetURI( p_item ); + if( !EMPTY_STR( psz_meta ) ) + emit uriSet( QString( psz_meta ) ); + } /* Other classic though */ UPDATE_META( Artist, artist_text ); @@ -262,10 +211,11 @@ void MetaPanel::update( input_item_t *p_item ) UPDATE_META( Language, language_text ); UPDATE_META( NowPlaying, nowplaying_text ); UPDATE_META( Publisher, publisher_text ); - UPDATE_META( Setting, setting_text ); +// UPDATE_META( Setting, setting_text ); +// UPDATE_META( EncodedBy, encodedby_text ); - UPDATE_META_INT( Date, date_text ); - UPDATE_META_INT( TrackNum, seqnum_text ); + UPDATE_META( Date, date_text ); + UPDATE_META( TrackNum, seqnum_text ); UPDATE_META_INT( Rating, rating_text ); #undef UPDATE_META_INT @@ -283,11 +233,94 @@ void MetaPanel::update( input_item_t *p_item ) free( psz_meta ); } +/** + * Save the MetaData, triggered by parent->save Button + **/ +void MetaPanel::saveMeta() +{ + playlist_t *p_playlist; + char psz[5]; + + meta_export_t p_export; + p_export.p_item = p_input; + + if( p_input == NULL ) + return; + + /* we can write meta data only in a file */ + vlc_mutex_lock( &p_input->lock ); + int i_type = p_input->i_type; + vlc_mutex_unlock( &p_input->lock ); + if( i_type == ITEM_TYPE_FILE ) + { + char *psz_uri_orig = input_item_GetURI( p_input ); + char *psz_uri = psz_uri_orig; + if( !strncmp( psz_uri, "file://", 7 ) ) + psz_uri += 7; /* strlen("file://") = 7 */ + + p_export.psz_file = strndup( psz_uri, PATH_MAX ); + free( psz_uri_orig ); + } + else + return; + + /* now we read the modified meta data */ + input_item_SetTitle( p_input, qtu( title_text->text() ) ); + input_item_SetArtist( p_input, qtu( artist_text->text() ) ); + input_item_SetAlbum( p_input, qtu( collection_text->text() ) ); + input_item_SetGenre( p_input, qtu( genre_text->text() ) ); + input_item_SetTrackNum( p_input, qtu( seqnum_text->text() ) ); + input_item_SetDate( p_input, qtu( date_text->text() ) ); + + input_item_SetCopyright( p_input, qtu( copyright_text->text() ) ); + input_item_SetPublisher( p_input, qtu( publisher_text->text() ) ); + input_item_SetDescription( p_input, qtu( description_text->text() ) ); + + p_playlist = pl_Yield( p_intf ); + PL_LOCK; + p_playlist->p_private = &p_export; + + module_t *p_mod = module_Need( p_playlist, "meta writer", NULL, 0 ); + if( p_mod ) + module_Unneed( p_playlist, p_mod ); + PL_UNLOCK; + pl_Release( p_playlist ); + + /* Reset the status of the mode. No need to emit any signal */ + b_inEditMode = false; +} + + +bool MetaPanel::isInEditMode() +{ + return b_inEditMode; +} + +void MetaPanel::enterEditMode() +{ + setEditMode( true ); +} + +void MetaPanel::setEditMode( bool b_editing ) +{ + b_inEditMode = b_editing; + if( b_editing )emit editing(); +} + +void MetaPanel::setInput( input_item_t *input ) +{ + if( b_inEditMode ) return; + + p_input = input; +} + /* * Clear all the metadata widgets - * Unused yet + * Unused yet FIXME */ -void MetaPanel::clear(){} +void MetaPanel::clear(){ + setEditMode( false ); +} /** * Second Panel - Shows the extra metadata in a tree, non editable. @@ -316,7 +349,7 @@ ExtraMetaPanel::ExtraMetaPanel( QWidget *parent, } /** - * Update the Extra Metadata from p_meta->i_extras + * Update the Extra Metadata from p_meta->i_extras **/ void ExtraMetaPanel::update( input_item_t *p_item ) { @@ -422,9 +455,7 @@ void InfoPanel::clear() **/ /* void InfoPanel::saveCodecsInfo() -{ - -} +{} */ /** @@ -463,10 +494,10 @@ InputStatsPanel::InputStatsPanel( QWidget *parent, catName->addChild( itemName ); } /* Create the main categories */ - CREATE_CATEGORY( input, qtr("Input") ); + CREATE_CATEGORY( audio, qtr("Audio") ); CREATE_CATEGORY( video, qtr("Video") ); + CREATE_CATEGORY( input, qtr("Input") ); CREATE_CATEGORY( streaming, qtr("Streaming") ); - CREATE_CATEGORY( audio, qtr("Audio") ); CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Read at media"), "0", input , "kB" ); @@ -552,5 +583,3 @@ void InputStatsPanel::update( input_item_t *p_item ) void InputStatsPanel::clear() { } - -