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
+1 -1
View File
@@ -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)
+57 -64
View File
@@ -464,32 +464,32 @@ void Split::addShortcuts()
{
HotkeyController::HotkeyMap actions{
{"delete",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->deleteFromContainer();
return "";
}},
{"changeChannel",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->changeChannel();
return "";
}},
{"showSearch",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->showSearch(true);
return "";
}},
{"showGlobalSearch",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->showSearch(false);
return "";
}},
{"reconnect",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->reconnect();
return "";
}},
{"debug",
[](std::vector<QString>) -> QString {
[](const std::vector<QString> &) -> 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<QString> arguments) -> QString {
if (arguments.size() == 0)
[this](const std::vector<QString> &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>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->getChannelView().getScrollBar().scrollToBottom(
getSettings()->enableSmoothScrollingNewMessages.getValue());
return "";
}},
{"scrollToTop",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->getChannelView().getScrollBar().scrollToTop(
getSettings()->enableSmoothScrollingNewMessages.getValue());
return "";
}},
{"scrollPage",
[this](std::vector<QString> arguments) -> QString {
if (arguments.size() == 0)
[this](const std::vector<QString> &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>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->setFiltersDialog();
return "";
}},
{"openInBrowser",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
if (this->getChannel()->getType() == Channel::Type::TwitchWhispers)
{
this->openWhispersInBrowser();
@@ -585,27 +585,27 @@ void Split::addShortcuts()
return "";
}},
{"openInStreamlink",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->openInStreamlink();
return "";
}},
{"openInCustomPlayer",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->openWithCustomScheme();
return "";
}},
{"openPlayerInBrowser",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->openBrowserPlayer();
return "";
}},
{"openModView",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->openModViewInBrowser();
return "";
}},
{"createClip",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> 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<QString> arguments) -> QString {
[this](const std::vector<QString> &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<QString> arguments) -> QString {
[this](const std::vector<QString> &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>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->showChatterList();
return "";
}},
{"clearMessages",
[this](std::vector<QString>) -> QString {
[this](const std::vector<QString> &) -> QString {
this->clear();
return "";
}},
{"runCommand",
[this](std::vector<QString> arguments) -> QString {
[this](const std::vector<QString> &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<QString> arguments) -> QString {
[this](const std::vector<QString> &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<QString> arguments) -> QString {
[this](const std::vector<QString> &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>) -> QString {
[chatterDock](const std::vector<QString> &) -> QString {
chatterDock->close();
return "";
}},
@@ -1527,7 +1520,7 @@ void Split::showChatterList()
{"scrollPage", nullptr},
{"openTab", nullptr},
{"search",
[searchBar](std::vector<QString>) -> QString {
[searchBar](const std::vector<QString> &) -> QString {
searchBar->setFocus();
searchBar->selectAll();
return "";
+1 -1
View File
@@ -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
*/
+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();