feat: setHighlightSounds & openSubscriptionPage split hotkeys (#5856)

This commit is contained in:
Brian
2025-03-03 14:20:09 -05:00
committed by GitHub
parent 34429671ba
commit 8dd19d2d5e
7 changed files with 92 additions and 13 deletions
+1
View File
@@ -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)
+12
View File
@@ -195,6 +195,18 @@ inline const std::map<HotkeyCategory, ActionDefinitionMap> 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,
{
+1 -1
View File
@@ -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;
}
+5 -2
View File
@@ -109,7 +109,10 @@ std::optional<QString> 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;
}
}
+2 -3
View File
@@ -678,6 +678,7 @@ private:
{"/moderation/actions"};
ChatterinoSetting<std::vector<ChannelLog>> loggedChannelsSetting = {
"/logging/channels"};
SignalVector<QString> mutedChannels;
public:
SignalVector<HighlightPhrase> highlightedMessages;
@@ -685,7 +686,6 @@ public:
SignalVector<HighlightBadge> highlightedBadges;
SignalVector<HighlightBlacklistUser> blacklistedUsers;
SignalVector<IgnorePhrase> ignoredMessages;
SignalVector<QString> mutedChannels;
SignalVector<FilterRecordPtr> filterRecords;
SignalVector<Nickname> nicknames;
SignalVector<ModerationAction> moderationActions;
@@ -696,11 +696,10 @@ public:
bool isMutedChannel(const QString &channelName);
bool toggleMutedChannel(const QString &channelName);
std::optional<QString> matchNickname(const QString &username);
private:
void mute(const QString &channelName);
void unmute(const QString &channelName);
private:
void updateModerationActions();
std::unique_ptr<rapidjson::Document> snapshot_;
+57 -5
View File
@@ -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<QString> 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<QString> 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<QString> 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<SplitContainer *>(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;
}
+14 -2
View File
@@ -537,7 +537,9 @@ std::unique_ptr<QMenu> 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<QMenu> 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<QString>()});
}
action->setShortcut(notifySeq);
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getSettings()->isMutedChannel(
this->split_->getChannel()->getName()));