mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 00:25:16 -04:00
- Moved HandleRichText from the folder "chat" to "util" and redesigned the source
- Extended RsHtml::formatText to replace the RetroShare links with an image and enabled this for the certificate links in the system messages (friend recommendation and user request) - Added new ObjectPainter for painting a button on a pixmap git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5160 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5a3863d216
commit
dc2d6c975e
27 changed files with 470 additions and 215 deletions
|
@ -31,6 +31,8 @@
|
|||
#include <QTimer>
|
||||
#include <QCompleter>
|
||||
#include <QItemDelegate>
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -55,7 +57,7 @@
|
|||
#include "TagsMenu.h"
|
||||
#include "gui/common/TagDefs.h"
|
||||
#include "gui/connect/ConfCertDialog.h"
|
||||
#include "gui/chat/HandleRichText.h"
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
#define IMAGE_GROUP16 ":/images/user/group16.png"
|
||||
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
|
@ -37,6 +40,7 @@
|
|||
#include "MessageWindow.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/printpreview.h"
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
|
@ -51,6 +55,35 @@
|
|||
#define COLUMN_FILE_HASH 2
|
||||
#define COLUMN_FILE_COUNT 3
|
||||
|
||||
class RsHtmlMsg : public RsHtml
|
||||
{
|
||||
public:
|
||||
RsHtmlMsg(uint msgFlags) : RsHtml()
|
||||
{
|
||||
this->msgFlags = msgFlags;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void anchorTextForImg(QDomDocument &doc, QDomElement &element, const RetroShareLink &link, QString &text)
|
||||
{
|
||||
if (link.type() == RetroShareLink::TYPE_CERTIFICATE) {
|
||||
if (msgFlags & RS_MSG_USER_REQUEST) {
|
||||
text = QApplication::translate("MessageWidget", "Confirm %1 as friend").arg(link.name());
|
||||
return;
|
||||
}
|
||||
if (msgFlags & RS_MSG_FRIEND_RECOMMENDATION) {
|
||||
text = QApplication::translate("MessageWidget", "Add %1 as friend").arg(link.name());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RsHtml::anchorTextForImg(doc, element, link, text);
|
||||
}
|
||||
|
||||
protected:
|
||||
uint msgFlags;
|
||||
};
|
||||
|
||||
MessageWidget *MessageWidget::openMsg(const std::string &msgId, bool window)
|
||||
{
|
||||
if (msgId.empty()) {
|
||||
|
@ -523,7 +556,7 @@ void MessageWidget::fill(const std::string &msgId)
|
|||
|
||||
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));
|
||||
|
||||
text = RsHtml::formatText(QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
|
||||
text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS);
|
||||
ui.msgText->setHtml(text);
|
||||
|
||||
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue