summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-01-23 13:26:34 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-01-23 13:26:34 (GMT)
commita7f73b3a741e558e65d5d9302f33fdedf12f05da (patch)
treeaa9f71c40ac6024998678618cce0a68a5a93647e
parent3a41fca4c1c2423c1f13cc3c77f9a70f767ae2dc (diff)
downloadswift-a7f73b3a741e558e65d5d9302f33fdedf12f05da.zip
swift-a7f73b3a741e558e65d5d9302f33fdedf12f05da.tar.bz2
Fixed highlight colours.
Change-Id: I69c2a9b6fe234ac973959a09d05e8de8279cd631
-rw-r--r--Swift/QtUI/QtWebKitChatView.cpp41
-rw-r--r--Swift/QtUI/QtWebKitChatView.h3
2 files changed, 20 insertions, 24 deletions
diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp
index 5d85913..2941f55 100644
--- a/Swift/QtUI/QtWebKitChatView.cpp
+++ b/Swift/QtUI/QtWebKitChatView.cpp
@@ -531,6 +531,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()) {
@@ -557,16 +573,8 @@ QString QtWebKitChatView::chatMessageToHTML(const ChatWindow::ChatMessage& messa
continue;
}
if ((highlightPart = boost::dynamic_pointer_cast<ChatWindow::ChatHighlightingMessagePart>(part))) {
-
- //class ChatHighlightingMessagePart : public ChatMessagePart {
- //public:
- //std::string foregroundColor;
- //std::string backgroundColor;
- //std::string text;
- //};
-
- /* TODO: this is just temporary for testing. it should take the color into account... */
- result += "<b>!" + QtUtilities::htmlEscape(P2QSTRING(highlightPart->text)) + "!</b>";
+ QString spanStart = getHighlightSpanStart(highlightPart->foregroundColor, highlightPart->backgroundColor);
+ result += spanStart + QtUtilities::htmlEscape(P2QSTRING(highlightPart->text)) + "</span>";
continue;
}
@@ -574,19 +582,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,
diff --git a/Swift/QtUI/QtWebKitChatView.h b/Swift/QtUI/QtWebKitChatView.h
index bdb2a75..b3997dd 100644
--- a/Swift/QtUI/QtWebKitChatView.h
+++ b/Swift/QtUI/QtWebKitChatView.h
@@ -148,8 +148,9 @@ namespace Swift {
const HighlightAction& highlight);
bool appendToPreviousCheck(PreviousMessageKind messageKind, const std::string& senderName, bool senderIsSelf);
static ChatSnippet::Direction getActualDirection(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction);
- QString chatMessageToHTML(const ChatWindow::ChatMessage& message);
+ QString getHighlightSpanStart(const std::string& text, const std::string& background);
QString getHighlightSpanStart(const HighlightAction& highlight);
+ QString chatMessageToHTML(const ChatWindow::ChatMessage& message);
static QString buildChatWindowButton(const QString& name, const QString& id, const QString& arg1 = QString(), const QString& arg2 = QString(), const QString& arg3 = QString(), const QString& arg4 = QString(), const QString& arg5 = QString());
private: