Add timestamp colors you can change in courtroom_fonts.ini (#698)

* Add ic_chatlog_timestamp_color and ic_chatlog_selftimestamp_color to courtroom_fonts.ini

* clang tidy. clang stronk.
This commit is contained in:
Crystalwarrior 2022-03-25 16:01:57 +03:00 committed by GitHub
parent ca83573d1b
commit 7bb7889923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -189,8 +189,12 @@ void Courtroom::char_clicked(int n_char)
set_courtroom_size(); set_courtroom_size();
} }
if (n_char != -1) if (n_char != -1) {
ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name);
}
else {
ui_ic_chat_name->setPlaceholderText("Spectator");
}
} }
void Courtroom::put_button_in_place(int starting, int chars_on_this_page) void Courtroom::put_button_in_place(int starting, int chars_on_this_page)

View File

@ -3162,6 +3162,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
QTextCharFormat italics; QTextCharFormat italics;
QTextCharFormat own_name; QTextCharFormat own_name;
QTextCharFormat other_name; QTextCharFormat other_name;
QTextCharFormat timestamp_format;
QTextCharFormat selftimestamp_format;
QTextBlockFormat format; QTextBlockFormat format;
bold.setFontWeight(QFont::Bold); bold.setFontWeight(QFont::Bold);
normal.setFontWeight(QFont::Normal); normal.setFontWeight(QFont::Normal);
@ -3170,6 +3172,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
own_name.setForeground(ao_app->get_color("ic_chatlog_selfname_color", "courtroom_fonts.ini")); own_name.setForeground(ao_app->get_color("ic_chatlog_selfname_color", "courtroom_fonts.ini"));
other_name.setFontWeight(QFont::Bold); other_name.setFontWeight(QFont::Bold);
other_name.setForeground(ao_app->get_color("ic_chatlog_showname_color", "courtroom_fonts.ini")); other_name.setForeground(ao_app->get_color("ic_chatlog_showname_color", "courtroom_fonts.ini"));
timestamp_format.setForeground(ao_app->get_color("ic_chatlog_timestamp_color", "courtroom_fonts.ini"));
selftimestamp_format.setForeground(ao_app->get_color("ic_chatlog_selftimestamp_color", "courtroom_fonts.ini"));
format.setTopMargin(log_margin); format.setTopMargin(log_margin);
const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
@ -3188,9 +3192,11 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
// Timestamp if we're doing that meme // Timestamp if we're doing that meme
if (log_timestamp) { if (log_timestamp) {
// Format the timestamp
QTextCharFormat format = selfname ? selftimestamp_format : timestamp_format;
if (timestamp.isValid()) { if (timestamp.isValid()) {
ui_ic_chatlog->textCursor().insertText( ui_ic_chatlog->textCursor().insertText(
"[" + timestamp.toString(log_timestamp_format) + "] ", normal); "[" + timestamp.toString(log_timestamp_format) + "] ", format);
} else { } else {
qCritical() << "could not insert invalid timestamp" << timestamp; qCritical() << "could not insert invalid timestamp" << timestamp;
} }