Merge pull request #3 from argoneuscze/reverse_ic_log
Fixed blank lines in IC log
This commit is contained in:
		
						commit
						22640d4825
					
				@ -13,7 +13,7 @@ RC_ICONS = logo.ico
 | 
			
		||||
TARGET = Attorney_Online_remake
 | 
			
		||||
TEMPLATE = app
 | 
			
		||||
 | 
			
		||||
VERSION = 2.4.10.0
 | 
			
		||||
VERSION = 2.5.1.0
 | 
			
		||||
 | 
			
		||||
SOURCES += main.cpp\
 | 
			
		||||
        lobby.cpp \
 | 
			
		||||
 | 
			
		||||
@ -226,7 +226,7 @@ public:
 | 
			
		||||
private:
 | 
			
		||||
  const int RELEASE = 2;
 | 
			
		||||
  const int MAJOR_VERSION = 5;
 | 
			
		||||
  const int MINOR_VERSION = 0;
 | 
			
		||||
  const int MINOR_VERSION = 1;
 | 
			
		||||
 | 
			
		||||
  QString current_theme = "default";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1139,6 +1139,9 @@ void Courtroom::handle_chatmessage_3()
 | 
			
		||||
 | 
			
		||||
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 normal;
 | 
			
		||||
  bold.setFontWeight(QFont::Bold);
 | 
			
		||||
@ -1146,21 +1149,37 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
 | 
			
		||||
  const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
 | 
			
		||||
  const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
 | 
			
		||||
 | 
			
		||||
  QTextCursor::MoveOperation move_op;
 | 
			
		||||
  int scrollbar_limit;
 | 
			
		||||
 | 
			
		||||
  if(ao_app->ic_scroll_down_enabled()) {
 | 
			
		||||
  if (ao_app->ic_scroll_down_enabled()) {
 | 
			
		||||
      scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
 | 
			
		||||
      ui_ic_chatlog->moveCursor(QTextCursor::End);
 | 
			
		||||
      move_op = QTextCursor::End;
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
      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;
 | 
			
		||||
 | 
			
		||||
  ui_ic_chatlog->moveCursor(move_op);
 | 
			
		||||
 | 
			
		||||
  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 + '\n', normal);
 | 
			
		||||
    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)
 | 
			
		||||
  {
 | 
			
		||||
@ -1171,14 +1190,14 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
      // 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(QTextCursor::End);
 | 
			
		||||
        ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->maximum());
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        ui_ic_chatlog->moveCursor(QTextCursor::Start);
 | 
			
		||||
        ui_ic_chatlog->verticalScrollBar()->setValue(ui_ic_chatlog->verticalScrollBar()->minimum());
 | 
			
		||||
      }
 | 
			
		||||
      ui_ic_chatlog->moveCursor(move_op);
 | 
			
		||||
 | 
			
		||||
      // update the value to the new maximum/minimum
 | 
			
		||||
      if (ao_app->ic_scroll_down_enabled())
 | 
			
		||||
        scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->maximum();
 | 
			
		||||
      else
 | 
			
		||||
        scrollbar_limit = ui_ic_chatlog->verticalScrollBar()->minimum();
 | 
			
		||||
      ui_ic_chatlog->verticalScrollBar()->setValue(scrollbar_limit);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user