diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2021-12-25 19:17:27 -0600 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2021-12-25 19:17:27 -0600 |
| commit | ecfe6f2542d73e9559b75a502f6eebffe63a76cf (patch) | |
| tree | 6ceea4666ade907af6e9a1ac79e5dc4763403c49 /src/courtroom.cpp | |
| parent | d1fb7fde16ec37dfa7b13e0a02489417655d315d (diff) | |
Change master chat in courtroom to debug log
Since the MS chat has been disabled for quite some time now (and we aren't planning on bringing it back since Discord, Guilded etc. have better chat features), I decided to go ahead and change the pane into a debug log to keep it useful and avoid creating a gaping hole in themes.
Though, maybe it is worth removing the whole switcher and keeping the debug log hidden away where it can't scare people.
Diffstat (limited to 'src/courtroom.cpp')
| -rw-r--r-- | src/courtroom.cpp | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3eda1635..b3272d92 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -111,11 +111,13 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() log_timestamp = ao_app->get_log_timestamp(); log_timestamp_format = ao_app->get_log_timestamp_format(); - ui_ms_chatlog = new AOTextArea(this); - ui_ms_chatlog->setReadOnly(true); - ui_ms_chatlog->setOpenExternalLinks(true); - ui_ms_chatlog->hide(); - ui_ms_chatlog->setObjectName("ui_ms_chatlog"); + ui_debug_log = new AOTextArea(this); + ui_debug_log->setReadOnly(true); + ui_debug_log->setOpenExternalLinks(true); + ui_debug_log->hide(); + ui_debug_log->setObjectName("ui_debug_log"); + connect(ao_app, &AOApplication::qt_log_message, + this, &Courtroom::debug_message_handler); ui_server_chatlog = new AOTextArea(this); ui_server_chatlog->setReadOnly(true); @@ -560,7 +562,7 @@ void Courtroom::set_courtroom_size() ao_app->get_element_dimensions("courtroom", filename); if (f_courtroom.width < 0 || f_courtroom.height < 0) { - qDebug() << "W: did not find courtroom width or height in " << filename; + qWarning() << "did not find courtroom width or height in " << filename; this->setFixedSize(714, 668); } @@ -679,7 +681,7 @@ void Courtroom::set_widgets() ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + qWarning() << "could not find \"chat_arrow\" in courtroom_design.ini"; ui_vp_chat_arrow->hide(); } else { @@ -725,8 +727,9 @@ void Courtroom::set_widgets() ui_ic_chatlog->setPlaceholderText(log_goes_downwards ? "▼ " + tr("Log goes down") + " ▼" : "▲ " + tr("Log goes up") + " ▲"); - set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); - ui_ms_chatlog->setFrameShape(QFrame::NoFrame); + set_size_and_pos(ui_debug_log, "ms_chatlog"); // Old name + set_size_and_pos(ui_debug_log, "debug_log"); // New name + ui_debug_log->setFrameShape(QFrame::NoFrame); set_size_and_pos(ui_server_chatlog, "server_chatlog"); ui_server_chatlog->setFrameShape(QFrame::NoFrame); @@ -786,7 +789,7 @@ void Courtroom::set_widgets() ao_app->get_element_dimensions("music_display", "courtroom_design.ini"); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"music_display\" in courtroom_design.ini"; + qWarning() << "could not find \"music_display\" in courtroom_design.ini"; ui_music_display->hide(); } else { @@ -1139,7 +1142,7 @@ void Courtroom::set_fonts(QString p_char) set_font(ui_vp_showname, "", "showname", p_char); set_font(ui_vp_message, "", "message", p_char); set_font(ui_ic_chatlog, "", "ic_chatlog", p_char); - set_font(ui_ms_chatlog, "", "ms_chatlog", p_char); + set_font(ui_debug_log, "", "debug_log", p_char); set_font(ui_server_chatlog, "", "server_chatlog", p_char); set_font(ui_music_list, "", "music_list", p_char); set_font(ui_area_list, "", "area_list", p_char); @@ -1248,7 +1251,7 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, QStrin ao_app->get_element_dimensions(p_identifier, filename, p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + qWarning() << "could not find \"" << p_identifier << "\" in " << filename; p_widget->hide(); } else { @@ -1282,7 +1285,7 @@ QPoint Courtroom::get_theme_pos(QString p_identifier) ao_app->get_element_dimensions(p_identifier, filename); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; + qWarning() << "could not find \"" << p_identifier << "\" in " << filename; return QPoint(0, 0); } else { @@ -1733,12 +1736,27 @@ void Courtroom::list_areas() } } -void Courtroom::append_ms_chatmessage(QString f_name, QString f_message) +void Courtroom::debug_message_handler(QtMsgType type, const QMessageLogContext &context, + const QString &msg) { - ui_ms_chatlog->append_chatmessage( - f_name, f_message, - ao_app->get_color("ms_chatlog_sender_color", "courtroom_fonts.ini") - .name()); + const QMap<QtMsgType, QString> colors = { + {QtDebugMsg, "debug"}, + {QtInfoMsg, "info"}, + {QtWarningMsg, "warn"}, + {QtCriticalMsg, "critical"}, + {QtFatalMsg, "fatal"} + }; + const QString color_id = QString("debug_log_%1_color").arg(colors.value(type, "info")); + ui_debug_log->append_chatmessage( + QString(), qFormatLogMessage(type, context, msg), + QString(), ao_app->get_color(color_id, "courtroom_fonts.ini").name()); +} + +void Courtroom::append_debug_message(QString f_message) +{ + ui_debug_log->append_chatmessage( + QString(), f_message, + ao_app->get_color("debug_log_color", "courtroom_fonts.ini").name()); } void Courtroom::append_server_chatmessage(QString p_name, QString p_message, @@ -1758,7 +1776,6 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, on_authentication_state_received(1); } - ui_server_chatlog->append_chatmessage(p_name, p_message, color); if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) { @@ -2492,7 +2509,7 @@ void Courtroom::handle_emote_mod(int emote_mod, bool p_immediate) break; default: // This should never happen, but if it does anyway, yell in the console about it. - qDebug() << "W: invalid emote mod: " << QString::number(emote_mod); + qWarning() << "invalid emote mod: " << QString::number(emote_mod); } } @@ -2732,7 +2749,7 @@ void Courtroom::initialize_chatbox() pos_size_type design_ini_result = ao_app->get_element_dimensions( "chat_arrow", "courtroom_design.ini", p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + qWarning() << "could not find \"chat_arrow\" in courtroom_design.ini"; ui_vp_chat_arrow->hide(); } else { @@ -3246,7 +3263,7 @@ void Courtroom::play_preanim(bool immediate) else anim_state = 1; preanim_done(); - qDebug() << "W: could not find " + anim_to_find; + qWarning() << "could not find " + anim_to_find; return; } ui_vp_player_char->set_static_duration(preanim_duration); @@ -4199,14 +4216,14 @@ void Courtroom::on_ooc_return_pressed() void Courtroom::on_ooc_toggle_clicked() { if (server_ooc) { - ui_ms_chatlog->show(); + ui_debug_log->show(); ui_server_chatlog->hide(); - ui_ooc_toggle->setText(tr("Master")); + ui_ooc_toggle->setText(tr("Debug")); server_ooc = false; } else { - ui_ms_chatlog->hide(); + ui_debug_log->hide(); ui_server_chatlog->show(); ui_ooc_toggle->setText(tr("Server")); @@ -4623,7 +4640,7 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index) } if (f_cid < 0 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; + qWarning() << "" << real_char << " not present in char_list"; return; } @@ -4657,7 +4674,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) } if (f_cid < -2 || f_cid >= char_list.size()) { - qDebug() << "W: " << real_char << " not present in char_list"; + qWarning() << "" << real_char << " not present in char_list"; return; } @@ -5104,7 +5121,7 @@ void Courtroom::on_text_color_changed(int p_color) int c = color_row_to_number.at(p_color); QString markdown_start = color_markdown_start_list.at(c); if (markdown_start.isEmpty()) { - qDebug() << "W: Color list dropdown selected a non-existent markdown " + qWarning() << "Color list dropdown selected a non-existent markdown " "start character"; return; } |
