mirror-chatterino2/src/widgets/settingspages/FeelPage.cpp

101 lines
3.4 KiB
C++
Raw Normal View History

#include "FeelPage.hpp"
2018-01-12 23:09:05 +01:00
2018-06-26 14:09:39 +02:00
#include "Application.hpp"
#include "util/LayoutCreator.hpp"
2018-01-12 23:09:05 +01:00
#include <QFormLayout>
2018-01-24 21:44:31 +01:00
#include <QGroupBox>
2018-01-12 23:09:05 +01:00
#include <QLabel>
#include <QVBoxLayout>
#define PAUSE_HOVERING "When hovering"
2018-07-05 18:17:12 +02:00
#define SCROLL_SMOOTH "Smooth scrolling"
#define SCROLL_NEWMSG "Smooth scrolling for new messages"
2018-01-12 23:09:05 +01:00
2018-08-06 21:17:03 +02:00
#define LIMIT_CHATTERS_FOR_SMALLER_STREAMERS \
"Only fetch chatters list for viewers under X viewers"
2018-01-12 23:09:05 +01:00
namespace chatterino {
FeelPage::FeelPage()
2018-04-25 20:35:32 +02:00
: SettingsPage("Feel", ":/images/behave.svg")
2018-01-12 23:09:05 +01:00
{
auto app = getApp();
LayoutCreator<FeelPage> layoutCreator(this);
2018-01-12 23:09:05 +01:00
2018-01-24 21:44:31 +01:00
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
// layout.append(this->createCheckBox("Use a seperate write connection.",
// getSettings()->twitchSeperateWriteConnection));
2018-08-06 21:17:03 +02:00
layout.append(this->createCheckBox(SCROLL_SMOOTH,
getSettings()->enableSmoothScrolling));
layout.append(this->createCheckBox(
SCROLL_NEWMSG, getSettings()->enableSmoothScrollingNewMessages));
2018-07-05 18:17:12 +02:00
2018-01-24 21:44:31 +01:00
auto form = layout.emplace<QFormLayout>().withoutMargin();
2018-01-12 23:09:05 +01:00
{
2018-05-27 13:37:49 +02:00
form->addRow(
2018-08-06 21:17:03 +02:00
"", this->createCheckBox(
"Show which users joined the channel (up to 1000 chatters)",
app->settings->showJoins));
2018-05-27 13:37:49 +02:00
form->addRow(
2018-08-06 21:17:03 +02:00
"", this->createCheckBox(
"Show which users parted the channel (up to 1000 chatters)",
app->settings->showParts));
form->addRow("Pause chat:",
2018-08-06 21:17:03 +02:00
this->createCheckBox(PAUSE_HOVERING,
app->settings->pauseChatHover));
2018-01-12 23:09:05 +01:00
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
2018-08-06 21:17:03 +02:00
form->addRow("Links:",
this->createCheckBox("Open links only on double click",
app->settings->linksDoubleClickOnly));
2018-01-24 21:44:31 +01:00
}
layout->addSpacing(16);
{
auto group = layout.emplace<QGroupBox>("Auto-completion");
auto groupLayout = group.setLayoutType<QFormLayout>();
groupLayout->addRow(
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
2018-08-06 21:17:03 +02:00
this->createCheckBox(
"", app->settings->onlyFetchChattersForSmallerStreamers));
2018-08-06 21:17:03 +02:00
groupLayout->addRow(
"What viewer count counts as a \"smaller streamer\"",
this->createSpinBox(app->settings->smallStreamerLimit, 10, 50000));
}
{
2018-04-25 20:35:32 +02:00
auto group = layout.emplace<QGroupBox>("Misc");
auto groupLayout = group.setLayoutType<QVBoxLayout>();
2018-08-06 21:17:03 +02:00
groupLayout.append(this->createCheckBox("Show whispers inline",
app->settings->inlineWhispers));
2018-01-12 23:09:05 +01:00
}
2018-01-24 21:44:31 +01:00
layout->addStretch(1);
2018-01-12 23:09:05 +01:00
}
QSlider *FeelPage::createMouseScrollSlider()
2018-01-12 23:09:05 +01:00
{
auto app = getApp();
auto slider = new QSlider(Qt::Horizontal);
2018-01-12 23:09:05 +01:00
float currentValue = app->settings->mouseScrollMultiplier;
int sliderValue = int(((currentValue - 0.1f) / 2.f) * 99.f);
2018-01-12 23:09:05 +01:00
slider->setValue(sliderValue);
QObject::connect(slider, &QSlider::valueChanged, [=](int newValue) {
2018-01-12 23:09:05 +01:00
float mul = static_cast<float>(newValue) / 99.f;
float newSliderValue = (mul * 2.1f) + 0.1f;
app->settings->mouseScrollMultiplier = newSliderValue;
2018-01-12 23:09:05 +01:00
});
return slider;
}
2018-01-12 23:09:05 +01:00
} // namespace chatterino