Salome HOME
getFileName() function is defined as pure virtual public in the SUIT_Application...
[modules/gui.git] / src / GLViewer / GLViewer_ViewFrame.cxx
index 5e9e173802a3e5b42b5b93217987b639a629e77b..14e2305abae6ac18696a2dade2e0e02d1a9dd413 100644 (file)
 #include "GLViewer_ViewPort2d.h"
 
 #include <SUIT_Desktop.h>
+#include <SUIT_Application.h>
 #include <SUIT_Session.h>
 #include <SUIT_ToolButton.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Tools.h>
 #include <QtxAction.h>
 #include <SUIT_MessageBox.h>
 
 #include <qcolor.h>
-#include <qfiledialog.h>
 #include <qimage.h>
 #include <qlayout.h>
 #include <qstring.h>
@@ -383,39 +384,22 @@ void GLViewer_ViewFrame::onViewDump()
 
     delete [] imageBits;
 
-    QString aFilter( "*.bmp\n*.png" );
+    SUIT_Application* app = getViewManager()->study()->application();
 
-    QFileDialog aFileDlg( QDir::current().absPath(), aFilter, this );
-    aFileDlg.setCaption( tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ) );
-    aFileDlg.setMode( QFileDialog::AnyFile );
+    QString aFileName = app->getFileName( false, QString::null, QString( "*.bmp;*.png" ), tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ), 0 );
 
-    if( !aFileDlg.exec() )
-        return;
-
-    QString aFileName = aFileDlg.selectedFile();
-    QString aFileExt = aFileDlg.selectedFilter();
-
-    if( aFileName.isEmpty() )
-    {
-        SUIT_MessageBox::error1( this,
-                                tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
-                                tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
-                                tr( "BUT_OK" ) );
-    }
+    if( aFileName.isEmpty() ) // cancelled
+      return;
 
-    QString aSaveOp = "BMP";
-    QString aTypedFileExt = QFileInfo( aFileName ).extension( false ).lower();
+    QString aSaveOp = SUIT_Tools::extension( aFileName ).upper();
 
-    if( aFileExt == "*.bmp" )
-    {
-        if( aTypedFileExt.isEmpty() )
-            aFileName += ".bmp";
-        aSaveOp = "BMP";
+    if ( aSaveOp != "BMP" && aSaveOp != "PNG" ) {
+      SUIT_MessageBox::error1( this,
+                              tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
+                              tr( "DUMP_VIEW_ERROR_UNSUPPORTED_FORMAT" ).arg( aSaveOp ),
+                              tr( "BUT_OK" ) );
+      return;
     }
-    else if( aFileExt == "*.png" )
-        if( aTypedFileExt.isEmpty() )
-            aFileName += ".png";
-        aSaveOp = "PNG";
 
     if( !anImage.save( aFileName, aSaveOp ) )
     {