From 0044141c1441b27363bcf7a6b1b515bd8b9ea9ab Mon Sep 17 00:00:00 2001 From: OmniTroid Date: Sun, 19 Feb 2017 20:10:28 +0100 Subject: [PATCH] added hyperlinks --- Attorney_Online_remake.pro | 2 +- aoapplication.h | 2 +- courtroom.cpp | 40 ++++++++++++++++++++++++++++++-------- courtroom.h | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 71850fa..c627350 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -13,7 +13,7 @@ RC_ICONS = logo.ico TARGET = Attorney_Online_remake TEMPLATE = app -VERSION = 2.2.1.0 +VERSION = 2.2.2.0 SOURCES += main.cpp\ lobby.cpp \ diff --git a/aoapplication.h b/aoapplication.h index cee9174..f25cb01 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -125,7 +125,7 @@ public: private: const int RELEASE = 2; const int MAJOR_VERSION = 2; - const int MINOR_VERSION = 1; + const int MINOR_VERSION = 2; QString user_theme = "default"; diff --git a/courtroom.cpp b/courtroom.cpp index 3392a6e..6a8dd49 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -76,12 +76,14 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_ic_chatlog = new QPlainTextEdit(this); ui_ic_chatlog->setReadOnly(true); - ui_ms_chatlog = new QPlainTextEdit(this); + ui_ms_chatlog = new QTextBrowser(this); ui_ms_chatlog->setReadOnly(true); + ui_ms_chatlog->setOpenExternalLinks(true); ui_ms_chatlog->hide(); - ui_server_chatlog = new QPlainTextEdit(this); + ui_server_chatlog = new QTextBrowser(this); ui_server_chatlog->setReadOnly(true); + ui_server_chatlog->setOpenExternalLinks(true); ui_mute_list = new QListWidget(this); //ui_area_list = new QListWidget(this); @@ -410,10 +412,10 @@ void Courtroom::set_widgets() "color: white; }"); set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); - ui_ms_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0); }"); + ui_ms_chatlog->setStyleSheet("QTextBrowser{ background-color: rgba(0, 0, 0, 0); }"); set_size_and_pos(ui_server_chatlog, "server_chatlog"); - ui_server_chatlog->setStyleSheet("QPlainTextEdit{ background-color: rgba(0, 0, 0, 0); }"); + ui_server_chatlog->setStyleSheet("QTextBrowser{ background-color: rgba(0, 0, 0, 0); }"); set_size_and_pos(ui_mute_list, "mute_list"); ui_mute_list->hide(); @@ -834,7 +836,18 @@ void Courtroom::append_ms_chatmessage(QString f_message) ui_ms_chatlog->moveCursor(QTextCursor::End); - ui_ms_chatlog->appendPlainText(f_message); + QStringList word_list = f_message.split(" "); + f_message = ""; + + for (QString i_word : word_list) + { + if (i_word.startsWith("http")) + i_word = "" + i_word + ""; + + f_message += i_word + " "; + } + + ui_ms_chatlog->append(f_message); if (old_cursor.hasSelection() || !is_scrolled_down) { @@ -858,7 +871,18 @@ void Courtroom::append_server_chatmessage(QString f_message) ui_server_chatlog->moveCursor(QTextCursor::End); - ui_server_chatlog->appendPlainText(f_message); + QStringList word_list = f_message.split(" "); + f_message = ""; + + for (QString i_word : word_list) + { + if (i_word.startsWith("http")) + i_word = "" + i_word + ""; + + f_message += i_word + " "; + } + + ui_server_chatlog->append(f_message); if (old_cursor.hasSelection() || !is_scrolled_down) { @@ -1446,7 +1470,7 @@ void Courtroom::set_ip_list(QString p_list) { QString f_list = p_list.replace("|", ":").replace("*", "\n"); - ui_server_chatlog->appendPlainText(f_list); + ui_server_chatlog->append(f_list); } void Courtroom::set_mute(bool p_muted, int p_cid) @@ -1533,7 +1557,7 @@ void Courtroom::set_hp_bar(int p_bar, int p_state) void Courtroom::mod_called(QString p_ip) { - ui_server_chatlog->appendPlainText(p_ip); + ui_server_chatlog->append(p_ip); if (ui_guard->isChecked()) modcall_player->play("sfx-gallery.wav"); } diff --git a/courtroom.h b/courtroom.h index 1fddb2a..fc0cc25 100644 --- a/courtroom.h +++ b/courtroom.h @@ -26,6 +26,7 @@ #include #include #include +#include class AOApplication; @@ -221,8 +222,8 @@ private: QPlainTextEdit *ui_ic_chatlog; - QPlainTextEdit *ui_ms_chatlog; - QPlainTextEdit *ui_server_chatlog; + QTextBrowser *ui_ms_chatlog; + QTextBrowser *ui_server_chatlog; QListWidget *ui_mute_list; QListWidget *ui_area_list;