Commit 0c86a4b8 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - MediaInformation, simplification of the states machine, removal of...

Qt4 - MediaInformation, simplification of the states machine, removal of over-complicated methods. Cleaning and other small fixes.
Please report regressions on that part.
parent e9ba6037
...@@ -55,9 +55,9 @@ MetaPanel::MetaPanel( QWidget *parent, ...@@ -55,9 +55,9 @@ MetaPanel::MetaPanel( QWidget *parent,
int line = 0; /* Counter for GridLayout */ int line = 0; /* Counter for GridLayout */
p_input = NULL; p_input = NULL;
#define ADD_META( string, widget ) { \ #define ADD_META( string, widget ) { \
metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
widget = new QLineEdit; \ widget = new QLineEdit; \
metaLayout->addWidget( widget, line, 1, 1, 9 ); \ metaLayout->addWidget( widget, line, 1, 1, 9 ); \
line++; } line++; }
...@@ -67,7 +67,7 @@ MetaPanel::MetaPanel( QWidget *parent, ...@@ -67,7 +67,7 @@ MetaPanel::MetaPanel( QWidget *parent,
ADD_META( VLC_META_COLLECTION, collection_text ); /* OK */ ADD_META( VLC_META_COLLECTION, collection_text ); /* OK */
/* Genre Name */ /* Genre Name */
/* FIXME List id3genres.h is not includable yet ? */ /* TODO List id3genres.h is not includable yet ? */
genre_text = new QLineEdit; genre_text = new QLineEdit;
metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 ); metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 );
metaLayout->addWidget( genre_text, line, 1, 1, 4 ); metaLayout->addWidget( genre_text, line, 1, 1, 4 );
...@@ -117,9 +117,9 @@ MetaPanel::MetaPanel( QWidget *parent, ...@@ -117,9 +117,9 @@ MetaPanel::MetaPanel( QWidget *parent,
l->addWidget( setting_text, line, 6, 1, 4 ); */ l->addWidget( setting_text, line, 6, 1, 4 ); */
/* Less used metadata */ /* Less used metadata */
#define ADD_META_2( string, widget ) { \ #define ADD_META_2( string, widget ) { \
metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \ metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
widget = new QLineEdit; \ widget = new QLineEdit; \
metaLayout->addWidget( widget, line, 1, 1, 7 ); \ metaLayout->addWidget( widget, line, 1, 1, 7 ); \
line++; } line++; }
...@@ -162,6 +162,7 @@ void MetaPanel::update( input_item_t *p_item ) ...@@ -162,6 +162,7 @@ void MetaPanel::update( input_item_t *p_item )
{ {
/* Don't update if you are in edit mode */ /* Don't update if you are in edit mode */
if( b_inEditMode ) return; if( b_inEditMode ) return;
else p_input = p_item;
char *psz_meta; char *psz_meta;
#define UPDATE_META( meta, widget ) { \ #define UPDATE_META( meta, widget ) { \
...@@ -241,7 +242,6 @@ void MetaPanel::update( input_item_t *p_item ) ...@@ -241,7 +242,6 @@ void MetaPanel::update( input_item_t *p_item )
void MetaPanel::saveMeta() void MetaPanel::saveMeta()
{ {
playlist_t *p_playlist; playlist_t *p_playlist;
char psz[5];
meta_export_t p_export; meta_export_t p_export;
p_export.p_item = p_input; p_export.p_item = p_input;
...@@ -309,18 +309,25 @@ void MetaPanel::setEditMode( bool b_editing ) ...@@ -309,18 +309,25 @@ void MetaPanel::setEditMode( bool b_editing )
if( b_editing )emit 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 * Clear all the metadata widgets
* Unused yet FIXME
*/ */
void MetaPanel::clear(){ void MetaPanel::clear()
{
uri_text->clear();
title_text->clear();
artist_text->clear();
genre_text->clear();
copyright_text->clear();
collection_text->clear();
seqnum_text->clear();
description_text->clear();
date_text->clear();
language_text->clear();
nowplaying_text->clear();
publisher_text->clear();
art_cover;
setEditMode( false ); setEditMode( false );
} }
......
...@@ -55,7 +55,6 @@ public: ...@@ -55,7 +55,6 @@ public:
MetaPanel( QWidget *, intf_thread_t * ); MetaPanel( QWidget *, intf_thread_t * );
virtual ~MetaPanel(); virtual ~MetaPanel();
void saveMeta(); void saveMeta();
void setInput( input_item_t * );
bool isInEditMode(); bool isInEditMode();
void setEditMode( bool ); void setEditMode( bool );
......
...@@ -35,13 +35,15 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -35,13 +35,15 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param ); vlc_value_t oldval, vlc_value_t newval, void *param );
MediaInfoDialog *MediaInfoDialog::instance = NULL; MediaInfoDialog *MediaInfoDialog::instance = NULL;
MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
input_item_t *_p_item,
bool _mainInput,
bool _stats ) : bool _stats ) :
QVLCFrame( _p_intf ), mainInput(_mainInput), QVLCFrame( _p_intf ), mainInput(_mainInput),
stats( _stats ) stats( _stats )
{ {
i_runs = 0; i_runs = 0;
p_input = NULL; p_item = _p_item;
b_need_update = true; b_need_update = true;
setWindowTitle( qtr( "Media information" ) ); setWindowTitle( qtr( "Media information" ) );
...@@ -85,13 +87,13 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, ...@@ -85,13 +87,13 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
/* Let the MetaData Panel update the URI */ /* Let the MetaData Panel update the URI */
CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) ); CONNECT( MP, uriSet( QString ), uriLine, setText( QString ) );
CONNECT( MP, editing(), this, editMeta() ); CONNECT( MP, editing(), this, showMetaSaveButton() );
CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
/* Create the main Update function with a time (150ms) */ /* Create the main Update function with a time (150ms) */
if( mainInput ) { if( mainInput ) {
ON_TIMEOUT( update() ); ON_TIMEOUT( updateOnTimeOut() );
var_AddCallback( THEPL, "item-change", ItemChanged, this ); var_AddCallback( THEPL, "item-change", ItemChanged, this );
} }
} }
...@@ -110,7 +112,7 @@ void MediaInfoDialog::showTab( int i_tab = 0 ) ...@@ -110,7 +112,7 @@ void MediaInfoDialog::showTab( int i_tab = 0 )
IT->setCurrentIndex( i_tab ); IT->setCurrentIndex( i_tab );
} }
void MediaInfoDialog::editMeta() void MediaInfoDialog::showMetaSaveButton()
{ {
saveMetaButton->show(); saveMetaButton->show();
} }
...@@ -129,36 +131,22 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -129,36 +131,22 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
void MediaInfoDialog::setInput( input_item_t *p_input ) /* Function called on TimeOut */
{ void MediaInfoDialog::updateOnTimeOut()
clear();
update( p_input, true, true );
/* if info is from current input, don't set default to edit, if user opens
* some other item, se default to edit, so it won't be updated to current item metas
*
* This really doesn't seem as clean solution as it could be
*/
input_thread_t *p_current =
MainInputManager::getInstance( p_intf )->getInput();
MP->setEditMode( ( !p_current || p_current->b_dead || input_GetItem( p_current ) != p_input ) ?
true: false );
}
void MediaInfoDialog::update()
{ {
/* Timer runs at 150 ms, dont' update more than 2 times per second */ /* Timer runs at 150 ms, dont' update more than 2 times per second */
i_runs++; i_runs++;
if( i_runs % 4 != 0 ) return; if( i_runs % 4 != 0 ) return;
/* Get Input and clear if non-existant */ /* Get Input and clear if non-existant */
input_thread_t *p_input = input_thread_t *p_input = THEMIM->getInput();
MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead ) if( !p_input || p_input->b_dead )
{ {
clear(); clear();
return; return;
} }
/* Launch the update in all the panels */
vlc_object_yield( p_input ); vlc_object_yield( p_input );
update( input_GetItem(p_input), b_need_update, b_need_update ); update( input_GetItem(p_input), b_need_update, b_need_update );
...@@ -168,10 +156,9 @@ void MediaInfoDialog::update() ...@@ -168,10 +156,9 @@ void MediaInfoDialog::update()
} }
void MediaInfoDialog::update( input_item_t *p_item, void MediaInfoDialog::update( input_item_t *p_item,
bool update_info, bool update_info,
bool update_meta ) bool update_meta )
{ {
MP->setInput( p_item );
if( update_info ) if( update_info )
IP->update( p_item ); IP->update( p_item );
if( update_meta ) if( update_meta )
...@@ -198,7 +185,6 @@ void MediaInfoDialog::close() ...@@ -198,7 +185,6 @@ void MediaInfoDialog::close()
if( mainInput == false ) { if( mainInput == false ) {
deleteLater(); deleteLater();
} }
MP->setEditMode( false );
} }
void MediaInfoDialog::updateButtons( int i_tab ) void MediaInfoDialog::updateButtons( int i_tab )
......
...@@ -36,33 +36,42 @@ class MediaInfoDialog : public QVLCFrame ...@@ -36,33 +36,42 @@ class MediaInfoDialog : public QVLCFrame
{ {
Q_OBJECT; Q_OBJECT;
public: public:
MediaInfoDialog( intf_thread_t *, bool stats = true, bool mainInput = false ); MediaInfoDialog( intf_thread_t *,
input_item_t *,
bool stats = true,
bool mainInput = false );
static MediaInfoDialog * getInstance( intf_thread_t *p_intf ) static MediaInfoDialog * getInstance( intf_thread_t *p_intf )
{ {
if( !instance) instance = new MediaInfoDialog( p_intf, true, true ); if( !instance) instance = new MediaInfoDialog( p_intf,
NULL,
true,
true );
return instance; return instance;
} }
static void killInstance() static void killInstance()
{ {
if( instance ) delete instance; if( instance ) delete instance;
instance= NULL; instance= NULL;
} }
virtual ~MediaInfoDialog(); virtual ~MediaInfoDialog();
void showTab( int ); void showTab( int );
#if 0
void setInput( input_item_t * ); void setInput( input_item_t * );
#endif
bool b_need_update; bool b_need_update;
private: private:
input_thread_t *p_input; input_item_t *p_item;
static MediaInfoDialog *instance; static MediaInfoDialog *instance;
int i_runs; int i_runs;
bool mainInput; bool mainInput;
bool stats; bool stats;
QTabWidget *IT; QTabWidget *IT;
InputStatsPanel *ISP; InputStatsPanel *ISP;
MetaPanel *MP; MetaPanel *MP;
...@@ -73,15 +82,14 @@ private: ...@@ -73,15 +82,14 @@ private:
QLineEdit *uriLine; QLineEdit *uriLine;
public slots: public slots:
void update(); void updateOnTimeOut();
void update( input_item_t *, bool, bool ); void update( input_item_t *, bool, bool );
private slots: private slots:
void close(); void close();
void clear(); void clear();
void saveMeta(); void saveMeta();
void editMeta(); void showMetaSaveButton();
void updateButtons( int i_tab ); void updateButtons( int i_tab );
}; };
......
...@@ -1046,11 +1046,11 @@ void PLModel::popupPlay() ...@@ -1046,11 +1046,11 @@ void PLModel::popupPlay()
void PLModel::popupInfo() void PLModel::popupInfo()
{ {
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item,VLC_TRUE ); i_popup_item,
VLC_TRUE );
if( p_item ) if( p_item )
{ {
MediaInfoDialog *mid = new MediaInfoDialog( p_intf ); MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input );
mid->setInput( p_item->p_input );
mid->show(); mid->show();
} }
} }
......
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