added an option to disable smooth scrolling

This commit is contained in:
fourtf 2017-12-18 20:18:20 +01:00
parent a399af9c66
commit f8cf983b7c
2 changed files with 16 additions and 8 deletions

View file

@ -155,7 +155,7 @@ void ChannelView::actuallyLayoutMessages()
if (h < 0) { if (h < 0) {
this->scrollBar.setLargeChange((messages.getLength() - i) + this->scrollBar.setLargeChange((messages.getLength() - i) +
(qreal)h / message->getHeight()); (qreal)h / message->getHeight());
this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue()); // this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue());
showScrollbar = true; showScrollbar = true;
break; break;
@ -245,8 +245,9 @@ QString ChannelView::getSelectedText()
if (first) { if (first) {
first = false; first = false;
bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex < bool isSingleWord =
part.getCharacterLength(); isSingleMessage &&
this->selection.max.charIndex - charIndex < part.getCharacterLength();
if (isSingleWord) { if (isSingleWord) {
// return single word // return single word
@ -340,9 +341,11 @@ void ChannelView::setChannel(std::shared_ptr<Channel> channel)
auto messageRef = new MessageRef(message); auto messageRef = new MessageRef(message);
if (this->messages.appendItem(SharedMessageRef(messageRef), deleted)) { if (this->messages.appendItem(SharedMessageRef(messageRef), deleted)) {
qreal value = std::max(0.0, this->getScrollBar().getDesiredValue() - 1); // qreal value = std::max(0.0, this->getScrollBar().getDesiredValue()
// - 1);
this->getScrollBar().setDesiredValue(value, false); // this->getScrollBar().setDesiredValue(value, false);
this->getScrollBar().offset(-1);
} }
layoutMessages(); layoutMessages();
@ -523,7 +526,8 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
// this->selectionMax.messageIndex >= messageIndex) { // this->selectionMax.messageIndex >= messageIndex) {
// painter.fillRect(buffer->rect(), QColor(24, 55, 25)); // painter.fillRect(buffer->rect(), QColor(24, 55, 25));
//} else { //} else {
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab()) painter.fillRect(buffer->rect(),
(messageRef->getMessage()->getCanHighlightTab())
? this->colorScheme.ChatBackgroundHighlighted ? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground); : this->colorScheme.ChatBackground);
//} //}

View file

@ -281,6 +281,10 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
}); });
} }
auto enableSmoothScrolling =
createCheckbox("Enable smooth scrolling", settings.enableSmoothScrolling);
form->addRow("Scrolling:", enableSmoothScrolling);
group->setLayout(form); group->setLayout(form);
layout->addWidget(group); layout->addWidget(group);