diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-02-17 16:53:24 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-02-17 16:53:24 (GMT) |
commit | de6cb039589e8dc06bf7a5ded562cbc8ce8fff8a (patch) | |
tree | d19bf2c5cbe675ffd6b7a62118cd39d48a597d77 /Swift | |
parent | ca9652bededa2b2d65f0203f467ca801dc5199dc (diff) | |
download | swift-de6cb039589e8dc06bf7a5ded562cbc8ce8fff8a.zip swift-de6cb039589e8dc06bf7a5ded562cbc8ce8fff8a.tar.bz2 |
Add /me support it QtUI
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/Chat/ChatControllerBase.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 10 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 1 |
3 files changed, 11 insertions, 4 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index 6fe50d3..8a68ebd 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -91,9 +91,9 @@ void ChatControllerBase::activateChatWindow() { void ChatControllerBase::addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) { if (message.beginsWith("/me ")) { - chatWindow_->addMessage(message, senderName, senderIsSelf, label, avatarPath); + chatWindow_->addAction(message.getSplittedAtFirst(' ').second, senderName, senderIsSelf, label, avatarPath); } else { - chatWindow_->addAction(message, senderName, senderIsSelf, label, avatarPath); + chatWindow_->addMessage(message, senderName, senderIsSelf, label, avatarPath); } } diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 6765e8a..915e941 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -165,6 +165,10 @@ void QtChatWindow::updateTitleWithUnreadCount() { } void QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) { + addMessage(message, senderName, senderIsSelf, label, avatarPath, ""); +} + +void QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const QString& style) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -177,7 +181,9 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b QString messageHTML(Qt::escape(P2QSTRING(message))); messageHTML.replace("\n","<br/>"); messageHTML = P2QSTRING(Linkify::linkify(Q2PSTRING(messageHTML))); - htmlString += messageHTML; + QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; + QString styleSpanEnd = style == "" ? "" : "</span>"; + htmlString += styleSpanStart + messageHTML + styleSpanEnd; bool appendToPrevious = !previousMessageWasSystem_ && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_ && previousSenderName_ == P2QSTRING(senderName))); QString qAvatarPath = avatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); @@ -189,7 +195,7 @@ void QtChatWindow::addMessage(const String &message, const String &senderName, b } void QtChatWindow::addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath) { - addMessage(message, senderName, senderIsSelf, label, avatarPath); + addMessage(" *" + message + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic "); } void QtChatWindow::addErrorMessage(const String& errorMessage) { diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index bde91e1..80d2868 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -50,6 +50,7 @@ namespace Swift { private: void updateTitleWithUnreadCount(); + void addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const QString& style); int unreadCount_; bool contactIsTyping_; |