Skip to content

Commit 1a3bc56

Browse files
author
g_j_m
committedSep 22, 2006
Fix for ticket #291 (same as image not giving the choice of image
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

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
 

‎src/gui/qgisapp.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2996,9 +2996,18 @@ void QgisApp::saveMapAsImage()
29962996
// get a list of supported output image types
29972997
int myCounterInt=0;
29982998
QString myFilters;
2999-
for ( ; myCounterInt < QPictureIO::outputFormats().count(); myCounterInt++ )
2999+
QList<QByteArray> formats = QPictureIO::outputFormats();
3000+
// Workaround for a problem with Qt4 - calls to outputFormats tend
3001+
// to return nothing :(
3002+
if (formats.count() == 0)
30003003
{
3001-
QString myFormat=QString(QPictureIO::outputFormats().at( myCounterInt ));
3004+
formats.append("png");
3005+
formats.append("jpg");
3006+
}
3007+
3008+
for ( ; myCounterInt < formats.count(); myCounterInt++ )
3009+
{
3010+
QString myFormat=QString(formats.at( myCounterInt ));
30023011
QString myFilter = createFileFilter_(myFormat + " format", "*."+myFormat);
30033012
myFilters += myFilter;
30043013
myFilterMap[myFilter] = myFormat;
@@ -3046,6 +3055,12 @@ void QgisApp::saveMapAsImage()
30463055
std::cout << "Image type to be passed to mapcanvas: " << (myFilterMap[myFilterString]).toLocal8Bit().data() << std::endl;
30473056
#endif
30483057

3058+
// Add the file type suffix to the filename if required
3059+
if (!myOutputFileNameQString.endsWith(myFilterMap[myFilterString]))
3060+
{
3061+
myOutputFileNameQString += "." + myFilterMap[myFilterString];
3062+
}
3063+
30493064
myQSettings.writeEntry("/UI/lastSaveAsImageFilter" , myFilterString);
30503065
myQSettings.writeEntry("/UI/lastSaveAsImageDir", myQFileDialog->directory().absolutePath());
30513066

0 commit comments

Comments
 (0)
Please sign in to comment.