mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
Issue #77 Break dependency of pixmap on statusmessage
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
@@ -75,31 +74,6 @@ namespace BlackMisc
|
||||
return "Pixmap";
|
||||
}
|
||||
|
||||
CPixmap CPixmap::loadFromFile(const QString &filePath, CStatusMessage &msg)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
{
|
||||
msg = CStatusMessage(CStatusMessage::SeverityError, u"no file path");
|
||||
return CPixmap();
|
||||
}
|
||||
if (!QFile(filePath).exists())
|
||||
{
|
||||
msg = CStatusMessage().error(u"file %1 does not exist") << filePath;
|
||||
return CPixmap();
|
||||
}
|
||||
QPixmap pm;
|
||||
if (pm.load(filePath))
|
||||
{
|
||||
msg = CStatusMessage().info(u"file %1 loaded") << filePath;
|
||||
return CPixmap(pm);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = CStatusMessage().error(u"file %1 not loaded") << filePath;
|
||||
return CPixmap();
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap CPixmap::toPixmap() const
|
||||
{
|
||||
return this->pixmap();
|
||||
|
||||
@@ -60,9 +60,6 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Load from file
|
||||
static CPixmap loadFromFile(const QString &filePath, CStatusMessage &msg);
|
||||
|
||||
private:
|
||||
//! Init the byte array with data
|
||||
void fillByteArray();
|
||||
|
||||
@@ -569,10 +569,13 @@ namespace BlackMisc
|
||||
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
||||
{
|
||||
static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, u"no icon");
|
||||
static const CStatusMessage loaded(this, CStatusMessage::SeverityInfo, u"icon loaded");
|
||||
if (m_iconFile.isEmpty()) { success = noIcon; return CPixmap(); }
|
||||
if (!QFile(m_iconFile).exists()) { success = noIcon; return CPixmap(); }
|
||||
|
||||
// load from file
|
||||
const CPixmap pm(CPixmap::loadFromFile(m_iconFile, success));
|
||||
QPixmap pm;
|
||||
if (!pm.load(m_iconFile)) { success = noIcon; return CPixmap(); }
|
||||
success = loaded;
|
||||
return pm;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user