Add setting to not fetch chatters for bigger streamers

Work on #57
This commit is contained in:
Rasmus Karlsson 2018-03-30 15:42:59 +02:00 committed by fourtf
parent c0a3613ae0
commit 655831d154
5 changed files with 47 additions and 2 deletions

View file

@ -59,6 +59,15 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
};
auto doRefreshChatters = [=]() {
const auto streamStatus = this->GetStreamStatus();
auto &settingManager = singletons::SettingManager::getInstance();
if (settingManager.onlyFetchChattersForSmallerStreamers) {
if (streamStatus.live && streamStatus.viewerCount > settingManager.smallStreamerLimit) {
return;
}
}
util::twitch::get("https://tmi.twitch.tv/group/user/" + this->name + "/chatters",
QThread::currentThread(), refreshChatters);
};

View file

@ -50,6 +50,13 @@ public:
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
// Auto-completion
BoolSetting onlyFetchChattersForSmallerStreamers = {
"/behaviour/autocompletion/onlyFetchChattersForSmallerStreamers", true};
IntSetting smallStreamerLimit = {"/behaviour/autocompletion/smallStreamerLimit", 1000};
// Streamlink
QStringSetting streamlinkPath = {"/behaviour/streamlink/path", ""};
QStringSetting preferredQuality = {"/behaviour/streamlink/quality", "Choose"};
QStringSetting streamlinkOpts = {"/behaviour/streamlink/options", ""};

View file

@ -12,6 +12,8 @@
#define LAST_MSG "Show last read message indicator (marks the spot where you left the window)"
#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"
namespace chatterino {
@ -39,8 +41,19 @@ BehaviourPage::BehaviourPage()
layout->addSpacing(16);
auto group = layout.emplace<QGroupBox>("Streamlink");
{
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");
auto groupLayout = group.setLayoutType<QFormLayout>();
groupLayout->addRow("Streamlink path:", this->createLineEdit(settings.streamlinkPath));
groupLayout->addRow("Prefered quality:",
@ -53,7 +66,7 @@ BehaviourPage::BehaviourPage()
QSlider *BehaviourPage::createMouseScrollSlider()
{
QSlider *slider = new QSlider(Qt::Horizontal);
auto slider = new QSlider(Qt::Horizontal);
float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier;
int sliderValue = ((currentValue - 0.1f) / 2.f) * 99.f;

View file

@ -79,6 +79,20 @@ QLineEdit *SettingsPage::createLineEdit(pajlada::Settings::Setting<QString> &set
return edit;
}
QSpinBox *SettingsPage::createSpinBox(pajlada::Settings::Setting<int> &setting, int min, int max)
{
QSpinBox *w = new QSpinBox;
w->setMinimum(min);
w->setMaximum(max);
setting.connect([w](const int &value, auto) { w->setValue(value); });
QObject::connect(w, QOverload<int>::of(&QSpinBox::valueChanged),
[&setting](int value) { setting.setValue(value); });
return w;
}
} // namespace settingspages
} // namespace widgets
} // namespace chatterino

View file

@ -3,6 +3,7 @@
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QSpinBox>
#include <pajlada/signals/signal.hpp>
#include "singletons/settingsmanager.hpp"
@ -25,6 +26,7 @@ public:
QComboBox *createComboBox(const QStringList &items,
pajlada::Settings::Setting<QString> &setting);
QLineEdit *createLineEdit(pajlada::Settings::Setting<QString> &setting);
QSpinBox *createSpinBox(pajlada::Settings::Setting<int> &setting, int min = 0, int max = 2500);
protected:
QString name;