aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkye Deving <76892045+skyedeving@users.noreply.github.com>2021-01-04 13:45:18 -0600
committerSkye Deving <76892045+skyedeving@users.noreply.github.com>2021-01-04 13:45:18 -0600
commit6570bcf0662d675cc3f0ed89820fc95efe4cace3 (patch)
tree7b8a0e2f083ac1fbf594adc520d7e096fc11fa5d
parent4d02cc8d680f4e069de0dddc8558ff9186153d59 (diff)
Fix timestamps when toggling showname
On toggling shownames, regenerate_ic_chatlog() gets called to reprint the entire chatlog with append_ic_text(). The issue is that append_ic_text() uses QDateTime::currentDateTime() for the timestamp when it's called. Therefore the fix is adding a new timestamp parameter to the append_ic_text() which we supply from the datetime provided by each chatlogpiece
-rw-r--r--include/courtroom.h2
-rw-r--r--src/courtroom.cpp18
2 files changed, 13 insertions, 7 deletions
diff --git a/include/courtroom.h b/include/courtroom.h
index f05b15ac..93324816 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -225,7 +225,7 @@ public:
// selected
// or the user isn't already scrolled to the top
void append_ic_text(QString p_text, QString p_name = "", QString action = "",
- int color = 0);
+ int color = 0, QDateTime timestamp = {});
// prints who played the song to IC chat and plays said song(if found on local
// filesystem) takes in a list where the first element is the song name and
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 95189112..9fda3954 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -2619,7 +2619,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname,
}
void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
- int color)
+ int color, QDateTime timestamp)
{
QTextCharFormat bold;
QTextCharFormat normal;
@@ -2645,10 +2645,15 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
}
// Timestamp if we're doing that meme
- if (log_timestamp)
- ui_ic_chatlog->textCursor().insertText(
- "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ",
- normal);
+ if (log_timestamp) {
+ if (timestamp.isValid()) {
+ ui_ic_chatlog->textCursor().insertText(
+ "[" + timestamp.toString("h:mm:ss AP") + "] ", normal);
+ } else {
+ ui_ic_chatlog->textCursor().insertText(
+ "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", normal);
+ }
+ }
// Format the name of the actor
ui_ic_chatlog->textCursor().insertText(p_name, bold);
@@ -4780,7 +4785,8 @@ void Courtroom::regenerate_ic_chatlog()
append_ic_text(item.get_message(),
ui_showname_enable->isChecked() ? item.get_showname()
: item.get_name(),
- item.get_action(), item.get_chat_color());
+ item.get_action(), item.get_chat_color(),
+ item.get_datetime().toLocalTime());
}
}