From 8887b4e7ceb9f3bf7c2e8262ffe0518dcb68522a Mon Sep 17 00:00:00 2001 From: Pavel Makarenko Date: Wed, 30 Jan 2019 17:37:56 +0300 Subject: [PATCH] Add support for more images formats (#436) * Add support for more images formats * Resolves extension verifying in case of empty save path string * Code formatting --- src/utils/screenshotsaver.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/screenshotsaver.cpp b/src/utils/screenshotsaver.cpp index 5ac5badd..11c66d05 100644 --- a/src/utils/screenshotsaver.cpp +++ b/src/utils/screenshotsaver.cpp @@ -60,15 +60,19 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) { QString savePath = QFileDialog::getSaveFileName( nullptr, QString(), - FileNameHandler().absoluteSavePath() + ".png"); + FileNameHandler().absoluteSavePath() + ".png", + QLatin1String("Portable Network Graphic file (PNG) (*.png);;BMP file (*.bmp);;JPEG file (*.jpg)")); if (savePath.isNull()) { break; } - if (!savePath.endsWith(QLatin1String(".png"))) { - savePath += QLatin1String(".png"); - } + if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) && + !savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) && + !savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) { + + savePath += QLatin1String(".png"); + } ok = capture.save(savePath);