Save image with correct extension

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-03-25 01:58:00 +02:00
parent fc27fa7fef
commit ae53e505c4

View File

@ -694,10 +694,14 @@ void DialogPatternProperties::SaveImage()
QByteArray byteArray;
byteArray.append(doc->GetImage().toUtf8());
QByteArray ba = QByteArray::fromBase64(byteArray);
QString extension = "." + doc->GetImageExtension();
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"));
QFile file(filename + extension);
QString filter = "Images (*" + extension + ")";
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), "untitled", filter, &filter);
if (not filename.endsWith(extension.toUpper()))
{
filename.append(extension);
}
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
file.write(ba);