Enabled clickable links in forums and messages.

Added new translation in messages (count of recommended files).
Fixed german translation.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3946 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-12-30 17:09:32 +00:00
parent 2307ef04a0
commit ad67844c7a
14 changed files with 80 additions and 77 deletions

View File

@ -1148,9 +1148,7 @@ void ForumsDialog::insertPost()
}
}
QString extraTxt;
extraTxt += QString::fromStdWString(msg.msg);
Emoticons::formatText(extraTxt);
QString extraTxt = RsHtml::formatText(QString::fromStdWString(msg.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
ui.postText->setHtml(extraTxt);
ui.threadTitle->setText(QString::fromStdWString(msg.title));

View File

@ -1718,15 +1718,10 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
text = QString::fromStdWString(msgInfo.msg);
Emoticons::formatText(text);
text = RsHtml::formatText(QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
ui.msgText->setHtml(text);
{
std::ostringstream out;
out << "(" << msgInfo.count << " Files)";
ui.filesText->setText(QString::fromStdString(out.str()));
}
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));
showTagLabels();

View File

@ -23,6 +23,8 @@
#include <QFileInfo>
#include <QWidgetAction>
#include <QTimer>
#include <QBuffer>
#include "common/vmessagebox.h"
#include "common/StatusDefs.h"

View File

@ -162,27 +162,6 @@ static QString getStyle(const QDir &styleDir, const QString &styleVariant, enumG
return style;
}
QString ChatStyle::formatText(const QString &message, unsigned int flag)
{
if (flag == 0) {
// nothing to do
return message;
}
QDomDocument doc;
doc.setContent(message);
QDomElement body = doc.documentElement();
if (flag & CHAT_FORMATTEXT_EMBED_LINKS) {
RsChat::embedHtml(doc, body, defEmbedAhref);
}
if (flag & CHAT_FORMATTEXT_EMBED_SMILEYS) {
RsChat::embedHtml(doc, body, Emoticons::defEmbedImg);
}
return doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit
}
QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, const QDateTime &timestamp, const QString &message, unsigned int flag)
{
QString style = m_style[type];
@ -216,13 +195,13 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
unsigned int formatFlag = 0;
if (flag & CHAT_FORMATMSG_EMBED_SMILEYS) {
formatFlag |= CHAT_FORMATTEXT_EMBED_SMILEYS;
formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
}
if (flag & CHAT_FORMATMSG_EMBED_LINKS) {
formatFlag |= CHAT_FORMATTEXT_EMBED_LINKS;
formatFlag |= RSHTML_FORMATTEXT_EMBED_LINKS;
}
QString msg = formatText(message, formatFlag);
QString msg = RsHtml::formatText(message, formatFlag);
// //replace http://, https:// and www. with <a href> links
// QRegExp rx("(retroshare://[^ <>]*)|(https?://[^ <>]*)|(www\\.[^ <>]*)");

View File

@ -27,8 +27,7 @@
#include <QDateTime>
#include <QHash>
#include <QMetaType>
#include "HandleRichText.h"
#include <QDir>
/* Flags for ChatStyle::formatMessage */
#define CHAT_FORMATMSG_EMBED_SMILEYS 1
@ -88,7 +87,6 @@ public:
bool setStyleFromSettings(enumStyleType styleType);
QString formatMessage(enumFormatMessage type, const QString &name, const QDateTime &timestamp, const QString &message, unsigned int flag);
QString formatText(const QString &message, unsigned int flag);
static bool getAvailableStyles(enumStyleType styleType, QList<ChatStyleInfo> &styles);
static bool getAvailableVariants(const QString &stylePath, QStringList &variants);
@ -102,9 +100,6 @@ private:
QString m_styleVariant;
QString m_style[FORMATMSG_COUNT];
/** store default information for embedding HTML */
RsChat::EmbedInHtmlAhref defEmbedAhref;
};
#endif // _CHATSTYLE_H

View File

@ -22,8 +22,9 @@
#include "HandleRichText.h"
namespace RsChat {
namespace RsHtml {
EmbedInHtmlImg defEmbedImg;
void EmbedInHtmlImg::InitFromAwkwardHash(const QHash< QString, QString >& hash)
{
@ -40,6 +41,27 @@ void EmbedInHtmlImg::InitFromAwkwardHash(const QHash< QString, QString >& hash)
myRE.setPattern(newRE);
}
QString formatText(const QString &text, unsigned int flag)
{
if (flag == 0) {
// nothing to do
return text;
}
QDomDocument doc;
doc.setContent(text);
QDomElement body = doc.documentElement();
if (flag & RSHTML_FORMATTEXT_EMBED_SMILEYS) {
embedHtml(doc, body, defEmbedImg);
}
if (flag & RSHTML_FORMATTEXT_EMBED_LINKS) {
EmbedInHtmlAhref defEmbedAhref;
embedHtml(doc, body, defEmbedAhref);
}
return doc.toString(-1); // -1 removes any annoying carriage return misinterpreted by QTextEdit
}
/**
* Parses a DOM tree and replaces text by HTML tags.
@ -123,5 +145,4 @@ void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embe
}
}
} // namespace RsChat
} // namespace RsHtml

View File

@ -33,8 +33,11 @@
#include <QRegExp>
#include <QtXml>
/* Flags for RsHtml::formatText */
#define RSHTML_FORMATTEXT_EMBED_SMILEYS 1
#define RSHTML_FORMATTEXT_EMBED_LINKS 2
namespace RsChat {
namespace RsHtml {
/**
@ -80,6 +83,7 @@ public:
};
/**
* This class is used to store information for embedding smileys into <img/> tags.
*
@ -102,11 +106,13 @@ public:
QHash<QString,QString> smileys;
};
extern EmbedInHtmlImg defEmbedImg;
QString formatText(const QString &text, unsigned int flag);
void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embedInfos);
} // namespace RsChat
} // namespace RsHtml
#endif // HANDLE_RICH_TEXT_H_

View File

@ -21,6 +21,7 @@
****************************************************************/
#include <QPixmap>
#include <QBuffer>
#include "PopupChatWindow.h"
#include "PopupChatDialog.h"

View File

@ -33,7 +33,6 @@
#include "Emoticons.h"
static QHash<QString, QString> Smileys;
RsChat::EmbedInHtmlImg Emoticons::defEmbedImg;
void Emoticons::load()
{
@ -119,7 +118,7 @@ void Emoticons::load()
}
// init <img> embedder
defEmbedImg.InitFromAwkwardHash(Smileys);
RsHtml::defEmbedImg.InitFromAwkwardHash(Smileys);
}
void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above)

View File

@ -36,9 +36,6 @@ public:
static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above);
static void formatText(QString &text);
public:
static RsChat::EmbedInHtmlImg defEmbedImg;
};
#endif

View File

@ -26,7 +26,7 @@
#include "FeedHolder.h"
#include "../RsAutoUpdatePage.h"
#include "gui/msgs/MessageComposer.h"
#include "gui/chat/ChatStyle.h"
#include "gui/chat/HandleRichText.h"
#include "gui/settings/rsharesettings.h"
#include "gui/notifyqt.h"
@ -149,15 +149,14 @@ void ChatMsgItem::insertChat(std::string &message)
QString formatMsg = QString::fromStdString(message);
ChatStyle style;
unsigned int formatFlag = CHAT_FORMATTEXT_EMBED_LINKS;
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;
// embed smileys ?
if (Settings->valueFromGroup(QString("Chat"), QString::fromUtf8("Emoteicons_GroupChat"), true).toBool()) {
formatFlag |= CHAT_FORMATTEXT_EMBED_SMILEYS;
formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
}
formatMsg = style.formatText(formatMsg, formatFlag);
formatMsg = RsHtml::formatText(formatMsg, formatFlag);
chatTextlabel->setText(formatMsg);
}

View File

@ -24,6 +24,7 @@
#define _IMHISTORYBROWSER_H
#include <QDialog>
#include <QThread>
#include <retroshare/rsmsgs.h>
#include "IMHistoryKeeper.h"

View File

@ -1141,7 +1141,7 @@ p, li { white-space: pre-wrap; }
<translation>Abbrechen</translation>
</message>
<message>
<location filename="../gui/feeds/ChatMsgItem.cpp" line="+274"/>
<location filename="../gui/feeds/ChatMsgItem.cpp" line="+273"/>
<source>Quick Message</source>
<translation>Schnelle Nachrricht</translation>
</message>
@ -1288,7 +1288,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>ChatStyle</name>
<message>
<location filename="../gui/chat/ChatStyle.cpp" line="+383"/>
<location filename="../gui/chat/ChatStyle.cpp" line="+362"/>
<source>Standard style for group chat</source>
<translation>Standard Stil für den Gruppenchat</translation>
</message>
@ -3585,7 +3585,7 @@ p, li { white-space: pre-wrap; }
<translation>keine</translation>
</message>
<message>
<location line="+503"/>
<location line="+501"/>
<location line="+81"/>
<source>RetroShare</source>
<translation></translation>
@ -3601,7 +3601,7 @@ p, li { white-space: pre-wrap; }
<translation>Du kannst einem anonymen Autor nicht antworten</translation>
</message>
<message>
<location line="-1275"/>
<location line="-1273"/>
<source>Your Forums</source>
<translation>Deine Foren</translation>
</message>
@ -3739,7 +3739,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location filename="../gui/ForumsDialog.cpp" line="+110"/>
<location line="+1086"/>
<location line="+1084"/>
<source>Start New Thread</source>
<translation>Erstelle neues Thema</translation>
</message>
@ -3767,7 +3767,7 @@ p, li { white-space: pre-wrap; }
<translation>Inhalt</translation>
</message>
<message>
<location filename="../gui/ForumsDialog.cpp" line="-1073"/>
<location filename="../gui/ForumsDialog.cpp" line="-1071"/>
<location line="+3"/>
<source>Mark as read</source>
<translation>Als gelesen markieren</translation>
@ -6073,15 +6073,15 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+177"/>
<location filename="../gui/MessagesDialog.cpp" line="-44"/>
<location line="+989"/>
<location line="+984"/>
<location line="+10"/>
<source>Inbox</source>
<translation>Posteingang</translation>
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-994"/>
<location line="+1007"/>
<location filename="../gui/MessagesDialog.cpp" line="-989"/>
<location line="+1002"/>
<location line="+8"/>
<source>Outbox</source>
<translation>Postausgang</translation>
@ -6093,7 +6093,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-1005"/>
<location filename="../gui/MessagesDialog.cpp" line="-1000"/>
<source>Sent</source>
<translation>Gesendet</translation>
</message>
@ -6155,13 +6155,13 @@ p, li { white-space: pre-wrap; }
<translation>Speichern unter...</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="+761"/>
<location filename="../gui/MessagesDialog.cpp" line="+756"/>
<source>Print Document</source>
<translation>Dokument drucken</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.ui" line="-889"/>
<location filename="../gui/MessagesDialog.cpp" line="-1568"/>
<location filename="../gui/MessagesDialog.cpp" line="-1563"/>
<source>Subject</source>
<translation>Betreff</translation>
</message>
@ -6226,7 +6226,17 @@ p, li { white-space: pre-wrap; }
<translation>Empfohlene Dateien einblenden</translation>
</message>
<message>
<location line="+1034"/>
<location line="+892"/>
<source>File</source>
<translation>Datei</translation>
</message>
<message>
<location line="+0"/>
<source>Files</source>
<translation>Dateien</translation>
</message>
<message>
<location line="+137"/>
<source>Save as...</source>
<translation>Speichern unter...</translation>
</message>
@ -6236,7 +6246,7 @@ p, li { white-space: pre-wrap; }
<translation>HTML-Dateien (*.htm *.html);;Alle Dateien (*)</translation>
</message>
<message>
<location line="-1545"/>
<location line="-1540"/>
<location line="+274"/>
<source>Reply to All</source>
<translation>Allen antworten</translation>
@ -6276,7 +6286,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+177"/>
<location filename="../gui/MessagesDialog.cpp" line="+628"/>
<location line="+1031"/>
<location line="+1026"/>
<location line="+5"/>
<source>Trash</source>
<translation>Papierkorb</translation>
@ -6292,7 +6302,7 @@ p, li { white-space: pre-wrap; }
<translation>Ordner</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="-1653"/>
<location filename="../gui/MessagesDialog.cpp" line="-1648"/>
<source>Remove All Tags</source>
<translation>Alle Schlagwörter entfernen</translation>
</message>
@ -6323,13 +6333,13 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+358"/>
<location line="+1022"/>
<location line="+1017"/>
<location line="+8"/>
<source>Drafts</source>
<translation>Entwürfe</translation>
</message>
<message>
<location line="-994"/>
<location line="-989"/>
<source>To</source>
<translation>An</translation>
</message>
@ -6339,7 +6349,7 @@ p, li { white-space: pre-wrap; }
<translation>Editieren...</translation>
</message>
<message>
<location line="+1409"/>
<location line="+1404"/>
<location line="+4"/>
<location line="+4"/>
<location line="+4"/>
@ -6351,7 +6361,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>MessengerWindow</name>
<message>
<location filename="../gui/MessengerWindow.cpp" line="+292"/>
<location filename="../gui/MessengerWindow.cpp" line="+294"/>
<source>Expand all</source>
<translation>Alle erweitern</translation>
</message>
@ -8166,7 +8176,7 @@ Do you want to send them a Message instead</source>
<translation>Tab abdocken</translation>
</message>
<message>
<location filename="../gui/chat/PopupChatWindow.cpp" line="+259"/>
<location filename="../gui/chat/PopupChatWindow.cpp" line="+260"/>
<source>RetroShare</source>
<translation>RetroShare</translation>
</message>
@ -8674,7 +8684,7 @@ p, li { white-space: pre-wrap; }
<translation>Die Datei wurde zur Downloadliste hinzugefügt.</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="-1149"/>
<location filename="../gui/MessagesDialog.cpp" line="-1144"/>
<location filename="../gui/RetroShareLink.cpp" line="+8"/>
<source>File Request canceled</source>
<translation>Dateianforderung abgebrochen</translation>