refactored the ignores page a bit

This commit is contained in:
fourtf 2018-07-05 16:45:34 +02:00
parent 1da23e5e91
commit 80c8e11cec
6 changed files with 51 additions and 57 deletions

View file

@ -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 \

View file

@ -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"

View file

@ -13,7 +13,7 @@
namespace chatterino {
BrowserExtensionPage::BrowserExtensionPage()
: SettingsPage("Browser Extension", "")
: SettingsPage("Browser integration", "")
{
auto layout = LayoutCreator<BrowserExtensionPage>(this).setLayoutType<QVBoxLayout>();

View file

@ -1,4 +1,4 @@
#include "IgnorePage.hpp"
#include "IgnoresPage.hpp"
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
@ -23,53 +23,32 @@
namespace chatterino {
static void addPhrasesTab(LayoutCreator<QVBoxLayout> box);
static void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> box, QStringListModel &model);
IgnoresPage::IgnoresPage()
: SettingsPage("Ignores", "")
{
auto app = getApp();
LayoutCreator<IgnoresPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
// auto group = layout.emplace<QGroupBox>("Ignored users").setLayoutType<QVBoxLayout>();
auto tabs = layout.emplace<QTabWidget>();
// tabs->setStyleSheet("color: #000");
// users
auto users = tabs.appendTab(new QVBoxLayout, "Users");
{
users.append(this->createCheckBox("Enable twitch ignored users",
app->settings->enableTwitchIgnoredUsers));
addPhrasesTab(tabs.appendTab(new QVBoxLayout, "Phrases"));
addUsersTab(*this, tabs.appendTab(new QVBoxLayout, "Users"), this->userListModel);
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
{
anyways.emplace<QLabel>("Show anyways if:");
anyways.emplace<QComboBox>();
anyways->addStretch(1);
auto label = layout.emplace<QLabel>(INFO);
label->setWordWrap(true);
label->setStyleSheet("color: #BBB");
}
auto addremove = users.emplace<QHBoxLayout>().withoutMargin();
{
auto add = addremove.emplace<QPushButton>("Ignore user");
auto remove = addremove.emplace<QPushButton>("Unignore User");
UNUSED(add); // TODO: Add on-clicked event
UNUSED(remove); // TODO: Add on-clicked event
addremove->addStretch(1);
}
users.emplace<QListView>()->setModel(&this->userListModel);
}
// messages
auto messages = tabs.appendTab(new QVBoxLayout, "Messages");
void addPhrasesTab(LayoutCreator<QVBoxLayout> layout)
{
EditableModelView *view =
messages.emplace<EditableModelView>(app->ignores->createModel(nullptr)).getElement();
layout.emplace<EditableModelView>(getApp()->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);
@ -80,9 +59,26 @@ IgnoresPage::IgnoresPage()
});
}
auto label = layout.emplace<QLabel>(INFO);
label->setWordWrap(true);
label->setStyleSheet("color: #BBB");
void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users, QStringListModel &userModel)
{
users.append(page.createCheckBox("Enable twitch ignored users",
getApp()->settings->enableTwitchIgnoredUsers));
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
{
anyways.emplace<QLabel>("Show anyways if:");
anyways.emplace<QComboBox>();
anyways->addStretch(1);
}
/*auto addremove = users.emplace<QHBoxLayout>().withoutMargin();
{
auto add = addremove.emplace<QPushButton>("Ignore user");
auto remove = addremove.emplace<QPushButton>("Unignore User");
addremove->addStretch(1);
}*/
users.emplace<QListView>()->setModel(&userModel);
}
void IgnoresPage::onShow()

View file

@ -4,6 +4,8 @@
#include <QStringListModel>
class QVBoxLayout;
namespace chatterino {
class IgnoresPage : public SettingsPage

View file

@ -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();