mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-01 02:36:23 -04:00
Styles for public chat, private chat and history.
RetroShare has a standard style for each type, but the user can define their own styles. The external directories "style/public", "style/private" and "style/history" are scanned for subdirs with user defined style informations. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3453 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
452faffa4b
commit
6bd6c50502
24 changed files with 1537 additions and 684 deletions
|
@ -20,19 +20,60 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <QFontDialog>
|
||||
#include <time.h>
|
||||
|
||||
#include "ChatPage.h"
|
||||
|
||||
#include "gui/chat/ChatStyle.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "rsharesettings.h"
|
||||
|
||||
static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWidget)
|
||||
{
|
||||
QList<ChatStyleInfo> styles;
|
||||
QList<ChatStyleInfo>::iterator style;
|
||||
QListWidgetItem *item;
|
||||
QListWidgetItem *activeItem = NULL;
|
||||
|
||||
QString stylePath;
|
||||
|
||||
switch (type) {
|
||||
case ChatStyle::TYPE_PUBLIC:
|
||||
Settings->getPublicChatStyle(stylePath);
|
||||
break;
|
||||
case ChatStyle::TYPE_PRIVATE:
|
||||
Settings->getPrivateChatStyle(stylePath);
|
||||
break;
|
||||
case ChatStyle::TYPE_HISTORY:
|
||||
Settings->getHistoryChatStyle(stylePath);
|
||||
break;
|
||||
case ChatStyle::TYPE_UNKNOWN:
|
||||
return "";
|
||||
}
|
||||
|
||||
ChatStyle::getAvailableStyles(type, styles);
|
||||
for (style = styles.begin(); style != styles.end(); style++) {
|
||||
item = new QListWidgetItem(style->styleName);
|
||||
item->setData(Qt::UserRole, qVariantFromValue(*style));
|
||||
listWidget->addItem(item);
|
||||
|
||||
if (style->stylePath == stylePath) {
|
||||
activeItem = item;
|
||||
}
|
||||
}
|
||||
|
||||
listWidget->setCurrentItem(activeItem);
|
||||
|
||||
return stylePath;
|
||||
}
|
||||
|
||||
/** Constructor */
|
||||
ChatPage::ChatPage(QWidget * parent, Qt::WFlags 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);
|
||||
|
||||
/* Hide platform specific features */
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#endif
|
||||
|
@ -59,6 +100,34 @@ ChatPage::save(QString &errmsg)
|
|||
|
||||
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
||||
|
||||
ChatStyleInfo info;
|
||||
QListWidgetItem *item = ui.publicList->currentItem();
|
||||
if (item) {
|
||||
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
if (publicStylePath != info.stylePath) {
|
||||
Settings->setPublicChatStyle(info.stylePath);
|
||||
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PUBLIC);
|
||||
}
|
||||
}
|
||||
|
||||
item = ui.privateList->currentItem();
|
||||
if (item) {
|
||||
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
if (privateStylePath != info.stylePath) {
|
||||
Settings->setPrivateChatStyle(info.stylePath);
|
||||
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_PRIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
item = ui.historyList->currentItem();
|
||||
if (item) {
|
||||
info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
if (historyStylePath != info.stylePath) {
|
||||
Settings->setHistoryChatStyle(info.stylePath);
|
||||
NotifyQt::getInstance()->notifyChatStyleChanged(ChatStyle::TYPE_HISTORY);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -80,6 +149,11 @@ ChatPage::load()
|
|||
|
||||
ui.labelChatFontPreview->setText(fontTempChat.rawName());
|
||||
ui.labelChatFontPreview->setFont(fontTempChat);
|
||||
|
||||
/* Load styles */
|
||||
publicStylePath = loadStyleInfo(ChatStyle::TYPE_PUBLIC, ui.publicList);
|
||||
privateStylePath = loadStyleInfo(ChatStyle::TYPE_PRIVATE, ui.privateList);
|
||||
historyStylePath = loadStyleInfo(ChatStyle::TYPE_HISTORY, ui.historyList);
|
||||
}
|
||||
|
||||
bool ChatPage::emotePrivatChat() const {
|
||||
|
@ -107,3 +181,91 @@ void ChatPage::on_pushButtonChangeChatFont_clicked()
|
|||
ui.labelChatFontPreview->setFont(fontTempChat);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatPage::setPreviewMessages(QString &stylePath, QTextBrowser *textBrowser)
|
||||
{
|
||||
ChatStyle style;
|
||||
style.setStylePath(stylePath);
|
||||
style.loadEmoticons();
|
||||
|
||||
textBrowser->clear();
|
||||
|
||||
QString nameIncoming = "Incoming";
|
||||
QString nameOutgoing = "Outgoing";
|
||||
QDateTime timestmp = QDateTime::fromTime_t(time(NULL));
|
||||
QTextEdit textEdit;
|
||||
QString message;
|
||||
|
||||
textEdit.setText(tr("Incoming message in history"));
|
||||
message = textEdit.toHtml();
|
||||
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS));
|
||||
textEdit.setText(tr("Outgoing message in history"));
|
||||
message = textEdit.toHtml();
|
||||
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HOUTGOING, nameOutgoing, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS));
|
||||
textEdit.setText(tr("Incoming message"));
|
||||
message = textEdit.toHtml();
|
||||
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_INCOMING, nameIncoming, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS));
|
||||
textEdit.setText(tr("Outgoing message"));
|
||||
message = textEdit.toHtml();
|
||||
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, message, CHAT_FORMATTEXT_EMBED_SMILEYS));
|
||||
}
|
||||
|
||||
void ChatPage::on_publicList_currentRowChanged(int currentRow)
|
||||
{
|
||||
if (currentRow != -1) {
|
||||
QListWidgetItem *item = ui.publicList->item(currentRow);
|
||||
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
setPreviewMessages(info.stylePath, ui.publicPreview);
|
||||
|
||||
QString author = info.authorName;
|
||||
if (info.authorEmail.isEmpty() == false) {
|
||||
author += " (" + info.authorEmail + ")";
|
||||
}
|
||||
ui.publicAuthor->setText(author);
|
||||
ui.publicDescription->setText(info.styleDescription);
|
||||
} else {
|
||||
ui.publicPreview->clear();
|
||||
ui.publicAuthor->clear();
|
||||
ui.publicDescription->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatPage::on_privateList_currentRowChanged(int currentRow)
|
||||
{
|
||||
if (currentRow != -1) {
|
||||
QListWidgetItem *item = ui.privateList->item(currentRow);
|
||||
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
setPreviewMessages(info.stylePath, ui.privatePreview);
|
||||
|
||||
QString author = info.authorName;
|
||||
if (info.authorEmail.isEmpty() == false) {
|
||||
author += " (" + info.authorEmail + ")";
|
||||
}
|
||||
ui.privateAuthor->setText(author);
|
||||
ui.privateDescription->setText(info.styleDescription);
|
||||
} else {
|
||||
ui.privatePreview->clear();
|
||||
ui.privateAuthor->clear();
|
||||
ui.privateDescription->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatPage::on_historyList_currentRowChanged(int currentRow)
|
||||
{
|
||||
if (currentRow != -1) {
|
||||
QListWidgetItem *item = ui.historyList->item(currentRow);
|
||||
ChatStyleInfo info = qVariantValue<ChatStyleInfo>(item->data(Qt::UserRole));
|
||||
setPreviewMessages(info.stylePath, ui.historyPreview);
|
||||
|
||||
QString author = info.authorName;
|
||||
if (info.authorEmail.isEmpty() == false) {
|
||||
author += " (" + info.authorEmail + ")";
|
||||
}
|
||||
ui.historyAuthor->setText(author);
|
||||
ui.historyDescription->setText(info.styleDescription);
|
||||
} else {
|
||||
ui.historyPreview->clear();
|
||||
ui.historyAuthor->clear();
|
||||
ui.historyDescription->clear();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue