Commit 9b14cc45 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Media Info. Re-add some info for DVB. Clean the in_Edit state that was...

Qt4 - Media Info. Re-add some info for DVB. Clean the in_Edit state that was stored two times in different classes.

parent fdd5a55a
......@@ -49,14 +49,15 @@ 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, 5 ); \
metaLayout->addWidget( widget, line, 1, 1, 9 ); \
line++; }
/* ART_URL */
......@@ -67,7 +68,7 @@ MetaPanel::MetaPanel( QWidget *parent,
art_cover->setMaximumWidth( 128 );
art_cover->setScaledContents( true );
art_cover->setPixmap( QPixmap( ":/noart.png" ) );
l->addWidget( art_cover, line, 6, 4, 2 );
metaLayout->addWidget( art_cover, line, 8, 4, 2 );
/* Title, artist and album*/
ADD_META( VLC_META_TITLE, title_text ); /* OK */
......@@ -77,155 +78,86 @@ 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, 2 );
metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 );
metaLayout->addWidget( genre_text, line, 1, 1, 2 );
/* Number */
l->addWidget( new QLabel( qtr( "Track Number" ) + " :" ),
/* Number - on the same line */
metaLayout->addWidget( new QLabel( qtr( "Track Number" ) + " :" ),
line, 3 );
seqnum_text = new QLineEdit;
seqnum_text->setInputMask("0000");
seqnum_text->setAlignment( Qt::AlignRight );
l->addWidget( seqnum_text, line, 4, 1, 2 );
metaLayout->addWidget( seqnum_text, line, 4, 1, 2 );
line++;
/* Date (Should be in years) */
date_text = new QLineEdit;
date_text->setInputMask("0000");
date_text->setAlignment( Qt::AlignRight );
l->addWidget( new QLabel( qtr( VLC_META_DATE ) + " :" ), line, 0 );
l->addWidget( date_text, line, 1, 1, 1 );
metaLayout->addWidget( new QLabel( qtr( VLC_META_DATE ) + " :" ), line, 0 );
metaLayout->addWidget( date_text, line, 1, 1, 1 );
/* Rating */
/* Rating - on the same line */
metaLayout->addWidget( new QLabel( qtr( VLC_META_RATING ) + " :" ), line, 2 );
rating_text = new QSpinBox; setSpinBounds( rating_text );
metaLayout->addWidget( rating_text, line, 3, 1, 1 );
l->addWidget( new QLabel( qtr( VLC_META_RATING ) + " :" ), line, 2 );
rating_text = new QSpinBox; setSpinBounds( rating_text) ;
l->addWidget( rating_text, line, 3, 1, 1 );
/* Language on the same line */
metaLayout->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 4 );
language_text = new QLineEdit;
metaLayout->addWidget( language_text, line, 5, 1, 1 );
line++;
/* Now Playing ? */
// ADD_META( VLC_META_NOW_PLAYING, nowplaying_text );
/* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */
ADD_META( VLC_META_NOW_PLAYING, nowplaying_text );
/* Language and settings */
l->addWidget( new QLabel( qfu( VLC_META_LANGUAGE ) + " :" ), line, 4 );
language_text = new QLineEdit;
l->addWidget( language_text, line, 5, 1, 1 );
/* 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 );
line++;*/
l->addWidget( setting_text, line, 6, 1, 4 ); */
/* useless metadata
/* 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 );
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, encodedby_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( date_text, textEdited( QString ), this, editMeta( QString ) );
CONNECT( seqnum_text, textEdited( QString ), this, editMeta( QString ) );
/* CONNECT( rating_text, valueChanged( QString ), this, editMeta( QString ) );*/
in_edit = false;
#undef ADD_META_2
CONNECT( title_text, textEdited( QString ), this, enterEditMode() );
CONNECT( description_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( date_text, textEdited( QString ), this, enterEditMode() );
CONNECT( seqnum_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 */
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_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_SetDate( p_input, qtu( date_text->text() ) );
input_item_SetTrackNum( p_input, qtu( seqnum_text->text() ) );
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;
/* 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 ); \
......@@ -241,7 +173,6 @@ 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 );
......@@ -271,12 +202,12 @@ void MetaPanel::update( input_item_t *p_item )
/* Other classic though */
UPDATE_META( Artist, artist_text );
UPDATE_META( Genre, genre_text );
// UPDATE_META( Copyright, copyright_text );
UPDATE_META( Copyright, copyright_text );
UPDATE_META( Album, collection_text );
// UPDATE_META( Description, description_text );
UPDATE_META( Description, description_text );
UPDATE_META( Language, language_text );
// UPDATE_META( NowPlaying, nowplaying_text );
// UPDATE_META( Publisher, publisher_text );
UPDATE_META( NowPlaying, nowplaying_text );
UPDATE_META( Publisher, publisher_text );
// UPDATE_META( Setting, setting_text );
// UPDATE_META( EncodedBy, encodedby_text );
......@@ -299,11 +230,92 @@ 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_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_SetDate( p_input, qtu( date_text->text() ) );
input_item_SetTrackNum( p_input, qtu( seqnum_text->text() ) );
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 );
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.
......@@ -568,5 +580,3 @@ void InputStatsPanel::update( input_item_t *p_item )
void InputStatsPanel::clear()
{
}
......@@ -55,32 +55,38 @@ public:
virtual ~MetaPanel();
void saveMeta();
void setInput( input_item_t * );
void setEdit( bool );
bool isInEditMode();
void setEditMode( bool );
private:
input_item_t *p_input;
intf_thread_t *p_intf;
bool b_inEditMode;
QLineEdit *uri_text;
QLineEdit *title_text;
QLineEdit *artist_text;
QLineEdit *genre_text;
// QLineEdit *copyright_text;
QLineEdit *copyright_text;
QLineEdit *collection_text;
QLineEdit *seqnum_text;
// QLineEdit *description_text;
QLineEdit *description_text;
QSpinBox *rating_text;
QLineEdit *date_text;
// QLineEdit *setting_text;
QLineEdit *language_text;
// QLineEdit *nowplaying_text;
// QLineEdit *publisher_text;
QLineEdit *nowplaying_text;
QLineEdit *publisher_text;
// QLineEdit *encodedby_text;
QLabel *art_cover;
bool in_edit;
public slots:
void update( input_item_t * );
void clear();
void editMeta( QString );
private slots:
void enterEditMode();
signals:
void uriSet( QString );
void editing();
......
......@@ -88,10 +88,9 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
/* Let the MetaData Panel update the URI */
CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
CONNECT( MP, editing(), this, editMeta() );
CONNECT( IT, currentChanged ( int ), this, updateButtons( int ) );
CONNECT( MP, editing( bool ), this, editMeta( bool ) );
CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
/* Create the main Update function with a time (150ms) */
if( mainInput ) {
......@@ -114,6 +113,8 @@ void MediaInfoDialog::showTab( int i_tab = 0 )
IT->setCurrentIndex( i_tab );
}
/**/
void MediaInfoDialog::editMeta()
{
saveMetaButton->show();
......@@ -144,11 +145,8 @@ void MediaInfoDialog::setInput( input_item_t *p_input )
*/
input_thread_t *p_current =
MainInputManager::getInstance( p_intf )->getInput();
if( !p_current || p_current->b_dead )
in_edit = true;
else
in_edit = ( input_GetItem( p_current ) != p_input );
MP->setEdit( in_edit );
MP->setEditMode( ( !p_current || p_current->b_dead ) ?
true: false );
}
void MediaInfoDialog::update()
......@@ -174,8 +172,9 @@ void MediaInfoDialog::update()
vlc_object_release( p_input );
}
void MediaInfoDialog::update( input_item_t *p_item, bool update_info,
bool update_meta )
void MediaInfoDialog::update( input_item_t *p_item,
bool update_info,
bool update_meta )
{
MP->setInput( p_item );
if( update_info )
......@@ -204,15 +203,12 @@ void MediaInfoDialog::close()
if( mainInput == false ) {
deleteLater();
}
MP->setEdit( false );
in_edit = false;
MP->setEditMode( false );
}
void MediaInfoDialog::updateButtons( int i_tab )
{
msg_Dbg( p_intf, "Coin Coin, Tab number: %i", i_tab );
if( in_edit and i_tab == 0 )
if( MP->isInEditMode() && i_tab == 0 )
saveMetaButton->show();
else
saveMetaButton->hide();
......
......@@ -62,13 +62,11 @@ private:
int i_runs;
bool mainInput;
bool stats;
bool in_edit;
InputStatsPanel *ISP;
MetaPanel *MP;
InfoPanel *IP;
ExtraMetaPanel *EMP;
QPushButton *saveMetaButton;
QPushButton *editMetaButton;
public slots:
void update();
void saveMeta();
......
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