mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 06:52: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);
|
||||
setOpenLinks(false);
|
||||
connect(this, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(openLink(const QUrl &)));
|
||||
showInGameTime = SettingsCache::instance().getLocalTime();
|
||||
}
|
||||
|
||||
void ChatView::retranslateUi()
|
||||
|
|
@ -102,11 +103,9 @@ void ChatView::appendHtml(const QString &html)
|
|||
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
||||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
QString htmlText;
|
||||
|
||||
htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) + ">" +
|
||||
QDateTime::currentDateTime().toString("[hh:mm:ss] ") + html + "</font>";
|
||||
|
||||
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : serverMessageColor.name()) +
|
||||
">" + getCurrentTime() + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
||||
|
|
@ -168,7 +167,7 @@ void ChatView::appendMessage(QString message,
|
|||
timeFormat.setForeground(serverMessageColor);
|
||||
timeFormat.setFontWeight(QFont::Bold);
|
||||
cursor.setCharFormat(timeFormat);
|
||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||
cursor.insertText(getCurrentTime());
|
||||
}
|
||||
|
||||
// nickname
|
||||
|
|
@ -459,16 +458,19 @@ bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> u
|
|||
|
||||
QString ChatView::getCurrentTime()
|
||||
{
|
||||
|
||||
int seconds = *elapsedSeconds;
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
int hours = minutes / 60;
|
||||
minutes -= hours * 60;
|
||||
return QString("[%1:%2:%3] ")
|
||||
.arg(QString::number(hours).rightJustified(2, '0'))
|
||||
.arg(QString::number(minutes).rightJustified(2, '0'))
|
||||
.arg(QString::number(seconds).rightJustified(2, '0'));
|
||||
if (showInGameTime) {
|
||||
int seconds = *elapsedSeconds;
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
int hours = minutes / 60;
|
||||
minutes -= hours * 60;
|
||||
return QString("[%1:%2:%3] ")
|
||||
.arg(QString::number(hours).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] ");
|
||||
}
|
||||
}
|
||||
|
||||
void ChatView::actMessageClicked()
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ private:
|
|||
QStringList highlightedWords;
|
||||
bool evenNumber;
|
||||
bool showTimestamps;
|
||||
bool showInGameTime;
|
||||
HoveredItemType hoveredItemType;
|
||||
QString hoveredContent;
|
||||
QAction *messageClicked;
|
||||
|
|
|
|||
|
|
@ -14,15 +14,19 @@
|
|||
|
||||
const QString MessageLogWidget::getCurrentTime()
|
||||
{
|
||||
int seconds = *elapsedSeconds;
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
int hours = minutes / 60;
|
||||
minutes -= hours * 60;
|
||||
return QString("[%1:%2:%3] ")
|
||||
.arg(QString::number(hours).rightJustified(2, '0'))
|
||||
.arg(QString::number(minutes).rightJustified(2, '0'))
|
||||
.arg(QString::number(seconds).rightJustified(2, '0'));
|
||||
if (showInGameTime) {
|
||||
int seconds = *elapsedSeconds;
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
int hours = minutes / 60;
|
||||
minutes -= hours * 60;
|
||||
return QString("[%1:%2:%3] ")
|
||||
.arg(QString::number(hours).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
|
||||
|
|
@ -628,13 +632,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber)
|
|||
|
||||
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>");
|
||||
}
|
||||
|
||||
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>");
|
||||
}
|
||||
|
||||
|
|
@ -874,6 +878,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
MessageLogWidget::MessageLogWidget(TabSupervisor *_tabSupervisor, TabGame *_game, int *seconds, QWidget *parent)
|
||||
: ChatView(_tabSupervisor, _game, true, parent), mulliganNumber(0), currentContext(MessageContext_None)
|
||||
{
|
||||
showInGameTime = SettingsCache::instance().getLocalTime();
|
||||
elapsedSeconds = seconds;
|
||||
ChatView::setTime(seconds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ private:
|
|||
MessageContext currentContext;
|
||||
QString messagePrefix, messageSuffix;
|
||||
int *elapsedSeconds;
|
||||
bool showInGameTime;
|
||||
|
||||
const QString getCurrentTime();
|
||||
const QString &tableConstant() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue