From 9b39b7d6aa2beb8b5496a528c2351adf125c4601 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 16 Sep 2019 06:09:39 +0300 Subject: Allow char.ini to override the chat font and font size with chat_font = and chat_size = Scream at the coders that decided hard-coding fonts and colors was a good idea (gotta properly let the themes modify that later) Fix a lot of ui elements not properly respecting the themes and their colors add a set_qfont method for those situations that need it Allow the theme to change sender colors for ooc and ms chatlogs rename url parser variable to something more immediately apparent as to what it is for readability's sake --- src/aotextarea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/aotextarea.cpp') diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index 5e14632..f9d21e6 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -18,7 +18,7 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p //cheap workarounds ahoy p_message += " "; - QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(omnis_dank_url_regex, "\\1" ); + QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(url_parser_regex, "\\1" ); this->insertHtml(result); @@ -36,7 +36,7 @@ void AOTextArea::append_error(QString p_message) this->append(""); p_message += " "; - QString result = p_message.replace("\n", "
").replace(omnis_dank_url_regex, "\\1" ); + QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1" ); this->insertHtml("" + result + ""); -- cgit From 6747bfdd5edee3693144c088ad1e732b5748fb8b Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 17 Sep 2019 03:31:18 +0300 Subject: 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) --- src/aotextarea.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/aotextarea.cpp') 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(); -- cgit From c8e12558cdd3fd0769b81679ad09edf1f29b780f Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 01:18:24 +0300 Subject: Clang-ify the code with this styling using Visual Studio Code: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Stroustrup, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All } (this is the Visual Studio preset with only "BreakBeforeBraces" changed from Allman to Stroustrup) --- src/aotextarea.cpp | 67 ++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'src/aotextarea.cpp') diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index a34bb1a..524f328 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -2,65 +2,62 @@ 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); + 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(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); - this->insertHtml("" + p_name.toHtmlEscaped() + ": "); + this->append(""); + this->insertHtml("" + p_name.toHtmlEscaped() + ": "); - //cheap workarounds ahoy - p_message += " "; - QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(url_parser_regex, "\\1" ); + //cheap workarounds ahoy + p_message += " "; + QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(url_parser_regex, "\\1"); - this->insertHtml(result); + this->insertHtml(result); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } void AOTextArea::append_error(QString p_message) { - const QTextCursor old_cursor = this->textCursor(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); + this->append(""); - p_message += " "; - QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1" ); + p_message += " "; + QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1"); - this->insertHtml("" + result + ""); + this->insertHtml("" + result + ""); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bool is_scrolled_down) { - if (old_cursor.hasSelection() || !is_scrolled_down) - { - // The user has selected text or scrolled away from the bottom: maintain position. - this->setTextCursor(old_cursor); - this->verticalScrollBar()->setValue(old_scrollbar_value); - } - else - { - // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom. - this->moveCursor(QTextCursor::End); - this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); - } + if (old_cursor.hasSelection() || !is_scrolled_down) { + // The user has selected text or scrolled away from the bottom: maintain position. + this->setTextCursor(old_cursor); + this->verticalScrollBar()->setValue(old_scrollbar_value); + } + else { + // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom. + this->moveCursor(QTextCursor::End); + this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); + } } -- cgit From 88de4cde0433ef5e606f38a2f1e6041f0d24a87e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 02:14:54 +0300 Subject: clang 2 electric boogaloo { BasedOnStyle: LLVM, BreakBeforeBraces: Stroustrup} --- src/aotextarea.cpp | 84 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 37 deletions(-) (limited to 'src/aotextarea.cpp') diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index 524f328..52e32f5 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -1,63 +1,73 @@ #include "aotextarea.h" -AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) -{ -} +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); + 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) +void AOTextArea::append_chatmessage(QString p_name, QString p_message, + QString p_colour) { - const QTextCursor old_cursor = this->textCursor(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); - this->insertHtml("" + p_name.toHtmlEscaped() + ": "); + this->append(""); + this->insertHtml("" + p_name.toHtmlEscaped() + + ": "); - //cheap workarounds ahoy - p_message += " "; - QString result = p_message.toHtmlEscaped().replace("\n", "
").replace(url_parser_regex, "\\1"); + // cheap workarounds ahoy + p_message += " "; + QString result = p_message.toHtmlEscaped() + .replace("\n", "
") + .replace(url_parser_regex, "\\1"); - this->insertHtml(result); + this->insertHtml(result); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } void AOTextArea::append_error(QString p_message) { - const QTextCursor old_cursor = this->textCursor(); - const int old_scrollbar_value = this->verticalScrollBar()->value(); - const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum(); + const QTextCursor old_cursor = this->textCursor(); + const int old_scrollbar_value = this->verticalScrollBar()->value(); + const bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); - this->moveCursor(QTextCursor::End); + this->moveCursor(QTextCursor::End); - this->append(""); + this->append(""); - p_message += " "; - QString result = p_message.replace("\n", "
").replace(url_parser_regex, "\\1"); + p_message += " "; + QString result = p_message.replace("\n", "
") + .replace(url_parser_regex, "\\1"); - this->insertHtml("" + result + ""); + this->insertHtml("" + result + ""); - this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); + this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down); } -void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bool is_scrolled_down) +void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, + bool is_scrolled_down) { - if (old_cursor.hasSelection() || !is_scrolled_down) { - // The user has selected text or scrolled away from the bottom: maintain position. - this->setTextCursor(old_cursor); - this->verticalScrollBar()->setValue(old_scrollbar_value); - } - else { - // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom. - this->moveCursor(QTextCursor::End); - this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); - } + if (old_cursor.hasSelection() || !is_scrolled_down) { + // The user has selected text or scrolled away from the bottom: maintain + // position. + this->setTextCursor(old_cursor); + this->verticalScrollBar()->setValue(old_scrollbar_value); + } + else { + // The user hasn't selected any text and the scrollbar is at the bottom: + // scroll to the bottom. + this->moveCursor(QTextCursor::End); + this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); + } } -- cgit