diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 1490caa50..efaa6219a 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -44,7 +44,6 @@ ChatForm::ChatForm(Friend* chatFriend) connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); connect(newChatForm, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); - connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } ChatForm::~ChatForm() diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index caa323ca7..d200963ef 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -137,7 +137,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); connect(newChatForm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } void GenericChatForm::setName(const QString &newName) @@ -163,13 +162,6 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos) menu.exec(pos); } -void GenericChatForm::onSliderRangeChanged() -{ - QScrollBar* scroll = newChatForm->verticalScrollBar(); - if (lockSliderToBottom) - scroll->setValue(scroll->maximum()); -} - void GenericChatForm::onSaveLogClicked() { QString path = QFileDialog::getSaveFileName(0, tr("Save chat log")); @@ -250,4 +242,8 @@ void GenericChatForm::updateChatContent() lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); newChatForm->setHtml(getHtmledMessages()); + if (lockSliderToBottom) + sliderPosition = scroll->maximum(); + + scroll->setValue(sliderPosition); } diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index f8b047ef3..8c6b67f4b 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -57,7 +57,6 @@ public slots: protected slots: void onChatContextMenuRequested(QPoint pos); - void onSliderRangeChanged(); void onSaveLogClicked(); void onEmoteButtonClicked(); void onEmoteInsertRequested(QString str); @@ -74,6 +73,7 @@ protected: ChatAreaWidget *newChatForm; int curRow; bool lockSliderToBottom; + int sliderPosition; QList messages;