Added two internal stylesheets:

- qss.default - This file is used as default for all stylesheets (e.g. the frames of the AvatarWidget) and can be overloaded from the selected stylesheet
- Standard.qss - The standard stylesheet for the current look of RetroShare. More internal stylesheets can be added.
The plan is to move nearly all internal stylesheets to the files Standard.qss/qss.default. After that the "empty" stylesheet should represent the system theme of the os.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5467 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-08-24 23:35:57 +00:00
parent 3f2ab9259d
commit 9279838d65
8 changed files with 119 additions and 95 deletions

View File

@ -10,15 +10,6 @@
<height>116</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">AvatarWidget{border-width: 10px;}
AvatarWidget[frameState=&quot;NORMAL&quot;]{border-image:url(:/images/avatarstatus-bg-116.png);}
AvatarWidget[frameState=&quot;OFFLINE&quot;]{border-image:url(:/images/avatarstatus-bg-offline-116.png);}
AvatarWidget[frameState=&quot;INACTIVE&quot;]{border-image:url(:/images/avatarstatus-bg-idle-116.png);}
AvatarWidget[frameState=&quot;ONLINE&quot;]{border-image:url(:/images/avatarstatus-bg-online-116.png);}
AvatarWidget[frameState=&quot;AWAY&quot;]{border-image:url(:/images/avatarstatus-bg-away-116.png);}
AvatarWidget[frameState=&quot;BUSY&quot;]{border-image:url(:/images/avatarstatus-bg-busy-116.png);}</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>

View File

@ -551,6 +551,8 @@
<file>qss/chat/compact/history/system.htm</file>
<file>qss/chat/compact/history/main.css</file>
<file>qss/chat/compact/history/variants/Standard.css</file>
<file>qss/stylesheet/qss.default</file>
<file>qss/stylesheet/Standard.qss</file>
<file>smileys/amorous.png</file>
<file>smileys/angry.png</file>
<file>smileys/bad.png</file>

View File

@ -0,0 +1 @@
/* Standard stylesheet for RetroShare */

View File

@ -0,0 +1,10 @@
/* Default stylesheet
This file is used as default for all stylesheets and can be overloaded */
AvatarWidget{border-width: 10px;}
AvatarWidget[frameState="NORMAL"]{border-image:url(:/images/avatarstatus-bg-116.png);}
AvatarWidget[frameState="OFFLINE"]{border-image:url(:/images/avatarstatus-bg-offline-116.png);}
AvatarWidget[frameState="INACTIVE"]{border-image:url(:/images/avatarstatus-bg-idle-116.png);}
AvatarWidget[frameState="ONLINE"]{border-image:url(:/images/avatarstatus-bg-online-116.png);}
AvatarWidget[frameState="AWAY"]{border-image:url(:/images/avatarstatus-bg-away-116.png);}
AvatarWidget[frameState="BUSY"]{border-image:url(:/images/avatarstatus-bg-busy-116.png);}

View File

@ -28,91 +28,79 @@
#include "AppearancePage.h"
#include "rsharesettings.h"
/** Constructor */
AppearancePage::AppearancePage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags)
: ConfigPage(parent, flags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect(ui.styleSheetCombo, SIGNAL(clicked()), this, SLOT(loadStyleSheet()));
connect(ui.styleSheetCombo, SIGNAL(activated(int)), this, SLOT(loadStyleSheet(int)));
/* Populate combo boxes */
foreach (QString code, LanguageSupport::languageCodes()) {
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
}
foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower());
}
/* Populate combo boxes */
foreach (QString code, LanguageSupport::languageCodes()) {
ui.cmboLanguage->addItem(QIcon(":/images/flags/" + code + ".png"), LanguageSupport::languageName(code), code);
}
foreach (QString style, QStyleFactory::keys()) {
ui.cmboStyle->addItem(style, style.toLower());
}
//loadStyleSheet("Default");
loadqss();
// add empty entry representing "no style sheet"
ui.styleSheetCombo->addItem("", "");
/* Hide platform specific features */
QMap<QString, QString> styleSheets;
Rshare::getAvailableStyleSheets(styleSheets);
foreach (QString name, styleSheets.keys()) {
ui.styleSheetCombo->addItem(name, styleSheets[name]);
}
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
AppearancePage::~AppearancePage()
{
/* reaload style sheet */
Rshare::loadStyleSheet(Settings->getSheetName());
}
/** Saves the changes on this page */
bool
AppearancePage::save(QString &errmsg)
bool AppearancePage::save(QString &errmsg)
{
Q_UNUSED(errmsg);
QString languageCode = LanguageSupport::languageCode(ui.cmboLanguage->currentText());
Q_UNUSED(errmsg);
Settings->setLanguageCode(languageCode);
Settings->setInterfaceStyle(ui.cmboStyle->currentText());
Settings->setSheetName(ui.styleSheetCombo->currentText());
QString languageCode = LanguageSupport::languageCode(ui.cmboLanguage->currentText());
/* Set to new style */
Rshare::setStyle(ui.cmboStyle->currentText());
return true;
Settings->setLanguageCode(languageCode);
Settings->setInterfaceStyle(ui.cmboStyle->currentText());
Settings->setSheetName(ui.styleSheetCombo->itemData(ui.styleSheetCombo->currentIndex()).toString());
/* Set to new style */
Rshare::setStyle(ui.cmboStyle->currentText());
return true;
}
/** Loads the settings for this page */
void
AppearancePage::load()
void AppearancePage::load()
{
int index = ui.cmboLanguage->findData(Settings->getLanguageCode());
ui.cmboLanguage->setCurrentIndex(index);
int index = ui.cmboLanguage->findData(Settings->getLanguageCode());
ui.cmboLanguage->setCurrentIndex(index);
index = ui.cmboStyle->findData(Rshare::style().toLower());
ui.cmboStyle->setCurrentIndex(index);
index = ui.cmboStyle->findData(Rshare::style().toLower());
ui.cmboStyle->setCurrentIndex(index);
index = ui.styleSheetCombo->findText(Settings->getSheetName());
if (index == -1) {
index = ui.styleSheetCombo->findText("noskin");
}
ui.styleSheetCombo->setCurrentIndex(index);
/** load saved extern Stylesheets **/
loadStyleSheet (Settings->getSheetName());
index = ui.styleSheetCombo->findData(Settings->getSheetName());
if (index == -1) {
/* set standard "no style sheet" */
index = ui.styleSheetCombo->findData("");
}
ui.styleSheetCombo->setCurrentIndex(index);
}
void AppearancePage::on_styleSheetCombo_activated(const QString &sheetName)
void AppearancePage::loadStyleSheet(int index)
{
loadStyleSheet(sheetName);
}
void AppearancePage::loadStyleSheet(const QString &sheetName)
{
Rshare::loadStyleSheet(sheetName);
}
void AppearancePage::loadqss()
{
QFileInfoList slist = QDir(QApplication::applicationDirPath() + "/qss/").entryInfoList();
// add empty entry representing "no style sheet"
ui.styleSheetCombo->addItem("");
foreach(QFileInfo st, slist)
{
if(st.fileName() != "." && st.fileName() != ".." && st.isFile())
ui.styleSheetCombo->addItem(st.fileName().remove(".qss"));
}
Rshare::loadStyleSheet(ui.styleSheetCombo->itemData(index).toString());
}

View File

@ -27,35 +27,28 @@
class AppearancePage : public ConfigPage
{
Q_OBJECT
Q_OBJECT
public:
/** Default Constructor */
AppearancePage(QWidget * parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
~AppearancePage();
public:
/** Default Constructor */
AppearancePage(QWidget * parent = 0, Qt::WFlags flags = 0);
/** Default Destructor */
~AppearancePage();
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
/** Saves the changes on this page */
virtual bool save(QString &errmsg);
/** Loads the settings for this page */
virtual void load();
virtual QPixmap iconPixmap() const { return QPixmap(":/images/looknfeel.png") ; }
virtual QString pageName() const { return tr("Appearance") ; }
virtual QPixmap iconPixmap() const { return QPixmap(":/images/looknfeel.png") ; }
virtual QString pageName() const { return tr("Appearance") ; }
private slots:
void loadStyleSheet(int index);
private slots:
void on_styleSheetCombo_activated(const QString &styleSheetName);
private:
void loadStyleSheet(const QString &sheetName);
void loadqss();
/** Qt Designer generated object */
Ui::AppearancePage ui;
private:
/** Qt Designer generated object */
Ui::AppearancePage ui;
};
#endif

View File

@ -364,17 +364,54 @@ void Rshare::loadStyleSheet(const QString &sheetName)
{
QString styleSheet;
/* load the default stylesheet */
QFile file(":/qss/stylesheet/qss.default");
if (file.open(QFile::ReadOnly)) {
styleSheet = QLatin1String(file.readAll()) + "\n";
file.close();
}
if (!sheetName.isEmpty()) {
/** extern Stylesheets **/
QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss");
QString fileName;
if (sheetName.left(1) == ":") {
/* internal stylesheet */
fileName = ":/qss/stylesheet/" + sheetName.mid(1) + ".qss";
} else {
/* external stylesheet */
fileName = QApplication::applicationDirPath() + "/qss/" + sheetName + ".qss";
}
file.setFileName(fileName);
if (file.open(QFile::ReadOnly)) {
styleSheet = QLatin1String(file.readAll());
styleSheet += QLatin1String(file.readAll());
file.close();
}
}
qApp->setStyleSheet(styleSheet);
}
/** get list of available stylesheets **/
void Rshare::getAvailableStyleSheets(QMap<QString, QString> &styleSheets)
{
QFileInfoList fileInfoList = QDir(":/qss/stylesheet/").entryInfoList(QStringList("*.qss"));
QFileInfo fileInfo;
foreach (fileInfo, fileInfoList) {
if (fileInfo.isFile()) {
QString name = fileInfo.baseName();
styleSheets.insert(QString("%1 (%2)").arg(name, tr("built-in")), ":" + name);
}
}
fileInfoList = QDir(applicationDirPath() + "/qss/").entryInfoList(QStringList("*.qss"));
foreach (fileInfo, fileInfoList) {
if (fileInfo.isFile()) {
QString name = fileInfo.baseName();
styleSheets.insert(name, name);
}
}
}
void Rshare::refreshStyleSheet(QWidget *widget, bool processChildren)
{
if (widget != NULL) {

View File

@ -79,6 +79,8 @@ public:
static bool setSheet(QString sheet = QString());
/** Loads stylesheet from external file **/
static void loadStyleSheet(const QString &sheetName);
/** get list of available stylesheets **/
static void getAvailableStyleSheets(QMap<QString, QString> &styleSheets);
/** Recalculates matching stylesheet for widget **/
static void refreshStyleSheet(QWidget *widget, bool processChildren);