Support of relative paths in branding.xml

This commit is contained in:
wmayer 2012-02-27 12:47:34 +01:00
parent 6a77635bdb
commit f250478c7e
2 changed files with 18 additions and 2 deletions

View File

@ -30,6 +30,8 @@
# include <sstream>
# include <stdexcept>
# include <QCloseEvent>
# include <QDir>
# include <QFileInfo>
# include <QLocale>
# include <QMessageBox>
# include <QPointer>
@ -1569,6 +1571,8 @@ void Application::runApplication(void)
SoQt::init(&mw);
SoFCDB::init();
QString home = QString::fromUtf8(App::GetApplication().GetHomePath());
const std::map<std::string,std::string>& cfg = App::Application::Config();
std::map<std::string,std::string>::const_iterator it;
it = cfg.find("WindowTitle");
@ -1579,11 +1583,17 @@ void Application::runApplication(void)
it = cfg.find("WindowIcon");
if (it != cfg.end()) {
QString path = QString::fromUtf8(it->second.c_str());
if (QDir(path).isRelative()) {
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
QApplication::setWindowIcon(QIcon(path));
}
it = cfg.find("ProgramLogo");
if (it != cfg.end()) {
QString path = QString::fromUtf8(it->second.c_str());
if (QDir(path).isRelative()) {
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
QPixmap px(path);
if (!px.isNull()) {
QLabel* logo = new QLabel();

View File

@ -79,8 +79,14 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void)
_pcSingleton = new BitmapFactoryInst;
std::map<std::string,std::string>::const_iterator it;
it = App::GetApplication().Config().find("ProgramIcons");
if (it != App::GetApplication().Config().end())
_pcSingleton->addPath(QString::fromUtf8(it->second.c_str()));
if (it != App::GetApplication().Config().end()) {
QString home = QString::fromUtf8(App::GetApplication().GetHomePath());
QString path = QString::fromUtf8(it->second.c_str());
if (QDir(path).isRelative()) {
path = QFileInfo(QDir(home), path).absoluteFilePath();
}
_pcSingleton->addPath(path);
}
_pcSingleton->addPath(QLatin1String(":/icons/"));
_pcSingleton->addPath(QLatin1String(":/Icons/"));
_pcSingleton->addPath(QString::fromUtf8(App::GetApplication().GetHomePath()));