2018-08-09 15:41:03 +02:00
|
|
|
#include "NotificationPage.hpp"
|
|
|
|
|
|
|
|
#include "Application.hpp"
|
2018-08-10 00:04:50 +02:00
|
|
|
#include "controllers/notifications/NotificationController.hpp"
|
|
|
|
#include "controllers/notifications/NotificationModel.hpp"
|
2018-08-09 15:41:03 +02:00
|
|
|
#include "singletons/Settings.hpp"
|
|
|
|
#include "util/LayoutCreator.hpp"
|
2019-04-27 10:12:51 +02:00
|
|
|
#include "widgets/helper/CommonTexts.hpp"
|
2018-08-09 15:41:03 +02:00
|
|
|
#include "widgets/helper/EditableModelView.hpp"
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
2018-08-24 18:05:36 +02:00
|
|
|
#include <QFileDialog>
|
2018-08-09 15:41:03 +02:00
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListView>
|
2018-08-24 18:05:36 +02:00
|
|
|
#include <QPushButton>
|
2018-08-09 15:41:03 +02:00
|
|
|
#include <QTableView>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
NotificationPage::NotificationPage()
|
2018-10-20 00:53:19 +02:00
|
|
|
: SettingsPage("Notifications", ":/settings/notification2.svg")
|
2018-08-09 15:41:03 +02:00
|
|
|
{
|
|
|
|
LayoutCreator<NotificationPage> layoutCreator(this);
|
|
|
|
|
|
|
|
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
|
|
|
|
{
|
|
|
|
auto tabs = layout.emplace<QTabWidget>();
|
|
|
|
{
|
|
|
|
auto settings = tabs.appendTab(new QVBoxLayout, "Options");
|
|
|
|
{
|
2018-08-18 13:07:12 +02:00
|
|
|
settings.emplace<QLabel>("Enable for selected channels");
|
2018-08-09 15:41:03 +02:00
|
|
|
settings.append(this->createCheckBox(
|
2018-09-30 18:55:41 +02:00
|
|
|
"Flash taskbar", getSettings()->notificationFlashTaskbar));
|
2018-08-09 15:41:03 +02:00
|
|
|
settings.append(this->createCheckBox(
|
2018-10-20 19:15:15 +02:00
|
|
|
"Play sound", getSettings()->notificationPlaySound));
|
2018-08-24 18:05:36 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2018-10-20 19:15:15 +02:00
|
|
|
settings.append(
|
|
|
|
this->createCheckBox("Enable toasts (Windows 8 or later)",
|
|
|
|
getSettings()->notificationToast));
|
2019-04-27 10:12:51 +02:00
|
|
|
auto openIn = settings.emplace<QHBoxLayout>().withoutMargin();
|
2019-04-22 09:03:52 +02:00
|
|
|
{
|
2019-04-27 10:12:51 +02:00
|
|
|
openIn.emplace<QLabel>("Open stream from Toast: ")
|
|
|
|
->setSizePolicy(QSizePolicy::Maximum,
|
|
|
|
QSizePolicy::Preferred);
|
|
|
|
openIn
|
|
|
|
.append(this->createComboBox(
|
|
|
|
{OPEN_IN_BROWSER, OPEN_PLAYER_IN_BROWSER,
|
|
|
|
OPEN_IN_STREAMLINK, DONT_OPEN},
|
|
|
|
getSettings()->openFromToast))
|
|
|
|
->setSizePolicy(QSizePolicy::Maximum,
|
|
|
|
QSizePolicy::Preferred);
|
2019-04-22 09:03:52 +02:00
|
|
|
}
|
2019-04-27 10:12:51 +02:00
|
|
|
openIn->setContentsMargins(40, 0, 0, 0);
|
2019-04-22 09:03:52 +02:00
|
|
|
openIn->setSizeConstraint(QLayout::SetMaximumSize);
|
2018-08-24 18:05:36 +02:00
|
|
|
#endif
|
|
|
|
auto customSound =
|
|
|
|
layout.emplace<QHBoxLayout>().withoutMargin();
|
|
|
|
{
|
|
|
|
customSound.append(this->createCheckBox(
|
|
|
|
"Custom sound",
|
2018-08-29 19:25:37 +02:00
|
|
|
getSettings()->notificationCustomSound));
|
2018-08-24 18:05:36 +02:00
|
|
|
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)"));
|
2018-09-30 18:55:41 +02:00
|
|
|
getSettings()->notificationPathSound = fileName;
|
2018-08-24 18:05:36 +02:00
|
|
|
});
|
|
|
|
}
|
2018-08-09 15:41:03 +02:00
|
|
|
|
|
|
|
settings->addStretch(1);
|
|
|
|
}
|
2018-08-12 15:29:40 +02:00
|
|
|
auto twitchChannels = tabs.appendTab(new QVBoxLayout, "Twitch");
|
2018-08-09 15:41:03 +02:00
|
|
|
{
|
|
|
|
EditableModelView *view =
|
2018-08-12 15:29:40 +02:00
|
|
|
twitchChannels
|
2018-08-09 15:41:03 +02:00
|
|
|
.emplace<EditableModelView>(
|
2018-08-12 18:54:32 +02:00
|
|
|
getApp()->notifications->createModel(
|
|
|
|
nullptr, Platform::Twitch))
|
2018-08-09 15:41:03 +02:00
|
|
|
.getElement();
|
2018-08-12 15:29:40 +02:00
|
|
|
view->setTitles({"Twitch channels"});
|
2018-08-09 15:41:03 +02:00
|
|
|
|
|
|
|
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([] {
|
2018-08-12 20:21:21 +02:00
|
|
|
getApp()
|
|
|
|
->notifications->channelMap[Platform::Twitch]
|
|
|
|
.appendItem("channel");
|
2018-08-12 15:29:40 +02:00
|
|
|
});
|
|
|
|
}
|
2018-08-12 21:05:12 +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([] {
|
2018-08-12 20:21:21 +02:00
|
|
|
getApp()
|
|
|
|
->notifications->channelMap[Platform::Mixer]
|
|
|
|
.appendItem("channel");
|
2018-08-09 15:41:03 +02:00
|
|
|
});
|
|
|
|
}
|
2018-08-12 21:05:12 +02:00
|
|
|
*/
|
2018-08-09 15:41:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace chatterino
|