Changed the path for additional styles to "stylesheets" for Linux in "~/.retroshare" (untested), for Windows in "%APPDATA%\RetroShare" and for the portable version in the appdir.

Added variants for styles. Variants are files in the subdir "variants" of the style with the extension .css. The file <variant>.css and main.css are matched together.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3456 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-07 23:19:27 +00:00
parent f254a7ae24
commit 20887fc93b
11 changed files with 367 additions and 100 deletions

View File

@ -34,6 +34,8 @@
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include <retroshare/rsinit.h>
enum enumGetStyle enum enumGetStyle
{ {
GETSTYLE_INCOMING, GETSTYLE_INCOMING,
@ -62,38 +64,42 @@ void ChatStyle::styleChanged(int styleType)
} }
} }
bool ChatStyle::setStylePath(QString stylePath) bool ChatStyle::setStylePath(QString stylePath, QString styleVariant)
{ {
m_styleType = TYPE_UNKNOWN; m_styleType = TYPE_UNKNOWN;
m_styleDir.setPath(QApplication::applicationDirPath()); m_styleDir.setPath(QApplication::applicationDirPath());
if (m_styleDir.cd(stylePath) == false) { if (m_styleDir.cd(stylePath) == false) {
m_styleDir = QDir(""); m_styleDir = QDir("");
m_styleVariant.clear();
return false; return false;
} }
m_styleVariant = styleVariant;
return true; return true;
} }
bool ChatStyle::setStyleFromSettings(enumStyleType styleType) bool ChatStyle::setStyleFromSettings(enumStyleType styleType)
{ {
QString stylePath; QString stylePath;
QString styleVariant;
switch (styleType) { switch (styleType) {
case TYPE_PUBLIC: case TYPE_PUBLIC:
Settings->getPublicChatStyle(stylePath); Settings->getPublicChatStyle(stylePath, styleVariant);
break; break;
case TYPE_PRIVATE: case TYPE_PRIVATE:
Settings->getPrivateChatStyle(stylePath); Settings->getPrivateChatStyle(stylePath, styleVariant);
break; break;
case TYPE_HISTORY: case TYPE_HISTORY:
Settings->getHistoryChatStyle(stylePath); Settings->getHistoryChatStyle(stylePath, styleVariant);
break; break;
case TYPE_UNKNOWN: case TYPE_UNKNOWN:
return false; return false;
} }
bool result = setStylePath(stylePath); bool result = setStylePath(stylePath, styleVariant);
m_styleType = styleType; m_styleType = styleType;
@ -248,7 +254,7 @@ void ChatStyle::showSmileyWidget(QWidget *parent, QWidget *button, const char *s
smWidget->show(); smWidget->show();
} }
static QString getStyle(QDir &styleDir, enumGetStyle type) static QString getStyle(QDir &styleDir, QString styleVariant, enumGetStyle type)
{ {
QString style; QString style;
@ -284,6 +290,18 @@ static QString getStyle(QDir &styleDir, enumGetStyle type)
css = fileCss.readAll(); css = fileCss.readAll();
fileCss.close(); fileCss.close();
} }
if (styleVariant.isEmpty() == false) {
QFile fileCssVariant(QFileInfo(styleDir, "variants/" + styleVariant + ".css").absoluteFilePath());
QString cssVariant;
if (fileCssVariant.open(QIODevice::ReadOnly)) {
cssVariant = fileCssVariant.readAll();
fileCssVariant.close();
css += "\n" + cssVariant;
}
}
style.replace("%css-style%", css); style.replace("%css-style%", css);
} }
@ -317,16 +335,16 @@ QString ChatStyle::formatMessage(enumFormatMessage type, QString &name, QDateTim
switch (type) { switch (type) {
case FORMATMSG_INCOMING: case FORMATMSG_INCOMING:
style = getStyle(m_styleDir, GETSTYLE_INCOMING); style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_INCOMING);
break; break;
case FORMATMSG_OUTGOING: case FORMATMSG_OUTGOING:
style = getStyle(m_styleDir, GETSTYLE_OUTGOING); style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_OUTGOING);
break; break;
case FORMATMSG_HINCOMING: case FORMATMSG_HINCOMING:
style = getStyle(m_styleDir, GETSTYLE_HINCOMING); style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_HINCOMING);
break; break;
case FORMATMSG_HOUTGOING: case FORMATMSG_HOUTGOING:
style = getStyle(m_styleDir, GETSTYLE_HOUTGOING); style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_HOUTGOING);
break; break;
} }
@ -481,10 +499,29 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle
return true; return true;
} }
static QString getBaseDir()
{
// application path
std::string configDir = RsInit::RsConfigDirectory();
QString baseDir = QString::fromStdString(configDir);
#ifdef WIN32
if (RsInit::isPortable ()) {
// application dir for portable version
baseDir = QApplication::applicationDirPath();
}
#endif
return baseDir;
}
/*static*/ bool ChatStyle::getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles) /*static*/ bool ChatStyle::getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles)
{ {
styles.clear(); styles.clear();
// base dir
QDir baseDir(getBaseDir());
ChatStyleInfo standardInfo; ChatStyleInfo standardInfo;
QString stylePath; QString stylePath;
@ -494,31 +531,30 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle
standardInfo.styleDescription = tr("Standard style for public chat"); standardInfo.styleDescription = tr("Standard style for public chat");
styles.append(standardInfo); styles.append(standardInfo);
} }
stylePath = "style/public"; stylePath = "stylesheets/public";
break; break;
case TYPE_PRIVATE: case TYPE_PRIVATE:
if (getStyleInfo(":/qss/chat/private", ":/qss/chat/private", standardInfo)) { if (getStyleInfo(":/qss/chat/private", ":/qss/chat/private", standardInfo)) {
standardInfo.styleDescription = tr("Standard style for private chat"); standardInfo.styleDescription = tr("Standard style for private chat");
styles.append(standardInfo); styles.append(standardInfo);
} }
stylePath = "style/private"; stylePath = "stylesheets/private";
break; break;
case TYPE_HISTORY: case TYPE_HISTORY:
if (getStyleInfo(":/qss/chat/history", ":/qss/chat/history", standardInfo)) { if (getStyleInfo(":/qss/chat/history", ":/qss/chat/history", standardInfo)) {
standardInfo.styleDescription = tr("Standard style for history"); standardInfo.styleDescription = tr("Standard style for history");
styles.append(standardInfo); styles.append(standardInfo);
} }
stylePath = "style/history"; stylePath = "stylesheets/history";
break; break;
case TYPE_UNKNOWN: case TYPE_UNKNOWN:
default: default:
return false; return false;
} }
// application path QDir dir(baseDir);
QDir applicationDir(QApplication::applicationDirPath());
QDir dir(QApplication::applicationDirPath());
if (dir.cd(stylePath) == false) { if (dir.cd(stylePath) == false) {
// no user styles available
return true; return true;
} }
@ -528,10 +564,43 @@ static bool getStyleInfo(QString stylePath, QString stylePathRelative, ChatStyle
// iterate style directories and get info // iterate style directories and get info
for (QFileInfoList::iterator dir = dirList.begin(); dir != dirList.end(); dir++) { for (QFileInfoList::iterator dir = dirList.begin(); dir != dirList.end(); dir++) {
ChatStyleInfo info; ChatStyleInfo info;
if (getStyleInfo(dir->absoluteFilePath(), applicationDir.relativeFilePath(dir->absoluteFilePath()), info)) { if (getStyleInfo(dir->absoluteFilePath(), baseDir.relativeFilePath(dir->absoluteFilePath()), info)) {
styles.append(info); styles.append(info);
} }
} }
return true; return true;
} }
/*static*/ bool ChatStyle::getAvailableVariants(QString stylePath, QStringList &variants)
{
variants.clear();
if (stylePath.isEmpty()) {
return false;
}
// application path
QDir dir(QApplication::applicationDirPath());
if (dir.cd(stylePath) == false) {
// style not found
return false;
}
if (dir.cd("variants") == false) {
// no variants available
return true;
}
// get all variants
QStringList filters;
filters.append("*.css");
QFileInfoList fileList = dir.entryInfoList(filters, QDir::Files, QDir::Name);
// iterate variants
for (QFileInfoList::iterator file = fileList.begin(); file != fileList.end(); file++) {
variants.append(file->baseName());
}
return true;
}

View File

@ -82,7 +82,7 @@ public:
/* Default destructor */ /* Default destructor */
~ChatStyle(); ~ChatStyle();
bool setStylePath(QString stylePath); bool setStylePath(QString stylePath, QString styleVariant);
bool setStyleFromSettings(enumStyleType styleType); bool setStyleFromSettings(enumStyleType styleType);
void loadEmoticons(); void loadEmoticons();
@ -91,6 +91,7 @@ public:
void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod); void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod);
static bool getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles); static bool getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles);
static bool getAvailableVariants(QString stylePath, QStringList &variants);
private slots: private slots:
void styleChanged(int styleType); void styleChanged(int styleType);
@ -98,6 +99,7 @@ private slots:
private: private:
enumStyleType m_styleType; enumStyleType m_styleType;
QDir m_styleDir; QDir m_styleDir;
QString m_styleVariant;
/** store default information for embedding HTML */ /** store default information for embedding HTML */
RsChat::EmbedInHtmlAhref defEmbedAhref; RsChat::EmbedInHtmlAhref defEmbedAhref;

View File

@ -457,18 +457,21 @@
<file>qss/chat/private/hincoming.htm</file> <file>qss/chat/private/hincoming.htm</file>
<file>qss/chat/private/houtgoing.htm</file> <file>qss/chat/private/houtgoing.htm</file>
<file>qss/chat/private/main.css</file> <file>qss/chat/private/main.css</file>
<file>qss/chat/private/variants/Standard.css</file>
<file>qss/chat/public/info.xml</file> <file>qss/chat/public/info.xml</file>
<file>qss/chat/public/incoming.htm</file> <file>qss/chat/public/incoming.htm</file>
<file>qss/chat/public/outgoing.htm</file> <file>qss/chat/public/outgoing.htm</file>
<file>qss/chat/public/hincoming.htm</file> <file>qss/chat/public/hincoming.htm</file>
<file>qss/chat/public/houtgoing.htm</file> <file>qss/chat/public/houtgoing.htm</file>
<file>qss/chat/public/main.css</file> <file>qss/chat/public/main.css</file>
<file>qss/chat/public/variants/Standard.css</file>
<file>qss/chat/history/info.xml</file> <file>qss/chat/history/info.xml</file>
<file>qss/chat/history/incoming.htm</file> <file>qss/chat/history/incoming.htm</file>
<file>qss/chat/history/outgoing.htm</file> <file>qss/chat/history/outgoing.htm</file>
<file>qss/chat/history/hincoming.htm</file> <file>qss/chat/history/hincoming.htm</file>
<file>qss/chat/history/houtgoing.htm</file> <file>qss/chat/history/houtgoing.htm</file>
<file>qss/chat/history/main.css</file> <file>qss/chat/history/main.css</file>
<file>qss/chat/history/variants/Standard.css</file>
<file>smileys/angry.png</file> <file>smileys/angry.png</file>
<file>smileys/beer.png</file> <file>smileys/beer.png</file>
<file>smileys/cake.png</file> <file>smileys/cake.png</file>

View File

@ -27,7 +27,9 @@
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "rsharesettings.h" #include "rsharesettings.h"
static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWidget) #define VARIANT_STANDARD "Standard"
static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWidget, QComboBox *comboBox, QString &styleVariant)
{ {
QList<ChatStyleInfo> styles; QList<ChatStyleInfo> styles;
QList<ChatStyleInfo>::iterator style; QList<ChatStyleInfo>::iterator style;
@ -38,13 +40,13 @@ static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWid
switch (type) { switch (type) {
case ChatStyle::TYPE_PUBLIC: case ChatStyle::TYPE_PUBLIC:
Settings->getPublicChatStyle(stylePath); Settings->getPublicChatStyle(stylePath, styleVariant);
break; break;
case ChatStyle::TYPE_PRIVATE: case ChatStyle::TYPE_PRIVATE:
Settings->getPrivateChatStyle(stylePath); Settings->getPrivateChatStyle(stylePath, styleVariant);
break; break;
case ChatStyle::TYPE_HISTORY: case ChatStyle::TYPE_HISTORY:
Settings->getHistoryChatStyle(stylePath); Settings->getHistoryChatStyle(stylePath, styleVariant);
break; break;
case ChatStyle::TYPE_UNKNOWN: case ChatStyle::TYPE_UNKNOWN:
return ""; return "";
@ -63,6 +65,16 @@ static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWid
listWidget->setCurrentItem(activeItem); listWidget->setCurrentItem(activeItem);
/* now the combobox should be filled */
int index = comboBox->findText(styleVariant);
if (index != -1) {
comboBox->setCurrentIndex(index);
} else {
if (comboBox->count()) {
comboBox->setCurrentIndex(0);
}
}
return stylePath; return stylePath;
} }
@ -104,8 +116,8 @@ ChatPage::save(QString &errmsg)
QListWidgetItem *item = ui.publicList->currentItem(); QListWidgetItem *item = ui.publicList->currentItem();
if (item) { if (item) {
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
if (publicStylePath != info.stylePath) { if (publicStylePath != info.stylePath || publicStyleVariant != ui.publicComboBoxVariant->currentText()) {
Settings->setPublicChatStyle(info.stylePath); Settings->setPublicChatStyle(info.stylePath, ui.publicComboBoxVariant->currentText());
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC);
} }
} }
@ -113,8 +125,8 @@ ChatPage::save(QString &errmsg)
item = ui.privateList->currentItem(); item = ui.privateList->currentItem();
if (item) { if (item) {
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
if (privateStylePath != info.stylePath) { if (privateStylePath != info.stylePath || privateStyleVariant != ui.privateComboBoxVariant->currentText()) {
Settings->setPrivateChatStyle(info.stylePath); Settings->setPrivateChatStyle(info.stylePath, ui.privateComboBoxVariant->currentText());
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE);
} }
} }
@ -122,8 +134,8 @@ ChatPage::save(QString &errmsg)
item = ui.historyList->currentItem(); item = ui.historyList->currentItem();
if (item) { if (item) {
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
if (historyStylePath != info.stylePath) { if (historyStylePath != info.stylePath || historyStyleVariant != ui.historyComboBoxVariant->currentText()) {
Settings->setHistoryChatStyle(info.stylePath); Settings->setHistoryChatStyle(info.stylePath, ui.historyComboBoxVariant->currentText());
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY); NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY);
} }
} }
@ -151,9 +163,9 @@ ChatPage::load()
ui.labelChatFontPreview->setFont(fontTempChat); ui.labelChatFontPreview->setFont(fontTempChat);
/* Load styles */ /* Load styles */
publicStylePath = loadStyleInfo(ChatStyle::TYPE_PUBLIC, ui.publicList); publicStylePath = loadStyleInfo(ChatStyle::TYPE_PUBLIC, ui.publicList, ui.publicComboBoxVariant, publicStyleVariant);
privateStylePath = loadStyleInfo(ChatStyle::TYPE_PRIVATE, ui.privateList); privateStylePath = loadStyleInfo(ChatStyle::TYPE_PRIVATE, ui.privateList, ui.privateComboBoxVariant, privateStyleVariant);
historyStylePath = loadStyleInfo(ChatStyle::TYPE_HISTORY, ui.historyList); historyStylePath = loadStyleInfo(ChatStyle::TYPE_HISTORY, ui.historyList, ui.historyComboBoxVariant, historyStyleVariant);
} }
bool ChatPage::emotePrivatChat() const { bool ChatPage::emotePrivatChat() const {
@ -182,10 +194,10 @@ void ChatPage::on_pushButtonChangeChatFont_clicked()
} }
} }
void ChatPage::setPreviewMessages(QString &stylePath, QTextBrowser *textBrowser) void ChatPage::setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser)
{ {
ChatStyle style; ChatStyle style;
style.setStylePath(stylePath); style.setStylePath(stylePath, styleVariant);
style.loadEmoticons(); style.loadEmoticons();
textBrowser->clear(); textBrowser->clear();
@ -210,12 +222,23 @@ void ChatPage::setPreviewMessages(QString &stylePath, QTextBrowser *textBrowser)
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS)); textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS));
} }
void ChatPage::fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser)
{
QListWidgetItem *item = listWidget->currentItem();
if (item) {
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
setPreviewMessages(info.stylePath, comboBox->currentText(), textBrowser);
} else {
textBrowser->clear();
}
}
void ChatPage::on_publicList_currentRowChanged(int currentRow) void ChatPage::on_publicList_currentRowChanged(int currentRow)
{ {
if (currentRow != -1) { if (currentRow != -1) {
QListWidgetItem *item = ui.publicList->item(currentRow); QListWidgetItem *item = ui.publicList->item(currentRow);
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
setPreviewMessages(info.stylePath, ui.publicPreview);
QString author = info.authorName; QString author = info.authorName;
if (info.authorEmail.isEmpty() == false) { if (info.authorEmail.isEmpty() == false) {
@ -223,11 +246,28 @@ void ChatPage::on_publicList_currentRowChanged(int currentRow)
} }
ui.publicAuthor->setText(author); ui.publicAuthor->setText(author);
ui.publicDescription->setText(info.styleDescription); ui.publicDescription->setText(info.styleDescription);
QStringList variants;
ChatStyle::getAvailableVariants(info.stylePath, variants);
ui.publicComboBoxVariant->clear();
ui.publicComboBoxVariant->setEnabled(variants.size() != 0);
ui.publicComboBoxVariant->addItems(variants);
/* try to find "Standard" */
int index = ui.publicComboBoxVariant->findText(VARIANT_STANDARD);
if (index != -1) {
ui.publicComboBoxVariant->setCurrentIndex(index);
} else {
ui.publicComboBoxVariant->setCurrentIndex(0);
}
} else { } else {
ui.publicPreview->clear();
ui.publicAuthor->clear(); ui.publicAuthor->clear();
ui.publicDescription->clear(); ui.publicDescription->clear();
ui.publicComboBoxVariant->clear();
ui.publicComboBoxVariant->setDisabled(true);
} }
fillPreview(ui.publicList, ui.publicComboBoxVariant, ui.publicPreview);
} }
void ChatPage::on_privateList_currentRowChanged(int currentRow) void ChatPage::on_privateList_currentRowChanged(int currentRow)
@ -235,7 +275,6 @@ void ChatPage::on_privateList_currentRowChanged(int currentRow)
if (currentRow != -1) { if (currentRow != -1) {
QListWidgetItem *item = ui.privateList->item(currentRow); QListWidgetItem *item = ui.privateList->item(currentRow);
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
setPreviewMessages(info.stylePath, ui.privatePreview);
QString author = info.authorName; QString author = info.authorName;
if (info.authorEmail.isEmpty() == false) { if (info.authorEmail.isEmpty() == false) {
@ -243,11 +282,28 @@ void ChatPage::on_privateList_currentRowChanged(int currentRow)
} }
ui.privateAuthor->setText(author); ui.privateAuthor->setText(author);
ui.privateDescription->setText(info.styleDescription); ui.privateDescription->setText(info.styleDescription);
QStringList variants;
ChatStyle::getAvailableVariants(info.stylePath, variants);
ui.privateComboBoxVariant->clear();
ui.privateComboBoxVariant->setEnabled(variants.size() != 0);
ui.privateComboBoxVariant->addItems(variants);
/* try to find "Standard" */
int index = ui.privateComboBoxVariant->findText(VARIANT_STANDARD);
if (index != -1) {
ui.privateComboBoxVariant->setCurrentIndex(index);
} else {
ui.privateComboBoxVariant->setCurrentIndex(0);
}
} else { } else {
ui.privatePreview->clear();
ui.privateAuthor->clear(); ui.privateAuthor->clear();
ui.privateDescription->clear(); ui.privateDescription->clear();
ui.privateComboBoxVariant->clear();
ui.privateComboBoxVariant->setDisabled(true);
} }
fillPreview(ui.privateList, ui.privateComboBoxVariant, ui.privatePreview);
} }
void ChatPage::on_historyList_currentRowChanged(int currentRow) void ChatPage::on_historyList_currentRowChanged(int currentRow)
@ -255,7 +311,6 @@ void ChatPage::on_historyList_currentRowChanged(int currentRow)
if (currentRow != -1) { if (currentRow != -1) {
QListWidgetItem *item = ui.historyList->item(currentRow); QListWidgetItem *item = ui.historyList->item(currentRow);
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole)); ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
setPreviewMessages(info.stylePath, ui.historyPreview);
QString author = info.authorName; QString author = info.authorName;
if (info.authorEmail.isEmpty() == false) { if (info.authorEmail.isEmpty() == false) {
@ -263,9 +318,41 @@ void ChatPage::on_historyList_currentRowChanged(int currentRow)
} }
ui.historyAuthor->setText(author); ui.historyAuthor->setText(author);
ui.historyDescription->setText(info.styleDescription); ui.historyDescription->setText(info.styleDescription);
QStringList variants;
ChatStyle::getAvailableVariants(info.stylePath, variants);
ui.historyComboBoxVariant->clear();
ui.historyComboBoxVariant->setEnabled(variants.size() != 0);
ui.historyComboBoxVariant->addItems(variants);
/* try to find "Standard" */
int index = ui.historyComboBoxVariant->findText(VARIANT_STANDARD);
if (index != -1) {
ui.historyComboBoxVariant->setCurrentIndex(index);
} else {
ui.historyComboBoxVariant->setCurrentIndex(0);
}
} else { } else {
ui.historyPreview->clear();
ui.historyAuthor->clear(); ui.historyAuthor->clear();
ui.historyDescription->clear(); ui.historyDescription->clear();
ui.historyComboBoxVariant->clear();
ui.historyComboBoxVariant->setDisabled(true);
} }
fillPreview(ui.historyList, ui.historyComboBoxVariant, ui.historyPreview);
}
void ChatPage::on_publicComboBoxVariant_currentIndexChanged(int index)
{
fillPreview(ui.publicList, ui.publicComboBoxVariant, ui.publicPreview);
}
void ChatPage::on_privateComboBoxVariant_currentIndexChanged(int index)
{
fillPreview(ui.privateList, ui.privateComboBoxVariant, ui.privatePreview);
}
void ChatPage::on_historyComboBoxVariant_currentIndexChanged(int index)
{
fillPreview(ui.historyList, ui.historyComboBoxVariant, ui.historyPreview);
} }

View File

@ -47,6 +47,9 @@ class ChatPage : public ConfigPage
QFont fontTempChat; QFont fontTempChat;
private slots: private slots:
void on_historyComboBoxVariant_currentIndexChanged(int index);
void on_privateComboBoxVariant_currentIndexChanged(int index);
void on_publicComboBoxVariant_currentIndexChanged(int index);
void on_pushButtonChangeChatFont_clicked(); void on_pushButtonChangeChatFont_clicked();
void on_publicList_currentRowChanged(int currentRow); void on_publicList_currentRowChanged(int currentRow);
void on_privateList_currentRowChanged(int currentRow); void on_privateList_currentRowChanged(int currentRow);
@ -54,11 +57,15 @@ class ChatPage : public ConfigPage
private: private:
void closeEvent (QCloseEvent * event); void closeEvent (QCloseEvent * event);
void setPreviewMessages(QString &stylePath, QTextBrowser *textBrowser); void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
QString publicStylePath; QString publicStylePath;
QString publicStyleVariant;
QString privateStylePath; QString privateStylePath;
QString privateStyleVariant;
QString historyStylePath; QString historyStylePath;
QString historyStyleVariant;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::ChatPage ui; Ui::ChatPage ui;

View File

@ -667,24 +667,55 @@
<attribute name="title"> <attribute name="title">
<string>Public</string> <string>Public</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_1"> <layout class="QVBoxLayout" name="publicLayout_1">
<item> <item>
<layout class="QHBoxLayout" name="publicListLayout"> <layout class="QHBoxLayout" name="publiclLayout_2">
<item> <item>
<widget class="QListWidget" name="publicList"> <layout class="QVBoxLayout" name="publicLayout_3">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Fixed" vsizetype="Ignored"> <widget class="QListWidget" name="publicList">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</sizepolicy> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="maximumSize"> </sizepolicy>
<size> </property>
<width>150</width> <property name="maximumSize">
<height>16777215</height> <size>
</size> <width>170</width>
</property> <height>16777215</height>
</widget> </size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="publicLayout_4">
<item>
<widget class="QLabel" name="publicLabelVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Variant</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="publicComboBoxVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="publicPreview"> <widget class="QTextBrowser" name="publicPreview">
@ -771,24 +802,55 @@
<attribute name="title"> <attribute name="title">
<string>Private</string> <string>Private</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="privateLayout_1">
<item> <item>
<layout class="QHBoxLayout" name="privateListLayout"> <layout class="QHBoxLayout" name="privatelLayout_2">
<item> <item>
<widget class="QListWidget" name="privateList"> <layout class="QVBoxLayout" name="privateLayout_3">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Fixed" vsizetype="Ignored"> <widget class="QListWidget" name="privateList">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</sizepolicy> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="maximumSize"> </sizepolicy>
<size> </property>
<width>150</width> <property name="maximumSize">
<height>16777215</height> <size>
</size> <width>170</width>
</property> <height>16777215</height>
</widget> </size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="privateLayout_4">
<item>
<widget class="QLabel" name="privateLabelVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Variant</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="privateComboBoxVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="privatePreview"> <widget class="QTextBrowser" name="privatePreview">
@ -875,24 +937,55 @@
<attribute name="title"> <attribute name="title">
<string>History</string> <string>History</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="historyLayout_1">
<item> <item>
<layout class="QHBoxLayout" name="historyListLayout"> <layout class="QHBoxLayout" name="historylLayout_2">
<item> <item>
<widget class="QListWidget" name="historyList"> <layout class="QVBoxLayout" name="historyLayout_3">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Fixed" vsizetype="Ignored"> <widget class="QListWidget" name="historyList">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</sizepolicy> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="maximumSize"> </sizepolicy>
<size> </property>
<width>150</width> <property name="maximumSize">
<height>16777215</height> <size>
</size> <width>170</width>
</property> <height>16777215</height>
</widget> </size>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="historyLayout_4">
<item>
<widget class="QLabel" name="historyLabelVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Variant</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="historyComboBoxVariant">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="historyPreview"> <widget class="QTextBrowser" name="historyPreview">

View File

@ -299,34 +299,40 @@ void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue); setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue);
} }
void RshareSettings::getPublicChatStyle(QString &stylePath) void RshareSettings::getPublicChatStyle(QString &stylePath, QString &styleVariant)
{ {
stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/public").toString(); stylePath = valueFromGroup("Chat", "StylePublic", ":/qss/chat/public").toString();
styleVariant = valueFromGroup("Chat", "StylePublicVariant", "").toString();
} }
void RshareSettings::setPublicChatStyle(QString stylePath) void RshareSettings::setPublicChatStyle(QString stylePath, QString styleVariant)
{ {
setValueToGroup("Chat", "StylePublic", stylePath); setValueToGroup("Chat", "StylePublic", stylePath);
setValueToGroup("Chat", "StylePublicVariant", styleVariant);
} }
void RshareSettings::getPrivateChatStyle(QString &stylePath) void RshareSettings::getPrivateChatStyle(QString &stylePath, QString &styleVariant)
{ {
stylePath = valueFromGroup("Chat", "StylePrivate", ":/qss/chat/private").toString(); stylePath = valueFromGroup("Chat", "StylePrivate", ":/qss/chat/private").toString();
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
} }
void RshareSettings::setPrivateChatStyle(QString stylePath) void RshareSettings::setPrivateChatStyle(QString stylePath, QString styleVariant)
{ {
setValueToGroup("Chat", "StylePrivate", stylePath); setValueToGroup("Chat", "StylePrivate", stylePath);
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
} }
void RshareSettings::getHistoryChatStyle(QString &stylePath) void RshareSettings::getHistoryChatStyle(QString &stylePath, QString &styleVariant)
{ {
stylePath = valueFromGroup("Chat", "StyleHistory", ":/qss/chat/history").toString(); stylePath = valueFromGroup("Chat", "StyleHistory", ":/qss/chat/history").toString();
styleVariant = valueFromGroup("Chat", "StylePrivateVariant", "").toString();
} }
void RshareSettings::setHistoryChatStyle(QString stylePath) void RshareSettings::setHistoryChatStyle(QString stylePath, QString styleVariant)
{ {
setValueToGroup("Chat", "StyleHistory", stylePath); setValueToGroup("Chat", "StyleHistory", stylePath);
setValueToGroup("Chat", "StylePrivateVariant", styleVariant);
} }
/** Returns true if RetroShare is set to run on system boot. */ /** Returns true if RetroShare is set to run on system boot. */

View File

@ -123,14 +123,14 @@ public:
void setChatSendMessageWithCtrlReturn(bool bValue); void setChatSendMessageWithCtrlReturn(bool bValue);
/* chat styles */ /* chat styles */
void getPublicChatStyle(QString &stylePath); void getPublicChatStyle(QString &stylePath, QString &styleVariant);
void setPublicChatStyle(QString stylePath); void setPublicChatStyle(QString stylePath, QString styleVariant);
void getPrivateChatStyle(QString &stylePath); void getPrivateChatStyle(QString &stylePath, QString &styleVariant);
void setPrivateChatStyle(QString stylePath); void setPrivateChatStyle(QString stylePath, QString styleVariant);
void getHistoryChatStyle(QString &stylePath); void getHistoryChatStyle(QString &stylePath, QString &styleVariant);
void setHistoryChatStyle(QString stylePath); void setHistoryChatStyle(QString stylePath, QString styleVariant);
//! Save placement, state and size information of a window. //! Save placement, state and size information of a window.
void saveWidgetInformation(QWidget *widget); void saveWidgetInformation(QWidget *widget);