diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 3e77f494..a1cdb4bc 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -14,7 +14,6 @@ SettingsManager::SettingsManager() , streamlinkPath("/behaviour/streamlink/path", "") , preferredQuality("/behaviour/streamlink/quality", "Choose") , emoteScale(this->settingsItems, "emoteScale", 1.0) - , mouseScrollMultiplier(this->settingsItems, "mouseScrollMultiplier", 1.0) , pathHighlightSound(this->settingsItems, "pathHighlightSound", "qrc:/sounds/ping2.wav") , highlightProperties(this->settingsItems, "highlightProperties", QMap>()) diff --git a/src/settingsmanager.hpp b/src/settingsmanager.hpp index d1a652cf..79a28e6d 100644 --- a/src/settingsmanager.hpp +++ b/src/settingsmanager.hpp @@ -15,6 +15,7 @@ class SettingsManager : public QObject Q_OBJECT using BoolSetting = pajlada::Settings::Setting; + using FloatSetting = pajlada::Settings::Setting; public: void load(); @@ -43,6 +44,7 @@ public: /// Behaviour BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true}; BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false}; + FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0}; /// Commands BoolSetting allowCommandsAtEnd = {"/commands/allowCommandsAtEnd", false}; @@ -69,7 +71,6 @@ public: pajlada::Settings::Setting preferredQuality; Setting emoteScale; - Setting mouseScrollMultiplier; Setting pathHighlightSound; Setting>> highlightProperties; diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index f7d4e637..245066d6 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -245,9 +245,8 @@ 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 @@ -526,10 +525,9 @@ 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 @@ -716,7 +714,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef * void ChannelView::wheelEvent(QWheelEvent *event) { if (this->scrollBar.isVisible()) { - auto mouseMultiplier = SettingsManager::getInstance().mouseScrollMultiplier.get(); + float mouseMultiplier = SettingsManager::getInstance().mouseScrollMultiplier; this->scrollBar.setDesiredValue( this->scrollBar.getDesiredValue() - event->delta() / 10.0 * mouseMultiplier, true); diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 88e90f45..03d91b28 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -1,5 +1,6 @@ #include "widgets/settingsdialog.hpp" #include "accountmanager.hpp" +#include "debug/log.hpp" #include "twitch/twitchmessagebuilder.hpp" #include "twitch/twitchuser.hpp" #include "widgets/helper/settingsdialogtab.hpp" @@ -315,12 +316,19 @@ QVBoxLayout *SettingsDialog::createBehaviourTab() form->addRow( "", createCheckbox("Show last read message indicator", settings.showLastMessageIndicator)); - // auto v = new QVBoxLayout(); - // v->addWidget(new QLabel("Mouse scroll speed")); - auto scroll = new QSlider(Qt::Horizontal); form->addRow("Mouse scroll speed:", scroll); + float currentValue = SettingsManager::getInstance().mouseScrollMultiplier; + int scrollValue = ((currentValue - 0.1f) / 2.f) * 99.f; + scroll->setValue(scrollValue); + + connect(scroll, &QSlider::valueChanged, [](int newValue) { + float mul = static_cast(newValue) / 99.f; + float newScrollValue = (mul * 2.1f) + 0.1f; + SettingsManager::getInstance().mouseScrollMultiplier = newScrollValue; + }); + form->addRow("Streamlink path:", createLineEdit(settings.streamlinkPath)); form->addRow(this->createCombobox( "Preferred quality:", settings.preferredQuality, @@ -329,9 +337,6 @@ QVBoxLayout *SettingsDialog::createBehaviourTab() setting = newValue.toStdString(); })); - // v->addWidget(scroll); - // v->addStretch(1); - // vbox->addLayout(v); layout->addLayout(form); return layout;