give users the ability to import files with wrong extension

This commit is contained in:
Syping 2017-09-17 23:27:49 +02:00
parent dc0a007774
commit 8a90ab7036
2 changed files with 29 additions and 10 deletions

View File

@ -32,6 +32,7 @@
#include "config.h" #include "config.h"
#include <QProgressDialog> #include <QProgressDialog>
#include <QStringBuilder> #include <QStringBuilder>
#include <QImageReader>
#include <QProgressBar> #include <QProgressBar>
#include <QInputDialog> #include <QInputDialog>
#include <QPushButton> #include <QPushButton>
@ -526,16 +527,25 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
{ {
if (!notMultiple) if (!notMultiple)
{ {
QImage snapmaticImage; QFile snapmaticFile(selectedFile);
QString customImageTitle; if (!snapmaticFile.open(QFile::ReadOnly))
QPixmap snapmaticPixmap(960, 536);
snapmaticPixmap.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticPixmap);
if (!snapmaticImage.load(selectedFile))
{ {
delete picture; delete picture;
return false; 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()) if (snapmaticImage.height() == snapmaticImage.width())
{ {
// Avatar mode // Avatar mode
@ -609,8 +619,17 @@ bool ProfileInterface::importFile(QString selectedFile, bool notMultiple)
else else
{ {
bool success = false; bool success = false;
QFile snapmaticFile(selectedFile);
if (!snapmaticFile.open(QFile::ReadOnly))
{
delete picture;
return false;
}
QImage snapmaticImage; QImage snapmaticImage;
if (!snapmaticImage.load(selectedFile)) QImageReader snapmaticImageReader;
snapmaticImageReader.setDecideFormatFromContent(true);
snapmaticImageReader.setDevice(&snapmaticFile);
if (!snapmaticImageReader.read(&snapmaticImage))
{ {
delete picture; delete picture;
return false; return false;
@ -1160,8 +1179,8 @@ void ProfileInterface::on_saProfileContent_dropped(const QMimeData *mimeData)
if (pathList.length() == 1) if (pathList.length() == 1)
{ {
QString selectedFile = pathList.at(0); QString selectedFile = pathList.at(0);
importFile(selectedFile, true); importFile(selectedFile, true);
} }
else if (pathList.length() > 1) else if (pathList.length() > 1)
{ {

View File

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB #ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.4.2" #define GTA5SYNC_APPVER "1.4.3"
#else #else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif #endif