Commit 6119143e authored by Vasily Fomin's avatar Vasily Fomin Committed by Jean-Baptiste Kempf

Qt: Automatic file extension in Transcode/Save

Close #4345
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent f447119e
...@@ -106,14 +106,19 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf, ...@@ -106,14 +106,19 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
BUTTONACT(cancelButton,cancel()); BUTTONACT(cancelButton,cancel());
CONNECT(dumpBox,toggled(bool),this,dumpChecked(bool)); CONNECT(dumpBox,toggled(bool),this,dumpChecked(bool));
CONNECT(profile, optionsChanged(), this, setDestinationFileExtension());
CONNECT(fileLine, editingFinished(), this, setDestinationFileExtension());
} }
void ConvertDialog::fileBrowse() void ConvertDialog::fileBrowse()
{ {
QString fileExtension = "." + profile->getMux();
QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ), QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
"", "",
qtr( "Containers (*.ps *.ts *.mpg *.ogg *.asf *.mp4 *.mov *.wav *.raw *.flv *.webm)" ) ); QString( qtr( "Containers (*" ) + fileExtension + ")" ) );
fileLine->setText( toNativeSeparators( fileName ) ); fileLine->setText( toNativeSeparators( fileName ) );
setDestinationFileExtension();
} }
void ConvertDialog::cancel() void ConvertDialog::cancel()
...@@ -156,3 +161,19 @@ void ConvertDialog::dumpChecked( bool checked ) ...@@ -156,3 +161,19 @@ void ConvertDialog::dumpChecked( bool checked )
displayBox->setEnabled( !checked ); displayBox->setEnabled( !checked );
profile->setEnabled( !checked ); profile->setEnabled( !checked );
} }
void ConvertDialog::setDestinationFileExtension()
{
if( !fileLine->text().isEmpty() )
{
QString newFileExtension = "." + profile->getMux();
QString newFileName;
int index = fileLine->text().lastIndexOf( "." );
if( index != -1 ) {
newFileName = fileLine->text().left( index ).append( newFileExtension );
} else {
newFileName = fileLine->text().append( newFileExtension );
}
fileLine->setText( toNativeSeparators( newFileName ) );
}
}
...@@ -50,6 +50,7 @@ private slots: ...@@ -50,6 +50,7 @@ private slots:
virtual void cancel(); virtual void cancel();
void fileBrowse(); void fileBrowse();
void dumpChecked(bool); void dumpChecked(bool);
void setDestinationFileExtension();
}; };
#endif #endif
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