2018-06-26 14:09:39 +02:00
|
|
|
#include "BehaviourPage.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-04-27 22:11:19 +02:00
|
|
|
|
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>
|
|
|
|
|
2018-05-23 12:31:03 +02:00
|
|
|
#ifdef USEWINSDK
|
|
|
|
#define WINDOW_TOPMOST "Window always on top"
|
|
|
|
#else
|
2018-01-12 23:09:05 +01:00
|
|
|
#define WINDOW_TOPMOST "Window always on top (requires restart)"
|
2018-05-23 12:31:03 +02:00
|
|
|
#endif
|
2018-01-12 23:09:05 +01:00
|
|
|
#define INPUT_EMPTY "Hide input box when empty"
|
|
|
|
#define PAUSE_HOVERING "When hovering"
|
2018-07-03 16:55:02 +02:00
|
|
|
#define LAST_MSG "Mark the last message you read (dotted line)"
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-03-30 15:42:59 +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 {
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
BehaviourPage::BehaviourPage()
|
2018-04-25 20:35:32 +02:00
|
|
|
: SettingsPage("Feel", ":/images/behave.svg")
|
2018-01-12 23:09:05 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-06-26 17:06:17 +02:00
|
|
|
LayoutCreator<BehaviourPage> layoutCreator(this);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
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
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, app->settings->windowTopMost));
|
|
|
|
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, app->settings->hideEmptyInput));
|
2018-05-27 13:37:49 +02:00
|
|
|
form->addRow(
|
|
|
|
"", this->createCheckBox("Show which users joined the channel (up to 1000 chatters)",
|
|
|
|
app->settings->showJoins));
|
|
|
|
form->addRow(
|
|
|
|
"", this->createCheckBox("Show which users parted the channel (up to 1000 chatters)",
|
|
|
|
app->settings->showParts));
|
2018-07-03 16:55:02 +02:00
|
|
|
|
|
|
|
form->addRow("", this->createCheckBox("Show message length while typing",
|
|
|
|
getSettings()->showMessageLength));
|
|
|
|
form->addRow("", this->createCheckBox(LAST_MSG, getSettings()->showLastMessageIndicator));
|
2018-07-03 17:21:41 +02:00
|
|
|
{
|
|
|
|
auto *combo = new QComboBox(this);
|
|
|
|
combo->addItems({"Dotted", "Solid"});
|
|
|
|
|
|
|
|
const auto currentIndex = []() -> int {
|
|
|
|
switch (getApp()->settings->lastMessagePattern.getValue()) {
|
|
|
|
case Qt::SolidLine: {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
case Qt::VerPattern: {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
combo->setCurrentIndex(currentIndex);
|
|
|
|
|
|
|
|
QObject::connect(combo,
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
[](int index) {
|
|
|
|
Qt::BrushStyle brush;
|
|
|
|
switch (index) {
|
|
|
|
case 1:
|
|
|
|
brush = Qt::SolidPattern;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
brush = Qt::VerPattern;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
getSettings()->lastMessagePattern = brush;
|
|
|
|
});
|
|
|
|
|
|
|
|
auto hbox = form.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
hbox.emplace<QLabel>("Last message indicator pattern");
|
|
|
|
hbox.append(combo);
|
|
|
|
}
|
2018-07-03 16:55:02 +02:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
form->addRow("Pause chat:",
|
|
|
|
this->createCheckBox(PAUSE_HOVERING, app->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",
|
2018-04-27 22:11:19 +02:00
|
|
|
app->settings->linksDoubleClickOnly));
|
2018-01-24 21:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
layout->addSpacing(16);
|
|
|
|
|
|
|
|
{
|
2018-03-30 15:42:59 +02:00
|
|
|
auto group = layout.emplace<QGroupBox>("Auto-completion");
|
|
|
|
auto groupLayout = group.setLayoutType<QFormLayout>();
|
|
|
|
groupLayout->addRow(
|
|
|
|
LIMIT_CHATTERS_FOR_SMALLER_STREAMERS,
|
2018-04-27 22:11:19 +02:00
|
|
|
this->createCheckBox("", app->settings->onlyFetchChattersForSmallerStreamers));
|
2018-03-30 15:42:59 +02:00
|
|
|
|
|
|
|
groupLayout->addRow("What viewer count counts as a \"smaller streamer\"",
|
2018-04-27 22:11:19 +02:00
|
|
|
this->createSpinBox(app->settings->smallStreamerLimit, 10, 50000));
|
2018-03-30 15:42:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2018-04-25 20:35:32 +02:00
|
|
|
auto group = layout.emplace<QGroupBox>("Misc");
|
|
|
|
auto groupLayout = group.setLayoutType<QVBoxLayout>();
|
|
|
|
|
2018-04-27 22:11:19 +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 *BehaviourPage::createMouseScrollSlider()
|
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-03-30 15:42:59 +02:00
|
|
|
auto slider = new QSlider(Qt::Horizontal);
|
2018-01-12 23:09:05 +01:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
float currentValue = app->settings->mouseScrollMultiplier;
|
2018-07-03 16:55:02 +02:00
|
|
|
int sliderValue = int(((currentValue - 0.1f) / 2.f) * 99.f);
|
2018-01-12 23:09:05 +01:00
|
|
|
slider->setValue(sliderValue);
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
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;
|
2018-04-27 22:11:19 +02:00
|
|
|
app->settings->mouseScrollMultiplier = newSliderValue;
|
2018-01-12 23:09:05 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return slider;
|
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-12 23:09:05 +01:00
|
|
|
} // namespace chatterino
|