mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 09:03:51 -05:00
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:
parent
2307ef04a0
commit
ad67844c7a
14 changed files with 80 additions and 77 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <QFileInfo>
|
||||
#include <QWidgetAction>
|
||||
#include <QTimer>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <a href> links
|
||||
// QRegExp rx("(retroshare://[^ <>]*)|(https?://[^ <>]*)|(www\\.[^ <>]*)");
|
||||
|
|
|
|||
|
|
@ -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 ×tamp, 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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_
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "PopupChatWindow.h"
|
||||
#include "PopupChatDialog.h"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#define _IMHISTORYBROWSER_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QThread>
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include "IMHistoryKeeper.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue