mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added moderation action settings back in
This commit is contained in:
parent
7d4feb2781
commit
63a596ef16
|
@ -223,7 +223,8 @@ SOURCES += \
|
||||||
src/singletons/Resources.cpp \
|
src/singletons/Resources.cpp \
|
||||||
src/singletons/Settings.cpp \
|
src/singletons/Settings.cpp \
|
||||||
src/singletons/Updates.cpp \
|
src/singletons/Updates.cpp \
|
||||||
src/singletons/Theme.cpp
|
src/singletons/Theme.cpp \
|
||||||
|
src/controllers/moderationactions/ModerationActionModel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/Application.hpp \
|
src/Application.hpp \
|
||||||
|
@ -393,7 +394,8 @@ HEADERS += \
|
||||||
src/singletons/Theme.hpp \
|
src/singletons/Theme.hpp \
|
||||||
src/common/SimpleSignalVector.hpp \
|
src/common/SimpleSignalVector.hpp \
|
||||||
src/common/SignalVector.hpp \
|
src/common/SignalVector.hpp \
|
||||||
src/common/Singleton.hpp
|
src/common/Singleton.hpp \
|
||||||
|
src/controllers/moderationactions/ModerationActionModel.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc \
|
resources/resources.qrc \
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isImage_;
|
bool isImage_;
|
||||||
Image *image_;
|
Image *image_ = nullptr;
|
||||||
QString line1_;
|
QString line1_;
|
||||||
QString line2_;
|
QString line2_;
|
||||||
QString action_;
|
QString action_;
|
||||||
|
|
27
src/controllers/moderationactions/ModerationActionModel.cpp
Normal file
27
src/controllers/moderationactions/ModerationActionModel.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "ModerationActionModel.hpp"
|
||||||
|
|
||||||
|
#include "util/StandardItemHelper.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
// commandmodel
|
||||||
|
ModerationActionModel ::ModerationActionModel(QObject *parent)
|
||||||
|
: SignalVectorModel<ModerationAction>(1, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn a vector item into a model row
|
||||||
|
ModerationAction ModerationActionModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const ModerationAction &original)
|
||||||
|
{
|
||||||
|
return ModerationAction(row[0]->data(Qt::DisplayRole).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
void ModerationActionModel::getRowFromItem(const ModerationAction &item,
|
||||||
|
std::vector<QStandardItem *> &row)
|
||||||
|
{
|
||||||
|
setStringItem(row[0], item.getAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
31
src/controllers/moderationactions/ModerationActionModel.hpp
Normal file
31
src/controllers/moderationactions/ModerationActionModel.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "common/SignalVectorModel.hpp"
|
||||||
|
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class ModerationActions;
|
||||||
|
|
||||||
|
class ModerationActionModel : public SignalVectorModel<ModerationAction>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ModerationActionModel(QObject *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// turn a vector item into a model row
|
||||||
|
virtual ModerationAction getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const ModerationAction &original) override;
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
virtual void getRowFromItem(const ModerationAction &item,
|
||||||
|
std::vector<QStandardItem *> &row) override;
|
||||||
|
|
||||||
|
friend class HighlightController;
|
||||||
|
|
||||||
|
friend class ModerationActions;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ModerationActions.hpp"
|
#include "ModerationActions.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "controllers/moderationactions/ModerationActionModel.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
@ -25,4 +26,12 @@ void ModerationActions::initialize()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModerationActionModel *ModerationActions::createModel(QObject *parent)
|
||||||
|
{
|
||||||
|
ModerationActionModel *model = new ModerationActionModel(parent);
|
||||||
|
model->init(&this->items);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/ChatterinoSetting.hpp"
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||||
#include "common/ChatterinoSetting.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
class ModerationActionModel;
|
||||||
|
|
||||||
class ModerationActions
|
class ModerationActions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -15,6 +17,8 @@ public:
|
||||||
|
|
||||||
UnsortedSignalVector<ModerationAction> items;
|
UnsortedSignalVector<ModerationAction> items;
|
||||||
|
|
||||||
|
ModerationActionModel *createModel(QObject *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ChatterinoSetting<std::vector<ModerationAction>> setting = {"/moderation/actions"};
|
ChatterinoSetting<std::vector<ModerationAction>> setting = {"/moderation/actions"};
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
|
@ -247,7 +247,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElement::Flags _flags)
|
MessageElement::Flags _flags)
|
||||||
{
|
{
|
||||||
if (_flags & MessageElement::ModeratorTools) {
|
if (_flags & MessageElement::ModeratorTools) {
|
||||||
QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16));
|
QSize size(int(container.getScale() * 16), int(container.getScale() * 16));
|
||||||
|
|
||||||
for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) {
|
for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) {
|
||||||
if (m.isImage()) {
|
if (m.isImage()) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "ModerationPage.hpp"
|
#include "ModerationPage.hpp"
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "controllers/moderationactions/ModerationActionModel.hpp"
|
||||||
|
#include "controllers/moderationactions/ModerationActions.hpp"
|
||||||
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
#include "controllers/taggedusers/TaggedUsersController.hpp"
|
||||||
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
#include "controllers/taggedusers/TaggedUsersModel.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
|
@ -8,6 +10,7 @@
|
||||||
#include "util/LayoutCreator.hpp"
|
#include "util/LayoutCreator.hpp"
|
||||||
#include "widgets/helper/EditableModelView.hpp"
|
#include "widgets/helper/EditableModelView.hpp"
|
||||||
|
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -82,7 +85,7 @@ ModerationPage::ModerationPage()
|
||||||
// Logs end
|
// Logs end
|
||||||
}
|
}
|
||||||
|
|
||||||
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation mode");
|
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation buttons");
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto label = modMode.emplace<QLabel>("Click the moderation mod button (<img width='18' height='18' src=':/images/moderatormode_disabled.png'>) in a channel that you moderate to enable moderator mode.<br>");
|
auto label = modMode.emplace<QLabel>("Click the moderation mod button (<img width='18' height='18' src=':/images/moderatormode_disabled.png'>) in a channel that you moderate to enable moderator mode.<br>");
|
||||||
|
@ -97,26 +100,17 @@ ModerationPage::ModerationPage()
|
||||||
// app->settings->timeoutAction));
|
// app->settings->timeoutAction));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// auto modButtons =
|
EditableModelView *view =
|
||||||
// modMode.emplace<QGroupBox>("Custom moderator buttons").setLayoutType<QVBoxLayout>();
|
modMode.emplace<EditableModelView>(app->moderationActions->createModel(nullptr))
|
||||||
// {
|
.getElement();
|
||||||
// auto label2 =
|
|
||||||
// modButtons.emplace<QLabel>("One action per line. {user} will be replaced with the
|
|
||||||
// "
|
|
||||||
// "username.<br>Example `/timeout {user} 120`<br>");
|
|
||||||
// label2->setWordWrap(true);
|
|
||||||
|
|
||||||
// auto text = modButtons.emplace<QTextEdit>().getElement();
|
view->setTitles({"Actions"});
|
||||||
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
|
||||||
// text->setPlainText(app->moderationActions->items);
|
view->addButtonPressed.connect([] {
|
||||||
|
getApp()->moderationActions->items.appendItem(ModerationAction("/timeout {user} 300"));
|
||||||
// QObject::connect(text, &QTextEdit::textChanged, this,
|
});
|
||||||
// [this] { this->itemsChangedTimer.start(200); });
|
|
||||||
|
|
||||||
// QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() {
|
|
||||||
// app->windows->moderationActions = text->toPlainText();
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users");
|
/*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users");
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue