WIP notification settings, doesn't actually work

This commit is contained in:
apa420
2018-08-09 15:41:03 +02:00
parent 7a9af4ae84
commit b68c7ded5f
11 changed files with 230 additions and 3 deletions
+2
View File
@@ -16,6 +16,7 @@
#include "widgets/settingspages/LogsPage.hpp"
#include "widgets/settingspages/LookPage.hpp"
#include "widgets/settingspages/ModerationPage.hpp"
#include "widgets/settingspages/NotificationPage.hpp"
#include "widgets/settingspages/SpecialChannelsPage.hpp"
#include <QDialogButtonBox>
@@ -100,6 +101,7 @@ void SettingsDialog::addTabs()
this->addTab(new KeyboardSettingsPage);
// this->addTab(new LogsPage);
this->addTab(new ModerationPage);
this->addTab(new NotificationPage);
// this->addTab(new SpecialChannelsPage);
this->addTab(new BrowserExtensionPage);
this->addTab(new ExternalToolsPage);
@@ -0,0 +1,66 @@
#include "NotificationPage.hpp"
#include "Application.hpp"
#include "singletons/Settings.hpp"
#include "src/controllers/notifications/NotificationController.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/helper/EditableModelView.hpp"
#include <QCheckBox>
#include <QGroupBox>
#include <QHeaderView>
#include <QLabel>
#include <QListView>
#include <QTableView>
#include <QTimer>
namespace chatterino {
NotificationPage::NotificationPage()
: SettingsPage("Notifications", "")
{
LayoutCreator<NotificationPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
{
auto tabs = layout.emplace<QTabWidget>();
{
auto settings = tabs.appendTab(new QVBoxLayout, "Options");
{
settings.emplace<QLabel>(
"Enable for channel next to channel name");
settings.append(this->createCheckBox(
"Flash taskbar",
getApp()->settings->notificationFlashTaskbar));
settings.append(this->createCheckBox(
"Playsound", getApp()->settings->notificationPlaySound));
settings->addStretch(1);
}
auto channels = tabs.appendTab(new QVBoxLayout, "Channels");
{
EditableModelView *view =
channels
.emplace<EditableModelView>(
getApp()->notifications->createModel(nullptr))
.getElement();
view->setTitles({"Channels"});
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()->notifications->addChannelNotification("channel");
});
}
}
}
}
} // namespace chatterino
@@ -0,0 +1,20 @@
#pragma once
#include "widgets/settingspages/SettingsPage.hpp"
class QPushButton;
class QListWidget;
class QVBoxLayout;
namespace chatterino {
class NotificationPage : public SettingsPage
{
public:
NotificationPage();
private:
};
} // namespace chatterino
+15
View File
@@ -2,6 +2,7 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/notifications/NotificationController.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Resources.hpp"
@@ -154,6 +155,20 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
&Split::openInPopupPlayer);
#endif
menu->addAction("Open streamlink", this->split_, &Split::openInStreamlink);
auto action = new QAction(this);
action->setText("Notify when live");
action->setCheckable(true);
QObject::connect(menu.get(), &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getApp()->notifications->isChannelNotified(
this->split_->getChannel()->getName()));
});
action->connect(action, &QAction::triggered, this, [this]() {
getApp()->notifications->updateChannelNotification(
this->split_->getChannel()->getName());
});
menu->addAction(action);
menu->addSeparator();
menu->addAction("Reload channel emotes", this,
SLOT(menuReloadChannelEmotes()));