mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added new variant to the compact chat style with colored nicknames calculated from the name.
It's disabled by default. You can enable it with the define COLORED_NICKNAMES in ChatStyle.cpp. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4884 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a1806bb04f
commit
d3e2eb1f54
@ -164,10 +164,10 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const QString& nickname,
|
|||||||
{
|
{
|
||||||
switch (event_type) {
|
switch (event_type) {
|
||||||
case RS_CHAT_LOBBY_EVENT_PEER_LEFT:
|
case RS_CHAT_LOBBY_EVENT_PEER_LEFT:
|
||||||
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the lobby.").arg(str), ChatWidget::TYPE_NORMAL);
|
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the lobby.").arg(str), ChatWidget::TYPE_SYSTEM);
|
||||||
break;
|
break;
|
||||||
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
||||||
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(str), ChatWidget::TYPE_NORMAL);
|
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(str), ChatWidget::TYPE_SYSTEM);
|
||||||
break;
|
break;
|
||||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||||
ui.chatWidget->updateStatusString(nickname + " %1", str);
|
ui.chatWidget->updateStatusString(nickname + " %1", str);
|
||||||
|
@ -99,6 +99,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
#include "ChatStyle.h"
|
#include "ChatStyle.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
@ -107,6 +108,8 @@
|
|||||||
|
|
||||||
#include <retroshare/rsinit.h>
|
#include <retroshare/rsinit.h>
|
||||||
|
|
||||||
|
//#define COLORED_NICKNAMES
|
||||||
|
|
||||||
enum enumGetStyle
|
enum enumGetStyle
|
||||||
{
|
{
|
||||||
GETSTYLE_INCOMING,
|
GETSTYLE_INCOMING,
|
||||||
@ -223,15 +226,19 @@ static QString getStyle(const QDir &styleDir, const QString &styleVariant, enumG
|
|||||||
fileCss.close();
|
fileCss.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (styleVariant.isEmpty() == false) {
|
QString variant = styleVariant;
|
||||||
QFile fileCssVariant(QFileInfo(styleDir, "variants/" + styleVariant + ".css").absoluteFilePath());
|
if (styleVariant.isEmpty()) {
|
||||||
QString cssVariant;
|
// use standard
|
||||||
if (fileCssVariant.open(QIODevice::ReadOnly)) {
|
variant = "Standard";
|
||||||
cssVariant = fileCssVariant.readAll();
|
}
|
||||||
fileCssVariant.close();
|
|
||||||
|
|
||||||
css += "\n" + cssVariant;
|
QFile fileCssVariant(QFileInfo(styleDir, "variants/" + variant + ".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);
|
||||||
@ -281,34 +288,31 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||||||
|
|
||||||
QString msg = RsHtml::formatText(message, formatFlag);
|
QString msg = RsHtml::formatText(message, formatFlag);
|
||||||
|
|
||||||
// //replace http://, https:// and www. with <a href> links
|
QColor color;
|
||||||
// QRegExp rx("(retroshare://[^ <>]*)|(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
#ifdef COLORED_NICKNAMES
|
||||||
// int count = 0;
|
if (flag & CHAT_FORMATMSG_SYSTEM) {
|
||||||
// int pos = 100; //ignore the first 100 char because of the standard DTD ref
|
color = Qt::darkBlue;
|
||||||
// while ( (pos = rx.indexIn(message, pos)) != -1 ) {
|
} else {
|
||||||
// //we need to look ahead to see if it's already a well formed link
|
// Calculate color from the name
|
||||||
// if (message.mid(pos - 6, 6) != "href=\"" && message.mid(pos - 6, 6) != "href='" && message.mid(pos - 6, 6) != "ttp://" ) {
|
// uint hash = 0x73ffe23a;
|
||||||
// QString tempMessg = message.left(pos) + "<a href=\"" + rx.cap(count) + "\">" + rx.cap(count) + "</a>" + message.mid(pos + rx.matchedLength(), -1);
|
// for (int i = 0; i < name.length(); ++i) {
|
||||||
// message = tempMessg;
|
// hash = (hash ^ 0x28594888) + ((uint32_t) name[i].toAscii() << (i % 4));
|
||||||
// }
|
// }
|
||||||
// pos += rx.matchedLength() + 15;
|
|
||||||
// count ++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// {
|
uint hash = 0;
|
||||||
// QHashIterator<QString, QString> i(smileys);
|
for (int i = 0; i < name.length(); ++i) {
|
||||||
// while(i.hasNext())
|
hash = (((hash << 1) + (hash >> 14)) ^ ((int) name[i].toAscii())) & 0x3fff;
|
||||||
// {
|
}
|
||||||
// i.next();
|
|
||||||
// foreach(QString code, i.key().split("|"))
|
color.setHsv(hash, 255, 150);
|
||||||
// message.replace(code, "<img src=\"" + i.value() + "\">");
|
}
|
||||||
// }
|
#endif
|
||||||
// }
|
|
||||||
|
|
||||||
QString formatMsg = style.replace("%name%", name)
|
QString formatMsg = style.replace("%name%", name)
|
||||||
.replace("%date%", timestamp.date().toString("dd.MM.yyyy"))
|
.replace("%date%", timestamp.date().toString("dd.MM.yyyy"))
|
||||||
.replace("%time%", timestamp.time().toString("hh:mm:ss"))
|
.replace("%time%", timestamp.time().toString("hh:mm:ss"))
|
||||||
.replace("%message%", msg);
|
.replace("%message%", msg)
|
||||||
|
.replace("%color%", color.name());
|
||||||
|
|
||||||
return formatMsg;
|
return formatMsg;
|
||||||
}
|
}
|
||||||
@ -519,6 +523,11 @@ static QString getBaseDir()
|
|||||||
|
|
||||||
// iterate variants
|
// iterate variants
|
||||||
for (QFileInfoList::iterator file = fileList.begin(); file != fileList.end(); file++) {
|
for (QFileInfoList::iterator file = fileList.begin(); file != fileList.end(); file++) {
|
||||||
|
#ifndef COLORED_NICKNAMES
|
||||||
|
if (file->baseName().toLower() == "colored") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
variants.append(file->baseName());
|
variants.append(file->baseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
/* Flags for ChatStyle::formatMessage */
|
/* Flags for ChatStyle::formatMessage */
|
||||||
#define CHAT_FORMATMSG_EMBED_SMILEYS 1
|
#define CHAT_FORMATMSG_EMBED_SMILEYS 1
|
||||||
#define CHAT_FORMATMSG_EMBED_LINKS 2
|
#define CHAT_FORMATMSG_EMBED_LINKS 2
|
||||||
|
#define CHAT_FORMATMSG_SYSTEM 4
|
||||||
|
|
||||||
/* Flags for ChatStyle::formatText */
|
/* Flags for ChatStyle::formatText */
|
||||||
#define CHAT_FORMATTEXT_EMBED_SMILEYS 1
|
#define CHAT_FORMATTEXT_EMBED_SMILEYS 1
|
||||||
|
@ -309,6 +309,10 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
|
|||||||
type = incoming ? ChatStyle::FORMATMSG_INCOMING : ChatStyle::FORMATMSG_OUTGOING;
|
type = incoming ? ChatStyle::FORMATMSG_INCOMING : ChatStyle::FORMATMSG_OUTGOING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatType == TYPE_SYSTEM) {
|
||||||
|
formatFlag |= CHAT_FORMATMSG_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
QString formatMsg = chatStyle.formatMessage(type, name, incoming ? sendTime : recvTime, message, formatFlag);
|
QString formatMsg = chatStyle.formatMessage(type, name, incoming ? sendTime : recvTime, message, formatFlag);
|
||||||
|
|
||||||
ui->textBrowser->append(formatMsg);
|
ui->textBrowser->append(formatMsg);
|
||||||
|
@ -41,9 +41,9 @@ class ChatWidget;
|
|||||||
class ChatWidget : public QWidget
|
class ChatWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum enumChatType { TYPE_NORMAL, TYPE_HISTORY, TYPE_OFFLINE };
|
enum enumChatType { TYPE_NORMAL, TYPE_HISTORY, TYPE_OFFLINE, TYPE_SYSTEM };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChatWidget(QWidget *parent = 0);
|
explicit ChatWidget(QWidget *parent = 0);
|
||||||
|
@ -506,6 +506,7 @@
|
|||||||
<file>qss/chat/compact/private/ooutgoing.htm</file>
|
<file>qss/chat/compact/private/ooutgoing.htm</file>
|
||||||
<file>qss/chat/compact/private/main.css</file>
|
<file>qss/chat/compact/private/main.css</file>
|
||||||
<file>qss/chat/compact/private/variants/Standard.css</file>
|
<file>qss/chat/compact/private/variants/Standard.css</file>
|
||||||
|
<file>qss/chat/compact/private/variants/Colored.css</file>
|
||||||
<file>qss/chat/compact/public/info.xml</file>
|
<file>qss/chat/compact/public/info.xml</file>
|
||||||
<file>qss/chat/compact/public/incoming.htm</file>
|
<file>qss/chat/compact/public/incoming.htm</file>
|
||||||
<file>qss/chat/compact/public/outgoing.htm</file>
|
<file>qss/chat/compact/public/outgoing.htm</file>
|
||||||
@ -514,6 +515,7 @@
|
|||||||
<file>qss/chat/compact/public/ooutgoing.htm</file>
|
<file>qss/chat/compact/public/ooutgoing.htm</file>
|
||||||
<file>qss/chat/compact/public/main.css</file>
|
<file>qss/chat/compact/public/main.css</file>
|
||||||
<file>qss/chat/compact/public/variants/Standard.css</file>
|
<file>qss/chat/compact/public/variants/Standard.css</file>
|
||||||
|
<file>qss/chat/compact/public/variants/Colored.css</file>
|
||||||
<file>qss/chat/compact/history/info.xml</file>
|
<file>qss/chat/compact/history/info.xml</file>
|
||||||
<file>qss/chat/compact/history/incoming.htm</file>
|
<file>qss/chat/compact/history/incoming.htm</file>
|
||||||
<file>qss/chat/compact/history/outgoing.htm</file>
|
<file>qss/chat/compact/history/outgoing.htm</file>
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
.incomingName {
|
||||||
|
color:#2D84C9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outgoingName {
|
||||||
|
color:#2D84C9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hincomingName {
|
||||||
|
color:#1E5684;
|
||||||
|
}
|
||||||
|
|
||||||
|
.houtgoingName {
|
||||||
|
color:#1E5684;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ooutgoingName {
|
||||||
|
color:#ff0000;
|
||||||
|
}
|
@ -5,23 +5,3 @@
|
|||||||
.time {
|
.time {
|
||||||
color:#808080;
|
color:#808080;
|
||||||
}
|
}
|
||||||
|
|
||||||
.incomingName {
|
|
||||||
color:#42940C;
|
|
||||||
}
|
|
||||||
|
|
||||||
.outgoingName {
|
|
||||||
color:#2F5A9B;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hincomingName {
|
|
||||||
color:#88f042;
|
|
||||||
}
|
|
||||||
|
|
||||||
.houtgoingName {
|
|
||||||
color:#6491d2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ooutgoingName {
|
|
||||||
color:#ff0000;
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
.incomingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hincomingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.houtgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ooutgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
.incomingName {
|
||||||
|
color:#42940C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outgoingName {
|
||||||
|
color:#2F5A9B;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hincomingName {
|
||||||
|
color:#88f042;
|
||||||
|
}
|
||||||
|
|
||||||
|
.houtgoingName {
|
||||||
|
color:#6491d2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ooutgoingName {
|
||||||
|
color:#ff0000;
|
||||||
|
}
|
@ -6,38 +6,18 @@
|
|||||||
color:#C00000;
|
color:#C00000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.incomingName {
|
|
||||||
color:#2D84C9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.outgoingTime {
|
.outgoingTime {
|
||||||
color:#C00000;
|
color:#C00000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.outgoingName {
|
|
||||||
color:#2D84C9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hincomingTime {
|
.hincomingTime {
|
||||||
color:#800000;
|
color:#800000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hincomingName {
|
|
||||||
color:#1E5684;
|
|
||||||
}
|
|
||||||
|
|
||||||
.houtgoingTime {
|
.houtgoingTime {
|
||||||
color:#800000;
|
color:#800000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.houtgoingName {
|
|
||||||
color:#1E5684;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ooutgoingTime {
|
.ooutgoingTime {
|
||||||
color:#C00000;
|
color:#C00000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ooutgoingName {
|
|
||||||
color:#ff0000;
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
.incomingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hincomingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.houtgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ooutgoingName {
|
||||||
|
color:%color%;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
.incomingName {
|
||||||
|
color:#2D84C9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.outgoingName {
|
||||||
|
color:#2D84C9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hincomingName {
|
||||||
|
color:#1E5684;
|
||||||
|
}
|
||||||
|
|
||||||
|
.houtgoingName {
|
||||||
|
color:#1E5684;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ooutgoingName {
|
||||||
|
color:#ff0000;
|
||||||
|
}
|
@ -39,5 +39,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ooutgoingName {
|
.ooutgoingName {
|
||||||
color:#2D84C9;
|
color:#FF0000;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user