Skip to content
Permalink
Browse files

Merge pull request #1029 from nyalldawson/composer_dialog_fixes

Save as Image dialog fixes and improvements
  • Loading branch information
timlinux committed Dec 30, 2013
2 parents 77fb9a5 + 377c13b commit 4aeaa3f7053105719d5072f80fcb728f69dc8319
Showing with 18 additions and 6 deletions.
  1. +17 −5 src/gui/qgisgui.cpp
  2. +1 −1 src/gui/qgisgui.h
@@ -83,7 +83,7 @@ namespace QgisGui
return false;
}

QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *theParent, QString theMessage )
QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget *theParent, QString theMessage, QString defaultFilename )
{
// get a list of supported output image types
QMap<QString, QString> filterMap;
@@ -93,7 +93,7 @@ namespace QgisGui
if ( format == "svg" )
continue;

filterMap.insert( createFileFilter_( format + " format", "*." + format ), format );
filterMap.insert( createFileFilter_( format.toUpper() + " format", "*." + format ), format );
}

#ifdef QGISDEBUG
@@ -113,8 +113,20 @@ namespace QgisGui
QString selectedFilter = lastUsedFilter;
QString ext;

#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
outputFileName = QFileDialog::getSaveFileName( theParent, theMessage, lastUsedDir, QStringList( filterMap.keys() ).join( ";;" ), &selectedFilter );
QString initialPath;
if ( defaultFilename.isNull() )
{
//no default filename provided, just use last directory
initialPath = lastUsedDir;
}
else
{
//a default filename was provided, so use it to build the initial path
initialPath = QDir( lastUsedDir ).filePath( defaultFilename );
}

#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_LINUX)
outputFileName = QFileDialog::getSaveFileName( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ), &selectedFilter );

if ( !outputFileName.isNull() )
{
@@ -125,7 +137,7 @@ namespace QgisGui
}
#else
//create a file dialog using the filter list generated above
std::auto_ptr<QFileDialog> fileDialog( new QFileDialog( theParent, theMessage, lastUsedDir, QStringList( filterMap.keys() ).join( ";;" ) ) );
std::auto_ptr<QFileDialog> fileDialog( new QFileDialog( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ) ) );

// allow for selection of more than one file
fileDialog->setFileMode( QFileDialog::AnyFile );
@@ -83,7 +83,7 @@ namespace QgisGui
* the file type
* @note added in 1.6
*/
QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget * theParent, QString theMessage );
QPair<QString, QString> GUI_EXPORT getSaveAsImageName( QWidget * theParent, QString theMessage, QString defaultFilename = NULL );

/**

0 comments on commit 4aeaa3f

Please sign in to comment.
You can’t perform that action at this time.