Commit 88cc4a8a authored by Ilkka Ollakka's avatar Ilkka Ollakka

Second try, show save meta button if user changes any input field, also
then set in_edit=true so playlist changes doesn't change meta-data what
to edit.
parent 0ddc9bae
...@@ -126,7 +126,18 @@ MetaPanel::MetaPanel( QWidget *parent, ...@@ -126,7 +126,18 @@ MetaPanel::MetaPanel( QWidget *parent,
#undef ADD_META #undef ADD_META
#undef ADD_META_2 #undef ADD_META_2
ReadOnly( true );
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;
} }
MetaPanel::~MetaPanel(){} MetaPanel::~MetaPanel(){}
...@@ -136,7 +147,6 @@ MetaPanel::~MetaPanel(){} ...@@ -136,7 +147,6 @@ MetaPanel::~MetaPanel(){}
**/ **/
void MetaPanel::saveMeta() void MetaPanel::saveMeta()
{ {
ReadOnly( true );
playlist_t *p_playlist; playlist_t *p_playlist;
char psz[5]; char psz[5];
...@@ -183,28 +193,25 @@ void MetaPanel::saveMeta() ...@@ -183,28 +193,25 @@ void MetaPanel::saveMeta()
module_Unneed( p_playlist, p_mod ); module_Unneed( p_playlist, p_mod );
PL_UNLOCK; PL_UNLOCK;
pl_Release( p_playlist ); pl_Release( p_playlist );
in_edit = false;
} }
void MetaPanel::ReadOnly(bool readonly) void MetaPanel::editMeta( QString edit )
{ {
title_text->setReadOnly( readonly ); in_edit = true;
artist_text->setReadOnly( readonly ); emit editing();
collection_text->setReadOnly( readonly ); }
genre_text->setReadOnly( readonly );
date_text->setReadOnly( readonly );
seqnum_text->setReadOnly( readonly );
rating_text->setReadOnly( readonly );
language_text->setReadOnly( readonly );
setting_text->setReadOnly( readonly );
copyright_text->setReadOnly( readonly );
publisher_text->setReadOnly( readonly );
description_text->setReadOnly( readonly );
void MetaPanel::setEdit( bool editing )
{
in_edit = editing;
} }
void MetaPanel::editMeta() void MetaPanel::setInput( input_item_t *input )
{ {
ReadOnly( false ); if( in_edit ) return;
p_input = input;
} }
/** /**
...@@ -212,6 +219,7 @@ void MetaPanel::editMeta() ...@@ -212,6 +219,7 @@ void MetaPanel::editMeta()
**/ **/
void MetaPanel::update( input_item_t *p_item ) void MetaPanel::update( input_item_t *p_item )
{ {
if( in_edit ) return;
char *psz_meta; char *psz_meta;
#define UPDATE_META( meta, widget ) { \ #define UPDATE_META( meta, widget ) { \
psz_meta = input_item_Get##meta( p_item ); \ psz_meta = input_item_Get##meta( p_item ); \
......
...@@ -53,10 +53,11 @@ class MetaPanel: public QWidget ...@@ -53,10 +53,11 @@ class MetaPanel: public QWidget
public: public:
MetaPanel( QWidget *, intf_thread_t * ); MetaPanel( QWidget *, intf_thread_t * );
virtual ~MetaPanel(); virtual ~MetaPanel();
input_item_t *p_input;
void saveMeta(); void saveMeta();
void editMeta(); void setInput( input_item_t * );
void setEdit( bool );
private: private:
input_item_t *p_input;
intf_thread_t *p_intf; intf_thread_t *p_intf;
QLineEdit *uri_text; QLineEdit *uri_text;
QLineEdit *title_text; QLineEdit *title_text;
...@@ -73,13 +74,15 @@ private: ...@@ -73,13 +74,15 @@ private:
QLineEdit *nowplaying_text; QLineEdit *nowplaying_text;
QLineEdit *publisher_text; QLineEdit *publisher_text;
QLabel *art_cover; QLabel *art_cover;
void ReadOnly( bool ); bool in_edit;
public slots: public slots:
void update( input_item_t * ); void update( input_item_t * );
void clear(); void clear();
void editMeta( QString );
signals: signals:
void uriSet( QString ); void uriSet( QString );
void editing();
}; };
class ExtraMetaPanel: public QWidget class ExtraMetaPanel: public QWidget
......
...@@ -67,7 +67,6 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, ...@@ -67,7 +67,6 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
QGridLayout *layout = new QGridLayout( this ); QGridLayout *layout = new QGridLayout( this );
/* FIXME GNOME/KDE ? */ /* FIXME GNOME/KDE ? */
editMetaButton = new QPushButton( qtr( "&Edit Metadata" ) );
saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) ); saveMetaButton = new QPushButton( qtr( "&Save Metadata" ) );
saveMetaButton->hide(); saveMetaButton->hide();
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
...@@ -80,17 +79,16 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput, ...@@ -80,17 +79,16 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, bool _mainInput,
layout->addWidget( uriLabel, 1, 0, 1, 1 ); layout->addWidget( uriLabel, 1, 0, 1, 1 );
layout->addWidget( uriLine, 1, 1, 1, 7 ); layout->addWidget( uriLine, 1, 1, 1, 7 );
layout->addWidget( saveMetaButton, 2, 6 ); layout->addWidget( saveMetaButton, 2, 6 );
layout->addWidget( editMetaButton, 2, 6 );
layout->addWidget( closeButton, 2, 7 ); layout->addWidget( closeButton, 2, 7 );
BUTTONACT( closeButton, close() ); BUTTONACT( closeButton, close() );
/* The tabs buttons are shown in the main dialog for space and cosmetics */ /* The tabs buttons are shown in the main dialog for space and cosmetics */
CONNECT( saveMetaButton, clicked(), this, saveMeta() ); CONNECT( saveMetaButton, clicked(), this, saveMeta() );
CONNECT( editMetaButton, clicked(), this, editMeta() );
/* 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( IT, currentChanged ( int ), this, updateButtons( int ) ); CONNECT( IT, currentChanged ( int ), this, updateButtons( int ) );
...@@ -118,18 +116,13 @@ void MediaInfoDialog::showTab( int i_tab = 0 ) ...@@ -118,18 +116,13 @@ void MediaInfoDialog::showTab( int i_tab = 0 )
void MediaInfoDialog::editMeta() void MediaInfoDialog::editMeta()
{ {
in_edit = true;
editMetaButton->hide();
saveMetaButton->show(); saveMetaButton->show();
MP->editMeta();
} }
void MediaInfoDialog::saveMeta() void MediaInfoDialog::saveMeta()
{ {
MP->saveMeta(); MP->saveMeta();
editMetaButton->show();
saveMetaButton->hide(); saveMetaButton->hide();
in_edit = false;
} }
static int ItemChanged( vlc_object_t *p_this, const char *psz_var, static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
...@@ -172,8 +165,7 @@ void MediaInfoDialog::update() ...@@ -172,8 +165,7 @@ void MediaInfoDialog::update()
void MediaInfoDialog::update( input_item_t *p_item, bool update_info, void MediaInfoDialog::update( input_item_t *p_item, bool update_info,
bool update_meta ) bool update_meta )
{ {
if( in_edit ) return; MP->setInput( p_item );
MP->p_input = p_item;
if( update_info ) if( update_info )
IP->update( p_item ); IP->update( p_item );
if( update_meta ) if( update_meta )
...@@ -195,12 +187,12 @@ void MediaInfoDialog::clear() ...@@ -195,12 +187,12 @@ void MediaInfoDialog::clear()
void MediaInfoDialog::close() void MediaInfoDialog::close()
{ {
in_edit = false;
this->toggleVisible(); this->toggleVisible();
if( mainInput == false ) { if( mainInput == false ) {
deleteLater(); deleteLater();
} }
MP->setEdit( false );
} }
void MediaInfoDialog::updateButtons( int i_tab ) void MediaInfoDialog::updateButtons( int i_tab )
......
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