From: vsr Date: Fri, 17 Jun 2005 07:04:45 +0000 (+0000) Subject: getFileName() function is defined as pure virtual public in the SUIT_Application... X-Git-Tag: T3_0_0_a4~97 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=40b238e953f129539147ae9573a532bca3443371;p=modules%2Fgui.git getFileName() function is defined as pure virtual public in the SUIT_Application class to be used from all packages in order to unify Open/Save dialog boxes throughout in the application. --- diff --git a/src/CAF/CAF_Application.cxx b/src/CAF/CAF_Application.cxx index 1ce1d0f30..3a069fdcb 100755 --- a/src/CAF/CAF_Application.cxx +++ b/src/CAF/CAF_Application.cxx @@ -15,7 +15,6 @@ #include #include #include -#include #include extern "C" CAF_EXPORT SUIT_Application* createApplication() @@ -175,4 +174,4 @@ void CAF_Application::updateCommandsStatus() void CAF_Application::onHelpAbout() { SUIT_MessageBox::info1( desktop(), tr( "About" ), tr( "ABOUT_INFO" ), "&OK" ); -} \ No newline at end of file +} diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index 5e9e17380..14e2305ab 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -17,14 +17,15 @@ #include "GLViewer_ViewPort2d.h" #include +#include #include #include #include +#include #include #include #include -#include #include #include #include @@ -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 ) ) { diff --git a/src/GLViewer/resources/GLViewer_msg_en.po b/src/GLViewer/resources/GLViewer_msg_en.po index f6a8cdab7..ca1b5e351 100644 --- a/src/GLViewer/resources/GLViewer_msg_en.po +++ b/src/GLViewer/resources/GLViewer_msg_en.po @@ -81,10 +81,13 @@ msgid "GLViewer_Viewer2d::CHANGE_BGCOLOR" msgstr "Change background..." msgid "GLViewer_ViewFrame::DUMP_VIEW_SAVE_FILE_DLG_CAPTION" -msgstr "Save Dump View in file" +msgstr "Dump View" msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_DLG_CAPTION" msgstr "Error" msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_DLG_TEXT" -msgstr "Can't save Dump View in file" +msgstr "Dump view operation failed." + +msgid "GLViewer_ViewFrame::DUMP_VIEW_ERROR_UNSUPPORTED_FORMAT" +msgstr "Can't dump view. Unsupported image format: %1." diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 58df1e245..eae8cda77 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -13,7 +13,6 @@ #include "SUIT_Tools.h" #include "SUIT_ResourceMgr.h" -#include "SUIT_FileDlg.h" #include "SUIT_MessageBox.h" #include @@ -22,7 +21,7 @@ #include #include #include - +#include const char* imageZoomCursor[] = { "32 32 3 1", @@ -778,19 +777,18 @@ void OCCViewer_ViewWindow::onDumpView() QPixmap px = QPixmap::grabWindow(myViewPort->winId()); QApplication::restoreOverrideCursor(); - QString fileName = SUIT_FileDlg::getFileName(this, - QString::null, - tr("OCC_IMAGE_FILES"), - tr("INF_APP_DUMP_VIEW"), - false); - if (!fileName.isNull()) { + SUIT_Application* app = getViewManager()->study()->application(); + + QString aFileName = app->getFileName( false, QString::null, tr("OCC_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 ); + + if ( !aFileName.isNull() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = SUIT_Tools::extension(fileName).upper(); + QString fmt = SUIT_Tools::extension( aFileName ).upper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG") fmt = "JPEG"; - bool bOk = px.save(fileName, fmt.latin1()); + bool bOk = px.save(aFileName, fmt.latin1()); QApplication::restoreOverrideCursor(); if (!bOk) { SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK")); diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index fa5105239..a5f7abd2a 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -7,10 +7,10 @@ #include "Plot2d_SetupViewDlg.h" #include "SUIT_Tools.h" -#include "SUIT_FileDlg.h" #include "SUIT_Session.h" #include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" +#include "SUIT_Application.h" //#include "utilities.h" @@ -1470,21 +1470,20 @@ void Plot2d_ViewFrame::onDump() QApplication::setOverrideCursor( Qt::waitCursor ); QPixmap px = QPixmap::grabWindow(winId()); QApplication::restoreOverrideCursor(); - - QString fileName = SUIT_FileDlg::getFileName(this, - QString::null, - tr("OCC_IMAGE_FILES"), - tr("INF_APP_DUMP_VIEW"), - false); - if ( !fileName.isNull() ) + + SUIT_Application* app = ((Plot2d_ViewWindow*)parent())->getViewManager()->study()->application(); + + QString aFileName = app->getFileName( false, QString::null, tr("PLOT2D_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 ); + + if ( !aFileName.isNull() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = SUIT_Tools::extension( fileName ).upper(); + QString fmt = SUIT_Tools::extension( aFileName ).upper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG") fmt = "JPEG"; - bool bOk = px.save(fileName, fmt.latin1()); + bool bOk = px.save(aFileName, fmt.latin1()); QApplication::restoreOverrideCursor(); if (!bOk) { SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK")); diff --git a/src/Plot2d/resources/Plot2d_msg_en.po b/src/Plot2d/resources/Plot2d_msg_en.po index 85bdd2256..ce99101b5 100755 --- a/src/Plot2d/resources/Plot2d_msg_en.po +++ b/src/Plot2d/resources/Plot2d_msg_en.po @@ -126,7 +126,7 @@ msgstr "Coordinates: X : %1, Y : %2 ( %3 )" #msgid "INF_READY" #msgstr "Ready" -msgid "OCC_IMAGE_FILES" +msgid "PLOT2D_IMAGE_FILES" msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)" msgid "INF_APP_DUMP_VIEW" diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 0b1901d8b..a840bb2f5 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -15,7 +15,6 @@ #include "SUIT_Tools.h" #include "SUIT_ResourceMgr.h" -#include "SUIT_FileDlg.h" #include "VTKViewer_Transform.h" #include "VTKViewer_Utilities.h" @@ -427,19 +426,18 @@ SVTK_ViewWindow QPixmap px = QPixmap::grabWindow(myRenderWindow->winId()); QApplication::restoreOverrideCursor(); - QString fileName = SUIT_FileDlg::getFileName(this, - QString::null, - tr("VTK_IMAGE_FILES"), - tr("INF_APP_DUMP_VIEW"), - false); - if (!fileName.isNull()) { + SUIT_Application* app = getViewManager()->study()->application(); + + QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 ); + + if ( !aFileName.isNull() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = SUIT_Tools::extension( fileName ).upper(); + QString fmt = SUIT_Tools::extension( aFileName ).upper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG") fmt = "JPEG"; - bool bOk = px.save(fileName, fmt.latin1()); + bool bOk = px.save(aFileName, fmt.latin1()); QApplication::restoreOverrideCursor(); if (!bOk) { SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK")); diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx index 81e525bd3..d06d2e0e3 100755 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -31,7 +31,6 @@ #include "SUIT_Application.h" #include "SUIT_Desktop.h" -#include "SUIT_FileDlg.h" #include "SUIT_MessageBox.h" #include "SUIT_Tools.h" #include "SUIT_Session.h" @@ -45,6 +44,7 @@ #include #include #include +#include #include #include @@ -333,34 +333,21 @@ void ToolsGUI_CatalogGeneratorDlg::onBrowseBtnClicked() { QPushButton* send = (QPushButton*)sender(); - QWidget* aParent = SUIT_Session::session()->activeApplication()->desktop(); + SUIT_Application* app = SUIT_Session::session()->activeApplication(); if ( send == myBrowseIdlBtn ) { - QString file = myIdlEdit->text().stripWhiteSpace(); - file = SUIT_FileDlg::getFileName(aParent, - file, - tr("TOOLS_MEN_IMPORT_IDL"), - tr("TOOLS_MEN_IMPORT"), - true); + QString file = app->getFileName( true, myIdlEdit->text().stripWhiteSpace(), tr("TOOLS_MEN_IMPORT_IDL"), tr("TOOLS_MEN_IMPORT"), 0 ); if ( !file.isEmpty() ) { myIdlEdit->setText(file); } } else if ( send == myBrowseXmlBtn ) { - QString file = SUIT_FileDlg::getFileName(aParent, - myXmlEdit->text().stripWhiteSpace(), - tr("TOOLS_MEN_EXPORT_XML"), - tr("TOOLS_MEN_EXPORT"), - false); + QString file = app->getFileName( false, myXmlEdit->text().stripWhiteSpace(), tr("TOOLS_MEN_EXPORT_XML"), tr("TOOLS_MEN_EXPORT"), 0 ); if ( !file.isEmpty() ) { myXmlEdit->setText(file); } } else if ( send == myBrowsePngBtn ) { - QString file = SUIT_FileDlg::getFileName(aParent, - myXmlEdit->text().stripWhiteSpace(), - tr("TOOLS_MEN_IMPORT_PNG"), - tr("TOOLS_MEN_IMPORT"), - true); + QString file = app->getFileName( true, myPngEdit->text().stripWhiteSpace(), tr("TOOLS_MEN_IMPORT_PNG"), tr("TOOLS_MEN_IMPORT"), 0 ); if ( !file.isEmpty() ) { myPngEdit->setText(file); diff --git a/src/VTKViewer/VTKViewer_ViewWindow.cxx b/src/VTKViewer/VTKViewer_ViewWindow.cxx index 6739715d9..124b95097 100755 --- a/src/VTKViewer/VTKViewer_ViewWindow.cxx +++ b/src/VTKViewer/VTKViewer_ViewWindow.cxx @@ -13,7 +13,6 @@ #include "SUIT_Tools.h" #include "SUIT_ResourceMgr.h" -#include "SUIT_FileDlg.h" #include @@ -393,20 +392,19 @@ void VTKViewer_ViewWindow::onDumpView() QApplication::setOverrideCursor( Qt::waitCursor ); QPixmap px = QPixmap::grabWindow(myRenderWindow->winId()); QApplication::restoreOverrideCursor(); - - QString fileName = SUIT_FileDlg::getFileName(this, - QString::null, - tr("VTK_IMAGE_FILES"), - tr("INF_APP_DUMP_VIEW"), - false); - if (!fileName.isNull()) { + + SUIT_Application* app = getViewManager()->study()->application(); + + QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 ); + + if ( !aFileName.isNull() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = SUIT_Tools::extension( fileName ).upper(); + QString fmt = SUIT_Tools::extension( aFileName ).upper(); if (fmt.isEmpty()) fmt = QString("BMP"); // default format if (fmt == "JPG") fmt = "JPEG"; - bool bOk = px.save(fileName, fmt.latin1()); + bool bOk = px.save(aFileName, fmt.latin1()); QApplication::restoreOverrideCursor(); if (!bOk) { SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));