summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-01-13 15:26:24 (GMT)
committerSwift Review <review@swift.im>2014-07-09 14:01:41 (GMT)
commitf2bcc401477dcb5ca52b5d9d5e85f4bf7bae9285 (patch)
tree01cf807b2ad59f5ea6504fd28d12e0f994e2f907 /Swift/QtUI/QtWebKitChatView.cpp
parent8e03583fe21bcd5e0025da81d8f4a34ed05cd058 (diff)
downloadswift-f2bcc401477dcb5ca52b5d9d5e85f4bf7bae9285.zip
swift-f2bcc401477dcb5ca52b5d9d5e85f4bf7bae9285.tar.bz2
Reworked highlight rules dialog. Added support for highlighting individual words in messages.
Change-Id: I378fa69077c29008db4ef7c2265e5212924bc2ce
Diffstat (limited to 'Swift/QtUI/QtWebKitChatView.cpp')
-rw-r--r--Swift/QtUI/QtWebKitChatView.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp
index 23bc099..1486293 100644
--- a/Swift/QtUI/QtWebKitChatView.cpp
+++ b/Swift/QtUI/QtWebKitChatView.cpp
@@ -536,6 +536,22 @@ std::string QtWebKitChatView::addMessage(
return addMessage(chatMessageToHTML(message), senderName, senderIsSelf, label, avatarPath, "", time, highlight, ChatSnippet::getDirection(message));
}
+QString QtWebKitChatView::getHighlightSpanStart(const std::string& text, const std::string& background) {
+ QString ecsapeColor = QtUtilities::htmlEscape(P2QSTRING(text));
+ QString escapeBackground = QtUtilities::htmlEscape(P2QSTRING(background));
+ if (ecsapeColor.isEmpty()) {
+ ecsapeColor = "black";
+ }
+ if (escapeBackground.isEmpty()) {
+ escapeBackground = "yellow";
+ }
+ return QString("<span style=\"color: %1; background: %2\">").arg(ecsapeColor).arg(escapeBackground);
+}
+
+QString QtWebKitChatView::getHighlightSpanStart(const HighlightAction& highlight) {
+ return getHighlightSpanStart(highlight.getTextColor(), highlight.getTextBackground());
+}
+
QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& message) {
QString result;
foreach (boost::shared_ptr<ChatWindow::ChatMessagePart> part, message.getParts()) {
@@ -562,7 +578,8 @@ QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& messa
continue;
}
if ((highlightPart = boost::dynamic_pointer_cast<ChatWindow::ChatHighlightingMessagePart>(part))) {
- //FIXME: Maybe do something here. Anything, really.
+ QString spanStart = getHighlightSpanStart(highlightPart->foregroundColor, highlightPart->backgroundColor);
+ result += spanStart + QtUtilities::htmlEscape(P2QSTRING(highlightPart->text)) + "</span>";
continue;
}
@@ -570,20 +587,6 @@ QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& messa
return result;
}
-
-QString QtWebKitChatView::getHighlightSpanStart(const HighlightAction& highlight) {
- QString color = QtUtilities::htmlEscape(P2QSTRING(highlight.getTextColor()));
- QString background = QtUtilities::htmlEscape(P2QSTRING(highlight.getTextBackground()));
- if (color.isEmpty()) {
- color = "black";
- }
- if (background.isEmpty()) {
- background = "yellow";
- }
-
- return QString("<span style=\"color: %1; background: %2\">").arg(color).arg(background);
-}
-
std::string QtWebKitChatView::addMessage(
const QString& message,
const std::string& senderName,