From e58e76ef1ecb04c2575f9b507d4cd20589a160c1 Mon Sep 17 00:00:00 2001 From: apa420 Date: Fri, 24 Aug 2018 18:05:36 +0200 Subject: [PATCH] added more playsound stuff --- .../notifications/NotificationController.cpp | 4 +-- src/singletons/Settings.hpp | 7 ++++-- src/widgets/helper/ChannelView.cpp | 12 +++++++++ .../settingspages/NotificationPage.cpp | 25 ++++++++++++++++--- src/widgets/splits/SplitHeader.cpp | 17 ++----------- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index d07b3a794..5f184bc33 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -81,9 +81,9 @@ void NotificationController::playSound() static QUrl currentPlayerUrl; QUrl highlightSoundUrl; - if (getApp()->settings->customHighlightSound) { + if (getApp()->settings->notificationCustomSound) { highlightSoundUrl = QUrl::fromLocalFile( - getApp()->settings->pathHighlightSound.getValue()); + getApp()->settings->notificationPathSound.getValue()); } else { highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav"); } diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 9a48d2bbd..1105470cb 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -144,10 +144,13 @@ public: false}; BoolSetting notificationPlaySound = {"/notifications/enablePlaySound", false}; + BoolSetting notificationCustomSound = {"/notifications/customPlaySound", + false}; + QStringSetting notificationPathSound = {"/notifications/highlightSoundPath", + "qrc:/sounds/ping3.wav"}; + BoolSetting notificationToast = {"/notifications/enableToast", false}; BoolSetting notificationDot = {"/notifications/enableDot", false}; - BoolSetting notificationSplitheaderHighlight = { - "/notifications/enableSplitheaderHighlight", false}; /// External tools // Streamlink diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 2ea32bb53..448354e13 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -559,6 +559,18 @@ void ChannelView::setChannel(ChannelPtr newChannel) if (tc != nullptr) { tc->tabHighlightRequested.connect([this](HighlightState state) { this->tabHighlightRequested.invoke(HighlightState::Notification); + /* + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.translate(2, 2); + painter.setPen(QColor("#6441A4")); + painter.drawEllipse(QRectF(10, 10, 5, 5)); +*/ + + QPainter painter(this); + auto radius = 10; + painter.setPen(QColor("#6441A4")); + painter.drawEllipse(this->rect().center(), radius, radius); }); } } diff --git a/src/widgets/settingspages/NotificationPage.cpp b/src/widgets/settingspages/NotificationPage.cpp index e856679ff..e5ef7b9f0 100644 --- a/src/widgets/settingspages/NotificationPage.cpp +++ b/src/widgets/settingspages/NotificationPage.cpp @@ -8,10 +8,12 @@ #include "widgets/helper/EditableModelView.hpp" #include +#include #include #include #include #include +#include #include #include @@ -35,15 +37,32 @@ NotificationPage::NotificationPage() settings.append(this->createCheckBox( "Playsound (doesn't mute the Windows 8.x sound of toasts)", getApp()->settings->notificationPlaySound)); +#ifdef Q_OS_WIN settings.append(this->createCheckBox( "Enable toasts (currently only for windows 8.x or 10)", getApp()->settings->notificationToast)); +#endif settings.append( this->createCheckBox("Red dot next to live splits", getApp()->settings->notificationDot)); - settings.append(this->createCheckBox( - "Change color of Splitheader (click to remove)", - getApp()->settings->notificationSplitheaderHighlight)); + auto customSound = + layout.emplace().withoutMargin(); + { + customSound.append(this->createCheckBox( + "Custom sound", + getApp()->settings->notificationCustomSound)); + auto selectFile = customSound.emplace( + "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); } diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 348b3f958..aa28bb18c 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -168,6 +168,7 @@ std::unique_ptr SplitHeader::createMainMenu() getApp()->notifications->updateChannelNotification( this->split_->getChannel()->getName(), Platform::Twitch); }); + menu->addAction(action); menu->addSeparator(); @@ -549,21 +550,7 @@ void SplitHeader::themeChangedEvent() getApp()->resources->buttons.menuLight); } - // this->titleLabel->setPalette(palette); - auto darkPalette = palette; - darkPalette.setColor(QPalette::Window, QColor(53, 53, 53)); - darkPalette.setColor(QPalette::WindowText, Qt::white); - darkPalette.setColor(QPalette::Base, QColor(25, 25, 25)); - darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53)); - darkPalette.setColor(QPalette::ToolTipBase, Qt::white); - darkPalette.setColor(QPalette::ToolTipText, Qt::white); - darkPalette.setColor(QPalette::Text, Qt::white); - darkPalette.setColor(QPalette::Button, QColor(53, 53, 53)); - darkPalette.setColor(QPalette::ButtonText, Qt::white); - darkPalette.setColor(QPalette::BrightText, Qt::red); - darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); - - this->titleLabel->setPalette(darkPalette); + this->titleLabel->setPalette(palette); } void SplitHeader::menuMoveSplit()