]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/convert.cpp
Qt: convert: don't enforce container extension (fix #9282)
[vlc] / modules / gui / qt4 / dialogs / convert.cpp
index 420c62209ef6f9cc55c21dba2fc33e308a02aa57..62cf8401870fa1b5cea9dfc6ca6d994710e7cf21 100644 (file)
@@ -68,28 +68,41 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
     destLayout->addWidget( fileSelectButton, 0, 2);
     BUTTONACT( fileSelectButton, fileBrowse() );
 
-    displayBox = new QCheckBox( qtr( "Display the output" ) );
-    displayBox->setToolTip( qtr( "This display the resulting media, but can "
-                               "slow things down." ) );
-    destLayout->addWidget( displayBox, 2, 0, 1, -1 );
-
-    mainLayout->addWidget( destBox, 1, 0, 1, -1  );
+    mainLayout->addWidget( destBox, 3, 0, 1, -1  );
 
 
     /* Profile Editor */
     QGroupBox *settingBox = new QGroupBox( qtr( "Settings" ) );
     QGridLayout *settingLayout = new QGridLayout( settingBox );
 
-    profile = new VLCProfileSelector( this );
-    settingLayout->addWidget( profile, 0, 0, 1, -1 );
+    QRadioButton *convertRadio = new QRadioButton( qtr( "Convert" ) );
+    dumpRadio = new QRadioButton( qtr( "Dump raw input" ) );
+    QButtonGroup *buttonGroup = new QButtonGroup(this);
+    buttonGroup->addButton( convertRadio );
+    buttonGroup->addButton( dumpRadio );
+    convertRadio->setChecked( true );
+
+    settingLayout->addWidget( convertRadio, 1, 0 );
+
+    QWidget *convertPanel = new QWidget( this );
+    QVBoxLayout *convertLayout = new QVBoxLayout( convertPanel );
+
+    displayBox = new QCheckBox( qtr( "Display the output" ) );
+    displayBox->setToolTip( qtr( "This display the resulting media, but can "
+                               "slow things down." ) );
+    convertLayout->addWidget( displayBox );
 
     deinterBox = new QCheckBox( qtr( "Deinterlace" ) );
-    settingLayout->addWidget( deinterBox, 1, 0 );
+    convertLayout->addWidget( deinterBox );
+
+    profile = new VLCProfileSelector( this );
+    convertLayout->addWidget( profile );
+
+    settingLayout->addWidget( convertPanel, 2, 0 );
 
-    dumpBox = new QCheckBox( qtr( "Dump raw input" ) );
-    settingLayout->addWidget( dumpBox, 1, 1 );
+    settingLayout->addWidget( dumpRadio, 5, 0 );
 
-    mainLayout->addWidget( settingBox, 3, 0, 1, -1  );
+    mainLayout->addWidget( settingBox, 1, 0, 1, -1  );
 
     /* Buttons */
     QPushButton *okButton = new QPushButton( qtr( "&Start" ) );
@@ -105,18 +118,19 @@ ConvertDialog::ConvertDialog( QWidget *parent, intf_thread_t *_p_intf,
     BUTTONACT(okButton,close());
     BUTTONACT(cancelButton,cancel());
 
-    CONNECT(dumpBox,toggled(bool),this,dumpChecked(bool));
+    CONNECT( convertRadio, toggled(bool), convertPanel, setEnabled(bool) );
     CONNECT(profile, optionsChanged(), this, setDestinationFileExtension());
     CONNECT(fileLine, editingFinished(), this, setDestinationFileExtension());
 }
 
 void ConvertDialog::fileBrowse()
 {
-    QString fileExtension = "." + profile->getMux();
+    QString fileExtension = ( ! profile->isEnabled() ) ? ".*" : "." + profile->getMux();
 
     QString fileName = QFileDialog::getSaveFileName( this, qtr( "Save file..." ),
-        "",
-        QString( qtr( "Containers (*" ) + fileExtension + ")" ) );
+        p_intf->p_sys->filepath,
+        QString( "%1 (*%2);;%3 (*.*)" ).arg( qtr( "Containers" ) )
+            .arg( fileExtension ).arg( qtr("All") ) );
     fileLine->setText( toNativeSeparators( fileName ) );
     setDestinationFileExtension();
 }
@@ -130,7 +144,7 @@ void ConvertDialog::close()
 {
     hide();
 
-    if( dumpBox->isChecked() )
+    if( dumpRadio->isChecked() )
     {
         mrl = "demux=dump :demuxdump-file=" + fileLine->text();
     }
@@ -156,25 +170,15 @@ void ConvertDialog::close()
     accept();
 }
 
-void ConvertDialog::dumpChecked( bool checked )
-{
-    deinterBox->setEnabled( !checked );
-    displayBox->setEnabled( !checked );
-    profile->setEnabled( !checked );
-}
-
 void ConvertDialog::setDestinationFileExtension()
 {
-    if( !fileLine->text().isEmpty() )
+    if( !fileLine->text().isEmpty() && profile->isEnabled() )
     {
         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 );
+        if( fileLine->text().lastIndexOf( "." ) == -1 )
+        {
+            QString newFileName = fileLine->text().append( newFileExtension );
+            fileLine->setText( toNativeSeparators( newFileName ) );
         }
-        fileLine->setText( toNativeSeparators( newFileName ) );
     }
 }