diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index c8ff3806d..d18c88228 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -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)); diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 3a914ce5b..11be5ee97 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -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(); diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 987c28912..09db3586a 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -23,6 +23,8 @@ #include #include #include +#include + #include "common/vmessagebox.h" #include "common/StatusDefs.h" diff --git a/retroshare-gui/src/gui/chat/ChatStyle.cpp b/retroshare-gui/src/gui/chat/ChatStyle.cpp index 55b23bb1b..afaf3d392 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.cpp +++ b/retroshare-gui/src/gui/chat/ChatStyle.cpp @@ -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 ×tamp, 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 links // QRegExp rx("(retroshare://[^ <>]*)|(https?://[^ <>]*)|(www\\.[^ <>]*)"); diff --git a/retroshare-gui/src/gui/chat/ChatStyle.h b/retroshare-gui/src/gui/chat/ChatStyle.h index 456d9d436..c1c1f2009 100644 --- a/retroshare-gui/src/gui/chat/ChatStyle.h +++ b/retroshare-gui/src/gui/chat/ChatStyle.h @@ -27,8 +27,7 @@ #include #include #include - -#include "HandleRichText.h" +#include /* 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 ×tamp, const QString &message, unsigned int flag); - QString formatText(const QString &message, unsigned int flag); static bool getAvailableStyles(enumStyleType styleType, QList &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 diff --git a/retroshare-gui/src/gui/chat/HandleRichText.cpp b/retroshare-gui/src/gui/chat/HandleRichText.cpp index 8c9634972..48e24093f 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.cpp +++ b/retroshare-gui/src/gui/chat/HandleRichText.cpp @@ -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 diff --git a/retroshare-gui/src/gui/chat/HandleRichText.h b/retroshare-gui/src/gui/chat/HandleRichText.h index bd6d481f2..a85d7de42 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.h +++ b/retroshare-gui/src/gui/chat/HandleRichText.h @@ -33,8 +33,11 @@ #include #include +/* 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 tags. * @@ -102,11 +106,13 @@ public: QHash 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_ diff --git a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp index c7ba08f0d..32b61f640 100644 --- a/retroshare-gui/src/gui/chat/PopupChatWindow.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatWindow.cpp @@ -21,6 +21,7 @@ ****************************************************************/ #include +#include #include "PopupChatWindow.h" #include "PopupChatDialog.h" diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index a0d633471..7156a69d8 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -33,7 +33,6 @@ #include "Emoticons.h" static QHash Smileys; -RsChat::EmbedInHtmlImg Emoticons::defEmbedImg; void Emoticons::load() { @@ -119,7 +118,7 @@ void Emoticons::load() } // init embedder - defEmbedImg.InitFromAwkwardHash(Smileys); + RsHtml::defEmbedImg.InitFromAwkwardHash(Smileys); } void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above) diff --git a/retroshare-gui/src/gui/common/Emoticons.h b/retroshare-gui/src/gui/common/Emoticons.h index 60da3d24d..d9c722d6b 100644 --- a/retroshare-gui/src/gui/common/Emoticons.h +++ b/retroshare-gui/src/gui/common/Emoticons.h @@ -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 diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index b166b4c14..c5f428f77 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -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); } diff --git a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h index 04fbae624..c39bffc47 100644 --- a/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h +++ b/retroshare-gui/src/gui/im_history/ImHistoryBrowser.h @@ -24,6 +24,7 @@ #define _IMHISTORYBROWSER_H #include +#include #include #include "IMHistoryKeeper.h" diff --git a/retroshare-gui/src/lang/retroshare_de.qm b/retroshare-gui/src/lang/retroshare_de.qm index f274d2acf..68941fc78 100644 Binary files a/retroshare-gui/src/lang/retroshare_de.qm and b/retroshare-gui/src/lang/retroshare_de.qm differ diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index 272ff334f..615967e55 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -1141,7 +1141,7 @@ p, li { white-space: pre-wrap; } Abbrechen - + Quick Message Schnelle Nachrricht @@ -1288,7 +1288,7 @@ p, li { white-space: pre-wrap; } ChatStyle - + Standard style for group chat Standard Stil für den Gruppenchat @@ -3585,7 +3585,7 @@ p, li { white-space: pre-wrap; } keine - + RetroShare @@ -3601,7 +3601,7 @@ p, li { white-space: pre-wrap; } Du kannst einem anonymen Autor nicht antworten - + Your Forums Deine Foren @@ -3739,7 +3739,7 @@ p, li { white-space: pre-wrap; } - + Start New Thread Erstelle neues Thema @@ -3767,7 +3767,7 @@ p, li { white-space: pre-wrap; } Inhalt - + Mark as read Als gelesen markieren @@ -6073,15 +6073,15 @@ p, li { white-space: pre-wrap; } - + Inbox Posteingang - - + + Outbox Postausgang @@ -6093,7 +6093,7 @@ p, li { white-space: pre-wrap; } - + Sent Gesendet @@ -6155,13 +6155,13 @@ p, li { white-space: pre-wrap; } Speichern unter... - + Print Document Dokument drucken - + Subject Betreff @@ -6226,7 +6226,17 @@ p, li { white-space: pre-wrap; } Empfohlene Dateien einblenden - + + File + Datei + + + + Files + Dateien + + + Save as... Speichern unter... @@ -6236,7 +6246,7 @@ p, li { white-space: pre-wrap; } HTML-Dateien (*.htm *.html);;Alle Dateien (*) - + Reply to All Allen antworten @@ -6276,7 +6286,7 @@ p, li { white-space: pre-wrap; } - + Trash Papierkorb @@ -6292,7 +6302,7 @@ p, li { white-space: pre-wrap; } Ordner - + Remove All Tags Alle Schlagwörter entfernen @@ -6323,13 +6333,13 @@ p, li { white-space: pre-wrap; } - + Drafts Entwürfe - + To An @@ -6339,7 +6349,7 @@ p, li { white-space: pre-wrap; } Editieren... - + @@ -6351,7 +6361,7 @@ p, li { white-space: pre-wrap; } MessengerWindow - + Expand all Alle erweitern @@ -8166,7 +8176,7 @@ Do you want to send them a Message instead Tab abdocken - + RetroShare RetroShare @@ -8674,7 +8684,7 @@ p, li { white-space: pre-wrap; } Die Datei wurde zur Downloadliste hinzugefügt. - + File Request canceled Dateianforderung abgebrochen