From c3065db16d3fa676eaa4a0c76e760873a4e6fb8c Mon Sep 17 00:00:00 2001 From: apa420 Date: Wed, 29 Aug 2018 01:21:36 +0200 Subject: [PATCH 1/3] highlighting whispers works better and looks better --- src/common/SignalVectorModel.hpp | 5 +- src/controllers/highlights/HighlightModel.cpp | 53 +++++++++++++++---- src/controllers/highlights/HighlightModel.hpp | 4 +- src/providers/twitch/TwitchMessageBuilder.cpp | 25 +++++---- src/singletons/Settings.hpp | 19 ++++--- .../settingspages/HighlightingPage.cpp | 2 - 6 files changed, 75 insertions(+), 33 deletions(-) diff --git a/src/common/SignalVectorModel.hpp b/src/common/SignalVectorModel.hpp index 237727d0d..4a56913b4 100644 --- a/src/common/SignalVectorModel.hpp +++ b/src/common/SignalVectorModel.hpp @@ -124,7 +124,7 @@ public: rowItem.items[column]->setData(value, role); if (rowItem.isCustomRow) { - this->customRowSetData(rowItem.items, column, value, role); + this->customRowSetData(rowItem.items, column, value, role, row); } else { int vecRow = this->getVectorIndexFromModelIndex(row); this->vector_->removeItem(vecRow, this); @@ -230,7 +230,8 @@ protected: } virtual void customRowSetData(const std::vector &row, - int column, const QVariant &value, int role) + int column, const QVariant &value, int role, + int rowIndex) { } diff --git a/src/controllers/highlights/HighlightModel.cpp b/src/controllers/highlights/HighlightModel.cpp index 827e23a4a..0ba232b37 100644 --- a/src/controllers/highlights/HighlightModel.cpp +++ b/src/controllers/highlights/HighlightModel.cpp @@ -36,36 +36,67 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item, void HighlightModel::afterInit() { - std::vector row = this->createRow(); - setBoolItem(row[0], getSettings()->enableHighlightsSelf.getValue(), true, + std::vector usernameRow = this->createRow(); + setBoolItem(usernameRow[0], getSettings()->enableSelfHighlight.getValue(), + true, false); + usernameRow[0]->setData("Your username (automatic)", Qt::DisplayRole); + setBoolItem(usernameRow[1], + getSettings()->enableSelfHighlightTaskbar.getValue(), true, false); - row[0]->setData("Your username (automatic)", Qt::DisplayRole); - setBoolItem(row[1], getSettings()->enableHighlightTaskbar.getValue(), true, + setBoolItem(usernameRow[2], + getSettings()->enableSelfHighlightSound.getValue(), true, false); - setBoolItem(row[2], getSettings()->enableHighlightSound.getValue(), true, + usernameRow[3]->setFlags(0); + this->insertCustomRow(usernameRow, 0); + std::vector whisperRow = this->createRow(); + setBoolItem(whisperRow[0], getSettings()->enableWhisperHighlight.getValue(), + true, false); + whisperRow[0]->setData("Whispers", Qt::DisplayRole); + setBoolItem(whisperRow[1], + getSettings()->enableWhisperHighlightTaskbar.getValue(), true, false); - row[3]->setFlags(0); - this->insertCustomRow(row, 0); + setBoolItem(whisperRow[2], + getSettings()->enableWhisperHighlightSound.getValue(), true, + false); + whisperRow[3]->setFlags(0); + this->insertCustomRow(whisperRow, 1); } void HighlightModel::customRowSetData(const std::vector &row, int column, const QVariant &value, - int role) + int role, int rowIndex) { switch (column) { case 0: { if (role == Qt::CheckStateRole) { - getSettings()->enableHighlightsSelf.setValue(value.toBool()); + if (rowIndex == 0) { + getSettings()->enableSelfHighlight.setValue(value.toBool()); + } else if (rowIndex == 1) { + getSettings()->enableWhisperHighlight.setValue( + value.toBool()); + } } } break; case 1: { if (role == Qt::CheckStateRole) { - getSettings()->enableHighlightTaskbar.setValue(value.toBool()); + if (rowIndex == 0) { + getSettings()->enableSelfHighlightTaskbar.setValue( + value.toBool()); + } else if (rowIndex == 1) { + getSettings()->enableWhisperHighlightTaskbar.setValue( + value.toBool()); + } } } break; case 2: { if (role == Qt::CheckStateRole) { - getSettings()->enableHighlightSound.setValue(value.toBool()); + if (rowIndex == 0) { + getSettings()->enableSelfHighlightSound.setValue( + value.toBool()); + } else if (rowIndex == 1) { + getSettings()->enableWhisperHighlightSound.setValue( + value.toBool()); + } } } break; case 3: { diff --git a/src/controllers/highlights/HighlightModel.hpp b/src/controllers/highlights/HighlightModel.hpp index b42246167..563706246 100644 --- a/src/controllers/highlights/HighlightModel.hpp +++ b/src/controllers/highlights/HighlightModel.hpp @@ -26,8 +26,8 @@ protected: virtual void afterInit() override; virtual void customRowSetData(const std::vector &row, - int column, const QVariant &value, - int role) override; + int column, const QVariant &value, int role, + int rowIndex) override; friend class HighlightController; }; diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index a5bf3a4d2..73415811a 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -507,10 +507,10 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) std::vector userHighlights = app->highlights->highlightedUsers.getVector(); - if (getSettings()->enableHighlightsSelf && currentUsername.size() > 0) { + if (getSettings()->enableSelfHighlight && currentUsername.size() > 0) { HighlightPhrase selfHighlight( - currentUsername, getSettings()->enableHighlightTaskbar, - getSettings()->enableHighlightSound, false); + currentUsername, getSettings()->enableSelfHighlightTaskbar, + getSettings()->enableSelfHighlightSound, false); activeHighlights.emplace_back(std::move(selfHighlight)); } @@ -564,6 +564,19 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) } } } + if (this->args.isReceivedWhisper) { + if (getSettings()->enableWhisperHighlight) { + log("Highlight because it's a whisper", + this->args.isReceivedWhisper); + doHighlight = true; + } + if (getSettings()->enableWhisperHighlightTaskbar) { + doAlert = true; + } + if (getSettings()->enableSelfHighlightSound) { + playSound = true; + } + } this->message().flags.set(MessageFlag::Highlighted, doHighlight); @@ -578,12 +591,6 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) 2500); } } - if (this->args.isReceivedWhisper && - getSettings()->highlightSoundOnWhisper) { - if (!hasFocus || getSettings()->highlightAlwaysPlaySound) { - player->play(); - } - } } } diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 861a0aec0..bb43b48cf 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -114,14 +114,19 @@ public: /// Highlighting // BoolSetting enableHighlights = {"/highlighting/enabled", true}; - BoolSetting enableHighlightsSelf = {"/highlighting/nameIsHighlightKeyword", - true}; - BoolSetting enableHighlightSound = {"/highlighting/enableSound", true}; - BoolSetting enableHighlightTaskbar = {"/highlighting/enableTaskbarFlashing", - true}; BoolSetting customHighlightSound = {"/highlighting/useCustomSound", false}; - BoolSetting highlightSoundOnWhisper = { - "/highlighting/highlightSoundOnWhisper", false}; + BoolSetting enableSelfHighlight = { + "/highlighting/selfHighlight/nameIsHighlightKeyword", true}; + BoolSetting enableSelfHighlightSound = { + "/highlighting/selfHighlight/enableSound", true}; + BoolSetting enableSelfHighlightTaskbar = { + "/highlighting/selfHighlight/enableTaskbarFlashing", true}; + BoolSetting enableWhisperHighlight = { + "/highlighting/whisperHighlight/whispersHighlighted", true}; + BoolSetting enableWhisperHighlightSound = { + "/highlighting/whisperHighlight/enableSound", false}; + BoolSetting enableWhisperHighlightTaskbar = { + "/highlighting/whisperHighlight/enableTaskbarFlashing", false}; /// Logging BoolSetting enableLogging = {"/logging/enabled", false}; diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index 626bb65d0..be394b3c2 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -149,8 +149,6 @@ HighlightingPage::HighlightingPage() layout.append(createCheckBox(ALWAYS_PLAY, getSettings()->highlightAlwaysPlaySound)); - layout.append(createCheckBox(("Notification on whisper"), - getSettings()->highlightSoundOnWhisper)); } // ---- misc From a36a2a2939c136120e1015fdbc0fc1d48baa7666 Mon Sep 17 00:00:00 2001 From: apa420 Date: Wed, 29 Aug 2018 01:24:35 +0200 Subject: [PATCH 2/3] fixed issue with having the wrong variable --- src/providers/twitch/TwitchMessageBuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 73415811a..94967b8da 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -573,7 +573,7 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) if (getSettings()->enableWhisperHighlightTaskbar) { doAlert = true; } - if (getSettings()->enableSelfHighlightSound) { + if (getSettings()->enableWhisperHighlightSound) { playSound = true; } } From 9a0205bdc93ad8a2bf2ffb751b945fc33d6d083b Mon Sep 17 00:00:00 2001 From: apa420 Date: Wed, 29 Aug 2018 01:37:57 +0200 Subject: [PATCH 3/3] did request --- src/providers/twitch/TwitchMessageBuilder.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 94967b8da..5bfc77254 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -564,12 +564,8 @@ void TwitchMessageBuilder::parseHighlights(bool isPastMsg) } } } - if (this->args.isReceivedWhisper) { - if (getSettings()->enableWhisperHighlight) { - log("Highlight because it's a whisper", - this->args.isReceivedWhisper); - doHighlight = true; - } + if (this->args.isReceivedWhisper && + getSettings()->enableWhisperHighlight) { if (getSettings()->enableWhisperHighlightTaskbar) { doAlert = true; }