diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2020-05-22 17:13:17 -0500 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2020-05-22 17:13:37 -0500 |
| commit | 8928aa2718378bc42d20d5bbe6c17be68d65d6f3 (patch) | |
| tree | bf90d3e73519d58cc89e2135b613e308ac0a0ed8 /src/aotextarea.cpp | |
| parent | 156a760ebab6839c53f9c613881f0937e814414a (diff) | |
Perform clang-format
If you don't want to see this commit on blames, use the hidden
whitespace option on GitHub, or use `-w` in git-blame.
Diffstat (limited to 'src/aotextarea.cpp')
| -rw-r--r-- | src/aotextarea.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp index 5e146326..ebc75e28 100644 --- a/src/aotextarea.cpp +++ b/src/aotextarea.cpp @@ -1,24 +1,26 @@ #include "aotextarea.h" -AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) -{ - -} +AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) {} -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 bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); this->moveCursor(QTextCursor::End); this->append(""); - this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + "</font></b>: "); + this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + + "</font></b>: "); - //cheap workarounds ahoy + // cheap workarounds ahoy p_message += " "; - QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" ); + QString result = p_message.toHtmlEscaped() + .replace("\n", "<br>") + .replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>"); this->insertHtml(result); @@ -29,32 +31,35 @@ 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 bool is_scrolled_down = + old_scrollbar_value == this->verticalScrollBar()->maximum(); this->moveCursor(QTextCursor::End); this->append(""); p_message += " "; - QString result = p_message.replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" ); + QString result = p_message.replace("\n", "<br>") + .replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>"); this->insertHtml("<font color='red'>" + result + "</font>"); 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); + 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()); + 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()); } } |
