From f8cf983b7c7d1d8c3dc82b97500ba916f9a3e5a3 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 18 Dec 2017 20:18:20 +0100 Subject: [PATCH] added an option to disable smooth scrolling --- src/widgets/helper/channelview.cpp | 20 ++++++++++++-------- src/widgets/settingsdialog.cpp | 4 ++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 833236461..634ddfd59 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -155,7 +155,7 @@ void ChannelView::actuallyLayoutMessages() if (h < 0) { this->scrollBar.setLargeChange((messages.getLength() - i) + (qreal)h / message->getHeight()); - this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue()); + // this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue()); showScrollbar = true; break; @@ -245,8 +245,9 @@ QString ChannelView::getSelectedText() if (first) { first = false; - bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex < - part.getCharacterLength(); + bool isSingleWord = + isSingleMessage && + this->selection.max.charIndex - charIndex < part.getCharacterLength(); if (isSingleWord) { // return single word @@ -340,9 +341,11 @@ void ChannelView::setChannel(std::shared_ptr channel) auto messageRef = new MessageRef(message); 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(); @@ -523,9 +526,10 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap // this->selectionMax.messageIndex >= messageIndex) { // painter.fillRect(buffer->rect(), QColor(24, 55, 25)); //} else { - painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab()) - ? this->colorScheme.ChatBackgroundHighlighted - : this->colorScheme.ChatBackground); + painter.fillRect(buffer->rect(), + (messageRef->getMessage()->getCanHighlightTab()) + ? this->colorScheme.ChatBackgroundHighlighted + : this->colorScheme.ChatBackground); //} // draw selection diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index e825eeef5..da6f44fb9 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -281,6 +281,10 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() }); } + auto enableSmoothScrolling = + createCheckbox("Enable smooth scrolling", settings.enableSmoothScrolling); + form->addRow("Scrolling:", enableSmoothScrolling); + group->setLayout(form); layout->addWidget(group);