+ Save selected image format for pictures

This commit is contained in:
wmayer 2013-10-21 13:01:38 +02:00
parent e8f752ec2d
commit 7cae1d9666

View File

@ -67,6 +67,8 @@
#include <Base/Exception.h> #include <Base/Exception.h>
#include <Base/FileInfo.h> #include <Base/FileInfo.h>
#include <Base/Reader.h> #include <Base/Reader.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <App/Document.h> #include <App/Document.h>
#include <App/GeoFeature.h> #include <App/GeoFeature.h>
#include <App/DocumentObjectGroup.h> #include <App/DocumentObjectGroup.h>
@ -1316,11 +1318,17 @@ void StdViewScreenShot::activated(int iMsg)
formats = rd.getWriteImageFiletypeInfo(); formats = rd.getWriteImageFiletypeInfo();
} }
Base::Reference<ParameterGrp> hExt = App::GetApplication().GetUserParameter().GetGroup("BaseApp")
->GetGroup("Preferences")->GetGroup("General");
QString ext = QString::fromAscii(hExt->GetASCII("OffscreenImageFormat").c_str());
QStringList filter; QStringList filter;
QString selFilter; QString selFilter;
for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) { for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) {
filter << QString::fromAscii("%1 %2 (*.%3)").arg((*it).toUpper()). filter << QString::fromAscii("%1 %2 (*.%3)").arg((*it).toUpper()).
arg(QObject::tr("files")).arg((*it).toLower()); arg(QObject::tr("files")).arg((*it).toLower());
if (ext == *it)
selFilter = filter.last();
} }
FileOptionsDialog fd(getMainWindow(), 0); FileOptionsDialog fd(getMainWindow(), 0);
@ -1328,6 +1336,8 @@ void StdViewScreenShot::activated(int iMsg)
fd.setAcceptMode(QFileDialog::AcceptSave); fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setWindowTitle(QObject::tr("Save picture")); fd.setWindowTitle(QObject::tr("Save picture"));
fd.setFilters(filter); fd.setFilters(filter);
if (!selFilter.isEmpty())
fd.selectNameFilter(selFilter);
// create the image options widget // create the image options widget
DlgSettingsImageImp* opt = new DlgSettingsImageImp(&fd); DlgSettingsImageImp* opt = new DlgSettingsImageImp(&fd);
@ -1341,7 +1351,7 @@ void StdViewScreenShot::activated(int iMsg)
opt, SLOT(onSelectedFilter(const QString&))); opt, SLOT(onSelectedFilter(const QString&)));
if (fd.exec() == QDialog::Accepted) { if (fd.exec() == QDialog::Accepted) {
selFilter = fd.selectedFilter(); selFilter = fd.selectedNameFilter();
QString fn = fd.selectedFiles().front(); QString fn = fd.selectedFiles().front();
// We must convert '\' path separators to '/' before otherwise // We must convert '\' path separators to '/' before otherwise
// Python would interpret them as escape sequences. // Python would interpret them as escape sequences.
@ -1362,6 +1372,8 @@ void StdViewScreenShot::activated(int iMsg)
} }
} }
hExt->SetASCII("OffscreenImageFormat", (const char*)format.toAscii());
// which background chosen // which background chosen
const char* background; const char* background;
switch(opt->backgroundType()){ switch(opt->backgroundType()){