diff --git a/chatterino.pro b/chatterino.pro index 445940de6..56ba15b98 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -404,7 +404,7 @@ HEADERS += \ src/widgets/settingspages/FeelPage.hpp \ src/util/InitUpdateButton.hpp \ src/widgets/dialogs/UpdateDialog.hpp \ - src/widgets/settingspages/IgnorePage.hpp + src/widgets/settingspages/IgnoresPage.hpp RESOURCES += \ resources/resources.qrc \ diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 5b7ee094c..4925c2896 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -11,7 +11,7 @@ #include "widgets/settingspages/ExternalToolsPage.hpp" #include "widgets/settingspages/FeelPage.hpp" #include "widgets/settingspages/HighlightingPage.hpp" -#include "widgets/settingspages/IgnorePage.hpp" +#include "widgets/settingspages/IgnoresPage.hpp" #include "widgets/settingspages/KeyboardSettingsPage.hpp" #include "widgets/settingspages/LogsPage.hpp" #include "widgets/settingspages/LookPage.hpp" diff --git a/src/widgets/settingspages/BrowserExtensionPage.cpp b/src/widgets/settingspages/BrowserExtensionPage.cpp index 6e8655b64..a38652b77 100644 --- a/src/widgets/settingspages/BrowserExtensionPage.cpp +++ b/src/widgets/settingspages/BrowserExtensionPage.cpp @@ -13,7 +13,7 @@ namespace chatterino { BrowserExtensionPage::BrowserExtensionPage() - : SettingsPage("Browser Extension", "") + : SettingsPage("Browser integration", "") { auto layout = LayoutCreator(this).setLayoutType(); diff --git a/src/widgets/settingspages/IgnoresPage.cpp b/src/widgets/settingspages/IgnoresPage.cpp index 4f187c90e..5d6131d29 100644 --- a/src/widgets/settingspages/IgnoresPage.cpp +++ b/src/widgets/settingspages/IgnoresPage.cpp @@ -1,4 +1,4 @@ -#include "IgnorePage.hpp" +#include "IgnoresPage.hpp" #include "Application.hpp" #include "controllers/accounts/AccountController.hpp" @@ -23,68 +23,64 @@ namespace chatterino { +static void addPhrasesTab(LayoutCreator box); +static void addUsersTab(IgnoresPage &page, LayoutCreator box, QStringListModel &model); + IgnoresPage::IgnoresPage() : SettingsPage("Ignores", "") { - auto app = getApp(); - LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType(); - - // auto group = layout.emplace("Ignored users").setLayoutType(); auto tabs = layout.emplace(); - // tabs->setStyleSheet("color: #000"); - // users - auto users = tabs.appendTab(new QVBoxLayout, "Users"); - { - users.append(this->createCheckBox("Enable twitch ignored users", - app->settings->enableTwitchIgnoredUsers)); - - auto anyways = users.emplace().withoutMargin(); - { - anyways.emplace("Show anyways if:"); - anyways.emplace(); - anyways->addStretch(1); - } - - auto addremove = users.emplace().withoutMargin(); - { - auto add = addremove.emplace("Ignore user"); - auto remove = addremove.emplace("Unignore User"); - UNUSED(add); // TODO: Add on-clicked event - UNUSED(remove); // TODO: Add on-clicked event - addremove->addStretch(1); - } - - users.emplace()->setModel(&this->userListModel); - } - - // messages - auto messages = tabs.appendTab(new QVBoxLayout, "Messages"); - { - EditableModelView *view = - messages.emplace(app->ignores->createModel(nullptr)).getElement(); - 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(IgnorePhrase{"my phrase", false}); - }); - } + addPhrasesTab(tabs.appendTab(new QVBoxLayout, "Phrases")); + addUsersTab(*this, tabs.appendTab(new QVBoxLayout, "Users"), this->userListModel); auto label = layout.emplace(INFO); label->setWordWrap(true); label->setStyleSheet("color: #BBB"); } +void addPhrasesTab(LayoutCreator layout) +{ + EditableModelView *view = + layout.emplace(getApp()->ignores->createModel(nullptr)).getElement(); + view->setTitles({"Pattern", "Regex"}); + view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); + view->getTableView()->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); + + QTimer::singleShot(1, [view] { + view->getTableView()->resizeColumnsToContents(); + view->getTableView()->setColumnWidth(0, 200); + }); + + view->addButtonPressed.connect([] { + getApp()->ignores->phrases.appendItem(IgnorePhrase{"my phrase", false}); + }); +} + +void addUsersTab(IgnoresPage &page, LayoutCreator users, QStringListModel &userModel) +{ + users.append(page.createCheckBox("Enable twitch ignored users", + getApp()->settings->enableTwitchIgnoredUsers)); + + auto anyways = users.emplace().withoutMargin(); + { + anyways.emplace("Show anyways if:"); + anyways.emplace(); + anyways->addStretch(1); + } + + /*auto addremove = users.emplace().withoutMargin(); + { + auto add = addremove.emplace("Ignore user"); + auto remove = addremove.emplace("Unignore User"); + addremove->addStretch(1); + }*/ + + users.emplace()->setModel(&userModel); +} + void IgnoresPage::onShow() { auto app = getApp(); diff --git a/src/widgets/settingspages/IgnorePage.hpp b/src/widgets/settingspages/IgnoresPage.hpp similarity index 87% rename from src/widgets/settingspages/IgnorePage.hpp rename to src/widgets/settingspages/IgnoresPage.hpp index 706c94cdd..5a966fcbb 100644 --- a/src/widgets/settingspages/IgnorePage.hpp +++ b/src/widgets/settingspages/IgnoresPage.hpp @@ -4,6 +4,8 @@ #include +class QVBoxLayout; + namespace chatterino { class IgnoresPage : public SettingsPage diff --git a/src/widgets/settingspages/LookPage.hpp b/src/widgets/settingspages/LookPage.hpp index f412d6437..5443f14d2 100644 --- a/src/widgets/settingspages/LookPage.hpp +++ b/src/widgets/settingspages/LookPage.hpp @@ -15,10 +15,6 @@ class LookPage : public SettingsPage public: LookPage(); - void addApplicationGroup(QVBoxLayout &layout); - void addMessagesGroup(QVBoxLayout &layout); - void addEmotesGroup(QVBoxLayout &layout); - QLayout *createThemeColorChanger(); QLayout *createFontChanger(); QLayout *createUiScaleSlider();