From f250478c7e135a35da23f8240bda7310448cb351 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 27 Feb 2012 12:47:34 +0100 Subject: [PATCH] Support of relative paths in branding.xml --- src/Gui/Application.cpp | 10 ++++++++++ src/Gui/BitmapFactory.cpp | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 232d0e23f..8c3ff25c6 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -30,6 +30,8 @@ # include # include # include +# include +# include # include # include # include @@ -1569,6 +1571,8 @@ void Application::runApplication(void) SoQt::init(&mw); SoFCDB::init(); + QString home = QString::fromUtf8(App::GetApplication().GetHomePath()); + const std::map& cfg = App::Application::Config(); std::map::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(); diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 3ec0189e7..0b2699bf2 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -79,8 +79,14 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void) _pcSingleton = new BitmapFactoryInst; std::map::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()));