diff options
author | Tobias Markmann <tm@ayena.de> | 2015-10-26 13:00:29 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2015-10-30 15:50:52 (GMT) |
commit | 7f321edd9ada1f531b1fbc3325ef61449218f40c (patch) | |
tree | f0a1998447a41fa2cedff39edd1c179eefb4b298 /Swift/QtUI/QtWebKitChatView.cpp | |
parent | 50a3962e4d0b16fd0316be54121cfb293c3117bd (diff) | |
download | swift-7f321edd9ada1f531b1fbc3325ef61449218f40c.zip swift-7f321edd9ada1f531b1fbc3325ef61449218f40c.tar.bz2 |
Only highlight text if a highlight color is set
This commit has the default rule set the default color and
changes HighlightAction::highlightText_ symbol to
HighlightAction::highlightWholeMessage_ as it is more
descriptive of its use.
Test-Information:
Tested highlighting with the default rule set, and one with
a highlight color set for the chat rule.
Change-Id: Ic638e6347bdf6623ab5959341486233494f005f0
Diffstat (limited to 'Swift/QtUI/QtWebKitChatView.cpp')
-rw-r--r-- | Swift/QtUI/QtWebKitChatView.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index f1278b8..7e0e505 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -620,14 +620,16 @@ std::string QtWebKitChatView::addMessage( htmlString = QString("<span style=\"border: thin dashed grey; padding-left: .5em; padding-right: .5em; color: %1; background-color: %2; font-size: 90%; margin-right: .5em; \" class='swift_label'>").arg(QtUtilities::htmlEscape(P2QSTRING(label->getForegroundColor()))).arg(QtUtilities::htmlEscape(P2QSTRING(label->getBackgroundColor()))); htmlString += QString("%1</span> ").arg(QtUtilities::htmlEscape(P2QSTRING(label->getDisplayMarking()))); } QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; QString styleSpanEnd = style == "" ? "" : "</span>"; - QString highlightSpanStart = highlight.highlightAllText() ? getHighlightSpanStart(highlight) : ""; - QString highlightSpanEnd = highlight.highlightAllText() ? "</span>" : ""; + + bool highlightWholeMessage = highlight.highlightWholeMessage() && highlight.getTextBackground() != "" && highlight.getTextColor() != ""; + QString highlightSpanStart = highlightWholeMessage ? getHighlightSpanStart(highlight) : ""; + QString highlightSpanEnd = highlightWholeMessage ? "</span>" : ""; htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + message + highlightSpanEnd + styleSpanEnd + "</span>" ; bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf); QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); @@ -868,14 +870,14 @@ void QtWebKitChatView::replaceMessage(const QString& message, const std::string& } QString messageHTML(message); QString styleSpanStart = style == "" ? "" : "<span style=\"" + style + "\">"; QString styleSpanEnd = style == "" ? "" : "</span>"; - QString highlightSpanStart = highlight.highlightAllText() ? getHighlightSpanStart(highlight) : ""; - QString highlightSpanEnd = highlight.highlightAllText() ? "</span>" : ""; + QString highlightSpanStart = highlight.highlightWholeMessage() ? getHighlightSpanStart(highlight) : ""; + QString highlightSpanEnd = highlight.highlightWholeMessage() ? "</span>" : ""; messageHTML = styleSpanStart + highlightSpanStart + messageHTML + highlightSpanEnd + styleSpanEnd; replaceMessage(messageHTML, P2QSTRING(id), B2QDATE(time)); } else { std::cerr << "Trying to replace a message with no id"; |