[vlmc-devel] commit: export dialog: sanity checks on the given path (Ludovic Fauvet )

git at videolan.org git at videolan.org
Sat Mar 20 01:34:53 CET 2010


vlmc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Sat Mar 20 01:24:14 2010 +0100| [3213986ea655b8dca070a8f215b188b09b0b196c] | committer: Ludovic Fauvet 

export dialog: sanity checks on the given path

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=3213986ea655b8dca070a8f215b188b09b0b196c
---

 src/Gui/export/RendererSettings.cpp |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/Gui/export/RendererSettings.cpp b/src/Gui/export/RendererSettings.cpp
index dcc532f..756fc4f 100644
--- a/src/Gui/export/RendererSettings.cpp
+++ b/src/Gui/export/RendererSettings.cpp
@@ -29,6 +29,7 @@
 #include <QMessageBox>
 #include <QCompleter>
 #include <QDirModel>
+#include <QFileInfo>
 
 RendererSettings::RendererSettings()
 {
@@ -57,14 +58,36 @@ RendererSettings::selectOutputFileName()
 void
 RendererSettings::accept()
 {
-    if ( width() <= 0 || height() <= 0 || outputFileName().isEmpty() == true ||
-         fps() <= .0f )
+    if ( width() <= 0 || height() <= 0 || fps() <= .0f )
     {
         QMessageBox::warning( this, tr( "Invalid parameters" ),
                               tr( "Please enter valid rendering parameters" ) );
+        return;
     }
-    else
-        QDialog::accept();
+
+    QFileInfo fileInfo( m_ui.outputFileName->text() );
+
+    if ( outputFileName().isEmpty() || fileInfo.isDir() || !fileInfo.dir().exists() )
+    {
+        QMessageBox::warning( this, tr( "Invalid parameters" ),
+                              tr( "Please provide a valid output file!" ) );
+        m_ui.outputFileName->setFocus();
+        return;
+    }
+
+    if ( fileInfo.isFile() )
+    {
+        QMessageBox::StandardButton b =
+                QMessageBox::question( this, tr( "File already exists!" ),
+                                       tr( "Output file already exists, do you want to "
+                                           "overwrite it ?" ),
+                                       QMessageBox::Yes | QMessageBox::No,
+                                       QMessageBox::No );
+        if ( b == QMessageBox::No )
+            return;
+    }
+
+    QDialog::accept();
 }
 
 quint32



More information about the Vlmc-devel mailing list