Commit 553e1f39 authored by Lochlin Duperron's avatar Lochlin Duperron Committed by Jean-Baptiste Kempf

Adds batch convert support to the VLC GUI.

This commit modifies the convert wizard to accept multiple files from the file dialog box

The GUI should operate the same when a single file is selected (providing
an option of where and what to name the file), but when multiple files are
selected the files are placed into the same folder with the same name and a
new extention (there is an option to append -converted if you are converting
to the same extention).
There are some tooltips to explain this operation.

Most of the changes are pretty straight-forward, converting QStrings to
QStringLists and passing the full list of MRLs around. The playlist already
supports the batch processing in a pretty straightforward way, so there's no
issues there.

StandardPanel.cpp was modified to create a temp QStringList for passing to the
streamingDialog, as it now takes the full list of input files rather than just
one

Convert.cpp/hpp modified to take the QStringList and to behave (semi)-intelligently when reciving multiple files,
Open.cpp modified to pass the MRLs rather than MRL[0]
and the Dialogs_provider.cpp/hpp to pass the MRLs along, pretty much.

It also clears the playlist when recieving a list and starts the playlist from the beginning when it's added all the files to be converted.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent af187120
...@@ -319,14 +319,22 @@ void StandardPLPanel::popupAction( QAction *action ) ...@@ -319,14 +319,22 @@ void StandardPLPanel::popupAction( QAction *action )
/* locally handled only */ /* locally handled only */
temp = model->getURI( index ); temp = model->getURI( index );
if ( ! temp.isEmpty() ) if ( ! temp.isEmpty() )
THEDP->streamingDialog( NULL, temp, false ); {
QStringList tempList;
tempList.append(temp);
THEDP->streamingDialog( NULL, tempList, false );
}
break; break;
case VLCModelSubInterface::ACTION_SAVE: case VLCModelSubInterface::ACTION_SAVE:
/* locally handled only */ /* locally handled only */
temp = model->getURI( index ); temp = model->getURI( index );
if ( ! temp.isEmpty() ) if ( ! temp.isEmpty() )
THEDP->streamingDialog( NULL, temp ); {
QStringList tempList;
tempList.append(temp);
THEDP->streamingDialog( NULL, tempList );
}
break; break;
case VLCModelSubInterface::ACTION_CREATENODE: case VLCModelSubInterface::ACTION_CREATENODE:
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <QCheckBox> #include <QCheckBox>
ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf, ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
const QString& inputMRL ) const QStringList& inputMRLs )
: QVLCDialog( parent, _p_intf ) : QVLCDialog( parent, _p_intf )
{ {
setWindowTitle( qtr( "Convert" ) ); setWindowTitle( qtr( "Convert" ) );
...@@ -46,7 +46,18 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf, ...@@ -46,7 +46,18 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
QGridLayout *mainLayout = new QGridLayout( this ); QGridLayout *mainLayout = new QGridLayout( this );
SoutInputBox *inputBox = new SoutInputBox( this ); SoutInputBox *inputBox = new SoutInputBox( this );
inputBox->setMRL( inputMRL ); incomingMRLs = &inputMRLs;
singleFileSelected = (inputMRLs.length() == 1);
if(singleFileSelected)
{
inputBox->setMRL( inputMRLs[0] );
}
else
{
inputBox->setMRL("Multiple files selected.");
}
mainLayout->addWidget( inputBox, 0, 0, 1, -1 ); mainLayout->addWidget( inputBox, 0, 0, 1, -1 );
/** /**
...@@ -62,12 +73,26 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf, ...@@ -62,12 +73,26 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
fileLine->setMinimumWidth( 300 ); fileLine->setMinimumWidth( 300 );
fileLine->setFocus( Qt::ActiveWindowFocusReason ); fileLine->setFocus( Qt::ActiveWindowFocusReason );
destLabel->setBuddy( fileLine ); destLabel->setBuddy( fileLine );
// You can set a specific name for only one file.
if(singleFileSelected)
{
QPushButton *fileSelectButton = new QPushButton( qtr( "Browse" ) );
destLayout->addWidget( fileSelectButton, 0, 2);
BUTTONACT( fileSelectButton, fileBrowse() );
}
QPushButton *fileSelectButton = new QPushButton( qtr( "Browse" ) ); // but multiple files follow a naming convention
destLayout->addWidget( fileLine, 0, 1 ); else
destLayout->addWidget( fileSelectButton, 0, 2); {
BUTTONACT( fileSelectButton, fileBrowse() ); fileLine->setText("Multiple Files Selected.");
fileLine->setReadOnly(true);
fileLine->setToolTip("Files will be placed in the same directory "
"with the same name.");
appendBox = new QCheckBox( qtr( "Append '-converted' to filename" ) );
destLayout->addWidget( appendBox, 1, 0 );
}
destLayout->addWidget( fileLine, 0, 1 );
mainLayout->addWidget( destBox, 3, 0, 1, -1 ); mainLayout->addWidget( destBox, 3, 0, 1, -1 );
...@@ -147,29 +172,74 @@ void ConvertDialog::close() ...@@ -147,29 +172,74 @@ void ConvertDialog::close()
{ {
hide(); hide();
if( dumpRadio->isChecked() ) for(int i = 0; i < incomingMRLs->length(); i++)
{
mrl = "demux=dump :demuxdump-file=" + fileLine->text();
}
else
{ {
mrl = "sout=#" + profile->getTranscode(); QString mrl;
if( deinterBox->isChecked() )
if( dumpRadio->isChecked() )
{ {
mrl.remove( '}' ); mrl = "demux=dump :demuxdump-file=" + fileLine->text();
mrl += ",deinterlace}";
} }
mrl += ":"; else
if( displayBox->isChecked() ) {
mrl += "duplicate{dst=display,dst="; mrl = "sout=#" + profile->getTranscode();
mrl += "std{access=file{no-overwrite},mux=" + profile->getMux() if( deinterBox->isChecked() )
+ ",dst='" + fileLine->text().replace( QChar('\''), "\\\'" ) {
+ "'}"; mrl.remove( '}' );
if( displayBox->isChecked() ) mrl += ",deinterlace}";
mrl += "}"; }
mrl += ":";
if( displayBox->isChecked() )
{
mrl += "duplicate{dst=display,dst=";
}
QString newFileName;
// Only one file, use the destination provided
if(singleFileSelected)
{
newFileName = fileLine->text();
}
// Multiple, use the convention.
else
{
QString fileExtension = ( ! profile->isEnabled() ) ? ".*" : "." + profile->getMux();
newFileName = incomingMRLs->at(i);
// Remove the file:// from the front of our MRL
newFileName = newFileName.remove(0,7);
// Remote the existing extention (if any)
int extentionPos = newFileName.lastIndexOf('.');
if(extentionPos >= 0)
{
newFileName = newFileName.remove(extentionPos, newFileName.length() - extentionPos);
}
// If we have multiple files (i.e. we have an appenBox) and it's checked
if(!singleFileSelected && appendBox->isChecked())
{
newFileName = newFileName.append("-converted");
}
// Stick our new extention on
newFileName = newFileName.append(fileExtension);
}
newFileName.replace( QChar('\''), "\\\'" );
mrl += "std{access=file{no-overwrite},mux=" + profile->getMux()
+ ",dst='" + newFileName
+ "'}";
if( displayBox->isChecked() )
mrl += "}";
}
msg_Dbg( p_intf, "Transcode MRL: %s", qtu( mrl ) );
mrls.append(mrl);
} }
msg_Dbg( p_intf, "Transcode MRL: %s", qtu( mrl ) );
accept(); accept();
} }
......
...@@ -36,19 +36,23 @@ class ConvertDialog : public QVLCDialog ...@@ -36,19 +36,23 @@ class ConvertDialog : public QVLCDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
ConvertDialog( QWidget *, intf_thread_t *, const QString& ); ConvertDialog( QWidget *, intf_thread_t *, const QStringList& );
virtual ~ConvertDialog(){} virtual ~ConvertDialog(){}
QString getMrl() {return mrl;} QStringList getMrls() {return mrls;}
private: private:
QLineEdit *fileLine; QLineEdit *fileLine;
QCheckBox *displayBox, *deinterBox; QCheckBox *displayBox, *deinterBox, *appendBox;
QRadioButton *dumpRadio; QRadioButton *dumpRadio;
QPushButton *okButton; QPushButton *okButton;
VLCProfileSelector *profile; VLCProfileSelector *profile;
QString mrl;
const QStringList *incomingMRLs;
bool singleFileSelected;
QStringList mrls;
private slots: private slots:
void close() Q_DECL_OVERRIDE; void close() Q_DECL_OVERRIDE;
void cancel() Q_DECL_OVERRIDE; void cancel() Q_DECL_OVERRIDE;
......
...@@ -392,13 +392,24 @@ void OpenDialog::transcode() ...@@ -392,13 +392,24 @@ void OpenDialog::transcode()
void OpenDialog::stream( bool b_transcode_only ) void OpenDialog::stream( bool b_transcode_only )
{ {
QString soutMRL = getMRL( false ); // QString soutMRL = getMRL( false );
if( soutMRL.isEmpty() ) return; // if( soutMRL.isEmpty() ) return;
QStringList soutMRLS = getMRLs(false);
if(soutMRLS.empty())
{
return;
}
toggleVisible(); toggleVisible();
/* Dbg and send :D */ /* Dbg and send :D */
msg_Dbg( p_intf, "MRL passed to the Sout: %s", qtu( soutMRL ) ); msg_Dbg( p_intf, "MRL(s) passed to the Sout: %i", soutMRLS.length() );
THEDP->streamingDialog( this, soutMRL, b_transcode_only, for(int i = 0; i < soutMRLS.length(); i++)
{
msg_Dbg( p_intf, "MRL(s) passed to the Sout: %s", qtu( soutMRLS[i] ) );
}
THEDP->streamingDialog( this, soutMRLS, b_transcode_only,
getOptions().split( " :" ) ); getOptions().split( " :" ) );
} }
......
...@@ -689,20 +689,22 @@ void DialogsProvider::saveRecentsToPlaylist() ...@@ -689,20 +689,22 @@ void DialogsProvider::saveRecentsToPlaylist()
****************************************************************************/ ****************************************************************************/
void DialogsProvider::streamingDialog( QWidget *parent, void DialogsProvider::streamingDialog( QWidget *parent,
const QString& mrl, const QStringList& mrls,
bool b_transcode_only, bool b_transcode_only,
QStringList options ) QStringList options )
{ {
QString soutoption; QStringList outputMRLs;
/* Stream */ /* Stream */
// Does streaming multiple files make sense? I suppose so, just stream one
// after the other, but not at the moment.
if( !b_transcode_only ) if( !b_transcode_only )
{ {
SoutDialog *s = new SoutDialog( parent, p_intf, mrl ); SoutDialog *s = new SoutDialog( parent, p_intf, mrls[0] );
s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883 s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
if( s->exec() == QDialog::Accepted ) if( s->exec() == QDialog::Accepted )
{ {
soutoption = s->getMrl(); outputMRLs.append(s->getMrl());
delete s; delete s;
} }
else else
...@@ -711,11 +713,15 @@ void DialogsProvider::streamingDialog( QWidget *parent, ...@@ -711,11 +713,15 @@ void DialogsProvider::streamingDialog( QWidget *parent,
} }
} else { } else {
/* Convert */ /* Convert */
ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl ); ConvertDialog *s = new ConvertDialog( parent, p_intf, mrls );
s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883 s->setAttribute( Qt::WA_QuitOnClose, false ); // See #4883
if( s->exec() == QDialog::Accepted ) if( s->exec() == QDialog::Accepted )
{ {
soutoption = s->getMrl(); /* Clear the playlist. This is because we're going to be populating
it */
playlist_Clear( THEPL, pl_Unlocked );
outputMRLs = s->getMrls();
delete s; delete s;
} }
else else
...@@ -724,12 +730,30 @@ void DialogsProvider::streamingDialog( QWidget *parent, ...@@ -724,12 +730,30 @@ void DialogsProvider::streamingDialog( QWidget *parent,
} }
} }
/* Get SoutMRL */ /* Get SoutMRL(s) */
if( !soutoption.isEmpty() ) if( !outputMRLs.isEmpty() )
{ {
options += soutoption.split( " :"); /* For all of our MRLs */
for(int i = 0; i < outputMRLs.length(); i++)
{
/* Duplicate the options list. This is because we need to have a
copy for every file we add to the playlist.*/
QStringList optionsCopy;
for(int j = 0; j < options.length(); j++)
{
optionsCopy.append(options[j]);
}
optionsCopy+= outputMRLs[i].split( " :");
QString title = "Converting " + mrls[i];
/* Add each file to convert to our playlist, making sure to not attempt to start playing it.*/
Open::openMRLwithOptions( p_intf, mrls[i], &optionsCopy, false, true, _(title.toStdString().c_str()) );
}
Open::openMRLwithOptions( p_intf, mrl, &options, true, true, _("Streaming") ); /* Start the playlist from the beginning */
playlist_Control(THEPL,PLAYLIST_PLAY,pl_Unlocked);
} }
} }
......
...@@ -160,7 +160,7 @@ public slots: ...@@ -160,7 +160,7 @@ public slots:
void PLOpenDir(); void PLOpenDir();
void PLAppendDir(); void PLAppendDir();
void streamingDialog( QWidget *parent, const QString& mrl, bool b_stream = true, void streamingDialog( QWidget *parent, const QStringList& mrls, bool b_stream = true,
QStringList options = QStringList("") ); QStringList options = QStringList("") );
void openAndStreamingDialogs(); void openAndStreamingDialogs();
void openAndTranscodingDialogs(); void openAndTranscodingDialogs();
......
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