mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Fixed icon loading (failed after new dir structure)
In same step improved paths in project (static const)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3a0ab1aff7
commit
6466260d8c
@@ -76,7 +76,8 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (this->m_designator.length() > 2)
|
if (this->m_designator.length() > 2)
|
||||||
{
|
{
|
||||||
return CIcon("images/airlines/" + m_designator.toLower() + ".png",
|
// relative to images
|
||||||
|
return CIcon("airlines/" + m_designator.toLower() + ".png",
|
||||||
this->convertToQString());
|
this->convertToQString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (this->m_dbKey.length() == 2)
|
if (this->m_dbKey.length() == 2)
|
||||||
{
|
{
|
||||||
return CIcon("images/flags/" + m_dbKey.toLower() + ".png",
|
// relative to images
|
||||||
|
return CIcon("flags/" + m_dbKey.toLower() + ".png",
|
||||||
this->convertToQString());
|
this->convertToQString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
|
#include "blackmisc/project.h"
|
||||||
|
#include "blackmisc/fileutilities.h"
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@@ -1079,9 +1081,7 @@ namespace BlackMisc
|
|||||||
Q_ASSERT_X(!fileName.isEmpty(), Q_FUNC_INFO, "missing filename");
|
Q_ASSERT_X(!fileName.isEmpty(), Q_FUNC_INFO, "missing filename");
|
||||||
if (!getResourceFileCache().contains(fileName))
|
if (!getResourceFileCache().contains(fileName))
|
||||||
{
|
{
|
||||||
QString path = fileName.contains("resources") ?
|
QString path = CFileUtils::appendFilePaths(CProject::getImagesDir(), fileName);
|
||||||
QCoreApplication::applicationDirPath().append("/").append(fileName) :
|
|
||||||
QCoreApplication::applicationDirPath().append("/resources/").append(fileName);
|
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
bool s = pm.load(path);
|
bool s = pm.load(path);
|
||||||
if (s)
|
if (s)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
#include "blackmisc/fileutilities.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
@@ -254,35 +255,66 @@ namespace BlackMisc
|
|||||||
return QProcessEnvironment::systemEnvironment().value(envVarPrivateSetupDir());
|
return QProcessEnvironment::systemEnvironment().value(envVarPrivateSetupDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CProject::getApplicationDir()
|
QString getApplicationDir_()
|
||||||
{
|
{
|
||||||
QFileInfo executable(QCoreApplication::applicationFilePath());
|
QFileInfo executable(QCoreApplication::applicationFilePath());
|
||||||
QDir p(executable.dir());
|
QDir p(executable.dir());
|
||||||
return p.absolutePath();
|
return p.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CProject::getSwiftResourceDir()
|
const QString &CProject::getApplicationDir()
|
||||||
{
|
{
|
||||||
QDir dir(getApplicationDir());
|
static const QString s(getApplicationDir_());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getSwiftResourceDir_()
|
||||||
|
{
|
||||||
|
QDir dir(CProject::getApplicationDir());
|
||||||
if (dir.cdUp()) { return dir.absolutePath(); }
|
if (dir.cdUp()) { return dir.absolutePath(); }
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CProject::getSwiftResourceDir()
|
||||||
|
{
|
||||||
|
static const QString s(getSwiftResourceDir_());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
QString CProject::getSwiftPrivateResourceDir()
|
QString CProject::getSwiftPrivateResourceDir()
|
||||||
{
|
{
|
||||||
static const QString dir(envVarPrivateSetupDirValue());
|
static const QString dir(envVarPrivateSetupDirValue());
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CProject::getSwiftStaticDbFilesDir()
|
QString getSwiftStaticDbFilesDir_()
|
||||||
{
|
{
|
||||||
QString d(getSwiftResourceDir());
|
QString d(CProject::getSwiftResourceDir());
|
||||||
if (d.isEmpty()) { return ""; }
|
if (d.isEmpty()) { return ""; }
|
||||||
QDir dir(d);
|
QDir dir(d);
|
||||||
if (dir.cd("swiftDB")) { return dir.absolutePath(); }
|
if (dir.cd("swiftDB")) { return dir.absolutePath(); }
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CProject::getSwiftStaticDbFilesDir()
|
||||||
|
{
|
||||||
|
static QString s(getSwiftResourceDir_());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getImagesDir_()
|
||||||
|
{
|
||||||
|
QString d(CProject::getSwiftResourceDir());
|
||||||
|
if (d.isEmpty()) return "";
|
||||||
|
return CFileUtils::appendFilePaths(d, "data/images");
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CProject::getImagesDir()
|
||||||
|
{
|
||||||
|
static const QString s(getImagesDir_());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
QString CProject::getEnvironmentVariables(const QString &separator)
|
QString CProject::getEnvironmentVariables(const QString &separator)
|
||||||
{
|
{
|
||||||
QString e(envDevelopmentSetup());
|
QString e(envDevelopmentSetup());
|
||||||
|
|||||||
@@ -100,16 +100,19 @@ namespace BlackMisc
|
|||||||
static bool isRunningInBetaOrDeveloperEnvironment();
|
static bool isRunningInBetaOrDeveloperEnvironment();
|
||||||
|
|
||||||
//! Application directory where current application is located
|
//! Application directory where current application is located
|
||||||
static QString getApplicationDir();
|
static const QString &getApplicationDir();
|
||||||
|
|
||||||
//! Where resource files (static DB files, ...) etc are located
|
//! Where resource files (static DB files, ...) etc are located
|
||||||
static QString getSwiftResourceDir();
|
static const QString &getSwiftResourceDir();
|
||||||
|
|
||||||
//! Private resource dir for developer's own resource files
|
//! Private resource dir for developer's own resource files
|
||||||
static QString getSwiftPrivateResourceDir();
|
static QString getSwiftPrivateResourceDir();
|
||||||
|
|
||||||
//! Where resource files (static DB files, ...) etc are located
|
//! Where static DB files are located
|
||||||
static QString getSwiftStaticDbFilesDir();
|
static const QString &getSwiftStaticDbFilesDir();
|
||||||
|
|
||||||
|
//! Where images are located
|
||||||
|
static const QString &getImagesDir();
|
||||||
|
|
||||||
//! Dump all env.variables
|
//! Dump all env.variables
|
||||||
static QString getEnvironmentVariables(const QString &separator = QString("\n"));
|
static QString getEnvironmentVariables(const QString &separator = QString("\n"));
|
||||||
|
|||||||
Reference in New Issue
Block a user