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
This commit is contained in:
thunder2 2012-10-12 18:42:24 +00:00
parent e22a9afadf
commit 85070b1b66

View File

@ -33,6 +33,7 @@
#include <util/stringutil.h> #include <util/stringutil.h>
#include <stdlib.h> #include <stdlib.h>
#include <retroshare/rsinit.h>
#include <lang/languagesupport.h> #include <lang/languagesupport.h>
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
@ -384,17 +385,16 @@ void Rshare::loadStyleSheet(const QString &sheetName)
} }
if (!sheetName.isEmpty()) { if (!sheetName.isEmpty()) {
QString fileName;
if (sheetName.left(1) == ":") { if (sheetName.left(1) == ":") {
/* internal stylesheet */ /* internal stylesheet */
fileName = ":/qss/stylesheet/" + sheetName.mid(1) + ".qss"; file.setFileName(":/qss/stylesheet/" + sheetName.mid(1) + ".qss");
} else { } else {
/* external stylesheet */ /* 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)) { if (file.open(QFile::ReadOnly)) {
styleSheet += QLatin1String(file.readAll()); styleSheet += QLatin1String(file.readAll());
file.close(); file.close();
@ -414,14 +414,22 @@ void Rshare::getAvailableStyleSheets(QMap<QString, QString> &styleSheets)
styleSheets.insert(QString("%1 (%2)").arg(name, tr("built-in")), ":" + name); styleSheets.insert(QString("%1 (%2)").arg(name, tr("built-in")), ":" + name);
} }
} }
fileInfoList = QDir(QString::fromUtf8(RsInit::RsConfigDirectory().c_str()) + "/qss/").entryInfoList(QStringList("*.qss"));
fileInfoList = QDir(applicationDirPath() + "/qss/").entryInfoList(QStringList("*.qss"));
foreach (fileInfo, fileInfoList) { foreach (fileInfo, fileInfoList) {
if (fileInfo.isFile()) { if (fileInfo.isFile()) {
QString name = fileInfo.baseName(); QString name = fileInfo.baseName();
styleSheets.insert(name, name); 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) void Rshare::refreshStyleSheet(QWidget *widget, bool processChildren)