From 85070b1b66742660967fc2167f438efc9451847e Mon Sep 17 00:00:00 2001 From: thunder2 Date: Fri, 12 Oct 2012 18:42:24 +0000 Subject: [PATCH] Addad patch from Henry Support for custom qss in data dir and config dir git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5669 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/rshare.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index cbed51346..50e887ad2 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include "gui/settings/rsharesettings.h" @@ -384,17 +385,16 @@ void Rshare::loadStyleSheet(const QString &sheetName) } if (!sheetName.isEmpty()) { - QString fileName; - if (sheetName.left(1) == ":") { /* internal stylesheet */ - fileName = ":/qss/stylesheet/" + sheetName.mid(1) + ".qss"; + file.setFileName(":/qss/stylesheet/" + sheetName.mid(1) + ".qss"); } else { /* external stylesheet */ - fileName = QApplication::applicationDirPath() + "/qss/" + sheetName + ".qss"; + file.setFileName(QString::fromUtf8(RsInit::RsConfigDirectory().c_str()) + "/qss/" + sheetName + ".qss"); + if (!file.exists()) { + file.setFileName(QString::fromUtf8(RsInit::getRetroshareDataDirectory().c_str()) + "/qss/" + sheetName + ".qss"); + } } - - file.setFileName(fileName); if (file.open(QFile::ReadOnly)) { styleSheet += QLatin1String(file.readAll()); file.close(); @@ -414,14 +414,22 @@ void Rshare::getAvailableStyleSheets(QMap &styleSheets) styleSheets.insert(QString("%1 (%2)").arg(name, tr("built-in")), ":" + name); } } - - fileInfoList = QDir(applicationDirPath() + "/qss/").entryInfoList(QStringList("*.qss")); + fileInfoList = QDir(QString::fromUtf8(RsInit::RsConfigDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss")); foreach (fileInfo, fileInfoList) { if (fileInfo.isFile()) { QString name = fileInfo.baseName(); styleSheets.insert(name, name); } } + fileInfoList = QDir(QString::fromUtf8(RsInit::getRetroshareDataDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss")); + foreach (fileInfo, fileInfoList) { + if (fileInfo.isFile()) { + QString name = fileInfo.baseName(); + if (!styleSheets.contains(name)) { + styleSheets.insert(name, name); + } + } + } } void Rshare::refreshStyleSheet(QWidget *widget, bool processChildren)