mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-16 23:42:15 -07:00
implement UI component
This commit is contained in:
parent
a9d3e73c15
commit
1dade7b9f7
4 changed files with 36 additions and 27 deletions
|
|
@ -61,6 +61,7 @@ ChatView::ChatView(TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTime
|
||||||
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
||||||
setOpenLinks(false);
|
setOpenLinks(false);
|
||||||
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
||||||
|
showInGameTime = SettingsCache::instance().getLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::retranslateUi()
|
void ChatView::retranslateUi()
|
||||||
|
|
@ -102,10 +103,8 @@ void ChatView::appendHtml(const QString &html)
|
||||||
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
||||||
{
|
{
|
||||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||||
QString htmlText;
|
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) +
|
||||||
|
">" + getCurrentTime() + html + "</font>";
|
||||||
htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
|
||||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
|
||||||
|
|
||||||
if (optionalIsBold)
|
if (optionalIsBold)
|
||||||
htmlText = "<b>" + htmlText + "</b>";
|
htmlText = "<b>" + htmlText + "</b>";
|
||||||
|
|
@ -168,7 +167,7 @@ void ChatView::appendMessage(QString message,
|
||||||
timeFormat.setForeground(serverMessageColor);
|
timeFormat.setForeground(serverMessageColor);
|
||||||
timeFormat.setFontWeight(QFont::Bold);
|
timeFormat.setFontWeight(QFont::Bold);
|
||||||
cursor.setCharFormat(timeFormat);
|
cursor.setCharFormat(timeFormat);
|
||||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
cursor.insertText(getCurrentTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// nickname
|
// nickname
|
||||||
|
|
@ -459,16 +458,19 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
|
||||||
|
|
||||||
QString ChatView::getCurrentTime()
|
QString ChatView::getCurrentTime()
|
||||||
{
|
{
|
||||||
|
if (showInGameTime) {
|
||||||
int seconds = *elapsedSeconds;
|
int seconds = *elapsedSeconds;
|
||||||
int minutes = seconds / 60;
|
int minutes = seconds / 60;
|
||||||
seconds -= minutes * 60;
|
seconds -= minutes * 60;
|
||||||
int hours = minutes / 60;
|
int hours = minutes / 60;
|
||||||
minutes -= hours * 60;
|
minutes -= hours * 60;
|
||||||
return QString("[%1:%2:%3] ")
|
return QString("[%1:%2:%3] ")
|
||||||
.arg(QString::number(hours).rightJustified(2, '0'))
|
.arg(QString::number(hours).rightJustified(2, '0'))
|
||||||
.arg(QString::number(minutes).rightJustified(2, '0'))
|
.arg(QString::number(minutes).rightJustified(2, '0'))
|
||||||
.arg(QString::number(seconds).rightJustified(2, '0'));
|
.arg(QString::number(seconds).rightJustified(2, '0'));
|
||||||
|
} else {
|
||||||
|
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatView::actMessageClicked()
|
void ChatView::actMessageClicked()
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ private:
|
||||||
QStringList highlightedWords;
|
QStringList highlightedWords;
|
||||||
bool evenNumber;
|
bool evenNumber;
|
||||||
bool showTimestamps;
|
bool showTimestamps;
|
||||||
|
bool showInGameTime;
|
||||||
HoveredItemType hoveredItemType;
|
HoveredItemType hoveredItemType;
|
||||||
QString hoveredContent;
|
QString hoveredContent;
|
||||||
QAction *messageClicked;
|
QAction *messageClicked;
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,19 @@
|
||||||
|
|
||||||
const QString MessageLogWidget::getCurrentTime()
|
const QString MessageLogWidget::getCurrentTime()
|
||||||
{
|
{
|
||||||
int seconds = *elapsedSeconds;
|
if (showInGameTime) {
|
||||||
int minutes = seconds / 60;
|
int seconds = *elapsedSeconds;
|
||||||
seconds -= minutes * 60;
|
int minutes = seconds / 60;
|
||||||
int hours = minutes / 60;
|
seconds -= minutes * 60;
|
||||||
minutes -= hours * 60;
|
int hours = minutes / 60;
|
||||||
return QString("[%1:%2:%3] ")
|
minutes -= hours * 60;
|
||||||
.arg(QString::number(hours).rightJustified(2, '0'))
|
return QString("[%1:%2:%3] ")
|
||||||
.arg(QString::number(minutes).rightJustified(2, '0'))
|
.arg(QString::number(hours).rightJustified(2, '0'))
|
||||||
.arg(QString::number(seconds).rightJustified(2, '0'));
|
.arg(QString::number(minutes).rightJustified(2, '0'))
|
||||||
|
.arg(QString::number(seconds).rightJustified(2, '0'));
|
||||||
|
} else {
|
||||||
|
return QDateTime::currentDateTime().toString("[hh:mm:ss] ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &MessageLogWidget::tableConstant() const
|
const QString &MessageLogWidget::tableConstant() const
|
||||||
|
|
@ -628,13 +632,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber)
|
||||||
|
|
||||||
soundEngine->playSound(phase.soundFileName);
|
soundEngine->playSound(phase.soundFileName);
|
||||||
|
|
||||||
appendHtml("<font color=\"" + phase.color + "\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") +
|
appendHtml("<font color=\"" + phase.color + "\"><b>" + getCurrentTime() +
|
||||||
phase.name + "</b></font>");
|
phase.name + "</b></font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetActivePlayer(Player *player)
|
void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||||
{
|
{
|
||||||
appendHtml("<br><font color=\"green\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") +
|
appendHtml("<br><font color=\"green\"><b>" + getCurrentTime() +
|
||||||
QString(tr("%1's turn.")).arg(player->getName()) + "</b></font><br>");
|
QString(tr("%1's turn.")).arg(player->getName()) + "</b></font><br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -874,6 +878,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
|
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
|
||||||
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||||
{
|
{
|
||||||
|
showInGameTime = SettingsCache::instance().getLocalTime();
|
||||||
elapsedSeconds = seconds;
|
elapsedSeconds = seconds;
|
||||||
ChatView::setTime(seconds);
|
ChatView::setTime(seconds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ private:
|
||||||
MessageContext currentContext;
|
MessageContext currentContext;
|
||||||
QString messagePrefix, messageSuffix;
|
QString messagePrefix, messageSuffix;
|
||||||
int *elapsedSeconds;
|
int *elapsedSeconds;
|
||||||
|
bool showInGameTime;
|
||||||
|
|
||||||
const QString getCurrentTime();
|
const QString getCurrentTime();
|
||||||
const QString &tableConstant() const;
|
const QString &tableConstant() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue