diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-04-13 19:52:51 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-04-14 15:45:03 (GMT) |
commit | 54aad4467142079f74471da6396ad31c9df389df (patch) | |
tree | f4af60c5cf308e17e750afa71c5bb14c941fa0cc /Swift/QtUI | |
parent | d4517116fc71d1b2d5967004757630293613e928 (diff) | |
download | swift-contrib-54aad4467142079f74471da6396ad31c9df389df.zip swift-contrib-54aad4467142079f74471da6396ad31c9df389df.tar.bz2 |
Fix correction from breaking /me actions
Check if the new message is an action when using correct last message.
Resolves: #1053
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 5223ddb..e4cb004 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -658,11 +658,24 @@ void QtChatWindow::addSystemMessage(const std::string& message) { previousMessageKind_ = PreviousMessageWasSystem; } +void QtChatWindow::replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time) { + replaceMessage(" *" + message + "*", id, time, "font-style:italic "); +} + void QtChatWindow::replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time) { + replaceMessage(message, id, time, ""); +} + +void QtChatWindow::replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const QString& style) { if (!id.empty()) { QString messageHTML(Qt::escape(P2QSTRING(message))); messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML))); messageHTML.replace("\n","<br/>"); + + QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; + QString styleSpanEnd = style == "" ? "" : "</span>"; + messageHTML = styleSpanStart + messageHTML + styleSpanEnd; + messageLog_->replaceMessage(messageHTML, P2QSTRING(id), B2QDATE(time)); } else { diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 9db1884..1d1959d 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -54,6 +54,7 @@ namespace Swift { void addPresenceMessage(const std::string& message); void addErrorMessage(const std::string& errorMessage); void replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time); + void replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time); // File transfer related stuff std::string addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes); void setFileTransferProgress(std::string id, const int percentageDone); @@ -144,6 +145,7 @@ namespace Swift { void beginCorrection(); void cancelCorrection(); std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time); + void replaceMessage(const std::string& message, const std::string& id, const boost::posix_time::ptime& time, const QString& style); void handleOccupantSelectionChanged(RosterItem* item); bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf) const; |