From 8a90ab7036257fa2db6405dc1d9805fccedd05ac Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 17 Sep 2017 23:27:49 +0200 Subject: [PATCH] give users the ability to import files with wrong extension --- ProfileInterface.cpp | 37 ++++++++++++++++++++++++++++--------- config.h | 2 +- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 4fb7c62..51e8cc0 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -32,6 +32,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -526,16 +527,25 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple) { if (!notMultiple) { - QImage snapmaticImage; - QString customImageTitle; - QPixmap snapmaticPixmap(960, 536); - snapmaticPixmap.fill(Qt::black); - QPainter snapmaticPainter(&snapmaticPixmap); - if (!snapmaticImage.load(selectedFile)) + QFile snapmaticFile(selectedFile); + if (!snapmaticFile.open(QFile::ReadOnly)) { delete picture; return false; } + QImage snapmaticImage; + QImageReader snapmaticImageReader; + snapmaticImageReader.setDecideFormatFromContent(true); + snapmaticImageReader.setDevice(&snapmaticFile); + if (!snapmaticImageReader.read(&snapmaticImage)) + { + delete picture; + return false; + } + QString customImageTitle; + QPixmap snapmaticPixmap(960, 536); + snapmaticPixmap.fill(Qt::black); + QPainter snapmaticPainter(&snapmaticPixmap); if (snapmaticImage.height() == snapmaticImage.width()) { // Avatar mode @@ -609,8 +619,17 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple) else { bool success = false; + QFile snapmaticFile(selectedFile); + if (!snapmaticFile.open(QFile::ReadOnly)) + { + delete picture; + return false; + } QImage snapmaticImage; - if (!snapmaticImage.load(selectedFile)) + QImageReader snapmaticImageReader; + snapmaticImageReader.setDecideFormatFromContent(true); + snapmaticImageReader.setDevice(&snapmaticFile); + if (!snapmaticImageReader.read(&snapmaticImage)) { delete picture; return false; @@ -1160,8 +1179,8 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData) if (pathList.length() == 1) { - QString selectedFile = pathList.at(0); - importFile(selectedFile, true); + QString selectedFile = pathList.at(0); + importFile(selectedFile, true); } else if (pathList.length() > 1) { diff --git a/config.h b/config.h index 9906204..a7b3ba8 100755 --- a/config.h +++ b/config.h @@ -50,7 +50,7 @@ #ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_DAILYB -#define GTA5SYNC_APPVER "1.4.2" +#define GTA5SYNC_APPVER "1.4.3" #else #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #endif