Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
efe388bd
Commit
efe388bd
authored
Jul 15, 2015
by
Fabio Bas
Browse files
Fix server message color; try to detect words inside parentheses, punctuation, etc..
parent
2e3e6c55
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/chatview.cpp
View file @
efe388bd
...
...
@@ -158,12 +158,13 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
cursor
.
insertText
(
sender
);
}
QTextCharFormat
messageFormat
;
// use different color for server messages
defaultFormat
=
QTextCharFormat
();
if
(
sender
.
isEmpty
())
{
message
Format
.
setForeground
(
Qt
::
darkGreen
);
message
Format
.
setFontWeight
(
QFont
::
Bold
);
default
Format
.
setForeground
(
Qt
::
darkGreen
);
default
Format
.
setFontWeight
(
QFont
::
Bold
);
}
cursor
.
setCharFormat
(
message
Format
);
cursor
.
setCharFormat
(
default
Format
);
bool
mentionEnabled
=
settingsCache
->
getChatMention
();
highlightedWords
=
settingsCache
->
getHighlightWords
().
split
(
' '
,
QString
::
SkipEmptyParts
);
...
...
@@ -178,17 +179,24 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
checkTag
(
cursor
,
message
);
break
;
case
'@'
:
if
(
mentionEnabled
)
if
(
mentionEnabled
)
{
checkMention
(
cursor
,
message
,
sender
,
userLevel
);
else
checkWord
(
cursor
,
message
);
}
else
{
cursor
.
insertText
(
c
,
defaultFormat
);
message
=
message
.
mid
(
1
);
}
break
;
case
' '
:
cursor
.
insertText
(
" "
,
defaultFormat
);
cursor
.
insertText
(
c
,
defaultFormat
);
message
=
message
.
mid
(
1
);
break
;
default:
checkWord
(
cursor
,
message
);
if
(
c
.
isLetterOrNumber
())
{
checkWord
(
cursor
,
message
);
}
else
{
cursor
.
insertText
(
c
,
defaultFormat
);
message
=
message
.
mid
(
1
);
}
break
;
}
}
...
...
@@ -346,7 +354,6 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
highlightFormat
.
setBackground
(
QBrush
(
getCustomHighlightColor
()));
highlightFormat
.
setForeground
(
settingsCache
->
getChatHighlightForeground
()
?
QBrush
(
Qt
::
white
)
:
QBrush
(
Qt
::
black
));
cursor
.
insertText
(
fullWordUpToSpaceOrEnd
,
highlightFormat
);
cursor
.
setCharFormat
(
defaultFormat
);
cursor
.
insertText
(
rest
,
defaultFormat
);
QApplication
::
alert
(
this
);
return
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment