fixed blank lines in IC log
This commit is contained in:
		
							parent
							
								
									bec2b7aef4
								
							
						
					
					
						commit
						25a45f2e87
					
				@ -1139,29 +1139,48 @@ void Courtroom::handle_chatmessage_3()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Courtroom::append_ic_text(QString p_text, QString p_name)
 | 
					void Courtroom::append_ic_text(QString p_text, QString p_name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  // a bit of a silly hack, should use QListWidget for IC in the first place though
 | 
				
			||||||
 | 
					  static bool isEmpty = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QTextCharFormat bold;
 | 
					  QTextCharFormat bold;
 | 
				
			||||||
  QTextCharFormat normal;
 | 
					  QTextCharFormat normal;
 | 
				
			||||||
  bold.setFontWeight(QFont::Bold);
 | 
					  bold.setFontWeight(QFont::Bold);
 | 
				
			||||||
  normal.setFontWeight(QFont::Normal);
 | 
					  normal.setFontWeight(QFont::Normal);
 | 
				
			||||||
  const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
 | 
					  const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
 | 
				
			||||||
  const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
 | 
					  const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
 | 
					  QTextCursor::MoveOperation move_op;
 | 
				
			||||||
  int scrollbar_limit;
 | 
					  int scrollbar_limit;
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  if(ao_app->ic_scroll_down_enabled()) {
 | 
					  if (ao_app->ic_scroll_down_enabled()) {
 | 
				
			||||||
      scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
 | 
					      scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
 | 
				
			||||||
      ui_ic_chatlog->moveCursor(QTextCursor::End);
 | 
					      move_op = QTextCursor::End;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
      scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum();
 | 
					      scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum();
 | 
				
			||||||
      ui_ic_chatlog->moveCursor(QTextCursor::Start);
 | 
					      move_op = QTextCursor::Start;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  const bool is_fully_scrolled = old_scrollbar_value == scrollbar_limit;
 | 
					  const bool is_fully_scrolled = old_scrollbar_value == scrollbar_limit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ic_chatlog->textCursor().insertText(p_name, bold);
 | 
					  ui_ic_chatlog->moveCursor(move_op);
 | 
				
			||||||
  ui_ic_chatlog->textCursor().insertText(p_text + '\n', normal);
 | 
					
 | 
				
			||||||
  
 | 
					  if (ao_app->ic_scroll_down_enabled()) {
 | 
				
			||||||
 | 
					    if (!isEmpty)
 | 
				
			||||||
 | 
					      ui_ic_chatlog->textCursor().insertText("\n", normal);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      isEmpty = false;
 | 
				
			||||||
 | 
					    ui_ic_chatlog->textCursor().insertText(p_name, bold);
 | 
				
			||||||
 | 
					    ui_ic_chatlog->textCursor().insertText(p_text, normal);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    ui_ic_chatlog->textCursor().insertText(p_name, bold);
 | 
				
			||||||
 | 
					    ui_ic_chatlog->textCursor().insertText(p_text, normal);
 | 
				
			||||||
 | 
					    if (!isEmpty)
 | 
				
			||||||
 | 
					      ui_ic_chatlog->textCursor().insertText("\n", normal);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      isEmpty = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (old_cursor.hasSelection() || !is_fully_scrolled)
 | 
					  if (old_cursor.hasSelection() || !is_fully_scrolled)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
      // The user has selected text or scrolled away from the top: maintain position.
 | 
					      // The user has selected text or scrolled away from the top: maintain position.
 | 
				
			||||||
@ -1171,14 +1190,14 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
 | 
				
			|||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
      // The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
 | 
					      // The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
 | 
				
			||||||
      if(ao_app->ic_scroll_down_enabled()) {
 | 
					      ui_ic_chatlog->moveCursor(move_op);
 | 
				
			||||||
        ui_ic_chatlog->moveCursor(QTextCursor::End);
 | 
					
 | 
				
			||||||
        ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum());
 | 
					      // update the value to the new maximum/minimum
 | 
				
			||||||
      }
 | 
					      if (ao_app->ic_scroll_down_enabled())
 | 
				
			||||||
      else {
 | 
					        scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
 | 
				
			||||||
        ui_ic_chatlog->moveCursor(QTextCursor::Start);
 | 
					      else
 | 
				
			||||||
        ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
 | 
					        scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum();
 | 
				
			||||||
      }
 | 
					      ui_ic_chatlog->verticalScrollBar()->setValue(scrollbar_limit);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user