From: rkv Date: Wed, 4 Dec 2013 11:51:43 +0000 (+0000) Subject: Fix for the bug #164: default Image name. X-Git-Tag: BR_hydro_v_0_4~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0e5bcf62a18219d11b921902156c0436d9edb8c3;p=modules%2Fhydro.git Fix for the bug #164: default Image name. --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index e9c2fa38..3c3f64f0 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -43,6 +43,7 @@ #include #include #include +#include HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule, const bool theIsEdit ) @@ -530,14 +531,27 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) } } - QString anImageName; - if( myIsEdit ) + // Set the image name in the dialog + QString anImageName = aPanel->getImageName().simplified(); + // If edit mode and the name was not set yet then get from the edited object + if( myIsEdit && anImageName.isEmpty() ) { if( !myEditedObject.IsNull() ) anImageName = myEditedObject->GetName(); } - else - anImageName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_IMAGE_NAME" ) ); + // If the name was not set then initialize it from the selected file name + if ( anImageName.isEmpty() ) + { + anImageName = aPanel->getFileName(); + if ( !anImageName.isEmpty() ) { + anImageName = QFileInfo( anImageName ).baseName(); + } + // If no file name then generate a new image name + if ( anImageName.isEmpty() ) { + anImageName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_IMAGE_NAME" ) ); + } + } + aPanel->setImageName( anImageName ); }