@@ -1145,14 +1145,27 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11451145 normal.setFontWeight (QFont::Normal);
11461146 const QTextCursor old_cursor = ui_ic_chatlog->textCursor ();
11471147 const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar ()->value ();
1148- const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar ()->minimum ();
1149-
1150- ui_ic_chatlog->moveCursor (QTextCursor::Start);
1148+
1149+ QTextCursor::MoveOperation move_op;
1150+ int scrollbar_limit;
1151+
1152+ if (ao_app->ic_scroll_down_enabled ()) {
1153+ scrollbar_limit = ui_ic_chatlog->verticalScrollBar ()->maximum ();
1154+ move_op = QTextCursor::End;
1155+ }
1156+ else {
1157+ scrollbar_limit = ui_ic_chatlog->verticalScrollBar ()->minimum ();
1158+ move_op = QTextCursor::Start;
1159+ }
1160+
1161+ const bool is_fully_scrolled = old_scrollbar_value == scrollbar_limit;
1162+
1163+ ui_ic_chatlog->moveCursor (move_op);
11511164
11521165 ui_ic_chatlog->textCursor ().insertText (p_name, bold);
11531166 ui_ic_chatlog->textCursor ().insertText (p_text + ' \n ' , normal);
1154-
1155- if (old_cursor.hasSelection () || !is_scrolled_up )
1167+
1168+ if (old_cursor.hasSelection () || !is_fully_scrolled )
11561169 {
11571170 // The user has selected text or scrolled away from the top: maintain position.
11581171 ui_ic_chatlog->setTextCursor (old_cursor);
@@ -1161,8 +1174,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11611174 else
11621175 {
11631176 // The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
1164- ui_ic_chatlog->moveCursor (QTextCursor::Start );
1165- ui_ic_chatlog->verticalScrollBar ()->setValue (ui_ic_chatlog-> verticalScrollBar ()-> minimum () );
1177+ ui_ic_chatlog->moveCursor (move_op );
1178+ ui_ic_chatlog->verticalScrollBar ()->setValue (scrollbar_limit );
11661179 }
11671180}
11681181
0 commit comments