Added /popup command to open currently focused split or supplied channel in a new window (#3529)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
qooq69 2022-03-05 11:54:09 +01:00 committed by GitHub
parent e29740bd59
commit 34aadbf7d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View file

@ -53,6 +53,7 @@
- Minor: Opening streamlink through hotkeys and/or split header menu matches `/streamlink` command and shows feedback in chat as well. (#3510)
- Minor: Removed timestamp from AutoMod messages. (#3503)
- Minor: Added ability to copy message ID with `Shift + Right Click`. (#3481)
- Minor: Added /popup command to open currently focused split or supplied channel in a new window. (#3529)
- Minor: Colorize the entire split header when focused. (#3379)
- Minor: Added incremental search to channel search. (#3544)
- Minor: Show right click context menu anywhere within a message's line. (#3566)

View file

@ -685,6 +685,51 @@ void CommandController::initialize(Settings &, Paths &paths)
return "";
});
this->registerCommand("/popup", [](const QStringList &words,
ChannelPtr channel) {
static const auto *usageMessage =
"Usage: /popup [channel]. Open specified Twitch channel in "
"a new window. If no channel argument is specified, open "
"the currently selected split instead.";
QString target(words.value(1));
stripChannelName(target);
if (target.isEmpty())
{
auto *currentPage =
dynamic_cast<SplitContainer *>(getApp()
->windows->getMainWindow()
.getNotebook()
.getSelectedPage());
if (currentPage != nullptr)
{
auto *currentSplit = currentPage->getSelectedSplit();
if (currentSplit != nullptr)
{
currentSplit->popup();
return "";
}
}
channel->addMessage(makeSystemMessage(usageMessage));
return "";
}
auto *app = getApp();
Window &window = app->windows->createWindow(WindowType::Popup, true);
auto *split = new Split(static_cast<SplitContainer *>(
window.getNotebook().getOrAddSelectedPage()));
split->setChannel(app->twitch.server->getOrAddChannel(target));
window.getNotebook().getOrAddSelectedPage()->appendSplit(split);
return "";
});
this->registerCommand("/clearmessages", [](const auto & /*words*/,
ChannelPtr channel) {
auto *currentPage = dynamic_cast<SplitContainer *>(