diff --git a/CHANGELOG.md b/CHANGELOG.md index 34066c8f..d10e783b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned +- Minor: Add `Set highlight sounds` and `Open subscription page` split hotkeys. (#5856) - Minor: `/clear` messages are now stacked like timeouts. (#5806) - Minor: Treat all browsers starting with `firefox` as a Firefox browser. (#5805) - Minor: Remove incognito browser support for `opera/launcher` (this should no longer be a thing). (#5805) diff --git a/src/controllers/hotkeys/ActionNames.hpp b/src/controllers/hotkeys/ActionNames.hpp index f15d2e20..a112e7ec 100644 --- a/src/controllers/hotkeys/ActionNames.hpp +++ b/src/controllers/hotkeys/ActionNames.hpp @@ -195,6 +195,18 @@ inline const std::map actionNames{ }, .argumentsPrompt = "Target popup:", }}, + {"setHighlightSounds", + ActionDefinition{ + .displayName = "Set highlight sounds", + .argumentDescription = "[on or off. default: toggle]", + .minCountArguments = 0, + .maxCountArguments = 1, + .possibleArguments = HOTKEY_ARG_ON_OFF_TOGGLE, + .argumentsPrompt = "New value:", + .argumentsPromptHover = + "Should highlight sounds be enabled, disabled or toggled", + }}, + {"openSubscriptionPage", ActionDefinition{"Open subscription page"}}, }}, {HotkeyCategory::SplitInput, { diff --git a/src/controllers/hotkeys/Hotkey.cpp b/src/controllers/hotkeys/Hotkey.cpp index b6d5fc6c..c255381e 100644 --- a/src/controllers/hotkeys/Hotkey.cpp +++ b/src/controllers/hotkeys/Hotkey.cpp @@ -75,7 +75,7 @@ Qt::ShortcutContext Hotkey::getContext() const } qCDebug(chatterinoHotkeys) << "Using default shortcut context for" << this->getCategory() - << "and hopeing for the best."; + << "and hoping for the best."; return Qt::WidgetShortcut; } diff --git a/src/singletons/Settings.cpp b/src/singletons/Settings.cpp index 357c1078..eca8d07d 100644 --- a/src/singletons/Settings.cpp +++ b/src/singletons/Settings.cpp @@ -109,7 +109,10 @@ std::optional Settings::matchNickname(const QString &usernameText) void Settings::mute(const QString &channelName) { - mutedChannels.append(channelName); + if (!this->isMutedChannel(channelName)) + { + this->mutedChannels.append(channelName); + } } void Settings::unmute(const QString &channelName) @@ -134,7 +137,7 @@ bool Settings::toggleMutedChannel(const QString &channelName) } else { - mute(channelName); + this->mutedChannels.append(channelName); return true; } } diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 8fff5b4f..fbfa024a 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -678,6 +678,7 @@ private: {"/moderation/actions"}; ChatterinoSetting> loggedChannelsSetting = { "/logging/channels"}; + SignalVector mutedChannels; public: SignalVector highlightedMessages; @@ -685,7 +686,6 @@ public: SignalVector highlightedBadges; SignalVector blacklistedUsers; SignalVector ignoredMessages; - SignalVector mutedChannels; SignalVector filterRecords; SignalVector nicknames; SignalVector moderationActions; @@ -696,11 +696,10 @@ public: bool isMutedChannel(const QString &channelName); bool toggleMutedChannel(const QString &channelName); std::optional matchNickname(const QString &username); - -private: void mute(const QString &channelName); void unmute(const QString &channelName); +private: void updateModerationActions(); std::unique_ptr snapshot_; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 195e71c6..203f16ab 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -611,7 +611,7 @@ void Split::addShortcuts() type != Channel::Type::Twitch && type != Channel::Type::TwitchWatching) { - return "Cannot create clip it non-twitch channel."; + return "Cannot create clips in a non-Twitch channel."; } auto *twitchChannel = @@ -651,7 +651,8 @@ void Split::addShortcuts() [this](std::vector arguments) -> QString { if (!this->getChannel()->isTwitchChannel()) { - return "Cannot set moderation mode in non-twitch channel."; + return "Cannot set moderation mode in a non-Twitch " + "channel."; } auto mode = 2; // 0 is off @@ -725,7 +726,7 @@ void Split::addShortcuts() [this](std::vector arguments) -> QString { if (!this->getChannel()->isTwitchChannel()) { - return "Cannot set channel notifications for non-twitch " + return "Cannot set channel notifications for a non-Twitch " "channel."; } auto mode = 2; @@ -807,6 +808,57 @@ void Split::addShortcuts() } return {}; }}, + {"setHighlightSounds", + [this](std::vector arguments) -> QString { + if (!this->getChannel()->isTwitchChannel()) + { + return "Cannot set highlight sounds in a non-Twitch " + "channel."; + } + + auto mode = 2; + // 0 is off + // 1 is on + // 2 is toggle + if (!arguments.empty()) + { + auto arg = arguments.at(0); + if (arg == "off") + { + mode = 0; + } + else if (arg == "on") + { + mode = 1; + } + } + + const QString channel = this->getChannel()->getName(); + + switch (mode) + { + case 0: + getSettings()->mute(channel); + break; + case 1: + getSettings()->unmute(channel); + break; + default: + getSettings()->toggleMutedChannel(channel); + } + return ""; + }}, + {"openSubscriptionPage", + [this](const auto &) -> QString { + if (!this->getChannel()->isTwitchChannel()) + { + return "Cannot subscribe to a non-Twitch " + "channel."; + } + + this->openSubPage(); + return ""; + }}, }; this->shortcuts_ = getApp()->getHotkeys()->shortcutsForCategory( @@ -1626,8 +1678,8 @@ void Split::drag() auto *container = dynamic_cast(this->parentWidget()); if (!container) { - qCWarning(chatterinoWidget) - << "Attempted to initiate split drag without a container parent"; + qCWarning(chatterinoWidget) << "Attempted to initiate split drag " + "without a container parent"; return; } diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index f1f84eff..f21e00ab 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -537,7 +537,9 @@ std::unique_ptr SplitHeader::createMainMenu() h->getDisplaySequence(HotkeyCategory::Split, "openViewerList")); } - moreMenu->addAction("Subscribe", this->split_, &Split::openSubPage); + moreMenu->addAction("Subscribe", this->split_, &Split::openSubPage, + h->getDisplaySequence(HotkeyCategory::Split, + "openSubscriptionPage")); auto *action = new QAction(this); action->setText("Notify when live"); @@ -569,9 +571,19 @@ std::unique_ptr SplitHeader::createMainMenu() if (twitchChannel) { auto *action = new QAction(this); - action->setText("Mute highlight sound"); + action->setText("Mute highlight sounds"); action->setCheckable(true); + auto notifySeq = h->getDisplaySequence( + HotkeyCategory::Split, "setHighlightSounds", {{"toggle"}}); + if (notifySeq.isEmpty()) + { + notifySeq = h->getDisplaySequence(HotkeyCategory::Split, + "setHighlightSounds", + {std::vector()}); + } + action->setShortcut(notifySeq); + QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() { action->setChecked(getSettings()->isMutedChannel( this->split_->getChannel()->getName()));