From 9748ae015ec21db98036860a48fa75e5cccdccaf Mon Sep 17 00:00:00 2001 From: Alfredo Ramos Date: Mon, 23 Jul 2018 04:15:39 -0500 Subject: [PATCH] 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 --- src/utils/screenshotsaver.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index b6bd3eee..3e13dcb4 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -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);