diff --git a/cockatrice/src/chatview.cpp b/cockatrice/src/chatview.cpp
index fba78601..9aecfd1e 100644
--- a/cockatrice/src/chatview.cpp
+++ b/cockatrice/src/chatview.cpp
@@ -6,7 +6,7 @@
#include "chatview.h"
ChatView::ChatView(const QString &_ownName, bool _showTimestamps, QWidget *parent)
- : QTextBrowser(parent), evenNumber(false), ownName(_ownName), showTimestamps(_showTimestamps)
+ : QTextBrowser(parent), evenNumber(true), ownName(_ownName), showTimestamps(_showTimestamps)
{
setReadOnly(true);
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
@@ -14,16 +14,20 @@ ChatView::ChatView(const QString &_ownName, bool _showTimestamps, QWidget *paren
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
}
-QTextCursor ChatView::prepareBlock()
+QTextCursor ChatView::prepareBlock(bool same)
{
+ lastSender.clear();
+
QTextCursor cursor(document()->lastBlock());
cursor.movePosition(QTextCursor::End);
-
- QTextBlockFormat blockFormat;
- if ((evenNumber = !evenNumber))
- blockFormat.setBackground(palette().alternateBase());
- blockFormat.setBottomMargin(2);
- cursor.insertBlock(blockFormat);
+ if (!same) {
+ QTextBlockFormat blockFormat;
+ if ((evenNumber = !evenNumber))
+ blockFormat.setBackground(palette().alternateBase());
+ blockFormat.setBottomMargin(2);
+ cursor.insertBlock(blockFormat);
+ } else
+ cursor.insertHtml("
");
return cursor;
}
@@ -36,11 +40,16 @@ void ChatView::appendHtml(const QString &html)
void ChatView::appendMessage(QString sender, QString message, QColor playerColor, bool playerBold)
{
- QTextCursor cursor = prepareBlock();
+ bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
+ QTextCursor cursor = prepareBlock(sameSender);
+ lastSender = sender;
if (showTimestamps) {
QTextCharFormat timeFormat;
- timeFormat.setForeground(Qt::black);
+ if (sameSender)
+ timeFormat.setForeground(Qt::transparent);
+ else
+ timeFormat.setForeground(Qt::black);
cursor.setCharFormat(timeFormat);
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm] "));
}
@@ -57,6 +66,8 @@ void ChatView::appendMessage(QString sender, QString message, QColor playerColor
if (playerBold)
senderFormat.setFontWeight(QFont::Bold);
}
+ if (sameSender)
+ senderFormat.setForeground(Qt::transparent);
cursor.setCharFormat(senderFormat);
if (!sender.isEmpty())
sender.append(": ");
diff --git a/cockatrice/src/chatview.h b/cockatrice/src/chatview.h
index 1be07621..33c583c6 100644
--- a/cockatrice/src/chatview.h
+++ b/cockatrice/src/chatview.h
@@ -12,13 +12,14 @@ class QMouseEvent;
class ChatView : public QTextBrowser {
Q_OBJECT;
private:
+ QString lastSender;
bool evenNumber;
QString ownName;
bool showTimestamps;
QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
QString getCardNameUnderMouse(QTextFragment frag) const;
QString getCardNameUnderMouse(const QPoint &pos) const;
- QTextCursor prepareBlock();
+ QTextCursor prepareBlock(bool same = false);
private slots:
void openLink(const QUrl &link);
public:
diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp
index 9c165d26..1feb63d0 100644
--- a/cockatrice/src/gameselector.cpp
+++ b/cockatrice/src/gameselector.cpp
@@ -22,6 +22,7 @@ GameSelector::GameSelector(AbstractClient *_client, TabRoom *_room, const QMapsetSortCaseSensitivity(Qt::CaseInsensitive);
gameListView->setModel(gameListProxyModel);
gameListView->setSortingEnabled(true);
+ gameListView->setAlternatingRowColors(true);
if (_room)
gameListView->header()->hideSection(0);
gameListView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
diff --git a/cockatrice/src/userlist.cpp b/cockatrice/src/userlist.cpp
index 20b60992..71101f48 100644
--- a/cockatrice/src/userlist.cpp
+++ b/cockatrice/src/userlist.cpp
@@ -107,6 +107,7 @@ UserList::UserList(TabSupervisor *_tabSupervisor, AbstractClient *_client, UserL
userTree->setRootIsDecorated(false);
userTree->setIconSize(QSize(20, 12));
userTree->setItemDelegate(itemDelegate);
+ userTree->setAlternatingRowColors(true);
connect(userTree, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, SLOT(userClicked(QTreeWidgetItem *, int)));
QVBoxLayout *vbox = new QVBoxLayout;