diff --git a/CHANGELOG.md b/CHANGELOG.md index ab337463..3a9ae87a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unversioned - Minor: Added an option to allow multiple user-selected extensions to interact with Chatterino. (#5997) -- Minor: Add `Set highlight sounds` and `Open subscription page` split hotkeys. (#5856) +- Minor: Add `Set highlight sounds` and `Open subscription page` split hotkeys. (#5856, #6030) - 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/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 203f16ab..26b4820d 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -464,32 +464,32 @@ void Split::addShortcuts() { HotkeyController::HotkeyMap actions{ {"delete", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->deleteFromContainer(); return ""; }}, {"changeChannel", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->changeChannel(); return ""; }}, {"showSearch", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->showSearch(true); return ""; }}, {"showGlobalSearch", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->showSearch(false); return ""; }}, {"reconnect", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->reconnect(); return ""; }}, {"debug", - [](std::vector) -> QString { + [](const std::vector &) -> QString { auto *popup = new DebugPopup; popup->setAttribute(Qt::WA_DeleteOnClose); popup->setWindowTitle("Chatterino - Debug popup"); @@ -497,8 +497,8 @@ void Split::addShortcuts() return ""; }}, {"focus", - [this](std::vector arguments) -> QString { - if (arguments.size() == 0) + [this](const std::vector &arguments) -> QString { + if (arguments.empty()) { return "focus action requires only one argument: the " "focus direction Use \"up\", \"above\", \"down\", " @@ -530,20 +530,20 @@ void Split::addShortcuts() return ""; }}, {"scrollToBottom", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->getChannelView().getScrollBar().scrollToBottom( getSettings()->enableSmoothScrollingNewMessages.getValue()); return ""; }}, {"scrollToTop", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->getChannelView().getScrollBar().scrollToTop( getSettings()->enableSmoothScrollingNewMessages.getValue()); return ""; }}, {"scrollPage", - [this](std::vector arguments) -> QString { - if (arguments.size() == 0) + [this](const std::vector &arguments) -> QString { + if (arguments.empty()) { qCWarning(chatterinoHotkeys) << "scrollPage hotkey called without arguments!"; @@ -567,12 +567,12 @@ void Split::addShortcuts() return ""; }}, {"pickFilters", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->setFiltersDialog(); return ""; }}, {"openInBrowser", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { if (this->getChannel()->getType() == Channel::Type::TwitchWhispers) { this->openWhispersInBrowser(); @@ -585,27 +585,27 @@ void Split::addShortcuts() return ""; }}, {"openInStreamlink", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->openInStreamlink(); return ""; }}, {"openInCustomPlayer", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->openWithCustomScheme(); return ""; }}, {"openPlayerInBrowser", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->openBrowserPlayer(); return ""; }}, {"openModView", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->openModViewInBrowser(); return ""; }}, {"createClip", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { // Alt+X: create clip LUL if (const auto type = this->getChannel()->getType(); type != Channel::Type::Twitch && @@ -621,10 +621,10 @@ void Split::addShortcuts() return ""; }}, {"reloadEmotes", - [this](std::vector arguments) -> QString { + [this](const std::vector &arguments) -> QString { auto reloadChannel = true; auto reloadSubscriber = true; - if (arguments.size() != 0) + if (!arguments.empty()) { auto arg = arguments.at(0); if (arg == "channel") @@ -648,7 +648,7 @@ void Split::addShortcuts() return ""; }}, {"setModerationMode", - [this](std::vector arguments) -> QString { + [this](const std::vector &arguments) -> QString { if (!this->getChannel()->isTwitchChannel()) { return "Cannot set moderation mode in a non-Twitch " @@ -658,7 +658,7 @@ void Split::addShortcuts() // 0 is off // 1 is on // 2 is toggle - if (arguments.size() != 0) + if (!arguments.empty()) { auto arg = arguments.at(0); if (arg == "off") @@ -669,45 +669,41 @@ void Split::addShortcuts() { mode = 1; } - else - { - mode = 2; - } } - if (mode == 0) + switch (mode) { - this->setModerationMode(false); - } - else if (mode == 1) - { - this->setModerationMode(true); - } - else - { - this->setModerationMode(!this->getModerationMode()); + case 0: + this->setModerationMode(false); + break; + case 1: + this->setModerationMode(true); + break; + default: + this->setModerationMode(!this->getModerationMode()); } + return ""; }}, {"openViewerList", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->showChatterList(); return ""; }}, {"clearMessages", - [this](std::vector) -> QString { + [this](const std::vector &) -> QString { this->clear(); return ""; }}, {"runCommand", - [this](std::vector arguments) -> QString { + [this](const std::vector &arguments) -> QString { if (arguments.empty()) { qCWarning(chatterinoHotkeys) << "runCommand hotkey called without arguments!"; return "runCommand hotkey called without arguments!"; } - QString requestedText = arguments.at(0).replace('\n', ' '); + QString requestedText = QString(arguments[0]).replace('\n', ' '); QString inputText = this->getInput().getInputText(); QString message = getApp()->getCommands()->execCustomCommand( @@ -723,7 +719,7 @@ void Split::addShortcuts() return ""; }}, {"setChannelNotification", - [this](std::vector arguments) -> QString { + [this](const std::vector &arguments) -> QString { if (!this->getChannel()->isTwitchChannel()) { return "Cannot set channel notifications for a non-Twitch " @@ -733,7 +729,7 @@ void Split::addShortcuts() // 0 is off // 1 is on // 2 is toggle - if (arguments.size() != 0) + if (!arguments.empty()) { auto arg = arguments.at(0); if (arg == "off") @@ -744,26 +740,23 @@ void Split::addShortcuts() { mode = 1; } - else - { - mode = 2; - } } - if (mode == 0) + auto *notifications = getApp()->getNotifications(); + const QString channelName = this->getChannel()->getName(); + switch (mode) { - getApp()->getNotifications()->removeChannelNotification( - this->getChannel()->getName(), Platform::Twitch); - } - else if (mode == 1) - { - getApp()->getNotifications()->addChannelNotification( - this->getChannel()->getName(), Platform::Twitch); - } - else - { - getApp()->getNotifications()->updateChannelNotification( - this->getChannel()->getName(), Platform::Twitch); + case 0: + notifications->removeChannelNotification(channelName, + Platform::Twitch); + break; + case 1: + notifications->addChannelNotification(channelName, + Platform::Twitch); + break; + default: + notifications->updateChannelNotification(channelName, + Platform::Twitch); } return ""; }}, @@ -809,7 +802,7 @@ void Split::addShortcuts() return {}; }}, {"setHighlightSounds", - [this](std::vector arguments) -> QString { + [this](const std::vector &arguments) -> QString { if (!this->getChannel()->isTwitchChannel()) { return "Cannot set highlight sounds in a non-Twitch " @@ -934,7 +927,7 @@ void Split::openChannelInBrowserPlayer(ChannelPtr channel) } } -void Split::openChannelInStreamlink(QString channelName) +void Split::openChannelInStreamlink(const QString channelName) { try { @@ -1518,7 +1511,7 @@ void Split::showChatterList() HotkeyController::HotkeyMap actions{ {"delete", - [chatterDock](std::vector) -> QString { + [chatterDock](const std::vector &) -> QString { chatterDock->close(); return ""; }}, @@ -1527,7 +1520,7 @@ void Split::showChatterList() {"scrollPage", nullptr}, {"openTab", nullptr}, {"search", - [searchBar](std::vector) -> QString { + [searchBar](const std::vector &) -> QString { searchBar->setFocus(); searchBar->selectAll(); return ""; diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index 0b4aa413..1b5babb1 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -133,7 +133,7 @@ private: /** * @brief Opens Twitch channel stream in streamlink app (if stream is live and streamlink is installed) */ - void openChannelInStreamlink(QString channelName); + void openChannelInStreamlink(const QString channelName); /** * @brief Opens Twitch channel chat in a new Chatterino tab */ diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index f21e00ab..f3132469 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -541,59 +541,64 @@ std::unique_ptr 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()}); - // 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()}); + // 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()}); + 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()}); + } + 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();