mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 17:15:09 -07:00
Merge branch 'master' into tooomm-qt5
This commit is contained in:
commit
9d4cf57c70
593 changed files with 12518 additions and 6581 deletions
|
|
@ -88,10 +88,11 @@ void ChatView::refreshBlockColors()
|
|||
for (QTextBlock block = doc->begin(); block.isValid(); block = block.next()) {
|
||||
QTextBlockFormat fmt = block.blockFormat();
|
||||
|
||||
if (even)
|
||||
if (even) {
|
||||
fmt.setBackground(palette().base());
|
||||
else
|
||||
} else {
|
||||
fmt.setBackground(palette().window());
|
||||
}
|
||||
|
||||
fmt.setForeground(palette().text());
|
||||
|
||||
|
|
@ -121,10 +122,11 @@ QTextCursor ChatView::prepareBlock(bool same)
|
|||
cursor.insertHtml("<br>");
|
||||
} else {
|
||||
QTextBlockFormat blockFormat;
|
||||
if (evenNumber)
|
||||
if (evenNumber) {
|
||||
blockFormat.setBackground(palette().base());
|
||||
else
|
||||
} else {
|
||||
blockFormat.setBackground(palette().window());
|
||||
}
|
||||
|
||||
evenNumber = !evenNumber;
|
||||
|
||||
|
|
@ -144,8 +146,9 @@ void ChatView::appendHtml(const QString &html)
|
|||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
prepareBlock().insertHtml(html);
|
||||
if (atBottom)
|
||||
if (atBottom) {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
||||
|
|
@ -156,12 +159,14 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
|
|||
"<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
if (optionalIsBold) {
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
}
|
||||
|
||||
prepareBlock().insertHtml(htmlText);
|
||||
if (atBottom)
|
||||
if (atBottom) {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
||||
|
|
@ -180,8 +185,9 @@ void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
|
|||
|
||||
void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
|
||||
{
|
||||
if (!url.contains("://"))
|
||||
if (!url.contains("://")) {
|
||||
url.prepend("https://");
|
||||
}
|
||||
|
||||
QTextCharFormat oldFormat = cursor.charFormat();
|
||||
QTextCharFormat anchorFormat = oldFormat;
|
||||
|
|
@ -255,7 +261,8 @@ void ChatView::appendMessage(QString message,
|
|||
defaultFormat = QTextCharFormat();
|
||||
if (!isUserMessage) {
|
||||
if (messageType == Event_RoomSay::ChatHistory) {
|
||||
defaultFormat.setForeground(Qt::gray); //! \todo hardcoded color
|
||||
//! \todo Remove hardcoded color.
|
||||
defaultFormat.setForeground(Qt::gray);
|
||||
defaultFormat.setFontWeight(QFont::Light);
|
||||
defaultFormat.setFontItalic(true);
|
||||
static const QRegularExpression userNameRegex("^(\\[[^\\]]*\\]\\s)(\\S+):\\s");
|
||||
|
|
@ -278,7 +285,8 @@ void ChatView::appendMessage(QString message,
|
|||
message.remove(0, pos.relativePosition - 2); // do not remove semicolon
|
||||
}
|
||||
} else {
|
||||
defaultFormat.setForeground(Qt::darkGreen); //! \todo hardcoded color
|
||||
//! \todo Remove hardcoded color.
|
||||
defaultFormat.setForeground(Qt::darkGreen);
|
||||
defaultFormat.setFontWeight(QFont::Bold);
|
||||
}
|
||||
}
|
||||
|
|
@ -317,8 +325,9 @@ void ChatView::appendMessage(QString message,
|
|||
}
|
||||
}
|
||||
|
||||
if (atBottom)
|
||||
if (atBottom) {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
||||
|
|
@ -327,10 +336,11 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message = message.mid(6);
|
||||
int closeTagIndex = message.indexOf("[/card]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
if (closeTagIndex == -1) {
|
||||
message.clear();
|
||||
else
|
||||
} else {
|
||||
message = message.mid(closeTagIndex + 7);
|
||||
}
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
|
|
@ -340,10 +350,11 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message = message.mid(2);
|
||||
int closeTagIndex = message.indexOf("]]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
if (closeTagIndex == -1) {
|
||||
message.clear();
|
||||
else
|
||||
} else {
|
||||
message = message.mid(closeTagIndex + 2);
|
||||
}
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
|
|
@ -353,10 +364,11 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
|||
message = message.mid(5);
|
||||
int closeTagIndex = message.indexOf("[/url]");
|
||||
QString url = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
if (closeTagIndex == -1) {
|
||||
message.clear();
|
||||
else
|
||||
} else {
|
||||
message = message.mid(closeTagIndex + 6);
|
||||
}
|
||||
|
||||
appendUrlTag(cursor, url);
|
||||
return;
|
||||
|
|
@ -573,8 +585,9 @@ QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
|
|||
QTextBlock::iterator it;
|
||||
for (it = block.begin(); !(it.atEnd()); ++it) {
|
||||
QTextFragment frag = it.fragment();
|
||||
if (frag.contains(cursor.position()))
|
||||
if (frag.contains(cursor.position())) {
|
||||
return frag;
|
||||
}
|
||||
}
|
||||
return QTextFragment();
|
||||
}
|
||||
|
|
@ -590,10 +603,11 @@ void ChatView::mouseMoveEvent(QMouseEvent *event)
|
|||
if (scheme == "card") {
|
||||
hoveredItemType = HoveredCard;
|
||||
emit cardNameHovered(hoveredContent);
|
||||
} else if (scheme == "user")
|
||||
} else if (scheme == "user") {
|
||||
hoveredItemType = HoveredUser;
|
||||
else
|
||||
} else {
|
||||
hoveredItemType = HoveredUrl;
|
||||
}
|
||||
viewport()->setCursor(Qt::PointingHandCursor);
|
||||
} else {
|
||||
hoveredItemType = HoveredNothing;
|
||||
|
|
@ -629,8 +643,9 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
case Qt::LeftButton: {
|
||||
if (event->modifiers() == Qt::ControlModifier) {
|
||||
emit openMessageDialog(userName, true);
|
||||
} else
|
||||
} else {
|
||||
emit addMentionTag("@" + userName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -647,16 +662,18 @@ void ChatView::mousePressEvent(QMouseEvent *event)
|
|||
|
||||
void ChatView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton))
|
||||
if ((event->button() == Qt::MiddleButton) || (event->button() == Qt::LeftButton)) {
|
||||
emit deleteCardInfoPopup(QString("_"));
|
||||
}
|
||||
|
||||
QTextBrowser::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void ChatView::openLink(const QUrl &link)
|
||||
{
|
||||
if ((link.scheme() == "card") || (link.scheme() == "user"))
|
||||
if ((link.scheme() == "card") || (link.scheme() == "user")) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDesktopServices::openUrl(link);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue