aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-17 03:31:18 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-17 03:31:18 +0300
commit6747bfdd5edee3693144c088ad1e732b5748fb8b (patch)
treeebb9efb5fc4bb0621586796fe54500a6a62fb32f
parent9695c621c23e3ebe1fded621c13eaea75bfc4372 (diff)
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)
-rw-r--r--include/aotextarea.h1
-rw-r--r--src/aotextarea.cpp6
-rw-r--r--src/courtroom.cpp4
-rw-r--r--src/lobby.cpp3
4 files changed, 11 insertions, 3 deletions
diff --git a/include/aotextarea.h b/include/aotextarea.h
index 266b7222..13b29c9e 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 f9d21e6e..a34bb1a6 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", "<br>").replace(url_parser_regex, "<a href='\\1'>\\1</a>" );
+ 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 3f06b796..a179fb88 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 963ed44f..79f18e52 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();