From 6747bfdd5edee3693144c088ad1e732b5748fb8b Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 17 Sep 2019 03:31:18 +0300 Subject: [PATCH] Allow lobby server descriptions to parse links Fix bad reference to ui_emote_right image Fix chatbox being part of the viewport (gets cut off if it's outside) --- include/aotextarea.h | 1 + src/aotextarea.cpp | 6 ++++++ src/courtroom.cpp | 4 ++-- src/lobby.cpp | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/aotextarea.h b/include/aotextarea.h index 266b722..13b29c9 100644 --- a/include/aotextarea.h +++ b/include/aotextarea.h @@ -12,6 +12,7 @@ class AOTextArea : public QTextBrowser public: AOTextArea(QWidget *p_parent = nullptr); + void append_linked(QString p_message); void append_chatmessage(QString p_name, QString p_message, QString p_colour); void append_error(QString p_message); diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index f9d21e6..a34bb1a 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -5,6 +5,12 @@ AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) } +void AOTextArea::append_linked(QString p_message) +{ + QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(url_parser_regex, "\\1" ); + this->insertHtml(result); +} + void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p_colour) { const QTextCursor old_cursor = this->textCursor(); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3f06b79..a179fb8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -84,7 +84,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_vp_evidence_display = new AOEvidenceDisplay(this, ao_app); - ui_vp_chatbox = new AOImage(ui_viewport, ao_app); + ui_vp_chatbox = new AOImage(this, ao_app); ui_vp_showname = new QLabel(ui_vp_chatbox); ui_vp_showname->setAlignment(Qt::AlignHCenter); ui_vp_chat_arrow = new AOMovie(ui_vp_chatbox, ao_app); @@ -566,7 +566,7 @@ void Courtroom::set_widgets() ui_emote_left->set_image("arrow_left"); set_size_and_pos(ui_emote_right, "emote_right"); - ui_emote_right->set_image("arrow_right."); + ui_emote_right->set_image("arrow_right"); set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); diff --git a/src/lobby.cpp b/src/lobby.cpp index 963ed44..79f18e5 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -23,6 +23,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_server_list = new QListWidget(this); ui_player_count = new QLabel(this); ui_description = new AOTextArea(this); + ui_description->setOpenExternalLinks(true); ui_chatbox = new AOTextArea(this); ui_chatbox->setOpenExternalLinks(true); ui_chatname = new QLineEdit(this); @@ -376,7 +377,7 @@ void Lobby::on_server_list_clicked(QModelIndex p_model) } ui_description->clear(); - ui_description->append(f_server.desc); + ui_description->append_linked(f_server.desc); ui_description->moveCursor(QTextCursor::Start); ui_description->ensureCursorVisible();