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

88 lines
3.4 KiB
C++
Raw Normal View History

2018-01-12 23:09:05 +01:00
#include "behaviourpage.hpp"
#include <QFormLayout>
2018-01-24 21:44:31 +01:00
#include <QGroupBox>
2018-01-12 23:09:05 +01:00
#include <QLabel>
#include <QVBoxLayout>
#include <util/layoutcreator.hpp>
#define WINDOW_TOPMOST "Window always on top (requires restart)"
#define INPUT_EMPTY "Hide input box when empty"
2018-01-23 22:48:33 +01:00
#define LAST_MSG "Show last read message indicator (marks the spot where you left the window)"
2018-01-12 23:09:05 +01:00
#define PAUSE_HOVERING "When hovering"
#define LIMIT_CHATTERS_FOR_SMALLER_STREAMERS "Only fetch chatters list for viewers under X viewers"
#define STREAMLINK_QUALITY "Choose", "Source", "High", "Medium", "Low", "Audio only"
2018-01-12 23:09:05 +01:00
namespace chatterino {
namespace widgets {
namespace settingspages {
2018-01-12 23:09:05 +01:00
BehaviourPage::BehaviourPage()
2018-01-13 00:18:18 +01:00
: SettingsPage("Behaviour", ":/images/behave.svg")
2018-01-12 23:09:05 +01:00
{
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<BehaviourPage> layoutCreator(this);
2018-01-24 21:44:31 +01:00
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
auto form = layout.emplace<QFormLayout>().withoutMargin();
2018-01-12 23:09:05 +01:00
{
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, settings.windowTopMost));
2018-01-16 18:59:10 +01:00
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, settings.hideEmptyInput));
form->addRow("", this->createCheckBox(LAST_MSG, settings.showLastMessageIndicator));
form->addRow("Pause chat:", this->createCheckBox(PAUSE_HOVERING, settings.pauseChatHover));
2018-01-12 23:09:05 +01:00
form->addRow("Mouse scroll speed:", this->createMouseScrollSlider());
2018-01-24 21:44:31 +01:00
form->addRow("Links:", this->createCheckBox("Open links only on double click",
settings.linksDoubleClickOnly));
}
layout->addSpacing(16);
{
auto group = layout.emplace<QGroupBox>("Auto-completion");
auto groupLayout = group.setLayoutType<QFormLayout>();
groupLayout->addRow(
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
this->createCheckBox("", settings.onlyFetchChattersForSmallerStreamers));
groupLayout->addRow("What viewer count counts as a \"smaller streamer\"",
this->createSpinBox(settings.smallStreamerLimit, 10, 50000));
}
{
auto group = layout.emplace<QGroupBox>("Streamlink");
2018-01-24 21:44:31 +01:00
auto groupLayout = group.setLayoutType<QFormLayout>();
groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
groupLayout->addRow("Prefered quality:",
this->createComboBox({STREAMLINK_QUALITY}, settings.preferredQuality));
groupLayout->addRow("Additional options:", this->createLineEdit(settings.streamlinkOpts));
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 *BehaviourPage::createMouseScrollSlider()
{
auto slider = new QSlider(Qt::Horizontal);
2018-01-12 23:09:05 +01:00
float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier;
int sliderValue = ((currentValue - 0.1f) / 2.f) * 99.f;
slider->setValue(sliderValue);
QObject::connect(slider, &QSlider::valueChanged, [](int newValue) {
float mul = static_cast<float>(newValue) / 99.f;
float newSliderValue = (mul * 2.1f) + 0.1f;
singletons::SettingManager::getInstance().mouseScrollMultiplier = newSliderValue;
});
return slider;
}
2018-01-12 23:09:05 +01:00
} // namespace settingspages
} // namespace widgets
} // namespace chatterino