Display proper error message when reading an icon fails.

Refs #512
This commit is contained in:
Felix Geyer 2016-07-31 14:43:33 +02:00
parent 8ace3ab7f2
commit 6e2de1cd79

View File

@ -19,6 +19,7 @@
#include "ui_EditWidgetIcons.h" #include "ui_EditWidgetIcons.h"
#include <QFileDialog> #include <QFileDialog>
#include <QImageReader>
#include "core/Group.h" #include "core/Group.h"
#include "core/Metadata.h" #include "core/Metadata.h"
@ -129,7 +130,8 @@ void EditWidgetIcons::addCustomIcon()
QString filename = QFileDialog::getOpenFileName( QString filename = QFileDialog::getOpenFileName(
this, tr("Select Image"), "", filter); this, tr("Select Image"), "", filter);
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
QImage image(filename); QImageReader imageReader(filename);
QImage image = imageReader.read();
if (!image.isNull()) { if (!image.isNull()) {
Uuid uuid = Uuid::random(); Uuid uuid = Uuid::random();
m_database->metadata()->addCustomIconScaled(uuid, image); m_database->metadata()->addCustomIconScaled(uuid, image);
@ -139,7 +141,8 @@ void EditWidgetIcons::addCustomIcon()
m_ui->customIconsView->setCurrentIndex(index); m_ui->customIconsView->setCurrentIndex(index);
} }
else { else {
// TODO: show error MessageBox::critical(this, tr("Error"),
tr("Can't read icon:").append("\n").append(imageReader.errorString()));
} }
} }
} }