Fix image file saving (#279)

This change ensures that the file name contains the PNG extension.

Currently the screenshots are saved as PNG only, so this only checks if the absolute path contains .png, it does not check the file suffix (QFileInfo).

Fixes #278
This commit is contained in:
Alfredo Ramos
2018-07-23 04:15:39 -05:00
committed by Dharkael
parent 21670e3344
commit 9748ae015e

View File

@@ -41,18 +41,21 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture,
completePath += ".png";
bool ok = capture.save(completePath);
QString saveMessage;
if (ok) {
ConfigHandler().setSavePath(path);
saveMessage = QObject::tr("Capture saved as ") + completePath;
} else {
saveMessage = QObject::tr("Error trying to save as ") + completePath;
}
SystemNotification().sendMessage(saveMessage);
return ok;
}
bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
bool ok = false;
while (!ok) {
QString savePath = QFileDialog::getSaveFileName(
nullptr,
@@ -62,7 +65,13 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
if (savePath.isNull()) {
break;
}
if (!savePath.endsWith(".png")) {
savePath += ".png";
}
ok = capture.save(savePath);
if (ok) {
QString pathNoFile = savePath.left(savePath.lastIndexOf("/"));
ConfigHandler().setSavePath(pathNoFile);