ref: unify Split popup logic (#3848)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Leon Richardt
2022-07-07 19:28:38 +02:00
committed by GitHub
parent 53a625e26e
commit e1b512a373
4 changed files with 22 additions and 14 deletions
+6 -10
View File
@@ -887,7 +887,7 @@ void CommandController::initialize(Settings &, Paths &paths)
});
this->registerCommand("/popup", [](const QStringList &words,
ChannelPtr channel) {
ChannelPtr sourceChannel) {
static const auto *usageMessage =
"Usage: /popup [channel]. Open specified Twitch channel in "
"a new window. If no channel argument is specified, open "
@@ -896,6 +896,7 @@ void CommandController::initialize(Settings &, Paths &paths)
QString target(words.value(1));
stripChannelName(target);
// Popup the current split
if (target.isEmpty())
{
auto *currentPage =
@@ -914,19 +915,14 @@ void CommandController::initialize(Settings &, Paths &paths)
}
}
channel->addMessage(makeSystemMessage(usageMessage));
sourceChannel->addMessage(makeSystemMessage(usageMessage));
return "";
}
// Open channel passed as argument in a popup
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->getOrAddChannel(target));
window.getNotebook().getOrAddSelectedPage()->appendSplit(split);
auto targetChannel = app->twitch->getOrAddChannel(target);
app->windows->openInPopup(targetChannel);
return "";
});