mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #643, moved aircraft model icon loading to model class
* removed iconForModel from interface and aircraft config parser * CPixmap support for loading pixmap from file * Access to model of model set loader by model string * icon path as member of CAircraftModel
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "pixmap.h"
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -69,6 +70,31 @@ namespace BlackMisc
|
||||
return "Pixmap";
|
||||
}
|
||||
|
||||
CPixmap CPixmap::loadFromFile(const QString &filePath, CStatusMessage &msg)
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
{
|
||||
msg = CStatusMessage(CStatusMessage::SeverityError, "no file path");
|
||||
return CPixmap();
|
||||
}
|
||||
if (!QFile(filePath).exists())
|
||||
{
|
||||
msg = CStatusMessage().error("file %1 does not exist") << filePath;
|
||||
return CPixmap();
|
||||
}
|
||||
QPixmap pm;
|
||||
if (pm.load(filePath))
|
||||
{
|
||||
msg = CStatusMessage().info("file %1 loaded") << filePath;
|
||||
return CPixmap(pm);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = CStatusMessage().error("file %1 not loaded") << filePath;
|
||||
return CPixmap();
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap CPixmap::toPixmap() const
|
||||
{
|
||||
return this->pixmap();
|
||||
|
||||
Reference in New Issue
Block a user