Merge pull request #64 from Daenyth/issue-64
Allow `[[Cardname]]` as a synonym for `[card]cardname[/card]`
This commit is contained in:
commit
a4ae1bcd39
1 changed files with 22 additions and 4 deletions
|
@ -118,6 +118,24 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
||||||
tempFormat.setAnchor(true);
|
tempFormat.setAnchor(true);
|
||||||
tempFormat.setAnchorHref("card://" + cardName);
|
tempFormat.setAnchorHref("card://" + cardName);
|
||||||
|
|
||||||
|
cursor.setCharFormat(tempFormat);
|
||||||
|
cursor.insertText(cardName);
|
||||||
|
cursor.setCharFormat(messageFormat);
|
||||||
|
} else if (message.startsWith("[[")) {
|
||||||
|
message = message.mid(2);
|
||||||
|
int closeTagIndex = message.indexOf("]]");
|
||||||
|
QString cardName = message.left(closeTagIndex);
|
||||||
|
if (closeTagIndex == -1)
|
||||||
|
message.clear();
|
||||||
|
else
|
||||||
|
message = message.mid(closeTagIndex + 2);
|
||||||
|
|
||||||
|
// TODO: Factor out this duplicated code (vs [card] parsing)
|
||||||
|
QTextCharFormat tempFormat = messageFormat;
|
||||||
|
tempFormat.setForeground(Qt::blue);
|
||||||
|
tempFormat.setAnchor(true);
|
||||||
|
tempFormat.setAnchorHref("card://" + cardName);
|
||||||
|
|
||||||
cursor.setCharFormat(tempFormat);
|
cursor.setCharFormat(tempFormat);
|
||||||
cursor.insertText(cardName);
|
cursor.insertText(cardName);
|
||||||
cursor.setCharFormat(messageFormat);
|
cursor.setCharFormat(messageFormat);
|
||||||
|
|
Loading…
Reference in a new issue