Skip to content

Commit

Permalink
Fix for ticket #291 (same as image not giving the choice of image
Browse files Browse the repository at this point in the history
 formats). The problem seems to with the list of formats that qt is
 supposed to provide, but doesn't. Hard-wired to provide jpg and png
 for the moment.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5868 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Sep 22, 2006
1 parent c897e91 commit 1a3bc56
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/gui/qgisapp.cpp
Expand Up @@ -2996,9 +2996,18 @@ void QgisApp::saveMapAsImage()
// get a list of supported output image types
int myCounterInt=0;
QString myFilters;
for ( ; myCounterInt < QPictureIO::outputFormats().count(); myCounterInt++ )
QList<QByteArray> formats = QPictureIO::outputFormats();
// Workaround for a problem with Qt4 - calls to outputFormats tend
// to return nothing :(
if (formats.count() == 0)
{
QString myFormat=QString(QPictureIO::outputFormats().at( myCounterInt ));
formats.append("png");
formats.append("jpg");
}

for ( ; myCounterInt < formats.count(); myCounterInt++ )
{
QString myFormat=QString(formats.at( myCounterInt ));
QString myFilter = createFileFilter_(myFormat + " format", "*."+myFormat);
myFilters += myFilter;
myFilterMap[myFilter] = myFormat;
Expand Down Expand Up @@ -3046,6 +3055,12 @@ void QgisApp::saveMapAsImage()
std::cout << "Image type to be passed to mapcanvas: " << (myFilterMap[myFilterString]).toLocal8Bit().data() << std::endl;
#endif

// Add the file type suffix to the filename if required
if (!myOutputFileNameQString.endsWith(myFilterMap[myFilterString]))
{
myOutputFileNameQString += "." + myFilterMap[myFilterString];
}

myQSettings.writeEntry("/UI/lastSaveAsImageFilter" , myFilterString);
myQSettings.writeEntry("/UI/lastSaveAsImageDir", myQFileDialog->directory().absolutePath());

Expand Down

0 comments on commit 1a3bc56

Please sign in to comment.