diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index 3b23076bb..8f7ecbcbc 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -74,6 +74,9 @@ public: /// Links BoolSetting linksDoubleClickOnly = {"/links/doubleClickToOpen", false}; + /// Moderation + QStringSetting moderationActions = {"/moderation/actions", "/ban {user}\n/timeout {user} 300"}; + /// Highlighting BoolSetting enableHighlights = {"/highlighting/enabled", true}; BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword", true}; diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 3422dcd9d..a46b671b9 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -81,7 +81,7 @@ void SettingsDialog::addTabs() this->addTab(new settingspages::EmotesPage); this->addTab(new settingspages::HighlightingPage); // this->addTab(new settingspages::LogsPage); - // this->addTab(new settingspages::ModerationPage); + this->addTab(new settingspages::ModerationPage); this->ui.tabContainer->addStretch(1); this->addTab(new settingspages::AboutPage, Qt::AlignBottom); } diff --git a/src/widgets/settingspages/moderationpage.cpp b/src/widgets/settingspages/moderationpage.cpp index 20bbab24d..c1ab7157a 100644 --- a/src/widgets/settingspages/moderationpage.cpp +++ b/src/widgets/settingspages/moderationpage.cpp @@ -1,12 +1,47 @@ #include "moderationpage.hpp" +#include +#include +#include +#include +#include +#include + +#include "util/layoutcreator.hpp" + namespace chatterino { namespace widgets { namespace settingspages { ModerationPage::ModerationPage() - : SettingsPage("Moderation", ":/images/VSO_Link_blue_16x.png") + : SettingsPage("Moderation", "") { + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); + util::LayoutCreator layoutCreator(this); + + auto layout = layoutCreator.emplace().withoutMargin(); + { + // clang-format off + auto label = layout.emplace("In channels that you moderate there is a button to enable moderation mode."); + label->setWordWrap(true); + // clang-format on + + auto text = layout.emplace().getElement(); + + QObject::connect(text, &QTextEdit::textChanged, this, + [this] { this->itemsChangedTimer.start(200); }); + + QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, + [text, &settings]() { settings.moderationActions = text->toPlainText(); }); + + settings.highlightUserBlacklist.connect([=](const QString &str, auto) { + text->setPlainText(str); // + }); + } + + // ---- misc + this->itemsChangedTimer.setSingleShot(true); } + } // namespace settingspages } // namespace widgets } // namespace chatterino diff --git a/src/widgets/settingspages/moderationpage.hpp b/src/widgets/settingspages/moderationpage.hpp index bce2d7f7e..c6ebdbdc3 100644 --- a/src/widgets/settingspages/moderationpage.hpp +++ b/src/widgets/settingspages/moderationpage.hpp @@ -1,7 +1,11 @@ #pragma once +#include + #include "widgets/settingspages/settingspage.hpp" +class QPushButton; + namespace chatterino { namespace widgets { namespace settingspages { @@ -10,6 +14,9 @@ class ModerationPage : public SettingsPage { public: ModerationPage(); + +private: + QTimer itemsChangedTimer; }; } // namespace settingspages } // namespace widgets