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
49d3ad73
Commit
49d3ad73
authored
Jan 17, 2015
by
Matt Lowe
Browse files
Uername block highlighting
I was able to find a simple way to achive the block highlighting.
parent
e4afd9fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/chatview.cpp
View file @
49d3ad73
...
...
@@ -18,6 +18,13 @@ ChatView::ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _sh
userContextMenu
=
new
UserContextMenu
(
tabSupervisor
,
this
,
game
);
connect
(
userContextMenu
,
SIGNAL
(
openMessageDialog
(
QString
,
bool
)),
this
,
SIGNAL
(
openMessageDialog
(
QString
,
bool
)));
userName
=
QString
::
fromStdString
(
tabSupervisor
->
getUserInfo
()
->
name
());
mention
=
"@"
+
userName
.
toLower
();
mentionFormat
.
setFontWeight
(
QFont
::
Bold
);
mentionFormat
.
setForeground
(
QBrush
(
Qt
::
white
));
mentionFormat
.
setBackground
(
QBrush
(
QColor
(
190
,
25
,
85
)));
viewport
()
->
setCursor
(
Qt
::
IBeamCursor
);
setReadOnly
(
true
);
setTextInteractionFlags
(
Qt
::
TextSelectableByMouse
|
Qt
::
LinksAccessibleByMouse
);
...
...
@@ -104,7 +111,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
QTextCharFormat
senderFormat
;
if
(
tabSupervisor
&&
tabSupervisor
->
getUserInfo
()
&&
(
sender
==
QString
::
fromStdString
(
tabSupervisor
->
getUserInfo
()
->
name
())))
{
senderFormat
.
setFontWeight
(
QFont
::
Bold
);
senderFormat
.
setForeground
(
QBrush
(
QColor
(
255
,
120
,
0
)));
senderFormat
.
setForeground
(
QBrush
(
QColor
(
190
,
25
,
85
)));
}
else
{
senderFormat
.
setForeground
(
Qt
::
blue
);
if
(
playerBold
)
...
...
@@ -172,15 +179,19 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
}
if
(
settingsCache
->
getChatMention
())
{
if
(
message
.
toLower
().
contains
(
"@"
+
QString
::
fromStdString
(
tabSupervisor
->
getUserInfo
()
->
name
()).
toLower
()))
{
messageFormat
.
setFontWeight
(
QFont
::
Bold
);
messageFormat
.
setForeground
(
QBrush
(
QColor
(
255
,
120
,
0
)));
if
(
message
.
toLower
().
contains
(
mention
))
{
int
mentionIndex
;
while
((
mentionIndex
=
message
.
toLower
().
indexOf
(
mention
))
!=
-
1
)
{
cursor
.
insertText
(
message
.
left
(
mentionIndex
),
defaultFormat
);
cursor
.
insertText
(
userName
,
mentionFormat
);
message
=
message
.
mid
(
mentionIndex
+
mention
.
size
());
}
}
}
if
(
!
message
.
isEmpty
())
cursor
.
insertText
(
message
,
message
Format
);
cursor
.
insertText
(
message
,
default
Format
);
if
(
atBottom
)
verticalScrollBar
()
->
setValue
(
verticalScrollBar
()
->
maximum
());
}
...
...
cockatrice/src/chatview.h
View file @
49d3ad73
...
...
@@ -22,6 +22,10 @@ private:
enum
HoveredItemType
{
HoveredNothing
,
HoveredUrl
,
HoveredCard
,
HoveredUser
};
UserContextMenu
*
userContextMenu
;
QString
lastSender
;
QString
userName
;
QString
mention
;
QTextCharFormat
mentionFormat
;
QTextCharFormat
defaultFormat
;
bool
evenNumber
;
bool
showTimestamps
;
HoveredItemType
hoveredItemType
;
...
...
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