From 23651fd51345a6339ea0f6e7c0f7e103c01f9b0d Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 8 Oct 2017 15:58:28 +0200 Subject: [PATCH] Add option to play highlight sounds even if Chatterino is focused. This is off by default --- src/settingsmanager.cpp | 1 + src/settingsmanager.hpp | 1 + src/twitch/twitchmessagebuilder.cpp | 5 ++++- src/widgets/settingsdialog.cpp | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 7b7471b79..4d18dd636 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -36,6 +36,7 @@ SettingsManager::SettingsManager() , highlightProperties(this->settingsItems, "highlightProperties", QMap>()) , highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "") + , highlightAlwaysPlaySound("/highlighting/alwaysPlaySound", false) , enableTwitchEmotes(this->settingsItems, "enableTwitchEmotes", true) , enableBttvEmotes(this->settingsItems, "enableBttvEmotes", true) , enableFfzEmotes(this->settingsItems, "enableFfzEmotes", true) diff --git a/src/settingsmanager.hpp b/src/settingsmanager.hpp index 58644bf5d..7f8263e47 100644 --- a/src/settingsmanager.hpp +++ b/src/settingsmanager.hpp @@ -50,6 +50,7 @@ public: Setting pathHighlightSound; Setting>> highlightProperties; Setting highlightUserBlacklist; + pajlada::Settings::Setting highlightAlwaysPlaySound; Setting enableTwitchEmotes; Setting enableBttvEmotes; Setting enableFfzEmotes; diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp index 3b0b77ffb..33e116852 100644 --- a/src/twitch/twitchmessagebuilder.cpp +++ b/src/twitch/twitchmessagebuilder.cpp @@ -412,6 +412,9 @@ void TwitchMessageBuilder::parseHighlights() bool doHighlight = false; bool playSound = false; bool doAlert = false; + + bool hasFocus = (QApplication::focusWidget() != nullptr); + if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) { for (const Highlight &highlight : activeHighlights) { if (this->originalMessage.contains(highlight.target, Qt::CaseInsensitive)) { @@ -437,7 +440,7 @@ void TwitchMessageBuilder::parseHighlights() this->setHighlight(doHighlight); - if (playSound) { + if (playSound && (!hasFocus || settings.highlightAlwaysPlaySound)) { player->play(); } diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 52c07572f..f0c9ac53d 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -484,6 +484,9 @@ void SettingsDialog::addTabs() } }); vbox->addLayout(soundForm); + vbox->addWidget( + createCheckbox("Always play highlight sound (Even if Chatterino is focused)", + settings.highlightAlwaysPlaySound)); auto layoutVbox = new QVBoxLayout(); auto btnHbox = new QHBoxLayout();