#include <SUIT_Desktop.h>
#include <QtxWorkstack.h>
#include <QApplication>
+#include <QFileInfo>
HYDROGUI_ImportImageOp::HYDROGUI_ImportImageOp( HYDROGUI_Module* theModule,
const bool theIsEdit )
}
}
- 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 );
}