chore: Cleanup of hotkeys & settings in #5856 (#6030)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
Co-authored-by: nerix <nerixdev@outlook.de>
This commit is contained in:
Brian
2025-03-05 09:33:10 -05:00
committed by GitHub
parent ffb3a230c2
commit 54793f1496
4 changed files with 112 additions and 114 deletions
+53 -48
View File
@@ -541,59 +541,64 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
h->getDisplaySequence(HotkeyCategory::Split,
"openSubscriptionPage"));
auto *action = new QAction(this);
action->setText("Notify when live");
action->setCheckable(true);
auto notifySeq = h->getDisplaySequence(
HotkeyCategory::Split, "setChannelNotification", {{"toggle"}});
if (notifySeq.isEmpty())
{
notifySeq = h->getDisplaySequence(HotkeyCategory::Split,
"setChannelNotification",
{std::vector<QString>()});
// this makes a full std::optional<> with an empty vector inside
auto *action = new QAction(this);
action->setText("Notify when live");
action->setCheckable(true);
auto notifySeq = h->getDisplaySequence(
HotkeyCategory::Split, "setChannelNotification", {{"toggle"}});
if (notifySeq.isEmpty())
{
notifySeq = h->getDisplaySequence(HotkeyCategory::Split,
"setChannelNotification",
{std::vector<QString>()});
// this makes a full std::optional<> with an empty vector inside
}
action->setShortcut(notifySeq);
QObject::connect(
moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(
getApp()->getNotifications()->isChannelNotified(
this->split_->getChannel()->getName(),
Platform::Twitch));
});
QObject::connect(action, &QAction::triggered, this, [this]() {
getApp()->getNotifications()->updateChannelNotification(
this->split_->getChannel()->getName(), Platform::Twitch);
});
moreMenu->addAction(action);
}
action->setShortcut(notifySeq);
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getApp()->getNotifications()->isChannelNotified(
this->split_->getChannel()->getName(), Platform::Twitch));
});
QObject::connect(action, &QAction::triggered, this, [this]() {
getApp()->getNotifications()->updateChannelNotification(
this->split_->getChannel()->getName(), Platform::Twitch);
});
moreMenu->addAction(action);
}
if (twitchChannel)
{
auto *action = new QAction(this);
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>()});
auto *action = new QAction(this);
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()));
});
QObject::connect(action, &QAction::triggered, this, [this]() {
getSettings()->toggleMutedChannel(
this->split_->getChannel()->getName());
});
moreMenu->addAction(action);
}
action->setShortcut(notifySeq);
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getSettings()->isMutedChannel(
this->split_->getChannel()->getName()));
});
QObject::connect(action, &QAction::triggered, this, [this]() {
getSettings()->toggleMutedChannel(
this->split_->getChannel()->getName());
});
moreMenu->addAction(action);
}
moreMenu->addSeparator();