mirror-chatterino2/src/widgets/settingspages/NotificationPage.cpp

124 lines
4.7 KiB
C++
Raw Normal View History

#include "NotificationPage.hpp"
#include "Application.hpp"
#include "controllers/notifications/NotificationController.hpp"
#include "controllers/notifications/NotificationModel.hpp"
#include "singletons/Settings.hpp"
#include "util/LayoutCreator.hpp"
#include "widgets/helper/EditableModelView.hpp"
#include <QCheckBox>
2018-08-24 18:05:36 +02:00
#include <QFileDialog>
#include <QGroupBox>
#include <QHeaderView>
#include <QLabel>
#include <QListView>
2018-08-24 18:05:36 +02:00
#include <QPushButton>
#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 selected channels");
settings.append(this->createCheckBox(
"Flash taskbar",
getApp()->settings->notificationFlashTaskbar));
settings.append(this->createCheckBox(
"Playsound (doesn't mute the Windows 8.x sound of toasts)",
getApp()->settings->notificationPlaySound));
2018-08-24 18:05:36 +02:00
#ifdef Q_OS_WIN
2018-08-12 18:54:32 +02:00
settings.append(this->createCheckBox(
"Enable toasts (currently only for windows 8.x or 10)",
2018-08-12 18:54:32 +02:00
getApp()->settings->notificationToast));
2018-08-24 18:05:36 +02:00
#endif
auto customSound =
layout.emplace<QHBoxLayout>().withoutMargin();
{
customSound.append(this->createCheckBox(
"Custom sound",
getApp()->settings->notificationCustomSound));
auto selectFile = customSound.emplace<QPushButton>(
"Select custom sound file");
QObject::connect(
selectFile.getElement(), &QPushButton::clicked, this,
[this] {
auto fileName = QFileDialog::getOpenFileName(
this, tr("Open Sound"), "",
tr("Audio Files (*.mp3 *.wav)"));
getApp()->settings->notificationPathSound =
fileName;
});
}
settings->addStretch(1);
}
2018-08-12 15:29:40 +02:00
auto twitchChannels = tabs.appendTab(new QVBoxLayout, "Twitch");
{
EditableModelView *view =
2018-08-12 15:29:40 +02:00
twitchChannels
.emplace<EditableModelView>(
2018-08-12 18:54:32 +02:00
getApp()->notifications->createModel(
nullptr, Platform::Twitch))
.getElement();
2018-08-12 15:29:40 +02:00
view->setTitles({"Twitch 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->channelMap[Platform::Twitch]
.appendItem("channel");
2018-08-12 15:29:40 +02:00
});
}
/*
2018-08-12 15:29:40 +02:00
auto mixerChannels = tabs.appendTab(new QVBoxLayout, "Mixer");
{
EditableModelView *view =
mixerChannels
.emplace<EditableModelView>(
2018-08-12 18:54:32 +02:00
getApp()->notifications->createModel(
nullptr, Platform::Mixer))
2018-08-12 15:29:40 +02:00
.getElement();
view->setTitles({"Mixer 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->channelMap[Platform::Mixer]
.appendItem("channel");
});
}
*/
}
}
}
} // namespace chatterino