mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
changed AccountManager to AccountController
This commit is contained in:
parent
b016f0fb88
commit
8c9be20f9b
|
@ -114,7 +114,6 @@ SOURCES += \
|
||||||
src/providers/twitch/twitchmessagebuilder.cpp \
|
src/providers/twitch/twitchmessagebuilder.cpp \
|
||||||
src/providers/twitch/twitchserver.cpp \
|
src/providers/twitch/twitchserver.cpp \
|
||||||
src/providers/twitch/pubsub.cpp \
|
src/providers/twitch/pubsub.cpp \
|
||||||
src/singletons/accountmanager.cpp \
|
|
||||||
src/singletons/commandmanager.cpp \
|
src/singletons/commandmanager.cpp \
|
||||||
src/singletons/emotemanager.cpp \
|
src/singletons/emotemanager.cpp \
|
||||||
src/singletons/fontmanager.cpp \
|
src/singletons/fontmanager.cpp \
|
||||||
|
@ -209,7 +208,10 @@ SOURCES += \
|
||||||
src/widgets/helper/splitoverlay.cpp \
|
src/widgets/helper/splitoverlay.cpp \
|
||||||
src/widgets/helper/dropoverlay.cpp \
|
src/widgets/helper/dropoverlay.cpp \
|
||||||
src/widgets/helper/splitnode.cpp \
|
src/widgets/helper/splitnode.cpp \
|
||||||
src/widgets/notificationpopup.cpp
|
src/widgets/notificationpopup.cpp \
|
||||||
|
src/controllers/taggedusers/taggeduserscontroller.cpp \
|
||||||
|
src/controllers/taggedusers/taggeduser.cpp \
|
||||||
|
src/controllers/taggedusers/taggedusersmodel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_header.hpp \
|
src/precompiled_header.hpp \
|
||||||
|
@ -238,7 +240,6 @@ HEADERS += \
|
||||||
src/providers/twitch/twitchmessagebuilder.hpp \
|
src/providers/twitch/twitchmessagebuilder.hpp \
|
||||||
src/providers/twitch/twitchserver.hpp \
|
src/providers/twitch/twitchserver.hpp \
|
||||||
src/providers/twitch/pubsub.hpp \
|
src/providers/twitch/pubsub.hpp \
|
||||||
src/singletons/accountmanager.hpp \
|
|
||||||
src/singletons/commandmanager.hpp \
|
src/singletons/commandmanager.hpp \
|
||||||
src/singletons/emotemanager.hpp \
|
src/singletons/emotemanager.hpp \
|
||||||
src/singletons/fontmanager.hpp \
|
src/singletons/fontmanager.hpp \
|
||||||
|
@ -359,7 +360,11 @@ HEADERS += \
|
||||||
src/widgets/helper/dropoverlay.hpp \
|
src/widgets/helper/dropoverlay.hpp \
|
||||||
src/widgets/helper/splitnode.hpp \
|
src/widgets/helper/splitnode.hpp \
|
||||||
src/widgets/notificationpopup.hpp \
|
src/widgets/notificationpopup.hpp \
|
||||||
src/util/mutexvalue.h
|
src/util/mutexvalue.h \
|
||||||
|
src/controllers/taggedusers/taggeduserscontroller.hpp \
|
||||||
|
src/controllers/taggedusers/taggeduser.hpp \
|
||||||
|
src/providerid.hpp \
|
||||||
|
src/controllers/taggedusers/taggedusersmodel.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "controllers/commands/commandcontroller.hpp"
|
#include "controllers/commands/commandcontroller.hpp"
|
||||||
#include "controllers/highlights/highlightcontroller.hpp"
|
#include "controllers/highlights/highlightcontroller.hpp"
|
||||||
#include "controllers/ignores/ignorecontroller.hpp"
|
#include "controllers/ignores/ignorecontroller.hpp"
|
||||||
|
#include "controllers/taggedusers/taggeduserscontroller.hpp"
|
||||||
#include "providers/twitch/pubsub.hpp"
|
#include "providers/twitch/pubsub.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/loggingmanager.hpp"
|
#include "singletons/loggingmanager.hpp"
|
||||||
|
@ -69,7 +70,8 @@ void Application::construct()
|
||||||
this->commands = new controllers::commands::CommandController;
|
this->commands = new controllers::commands::CommandController;
|
||||||
this->highlights = new controllers::highlights::HighlightController;
|
this->highlights = new controllers::highlights::HighlightController;
|
||||||
this->ignores = new controllers::ignores::IgnoreController;
|
this->ignores = new controllers::ignores::IgnoreController;
|
||||||
this->accounts = new singletons::AccountManager;
|
this->taggedUsers = new controllers::taggedusers::TaggedUsersController;
|
||||||
|
this->accounts = new controllers::accounts::AccountController;
|
||||||
this->emotes = new singletons::EmoteManager;
|
this->emotes = new singletons::EmoteManager;
|
||||||
this->fonts = new singletons::FontManager;
|
this->fonts = new singletons::FontManager;
|
||||||
this->resources = new singletons::ResourceManager;
|
this->resources = new singletons::ResourceManager;
|
||||||
|
|
|
@ -26,6 +26,12 @@ class HighlightController;
|
||||||
namespace ignores {
|
namespace ignores {
|
||||||
class IgnoreController;
|
class IgnoreController;
|
||||||
}
|
}
|
||||||
|
namespace taggedusers {
|
||||||
|
class TaggedUsersController;
|
||||||
|
}
|
||||||
|
namespace accounts {
|
||||||
|
class AccountController;
|
||||||
|
}
|
||||||
} // namespace controllers
|
} // namespace controllers
|
||||||
|
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
@ -67,7 +73,8 @@ public:
|
||||||
controllers::commands::CommandController *commands = nullptr;
|
controllers::commands::CommandController *commands = nullptr;
|
||||||
controllers::highlights::HighlightController *highlights = nullptr;
|
controllers::highlights::HighlightController *highlights = nullptr;
|
||||||
controllers::ignores::IgnoreController *ignores = nullptr;
|
controllers::ignores::IgnoreController *ignores = nullptr;
|
||||||
singletons::AccountManager *accounts = nullptr;
|
controllers::taggedusers::TaggedUsersController *taggedUsers = nullptr;
|
||||||
|
controllers::accounts::AccountController *accounts = nullptr;
|
||||||
singletons::EmoteManager *emotes = nullptr;
|
singletons::EmoteManager *emotes = nullptr;
|
||||||
singletons::NativeMessagingManager *nativeMessaging = nullptr;
|
singletons::NativeMessagingManager *nativeMessaging = nullptr;
|
||||||
singletons::SettingManager *settings = nullptr;
|
singletons::SettingManager *settings = nullptr;
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "account.hpp"
|
#include "account.hpp"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace controllers {
|
namespace controllers {
|
||||||
namespace accounts {
|
namespace accounts {
|
||||||
|
|
||||||
Account::Account(const QString &category)
|
Account::Account(const QString &_category)
|
||||||
|
: category(_category)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,14 +18,10 @@ const QString &Account::getCategory() const
|
||||||
|
|
||||||
bool Account::operator<(const Account &other) const
|
bool Account::operator<(const Account &other) const
|
||||||
{
|
{
|
||||||
if (this->category < other.category) {
|
QString a = this->toString();
|
||||||
return true;
|
QString b = other.toString();
|
||||||
} else if (this->category == other.category) {
|
|
||||||
if (this->toString() < other.toString()) {
|
return std::tie(this->category, a) < std::tie(other.category, b);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace accounts
|
} // namespace accounts
|
||||||
|
|
|
@ -10,6 +10,11 @@ AccountController::AccountController()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountController::load()
|
||||||
|
{
|
||||||
|
this->Twitch.load();
|
||||||
|
}
|
||||||
|
|
||||||
AccountModel *AccountController::createModel(QObject *parent)
|
AccountModel *AccountController::createModel(QObject *parent)
|
||||||
{
|
{
|
||||||
AccountModel *model = new AccountModel(parent);
|
AccountModel *model = new AccountModel(parent);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "controllers/accounts/account.hpp"
|
#include "controllers/accounts/account.hpp"
|
||||||
|
#include "providers/twitch/twitchaccountmanager.hpp"
|
||||||
#include "util/sharedptrelementless.hpp"
|
#include "util/sharedptrelementless.hpp"
|
||||||
#include "util/signalvector2.hpp"
|
#include "util/signalvector2.hpp"
|
||||||
|
|
||||||
|
@ -19,6 +20,10 @@ public:
|
||||||
|
|
||||||
AccountModel *createModel(QObject *parent);
|
AccountModel *createModel(QObject *parent);
|
||||||
|
|
||||||
|
void load();
|
||||||
|
|
||||||
|
providers::twitch::TwitchAccountManager Twitch;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
util::SortedSignalVector<std::shared_ptr<Account>, util::SharedPtrElementLess<Account>>
|
util::SortedSignalVector<std::shared_ptr<Account>, util::SharedPtrElementLess<Account>>
|
||||||
accounts;
|
accounts;
|
||||||
|
|
|
@ -10,9 +10,10 @@ AccountModel::AccountModel(QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
std::shared_ptr<Account> AccountModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
std::shared_ptr<Account> AccountModel::getItemFromRow(std::vector<QStandardItem *> &,
|
||||||
|
const std::shared_ptr<Account> &original)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
|
|
|
@ -16,7 +16,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
virtual std::shared_ptr<Account> getItemFromRow(std::vector<QStandardItem *> &row) override;
|
virtual std::shared_ptr<Account> getItemFromRow(
|
||||||
|
std::vector<QStandardItem *> &row, const std::shared_ptr<Account> &original) override;
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
virtual void getRowFromItem(const std::shared_ptr<Account> &item,
|
virtual void getRowFromItem(const std::shared_ptr<Account> &item,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "commandcontroller.hpp"
|
#include "commandcontroller.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "controllers/commands/command.hpp"
|
#include "controllers/commands/command.hpp"
|
||||||
#include "controllers/commands/commandmodel.hpp"
|
#include "controllers/commands/commandmodel.hpp"
|
||||||
#include "messages/messagebuilder.hpp"
|
#include "messages/messagebuilder.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "util/signalvector2.hpp"
|
#include "util/signalvector2.hpp"
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ CommandModel::CommandModel(QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row, const Command &original)
|
||||||
{
|
{
|
||||||
return Command(row[0]->data(Qt::EditRole).toString(), row[1]->data(Qt::EditRole).toString());
|
return Command(row[0]->data(Qt::EditRole).toString(), row[1]->data(Qt::EditRole).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ class CommandModel : public util::SignalVectorModel<Command>
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
virtual Command getItemFromRow(std::vector<QStandardItem *> &row) override;
|
virtual Command getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const Command &command) override;
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
virtual void getRowFromItem(const Command &item, std::vector<QStandardItem *> &row) override;
|
virtual void getRowFromItem(const Command &item, std::vector<QStandardItem *> &row) override;
|
||||||
|
|
|
@ -22,7 +22,6 @@ void HighlightController::initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
this->phrases.delayedItemsChanged.connect([this] { //
|
this->phrases.delayedItemsChanged.connect([this] { //
|
||||||
int xd = this->phrases.getVector().size();
|
|
||||||
this->highlightsSetting.setValue(this->phrases.getVector());
|
this->highlightsSetting.setValue(this->phrases.getVector());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ HighlightModel::HighlightModel(QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const HighlightPhrase &original)
|
||||||
{
|
{
|
||||||
// key, alert, sound, regex
|
// key, alert, sound, regex
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ class HighlightModel : public util::SignalVectorModel<HighlightPhrase>
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row) override;
|
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const HighlightPhrase &original) override;
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
virtual void getRowFromItem(const HighlightPhrase &item,
|
virtual void getRowFromItem(const HighlightPhrase &item,
|
||||||
|
|
|
@ -15,7 +15,8 @@ IgnoreModel::IgnoreModel(QObject *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
IgnorePhrase IgnoreModel::getItemFromRow(std::vector<QStandardItem *> &row)
|
IgnorePhrase IgnoreModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const IgnorePhrase &original)
|
||||||
{
|
{
|
||||||
// key, regex
|
// key, regex
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ class IgnoreModel : public util::SignalVectorModel<IgnorePhrase>
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
virtual IgnorePhrase getItemFromRow(std::vector<QStandardItem *> &row) override;
|
virtual IgnorePhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const IgnorePhrase &original) override;
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
virtual void getRowFromItem(const IgnorePhrase &item,
|
virtual void getRowFromItem(const IgnorePhrase &item,
|
||||||
|
|
24
src/controllers/taggedusers/taggeduser.cpp
Normal file
24
src/controllers/taggedusers/taggeduser.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#include "taggeduser.hpp"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
TaggedUser::TaggedUser(ProviderId _provider, const QString &_name, const QString &_id)
|
||||||
|
: provider(_provider)
|
||||||
|
, name(_name)
|
||||||
|
, id(_id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TaggedUser::operator<(const TaggedUser &other) const
|
||||||
|
{
|
||||||
|
return std::tie(this->provider, this->name, this->id) <
|
||||||
|
std::tie(other.provider, other.name, other.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
24
src/controllers/taggedusers/taggeduser.hpp
Normal file
24
src/controllers/taggedusers/taggeduser.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <providerid.hpp>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
class TaggedUser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TaggedUser(ProviderId provider, const QString &name, const QString &id);
|
||||||
|
|
||||||
|
bool operator<(const TaggedUser &other) const;
|
||||||
|
|
||||||
|
ProviderId provider;
|
||||||
|
QString name;
|
||||||
|
QString id;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
23
src/controllers/taggedusers/taggeduserscontroller.cpp
Normal file
23
src/controllers/taggedusers/taggeduserscontroller.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include "taggeduserscontroller.hpp"
|
||||||
|
|
||||||
|
#include "controllers/taggedusers/taggedusersmodel.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
TaggedUsersController::TaggedUsersController()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TaggedUsersModel *TaggedUsersController::createModel(QObject *parent)
|
||||||
|
{
|
||||||
|
TaggedUsersModel *model = new TaggedUsersModel(parent);
|
||||||
|
model->init(&this->users);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
24
src/controllers/taggedusers/taggeduserscontroller.hpp
Normal file
24
src/controllers/taggedusers/taggeduserscontroller.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "controllers/taggedusers/taggeduser.hpp"
|
||||||
|
#include "util/signalvector2.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
class TaggedUsersModel;
|
||||||
|
|
||||||
|
class TaggedUsersController
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TaggedUsersController();
|
||||||
|
|
||||||
|
util::SortedSignalVector<TaggedUser, std::less<TaggedUser>> users;
|
||||||
|
|
||||||
|
TaggedUsersModel *createModel(QObject *parent = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
66
src/controllers/taggedusers/taggedusersmodel.cpp
Normal file
66
src/controllers/taggedusers/taggedusersmodel.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#include "taggedusersmodel.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
|
#include "util/standarditemhelper.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
// commandmodel
|
||||||
|
TaggedUsersModel::TaggedUsersModel(QObject *parent)
|
||||||
|
: util::SignalVectorModel<TaggedUser>(1, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn a vector item into a model row
|
||||||
|
TaggedUser TaggedUsersModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const TaggedUser &original)
|
||||||
|
{
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStandardItem *> &row)
|
||||||
|
{
|
||||||
|
util::setStringItem(row[0], item.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TaggedUsersModel::afterInit()
|
||||||
|
{
|
||||||
|
// std::vector<QStandardItem *> row = this->createRow();
|
||||||
|
// util::setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true,
|
||||||
|
// false); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||||
|
// util::setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true,
|
||||||
|
// false); util::setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
|
||||||
|
// true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// void TaggedUserModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||||
|
// const QVariant &value, int role)
|
||||||
|
//{
|
||||||
|
// switch (column) {
|
||||||
|
// case 0: {
|
||||||
|
// if (role == Qt::CheckStateRole) {
|
||||||
|
// getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
||||||
|
// }
|
||||||
|
// } break;
|
||||||
|
// case 1: {
|
||||||
|
// if (role == Qt::CheckStateRole) {
|
||||||
|
// getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
||||||
|
// }
|
||||||
|
// } break;
|
||||||
|
// case 2: {
|
||||||
|
// if (role == Qt::CheckStateRole) {
|
||||||
|
// getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
||||||
|
// }
|
||||||
|
// } break;
|
||||||
|
// case 3: {
|
||||||
|
// // empty element
|
||||||
|
// } break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
34
src/controllers/taggedusers/taggedusersmodel.hpp
Normal file
34
src/controllers/taggedusers/taggedusersmodel.hpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "controllers/taggedusers/taggeduser.hpp"
|
||||||
|
#include "util/signalvectormodel.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
|
namespace taggedusers {
|
||||||
|
|
||||||
|
class TaggedUsersController;
|
||||||
|
|
||||||
|
class TaggedUsersModel : public util::SignalVectorModel<TaggedUser>
|
||||||
|
{
|
||||||
|
explicit TaggedUsersModel(QObject *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// turn a vector item into a model row
|
||||||
|
virtual TaggedUser getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const TaggedUser &original) override;
|
||||||
|
|
||||||
|
// turns a row in the model into a vector item
|
||||||
|
virtual void getRowFromItem(const TaggedUser &item, std::vector<QStandardItem *> &row) override;
|
||||||
|
|
||||||
|
virtual void afterInit() override;
|
||||||
|
|
||||||
|
// virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||||
|
// const QVariant &value, int role) override;
|
||||||
|
|
||||||
|
friend class TaggedUsersController;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace taggedusers
|
||||||
|
} // namespace controllers
|
||||||
|
} // namespace chatterino
|
5
src/providerid.hpp
Normal file
5
src/providerid.hpp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
enum class ProviderId { Twitch };
|
||||||
|
}
|
|
@ -3,7 +3,6 @@
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "providers/twitch/pubsubactions.hpp"
|
#include "providers/twitch/pubsubactions.hpp"
|
||||||
#include "providers/twitch/pubsubhelpers.hpp"
|
#include "providers/twitch/pubsubhelpers.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "util/rapidjson-helpers.hpp"
|
#include "util/rapidjson-helpers.hpp"
|
||||||
|
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "providers/twitch/pubsubhelpers.hpp"
|
#include "providers/twitch/pubsubhelpers.hpp"
|
||||||
|
|
||||||
#include "providers/twitch/pubsubactions.hpp"
|
#include "providers/twitch/pubsubactions.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "util/rapidjson-helpers.hpp"
|
#include "util/rapidjson-helpers.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
|
@ -15,10 +15,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
namespace controllers {
|
||||||
namespace singletons {
|
namespace accounts {
|
||||||
class AccountManager;
|
class AccountController;
|
||||||
} // namespace singletons
|
}
|
||||||
|
} // namespace controllers
|
||||||
|
|
||||||
namespace providers {
|
namespace providers {
|
||||||
namespace twitch {
|
namespace twitch {
|
||||||
|
@ -70,7 +71,7 @@ private:
|
||||||
std::vector<std::shared_ptr<TwitchAccount>> users;
|
std::vector<std::shared_ptr<TwitchAccount>> users;
|
||||||
mutable std::mutex mutex;
|
mutable std::mutex mutex;
|
||||||
|
|
||||||
friend class chatterino::singletons::AccountManager;
|
friend class chatterino::controllers::accounts::AccountController;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace twitch
|
} // namespace twitch
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "providers/twitch/pubsub.hpp"
|
#include "providers/twitch/pubsub.hpp"
|
||||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "controllers/highlights/highlightcontroller.hpp"
|
#include "controllers/highlights/highlightcontroller.hpp"
|
||||||
#include "controllers/ignores/ignorecontroller.hpp"
|
#include "controllers/ignores/ignorecontroller.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/resourcemanager.hpp"
|
#include "singletons/resourcemanager.hpp"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "twitchserver.hpp"
|
#include "twitchserver.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "controllers/highlights/highlightcontroller.hpp"
|
#include "controllers/highlights/highlightcontroller.hpp"
|
||||||
#include "providers/twitch/ircmessagehandler.hpp"
|
#include "providers/twitch/ircmessagehandler.hpp"
|
||||||
#include "providers/twitch/twitchaccount.hpp"
|
#include "providers/twitch/twitchaccount.hpp"
|
||||||
#include "providers/twitch/twitchhelpers.hpp"
|
#include "providers/twitch/twitchhelpers.hpp"
|
||||||
#include "providers/twitch/twitchmessagebuilder.hpp"
|
#include "providers/twitch/twitchmessagebuilder.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "util/posttothread.hpp"
|
#include "util/posttothread.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
namespace singletons {
|
|
||||||
|
|
||||||
void AccountManager::load()
|
|
||||||
{
|
|
||||||
this->Twitch.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace singletons
|
|
||||||
} // namespace chatterino
|
|
|
@ -1,21 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "providers/twitch/twitchaccountmanager.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
namespace singletons {
|
|
||||||
|
|
||||||
class AccountManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AccountManager() = default;
|
|
||||||
|
|
||||||
~AccountManager() = delete;
|
|
||||||
|
|
||||||
void load();
|
|
||||||
|
|
||||||
providers::twitch::TwitchAccountManager Twitch;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace singletons
|
|
||||||
} // namespace chatterino
|
|
|
@ -107,15 +107,14 @@ template <typename TVectorItem, typename Compare>
|
||||||
class SortedSignalVector : public BaseSignalVector<TVectorItem>
|
class SortedSignalVector : public BaseSignalVector<TVectorItem>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int insertItem(const TVectorItem &item, int proposedIndex = -1,
|
virtual int insertItem(const TVectorItem &item, int = -1, void *caller = nullptr) override
|
||||||
void *caller = 0) override
|
|
||||||
{
|
{
|
||||||
util::assertInGuiThread();
|
util::assertInGuiThread();
|
||||||
|
|
||||||
int index =
|
auto it = std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{});
|
||||||
this->vector.insert(
|
int index = it - this->vector.begin();
|
||||||
std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{}), item) -
|
this->vector.insert(it, item);
|
||||||
this->vector.begin();
|
|
||||||
typename ReadOnlySignalVector<TVectorItem>::ItemArgs args{item, index, caller};
|
typename ReadOnlySignalVector<TVectorItem>::ItemArgs args{item, index, caller};
|
||||||
this->itemInserted.invoke(args);
|
this->itemInserted.invoke(args);
|
||||||
this->invokeDelayedItemsChanged();
|
this->invokeDelayedItemsChanged();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
#include <boost/optional.hpp>
|
||||||
#include <util/signalvector2.hpp>
|
#include <util/signalvector2.hpp>
|
||||||
|
|
||||||
#include <pajlada/signals/signalholder.hpp>
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
|
@ -43,7 +44,7 @@ public:
|
||||||
index = this->beforeInsert(args.item, row, index);
|
index = this->beforeInsert(args.item, row, index);
|
||||||
|
|
||||||
this->beginInsertRows(QModelIndex(), index, index);
|
this->beginInsertRows(QModelIndex(), index, index);
|
||||||
this->rows.insert(this->rows.begin() + index, Row(row));
|
this->rows.insert(this->rows.begin() + index, Row(row, args.item));
|
||||||
this->endInsertRows();
|
this->endInsertRows();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +118,10 @@ public:
|
||||||
} else {
|
} else {
|
||||||
int vecRow = this->getVectorIndexFromModelIndex(row);
|
int vecRow = this->getVectorIndexFromModelIndex(row);
|
||||||
this->vector->removeItem(vecRow, this);
|
this->vector->removeItem(vecRow, this);
|
||||||
TVectorItem item = this->getItemFromRow(this->rows[row].items);
|
|
||||||
|
assert(this->rows[row].original);
|
||||||
|
TVectorItem item =
|
||||||
|
this->getItemFromRow(this->rows[row].items, this->rows[row].original.get());
|
||||||
this->vector->insertItem(item, vecRow, this);
|
this->vector->insertItem(item, vecRow, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +196,8 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn a vector item into a model row
|
// turn a vector item into a model row
|
||||||
virtual TVectorItem getItemFromRow(std::vector<QStandardItem *> &row) = 0;
|
virtual TVectorItem getItemFromRow(std::vector<QStandardItem *> &row,
|
||||||
|
const TVectorItem &original) = 0;
|
||||||
|
|
||||||
// turns a row in the model into a vector item
|
// turns a row in the model into a vector item
|
||||||
virtual void getRowFromItem(const TVectorItem &item, std::vector<QStandardItem *> &row) = 0;
|
virtual void getRowFromItem(const TVectorItem &item, std::vector<QStandardItem *> &row) = 0;
|
||||||
|
@ -232,6 +237,7 @@ protected:
|
||||||
|
|
||||||
struct Row {
|
struct Row {
|
||||||
std::vector<QStandardItem *> items;
|
std::vector<QStandardItem *> items;
|
||||||
|
boost::optional<TVectorItem> original;
|
||||||
bool isCustomRow;
|
bool isCustomRow;
|
||||||
|
|
||||||
Row(std::vector<QStandardItem *> _items, bool _isCustomRow = false)
|
Row(std::vector<QStandardItem *> _items, bool _isCustomRow = false)
|
||||||
|
@ -239,6 +245,14 @@ protected:
|
||||||
, isCustomRow(_isCustomRow)
|
, isCustomRow(_isCustomRow)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row(std::vector<QStandardItem *> _items, const TVectorItem &_original,
|
||||||
|
bool _isCustomRow = false)
|
||||||
|
: items(std::move(_items))
|
||||||
|
, original(_original)
|
||||||
|
, isCustomRow(_isCustomRow)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
std::vector<Row> rows;
|
std::vector<Row> rows;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "util/networkmanager.hpp"
|
#include "util/networkmanager.hpp"
|
||||||
#include "util/networkrequest.hpp"
|
#include "util/networkrequest.hpp"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "credentials.hpp"
|
#include "credentials.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "ui_accountpopupform.h"
|
#include "ui_accountpopupform.h"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "emotepopup.hpp"
|
#include "emotepopup.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "messages/messagebuilder.hpp"
|
#include "messages/messagebuilder.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "widgets/notebook.hpp"
|
#include "widgets/notebook.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
|
@ -2,11 +2,17 @@
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "const.hpp"
|
#include "const.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
|
#include "controllers/accounts/accountmodel.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
#include "widgets/helper/editablemodelview.hpp"
|
||||||
#include "widgets/logindialog.hpp"
|
#include "widgets/logindialog.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QTableView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -16,32 +22,42 @@ namespace settingspages {
|
||||||
AccountsPage::AccountsPage()
|
AccountsPage::AccountsPage()
|
||||||
: SettingsPage("Accounts", ":/images/accounts.svg")
|
: SettingsPage("Accounts", ":/images/accounts.svg")
|
||||||
{
|
{
|
||||||
|
auto *app = getApp();
|
||||||
|
|
||||||
util::LayoutCreator<AccountsPage> layoutCreator(this);
|
util::LayoutCreator<AccountsPage> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
||||||
auto buttons = layout.emplace<QDialogButtonBox>();
|
|
||||||
{
|
|
||||||
this->addButton = buttons->addButton("Add", QDialogButtonBox::YesRole);
|
|
||||||
this->removeButton = buttons->addButton("Remove", QDialogButtonBox::NoRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget);
|
helper::EditableModelView *view =
|
||||||
|
*layout.emplace<helper::EditableModelView>(app->accounts->createModel(nullptr));
|
||||||
|
|
||||||
|
view->setTitles({"Name"});
|
||||||
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
|
view->addButtonPressed.connect([] {});
|
||||||
|
|
||||||
|
// auto buttons = layout.emplace<QDialogButtonBox>();
|
||||||
|
// {
|
||||||
|
// this->addButton = buttons->addButton("Add", QDialogButtonBox::YesRole);
|
||||||
|
// this->removeButton = buttons->addButton("Remove", QDialogButtonBox::NoRole);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// layout.emplace<AccountSwitchWidget>(this).assign(&this->accSwitchWidget);
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
QObject::connect(this->addButton, &QPushButton::clicked, []() {
|
// QObject::connect(this->addButton, &QPushButton::clicked, []() {
|
||||||
static auto loginWidget = new LoginWidget();
|
// static auto loginWidget = new LoginWidget();
|
||||||
loginWidget->show();
|
// loginWidget->show();
|
||||||
});
|
// });
|
||||||
|
|
||||||
QObject::connect(this->removeButton, &QPushButton::clicked, [this] {
|
// QObject::connect(this->removeButton, &QPushButton::clicked, [this] {
|
||||||
auto selectedUser = this->accSwitchWidget->currentItem()->text();
|
// auto selectedUser = this->accSwitchWidget->currentItem()->text();
|
||||||
if (selectedUser == ANONYMOUS_USERNAME_LABEL) {
|
// if (selectedUser == ANONYMOUS_USERNAME_LABEL) {
|
||||||
// Do nothing
|
// // Do nothing
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
getApp()->accounts->Twitch.removeUser(selectedUser);
|
// getApp()->accounts->Twitch.removeUser(selectedUser);
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace settingspages
|
} // namespace settingspages
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "ignoreuserspage.hpp"
|
#include "ignoreuserspage.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "controllers/ignores/ignorecontroller.hpp"
|
#include "controllers/ignores/ignorecontroller.hpp"
|
||||||
#include "controllers/ignores/ignoremodel.hpp"
|
#include "controllers/ignores/ignoremodel.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
#include "widgets/helper/editablemodelview.hpp"
|
#include "widgets/helper/editablemodelview.hpp"
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
#include "moderationpage.hpp"
|
#include "moderationpage.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
|
#include "controllers/taggedusers/taggeduserscontroller.hpp"
|
||||||
|
#include "controllers/taggedusers/taggedusersmodel.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
#include "widgets/helper/editablemodelview.hpp"
|
||||||
|
|
||||||
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTableView>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -32,37 +38,41 @@ ModerationPage::ModerationPage()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
util::LayoutCreator<ModerationPage> layoutCreator(this);
|
util::LayoutCreator<ModerationPage> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
auto tabs = layoutCreator.emplace<QTabWidget>();
|
||||||
|
|
||||||
|
auto logs = tabs.appendTab(new QVBoxLayout, "Logs");
|
||||||
{
|
{
|
||||||
// Logs (copied from LoggingMananger)
|
|
||||||
auto logPath = app->paths->logsFolderPath;
|
auto logPath = app->paths->logsFolderPath;
|
||||||
|
|
||||||
auto created = layout.emplace<QLabel>();
|
auto created = logs.emplace<QLabel>();
|
||||||
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
created->setText("Logs are saved to " + CreateLink(logPath, true));
|
||||||
created->setTextFormat(Qt::RichText);
|
created->setTextFormat(Qt::RichText);
|
||||||
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
created->setTextInteractionFlags(Qt::TextBrowserInteraction |
|
||||||
Qt::LinksAccessibleByKeyboard |
|
Qt::LinksAccessibleByKeyboard |
|
||||||
Qt::LinksAccessibleByKeyboard);
|
Qt::LinksAccessibleByKeyboard);
|
||||||
created->setOpenExternalLinks(true);
|
created->setOpenExternalLinks(true);
|
||||||
layout.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
|
logs.append(this->createCheckBox("Enable logging", app->settings->enableLogging));
|
||||||
|
|
||||||
layout->addStretch(1);
|
logs->addStretch(1);
|
||||||
// Logs end
|
}
|
||||||
|
|
||||||
|
auto modMode = tabs.appendTab(new QVBoxLayout, "Moderation mode");
|
||||||
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto label = layout.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>");
|
||||||
label->setWordWrap(true);
|
label->setWordWrap(true);
|
||||||
label->setStyleSheet("color: #bbb");
|
label->setStyleSheet("color: #bbb");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
auto form = layout.emplace<QFormLayout>();
|
// auto form = modMode.emplace<QFormLayout>();
|
||||||
{
|
// {
|
||||||
form->addRow("Action on timed out messages (unimplemented):",
|
// form->addRow("Action on timed out messages (unimplemented):",
|
||||||
this->createComboBox({"Disable", "Hide"}, app->settings->timeoutAction));
|
// this->createComboBox({"Disable", "Hide"},
|
||||||
}
|
// app->settings->timeoutAction));
|
||||||
|
// }
|
||||||
|
|
||||||
auto modButtons =
|
auto modButtons =
|
||||||
layout.emplace<QGroupBox>("Custom moderator buttons").setLayoutType<QVBoxLayout>();
|
modMode.emplace<QGroupBox>("Custom moderator buttons").setLayoutType<QVBoxLayout>();
|
||||||
{
|
{
|
||||||
auto label2 =
|
auto label2 =
|
||||||
modButtons.emplace<QLabel>("One action per line. {user} will be replaced with the "
|
modButtons.emplace<QLabel>("One action per line. {user} will be replaced with the "
|
||||||
|
@ -80,6 +90,20 @@ ModerationPage::ModerationPage()
|
||||||
app->settings->moderationActions = text->toPlainText();
|
app->settings->moderationActions = text->toPlainText();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users");
|
||||||
|
{
|
||||||
|
helper::EditableModelView *view = *taggedUsers.emplace<helper::EditableModelView>(
|
||||||
|
app->taggedUsers->createModel(nullptr));
|
||||||
|
|
||||||
|
view->setTitles({"Name"});
|
||||||
|
view->getTableView()->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
|
view->addButtonPressed.connect([] {
|
||||||
|
getApp()->taggedUsers->users.appendItem(
|
||||||
|
controllers::taggedusers::TaggedUser(ProviderId::Twitch, "example", "xD"));
|
||||||
|
});
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- misc
|
// ---- misc
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "widgets/window.hpp"
|
#include "widgets/window.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "controllers/accounts/accountcontroller.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
Loading…
Reference in a new issue