refactor: turn StreamerMode into a singleton(-like thing) (#5216)

This commit is contained in:
nerix
2024-03-01 21:12:02 +01:00
committed by GitHub
parent ea19c5c989
commit c1fa51242f
28 changed files with 386 additions and 210 deletions
+3 -2
View File
@@ -11,10 +11,10 @@
#include "messages/MessageElement.hpp"
#include "providers/twitch/TwitchBadge.hpp"
#include "singletons/Settings.hpp"
#include "singletons/StreamerMode.hpp"
#include "singletons/WindowManager.hpp"
#include "util/Helpers.hpp"
#include "util/Qt.hpp"
#include "util/StreamerMode.hpp"
#include <QFileInfo>
@@ -204,7 +204,8 @@ void SharedMessageBuilder::triggerHighlights(
const QString &channelName, bool playSound,
const std::optional<QUrl> &customSoundUrl, bool windowAlert)
{
if (isInStreamerMode() && getSettings()->streamerModeMuteMentions)
if (getIApp()->getStreamerMode()->isEnabled() &&
getSettings()->streamerModeMuteMentions)
{
// We are in streamer mode with muting mention sounds enabled. Do nothing.
return;
+2 -4
View File
@@ -9,9 +9,9 @@
#include "messages/Selection.hpp"
#include "providers/colors/ColorProvider.hpp"
#include "singletons/Settings.hpp"
#include "singletons/StreamerMode.hpp"
#include "singletons/WindowManager.hpp"
#include "util/DebugCount.hpp"
#include "util/StreamerMode.hpp"
#include <QApplication>
#include <QDebug>
@@ -160,11 +160,9 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags flags)
if (this->message_->flags.has(MessageFlag::Timeout) ||
this->message_->flags.has(MessageFlag::Untimeout))
{
// This condition has been set up to execute isInStreamerMode() as the last thing
// as it could end up being expensive.
if (hideModerationActions ||
(getSettings()->streamerModeHideModActions &&
isInStreamerMode()))
getIApp()->getStreamerMode()->isEnabled()))
{
continue;
}