2018-01-23 21:33:49 +01:00
|
|
|
#include "ignoreuserspage.hpp"
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
#include "application.hpp"
|
2018-05-26 20:25:00 +02:00
|
|
|
#include "controllers/accounts/accountcontroller.hpp"
|
2018-05-13 19:24:32 +02:00
|
|
|
#include "controllers/ignores/ignorecontroller.hpp"
|
|
|
|
#include "controllers/ignores/ignoremodel.hpp"
|
2018-01-23 21:33:49 +01:00
|
|
|
#include "singletons/settingsmanager.hpp"
|
|
|
|
#include "util/layoutcreator.hpp"
|
2018-05-13 19:24:32 +02:00
|
|
|
#include "widgets/helper/editablemodelview.hpp"
|
2018-01-23 21:33:49 +01:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
2018-01-23 23:10:27 +01:00
|
|
|
#include <QGroupBox>
|
2018-01-23 21:33:49 +01:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QListView>
|
|
|
|
#include <QPushButton>
|
2018-05-13 19:24:32 +02:00
|
|
|
#include <QTableView>
|
2018-01-23 21:33:49 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
// clang-format off
|
2018-04-26 23:07:02 +02:00
|
|
|
#define INFO "/ignore <user> in chat ignores a user\n/unignore <user> in chat unignores a user"
|
2018-01-23 21:33:49 +01:00
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
namespace settingspages {
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-01-23 21:33:49 +01:00
|
|
|
IgnoreUsersPage::IgnoreUsersPage()
|
2018-04-26 23:07:02 +02:00
|
|
|
: SettingsPage("Ignores", "")
|
2018-01-23 21:33:49 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
|
|
|
|
2018-01-23 21:33:49 +01:00
|
|
|
util::LayoutCreator<IgnoreUsersPage> layoutCreator(this);
|
2018-01-23 21:56:25 +01:00
|
|
|
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
|
2018-01-23 21:33:49 +01:00
|
|
|
|
2018-04-27 01:11:09 +02:00
|
|
|
// auto group = layout.emplace<QGroupBox>("Ignored users").setLayoutType<QVBoxLayout>();
|
|
|
|
auto tabs = layout.emplace<QTabWidget>();
|
2018-05-28 08:34:54 +02:00
|
|
|
// tabs->setStyleSheet("color: #000");
|
2018-04-27 01:11:09 +02:00
|
|
|
|
|
|
|
// users
|
|
|
|
auto users = tabs.appendTab(new QVBoxLayout, "Users");
|
2018-01-23 21:33:49 +01:00
|
|
|
{
|
2018-04-28 13:48:49 +02:00
|
|
|
users.append(this->createCheckBox("Enable twitch ignored users",
|
2018-04-27 22:11:19 +02:00
|
|
|
app->settings->enableTwitchIgnoredUsers));
|
2018-01-23 23:10:27 +01:00
|
|
|
|
2018-04-27 01:11:09 +02:00
|
|
|
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
|
2018-01-23 23:10:27 +01:00
|
|
|
{
|
|
|
|
anyways.emplace<QLabel>("Show anyways if:");
|
|
|
|
anyways.emplace<QComboBox>();
|
|
|
|
anyways->addStretch(1);
|
|
|
|
}
|
|
|
|
|
2018-04-27 01:11:09 +02:00
|
|
|
auto addremove = users.emplace<QHBoxLayout>().withoutMargin();
|
2018-01-23 23:10:27 +01:00
|
|
|
{
|
|
|
|
auto add = addremove.emplace<QPushButton>("Ignore user");
|
|
|
|
auto remove = addremove.emplace<QPushButton>("Unignore User");
|
2018-04-14 21:59:51 +02:00
|
|
|
UNUSED(add); // TODO: Add on-clicked event
|
|
|
|
UNUSED(remove); // TODO: Add on-clicked event
|
2018-01-23 23:10:27 +01:00
|
|
|
addremove->addStretch(1);
|
|
|
|
}
|
|
|
|
|
2018-05-12 20:34:13 +02:00
|
|
|
users.emplace<QListView>()->setModel(&this->userListModel);
|
2018-01-23 21:33:49 +01:00
|
|
|
}
|
2018-04-26 23:07:02 +02:00
|
|
|
|
2018-04-27 01:11:09 +02:00
|
|
|
// messages
|
|
|
|
auto messages = tabs.appendTab(new QVBoxLayout, "Messages");
|
|
|
|
{
|
2018-05-13 19:24:32 +02:00
|
|
|
helper::EditableModelView *view =
|
|
|
|
*messages.emplace<helper::EditableModelView>(app->ignores->createModel(nullptr));
|
|
|
|
view->setTitles({"Pattern", "Regex"});
|
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
|
|
|
view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
|
|
|
|
|
|
// fourtf: make class extrend BaseWidget and add this to dpiChanged
|
|
|
|
QTimer::singleShot(1, [view] {
|
|
|
|
view->getTableView()->resizeColumnsToContents();
|
|
|
|
view->getTableView()->setColumnWidth(0, 200);
|
|
|
|
});
|
|
|
|
|
|
|
|
view->addButtonPressed.connect([] {
|
|
|
|
getApp()->ignores->phrases.appendItem(
|
|
|
|
controllers::ignores::IgnorePhrase{"my phrase", false});
|
|
|
|
});
|
2018-04-27 01:11:09 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 23:07:02 +02:00
|
|
|
auto label = layout.emplace<QLabel>(INFO);
|
|
|
|
label->setWordWrap(true);
|
|
|
|
label->setStyleSheet("color: #BBB");
|
2018-01-23 21:33:49 +01:00
|
|
|
}
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-05-12 20:34:13 +02:00
|
|
|
void IgnoreUsersPage::onShow()
|
|
|
|
{
|
|
|
|
auto app = getApp();
|
|
|
|
|
2018-05-26 20:26:25 +02:00
|
|
|
auto user = app->accounts->twitch.getCurrent();
|
2018-05-12 20:34:13 +02:00
|
|
|
|
|
|
|
if (user->isAnon()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList users;
|
|
|
|
for (const auto &ignoredUser : user->getIgnores()) {
|
|
|
|
users << ignoredUser.name;
|
|
|
|
}
|
|
|
|
this->userListModel.setStringList(users);
|
|
|
|
}
|
|
|
|
|
2018-01-23 21:33:49 +01:00
|
|
|
} // namespace settingspages
|
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|