Browse Source

qt: open an error dialog when saving metadata fails

pull/192/head
Pierre Lamot 9 months ago
committed by Steve Lhomme
parent
commit
de6a6b6e29
  1. 17
      modules/gui/qt/dialogs/mediainfo/info_panels.cpp
  2. 2
      modules/gui/qt/dialogs/mediainfo/info_panels.hpp
  3. 5
      modules/gui/qt/dialogs/mediainfo/mediainfo.cpp

17
modules/gui/qt/dialogs/mediainfo/info_panels.cpp

@ -50,6 +50,7 @@
#include <QApplication>
#include <QPushButton>
#include <QRegularExpression>
#include <QMessageBox>
/************************************************************************
* Single panels
@ -255,12 +256,14 @@ void MetaPanel::update( const SharedInputItem& p_item )
/**
* Save the MetaData, triggered by parent->save Button
**/
void MetaPanel::saveMeta()
bool MetaPanel::saveMeta()
{
const auto input = p_input.get();
if( input == NULL )
return;
if( input == NULL ) {
QMessageBox::warning( this, qtr("Metadata"), qtr("Not editing a file") );
return false;
}
/* now we read the modified meta data */
input_item_SetTitle( input, qtu( title_text->text() ) );
@ -276,11 +279,15 @@ void MetaPanel::saveMeta()
input_item_SetPublisher( input, qtu( publisher_text->text() ) );
input_item_SetDescription( input, qtu( description_text->toPlainText() ) );
input_item_WriteMeta( VLC_OBJECT(p_intf), input );
/* Reset the status of the mode. No need to emit any signal because parent
is the only caller */
b_inEditMode = false;
int vlcret = input_item_WriteMeta( VLC_OBJECT(p_intf), input );
if (vlcret != VLC_SUCCESS) {
QMessageBox::warning( this, qtr("Metadata"), qtr("Failed to save metadata") );
return false;
}
return true;
}

2
modules/gui/qt/dialogs/mediainfo/info_panels.hpp

@ -50,7 +50,7 @@ class MetaPanel: public QWidget
Q_OBJECT
public:
MetaPanel( QWidget *, qt_intf_t * );
void saveMeta();
bool saveMeta();
bool isInEditMode();
void setEditMode( bool );

5
modules/gui/qt/dialogs/mediainfo/mediainfo.cpp

@ -152,8 +152,9 @@ int MediaInfoDialog::currentTab()
void MediaInfoDialog::saveMeta()
{
MP->saveMeta();
saveMetaButton->hide();
bool success = MP->saveMeta();
if (success)
saveMetaButton->hide();
}
void MediaInfoDialog::updateAllTabs( const SharedInputItem& p_item )

Loading…
Cancel
Save