Added (and modified) patch from Imanuel

- Added ability to style the system messages in chat (e.g. Lobby management)
Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5130 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-05-01 12:58:28 +00:00
parent c331098203
commit 8bd1b7aa4a
21 changed files with 232 additions and 75 deletions

View file

@ -373,7 +373,7 @@ void FriendsDialog::publicChatChanged(int type)
void FriendsDialog::addChatMsg(bool incoming, bool history, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message)
{
unsigned int formatFlag = CHAT_FORMATMSG_EMBED_LINKS;
unsigned int formatFlag = CHAT_FORMATMSG_EMBED_LINKS | CHAT_FORMATMSG_OPTIMIZE;
// embed smileys ?
if (Settings->valueFromGroup("Chat", "Emoteicons_GroupChat", true).toBool()) {

View file

@ -43,6 +43,7 @@
hincoming.htm - incoming history messages
houtgoing.htm - outgoing history messages
ooutgoing.htm - outgoing offline messages (private chat)
system.htm - system messages
main.css - stylesheet
variants - directory with variants (optional)
@ -116,7 +117,8 @@ enum enumGetStyle
GETSTYLE_OUTGOING,
GETSTYLE_HINCOMING,
GETSTYLE_HOUTGOING,
GETSTYLE_OOUTGOING
GETSTYLE_OOUTGOING,
GETSTYLE_SYSTEM
};
/* Default constructor */
@ -226,6 +228,9 @@ static QString getStyle(const QDir &styleDir, const QString &styleVariant, enumG
case GETSTYLE_OOUTGOING:
fileHtml.setFileName(QFileInfo(styleDir, "ooutgoing.htm").absoluteFilePath());
break;
case GETSTYLE_SYSTEM:
fileHtml.setFileName(QFileInfo(styleDir, "system.htm").absoluteFilePath());
break;
default:
return "";
}
@ -283,6 +288,9 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
case FORMATMSG_OOUTGOING:
style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_OOUTGOING);
break;
case FORMATMSG_SYSTEM:
style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_SYSTEM);
break;
}
if (style.isEmpty()) {
@ -300,6 +308,9 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
if (flag & CHAT_FORMATMSG_EMBED_LINKS) {
formatFlag |= RSHTML_FORMATTEXT_EMBED_LINKS;
}
if (flag & CHAT_FORMATMSG_OPTIMIZE) {
formatFlag |= RSHTML_FORMATTEXT_OPTIMIZE;
}
QString msg = RsHtml::formatText(message, formatFlag);

View file

@ -33,12 +33,13 @@
#define CHAT_FORMATMSG_EMBED_SMILEYS 1
#define CHAT_FORMATMSG_EMBED_LINKS 2
#define CHAT_FORMATMSG_SYSTEM 4
#define CHAT_FORMATMSG_OPTIMIZE 8
/* Flags for ChatStyle::formatText */
#define CHAT_FORMATTEXT_EMBED_SMILEYS 1
#define CHAT_FORMATTEXT_EMBED_LINKS 2
#define FORMATMSG_COUNT 5
#define FORMATMSG_COUNT 6
class ChatStyleInfo
{
@ -67,6 +68,7 @@ public:
FORMATMSG_HINCOMING = 2,
FORMATMSG_HOUTGOING = 3,
FORMATMSG_OOUTGOING = 4,
FORMATMSG_SYSTEM = 5,
// FORMATMSG_COUNT
};

View file

@ -305,7 +305,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
std::cout << "ChatWidget::addChatMsg message : " << message.toStdString() << std::endl;
#endif
unsigned int formatFlag = CHAT_FORMATMSG_EMBED_LINKS;
unsigned int formatFlag = CHAT_FORMATMSG_EMBED_LINKS | CHAT_FORMATMSG_OPTIMIZE;
// embed smileys ?
if (Settings->valueFromGroup(QString("Chat"), QString::fromUtf8("Emoteicons_PrivatChat"), true).toBool()) {
@ -315,6 +315,8 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
ChatStyle::enumFormatMessage type;
if (chatType == TYPE_OFFLINE) {
type = ChatStyle::FORMATMSG_OOUTGOING;
} else if (chatType == TYPE_SYSTEM) {
type = ChatStyle::FORMATMSG_SYSTEM;
} else if (chatType == TYPE_HISTORY) {
type = incoming ? ChatStyle::FORMATMSG_HINCOMING : ChatStyle::FORMATMSG_HOUTGOING;
} else {

View file

@ -182,7 +182,7 @@ QString formatText(const QString &text, unsigned int flag)
if (flag & RSHTML_FORMATTEXT_REMOVE_COLOR) {
optimizeFlag |= RSHTML_OPTIMIZEHTML_REMOVE_COLOR;
}
if (optimizeFlag) {
if (optimizeFlag || (flag & RSHTML_FORMATTEXT_OPTIMIZE)) {
optimizeHtml(formattedText, optimizeFlag);
}

View file

@ -39,6 +39,7 @@
#define RSHTML_FORMATTEXT_REMOVE_FONT 4
#define RSHTML_FORMATTEXT_REMOVE_COLOR 8
#define RSHTML_FORMATTEXT_CLEANSTYLE (RSHTML_FORMATTEXT_REMOVE_FONT | RSHTML_FORMATTEXT_REMOVE_COLOR)
#define RSHTML_FORMATTEXT_OPTIMIZE 16
/* Flags for RsHtml::formatText */
#define RSHTML_OPTIMIZEHTML_REMOVE_FONT 2

View file

@ -493,6 +493,7 @@
<file>qss/chat/standard/private/hincoming.htm</file>
<file>qss/chat/standard/private/houtgoing.htm</file>
<file>qss/chat/standard/private/ooutgoing.htm</file>
<file>qss/chat/standard/private/system.htm</file>
<file>qss/chat/standard/private/main.css</file>
<file>qss/chat/standard/private/variants/Standard.css</file>
<file>qss/chat/standard/public/info.xml</file>
@ -501,6 +502,7 @@
<file>qss/chat/standard/public/hincoming.htm</file>
<file>qss/chat/standard/public/houtgoing.htm</file>
<file>qss/chat/standard/public/ooutgoing.htm</file>
<file>qss/chat/standard/public/system.htm</file>
<file>qss/chat/standard/public/main.css</file>
<file>qss/chat/standard/public/variants/Standard.css</file>
<file>qss/chat/standard/history/info.xml</file>
@ -509,6 +511,7 @@
<file>qss/chat/standard/history/hincoming.htm</file>
<file>qss/chat/standard/history/houtgoing.htm</file>
<file>qss/chat/standard/history/ooutgoing.htm</file>
<file>qss/chat/standard/history/system.htm</file>
<file>qss/chat/standard/history/main.css</file>
<file>qss/chat/standard/history/variants/Standard.css</file>
<file>qss/chat/compact/private/info.xml</file>
@ -517,6 +520,7 @@
<file>qss/chat/compact/private/hincoming.htm</file>
<file>qss/chat/compact/private/houtgoing.htm</file>
<file>qss/chat/compact/private/ooutgoing.htm</file>
<file>qss/chat/compact/private/system.htm</file>
<file>qss/chat/compact/private/main.css</file>
<file>qss/chat/compact/private/variants/Standard.css</file>
<file>qss/chat/compact/private/variants/Colored.css</file>
@ -526,6 +530,7 @@
<file>qss/chat/compact/public/hincoming.htm</file>
<file>qss/chat/compact/public/houtgoing.htm</file>
<file>qss/chat/compact/public/ooutgoing.htm</file>
<file>qss/chat/compact/public/system.htm</file>
<file>qss/chat/compact/public/main.css</file>
<file>qss/chat/compact/public/variants/Standard.css</file>
<file>qss/chat/compact/public/variants/Colored.css</file>
@ -535,6 +540,7 @@
<file>qss/chat/compact/history/hincoming.htm</file>
<file>qss/chat/compact/history/houtgoing.htm</file>
<file>qss/chat/compact/history/ooutgoing.htm</file>
<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>smileys/amorous.png</file>

View file

@ -64,3 +64,12 @@
.ooutgoingName {
color: #244578;
}
.incomingTable {
}
.incomingTime {
}
.incomingName {
}

View file

@ -0,0 +1,11 @@
<style type="text/css">
%css-style%
</style>
<table class='systemTable' width='100%'>
<tr><td>
<span class='systemTime'>%date% %time%</span>
<span class='name systemName'>%name%:</span>
%message%
</td></tr>
</table>

View file

@ -0,0 +1,7 @@
<style type="text/css">
%css-style%
</style>
<span class='time'>%time%</span>
<span class='name systemName'>%name%:</span>
%message%

View file

@ -21,3 +21,7 @@
.ooutgoingTime {
color:#808080;
}
.systemTime {
color:#808080;
}

View file

@ -0,0 +1,7 @@
<style type="text/css">
%css-style%
</style>
<span class='systemTime'>%time%</span>
<span class='name systemName'>%name%:</span>
%message%

View file

@ -69,3 +69,13 @@
.ooutgoingTime {
color: #244578;
}
.incomingTable {
color: #000000;
}
.systemHeader {
}
.systemTime {
}

View file

@ -0,0 +1,15 @@
<style type="text/css">
%css-style%
</style>
<table class='systemTable' width='100%'>
<tr>
<td class='header systemHeader'>%name%</td>
<td width='130' align='right' class='time systemTime'>[%date% %time%]</td>
</tr>
</table>
<table class='systemTable' width='100%'>
<tr>
<td>%message%</td>
</tr>
</table>

View file

@ -34,3 +34,6 @@
border-color:#fafafa #e3e3e3 #e3e3e3 #fafafa;
color: #244578;
}
.systemHeader {
}

View file

@ -0,0 +1,14 @@
<style type="text/css">
%css-style%
</style>
<table class='systemHeader' width='100%'>
<tr>
<td class='name'>%name%</td>
<td width='130' align='right' class='time'>%time%</td>
</tr>
</table>
<table width='100%'>
<tr>
<td>%message%</td>
</tr>
</table>

View file

@ -41,3 +41,9 @@
.ooutgoingName {
color:#FF0000;
}
.systemTime {
}
.systemName {
}

View file

@ -0,0 +1,7 @@
<style type="text/css">
%css-style%
</style>
<span class='systemTime'>%time%</span>
<span class='name systemName'>%name%</span><br>
%message%

View file

@ -206,11 +206,12 @@ void ChatPage::setPreviewMessages(QString &stylePath, QString styleVariant, QTex
QString nameOutgoing = tr("Outgoing");
QDateTime timestmp = QDateTime::fromTime_t(time(NULL));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, tr("Incoming message in history"), CHAT_FORMATTEXT_EMBED_SMILEYS));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HOUTGOING, nameOutgoing, timestmp, tr("Outgoing message in history"), CHAT_FORMATTEXT_EMBED_SMILEYS));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_INCOMING, nameIncoming, timestmp, tr("Incoming message"), CHAT_FORMATTEXT_EMBED_SMILEYS));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, tr("Outgoing message"), CHAT_FORMATTEXT_EMBED_SMILEYS));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OOUTGOING, nameOutgoing, timestmp, tr("Outgoing offline message"), CHAT_FORMATTEXT_EMBED_SMILEYS));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HINCOMING, nameIncoming, timestmp, tr("Incoming message in history"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_HOUTGOING, nameOutgoing, timestmp, tr("Outgoing message in history"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_INCOMING, nameIncoming, timestmp, tr("Incoming message"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OUTGOING, nameOutgoing, timestmp, tr("Outgoing message"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_OOUTGOING, nameOutgoing, timestmp, tr("Outgoing offline message"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
textBrowser->append(style.formatMessage(ChatStyle::FORMATMSG_SYSTEM, tr("System"), timestmp, tr("System message"), CHAT_FORMATTEXT_EMBED_SMILEYS | CHAT_FORMATMSG_OPTIMIZE));
}
void ChatPage::fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser)