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,
int line = 0; /* Counter for GridLayout */
p_input = NULL;
#define ADD_META( string, widget ) { \
#define ADD_META( string, widget ) { \
metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
widget = new QLineEdit; \
widget = new QLineEdit; \
metaLayout->addWidget( widget, line, 1, 1, 9 ); \
line++; }
......@@ -67,7 +67,7 @@ MetaPanel::MetaPanel( QWidget *parent,
ADD_META( VLC_META_COLLECTION, collection_text ); /* OK */
/* Genre Name */
/* FIXME List id3genres.h is not includable yet ? */
/* TODO List id3genres.h is not includable yet ? */
genre_text = new QLineEdit;
metaLayout->addWidget( new QLabel( qtr( VLC_META_GENRE ) + " :" ), line, 0 );
metaLayout->addWidget( genre_text, line, 1, 1, 4 );
......@@ -117,9 +117,9 @@ MetaPanel::MetaPanel( QWidget *parent,
l->addWidget( setting_text, line, 6, 1, 4 ); */
/* Less used metadata */
#define ADD_META_2( string, widget ) { \
#define ADD_META_2( string, widget ) { \
metaLayout->addWidget( new QLabel( qtr( string ) + " :" ), line, 0 ); \
widget = new QLineEdit; \
widget = new QLineEdit; \
metaLayout->addWidget( widget, line, 1, 1, 7 ); \
line++; }
......@@ -162,6 +162,7 @@ void MetaPanel::update( input_item_t *p_item )
{
/* Don't update if you are in edit mode */
if( b_inEditMode ) return;
else p_input = p_item;
char *psz_meta;
#define UPDATE_META( meta, widget ) { \
......@@ -241,7 +242,6 @@ void MetaPanel::update( input_item_t *p_item )
void MetaPanel::saveMeta()
{
playlist_t *p_playlist;
char psz[5];
meta_export_t p_export;
p_export.p_item = p_input;
......@@ -309,18 +309,25 @@ void MetaPanel::setEditMode( bool 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 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 );
}
......
......@@ -55,7 +55,6 @@ public:
MetaPanel( QWidget *, intf_thread_t * );
virtual ~MetaPanel();
void saveMeta();
void setInput( input_item_t * );
bool isInEditMode();
void setEditMode( bool );
......
......@@ -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 );
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 ) :
QVLCFrame( _p_intf ), mainInput(_mainInput),
stats( _stats )
{
i_runs = 0;
p_input = NULL;
p_item = _p_item;
b_need_update = true;
setWindowTitle( qtr( "Media information" ) );
......@@ -85,13 +87,13 @@ 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( MP, editing(), this, showMetaSaveButton() );
CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
/* Create the main Update function with a time (150ms) */
if( mainInput ) {
ON_TIMEOUT( update() );
ON_TIMEOUT( updateOnTimeOut() );
var_AddCallback( THEPL, "item-change", ItemChanged, this );
}
}
......@@ -110,7 +112,7 @@ void MediaInfoDialog::showTab( int i_tab = 0 )
IT->setCurrentIndex( i_tab );
}
void MediaInfoDialog::editMeta()
void MediaInfoDialog::showMetaSaveButton()
{
saveMetaButton->show();
}
......@@ -129,36 +131,22 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
void MediaInfoDialog::setInput( input_item_t *p_input )
{
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()
/* Function called on TimeOut */
void MediaInfoDialog::updateOnTimeOut()
{
/* Timer runs at 150 ms, dont' update more than 2 times per second */
i_runs++;
if( i_runs % 4 != 0 ) return;
/* Get Input and clear if non-existant */
input_thread_t *p_input =
MainInputManager::getInstance( p_intf )->getInput();
input_thread_t *p_input = THEMIM->getInput();
if( !p_input || p_input->b_dead )
{
clear();
return;
}
/* Launch the update in all the panels */
vlc_object_yield( p_input );
update( input_GetItem(p_input), b_need_update, b_need_update );
......@@ -168,10 +156,9 @@ void MediaInfoDialog::update()
}
void MediaInfoDialog::update( input_item_t *p_item,
bool update_info,
bool update_meta )
bool update_info,
bool update_meta )
{
MP->setInput( p_item );
if( update_info )
IP->update( p_item );
if( update_meta )
......@@ -198,7 +185,6 @@ void MediaInfoDialog::close()
if( mainInput == false ) {
deleteLater();
}
MP->setEditMode( false );
}
void MediaInfoDialog::updateButtons( int i_tab )
......
......@@ -36,33 +36,42 @@ class MediaInfoDialog : public QVLCFrame
{
Q_OBJECT;
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 )
{
if( !instance) instance = new MediaInfoDialog( p_intf, true, true );
if( !instance) instance = new MediaInfoDialog( p_intf,
NULL,
true,
true );
return instance;
}
static void killInstance()
{
if( instance ) delete instance;
instance= NULL;
}
virtual ~MediaInfoDialog();
void showTab( int );
#if 0
void setInput( input_item_t * );
#endif
bool b_need_update;
private:
input_thread_t *p_input;
input_item_t *p_item;
static MediaInfoDialog *instance;
int i_runs;
bool mainInput;
bool stats;
QTabWidget *IT;
InputStatsPanel *ISP;
MetaPanel *MP;
......@@ -73,15 +82,14 @@ private:
QLineEdit *uriLine;
public slots:
void update();
void updateOnTimeOut();
void update( input_item_t *, bool, bool );
private slots:
void close();
void clear();
void saveMeta();
void editMeta();
void showMetaSaveButton();
void updateButtons( int i_tab );
};
......
......@@ -1046,11 +1046,11 @@ void PLModel::popupPlay()
void PLModel::popupInfo()
{
playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item,VLC_TRUE );
i_popup_item,
VLC_TRUE );
if( p_item )
{
MediaInfoDialog *mid = new MediaInfoDialog( p_intf );
mid->setInput( p_item->p_input );
MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input );
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