1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

scroll fix

This commit is contained in:
apprb 2014-09-07 00:10:48 +07:00
parent db4c84a222
commit b68cc66ede
3 changed files with 5 additions and 10 deletions

View File

@ -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()

View File

@ -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);
}

View File

@ -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<ChatAction*> messages;