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 ## Unversioned
- Minor: Add `Set highlight sounds` and `Open subscription page` split hotkeys. (#5856)
- Minor: `/clear` messages are now stacked like timeouts. (#5806) - Minor: `/clear` messages are now stacked like timeouts. (#5806)
- Minor: Treat all browsers starting with `firefox` as a Firefox browser. (#5805) - 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) - 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:", .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, {HotkeyCategory::SplitInput,
{ {
+1 -1
View File
@@ -75,7 +75,7 @@ Qt::ShortcutContext Hotkey::getContext() const
} }
qCDebug(chatterinoHotkeys) qCDebug(chatterinoHotkeys)
<< "Using default shortcut context for" << this->getCategory() << "Using default shortcut context for" << this->getCategory()
<< "and hopeing for the best."; << "and hoping for the best.";
return Qt::WidgetShortcut; 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) void Settings::mute(const QString &channelName)
{ {
mutedChannels.append(channelName); if (!this->isMutedChannel(channelName))
{
this->mutedChannels.append(channelName);
}
} }
void Settings::unmute(const QString &channelName) void Settings::unmute(const QString &channelName)
@@ -134,7 +137,7 @@ bool Settings::toggleMutedChannel(const QString &channelName)
} }
else else
{ {
mute(channelName); this->mutedChannels.append(channelName);
return true; return true;
} }
} }
+2 -3
View File
@@ -678,6 +678,7 @@ private:
{"/moderation/actions"}; {"/moderation/actions"};
ChatterinoSetting<std::vector<ChannelLog>> loggedChannelsSetting = { ChatterinoSetting<std::vector<ChannelLog>> loggedChannelsSetting = {
"/logging/channels"}; "/logging/channels"};
SignalVector<QString> mutedChannels;
public: public:
SignalVector<HighlightPhrase> highlightedMessages; SignalVector<HighlightPhrase> highlightedMessages;
@@ -685,7 +686,6 @@ public:
SignalVector<HighlightBadge> highlightedBadges; SignalVector<HighlightBadge> highlightedBadges;
SignalVector<HighlightBlacklistUser> blacklistedUsers; SignalVector<HighlightBlacklistUser> blacklistedUsers;
SignalVector<IgnorePhrase> ignoredMessages; SignalVector<IgnorePhrase> ignoredMessages;
SignalVector<QString> mutedChannels;
SignalVector<FilterRecordPtr> filterRecords; SignalVector<FilterRecordPtr> filterRecords;
SignalVector<Nickname> nicknames; SignalVector<Nickname> nicknames;
SignalVector<ModerationAction> moderationActions; SignalVector<ModerationAction> moderationActions;
@@ -696,11 +696,10 @@ public:
bool isMutedChannel(const QString &channelName); bool isMutedChannel(const QString &channelName);
bool toggleMutedChannel(const QString &channelName); bool toggleMutedChannel(const QString &channelName);
std::optional<QString> matchNickname(const QString &username); std::optional<QString> matchNickname(const QString &username);
private:
void mute(const QString &channelName); void mute(const QString &channelName);
void unmute(const QString &channelName); void unmute(const QString &channelName);
private:
void updateModerationActions(); void updateModerationActions();
std::unique_ptr<rapidjson::Document> snapshot_; std::unique_ptr<rapidjson::Document> snapshot_;
+57 -5
View File
@@ -611,7 +611,7 @@ void Split::addShortcuts()
type != Channel::Type::Twitch && type != Channel::Type::Twitch &&
type != Channel::Type::TwitchWatching) type != Channel::Type::TwitchWatching)
{ {
return "Cannot create clip it non-twitch channel."; return "Cannot create clips in a non-Twitch channel.";
} }
auto *twitchChannel = auto *twitchChannel =
@@ -651,7 +651,8 @@ void Split::addShortcuts()
[this](std::vector<QString> arguments) -> QString { [this](std::vector<QString> arguments) -> QString {
if (!this->getChannel()->isTwitchChannel()) 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; auto mode = 2;
// 0 is off // 0 is off
@@ -725,7 +726,7 @@ void Split::addShortcuts()
[this](std::vector<QString> arguments) -> QString { [this](std::vector<QString> arguments) -> QString {
if (!this->getChannel()->isTwitchChannel()) if (!this->getChannel()->isTwitchChannel())
{ {
return "Cannot set channel notifications for non-twitch " return "Cannot set channel notifications for a non-Twitch "
"channel."; "channel.";
} }
auto mode = 2; auto mode = 2;
@@ -807,6 +808,57 @@ void Split::addShortcuts()
} }
return {}; 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( this->shortcuts_ = getApp()->getHotkeys()->shortcutsForCategory(
@@ -1626,8 +1678,8 @@ void Split::drag()
auto *container = dynamic_cast<SplitContainer *>(this->parentWidget()); auto *container = dynamic_cast<SplitContainer *>(this->parentWidget());
if (!container) if (!container)
{ {
qCWarning(chatterinoWidget) qCWarning(chatterinoWidget) << "Attempted to initiate split drag "
<< "Attempted to initiate split drag without a container parent"; "without a container parent";
return; return;
} }
+14 -2
View File
@@ -537,7 +537,9 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
h->getDisplaySequence(HotkeyCategory::Split, "openViewerList")); 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); auto *action = new QAction(this);
action->setText("Notify when live"); action->setText("Notify when live");
@@ -569,9 +571,19 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
if (twitchChannel) if (twitchChannel)
{ {
auto *action = new QAction(this); auto *action = new QAction(this);
action->setText("Mute highlight sound"); action->setText("Mute highlight sounds");
action->setCheckable(true); 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]() { QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getSettings()->isMutedChannel( action->setChecked(getSettings()->isMutedChannel(
this->split_->getChannel()->getName())); this->split_->getChannel()->getName()));