Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added opening a user's chat in a new tab/split/window with keybinds+click #3766

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Minor: Added chatter count for each category in viewer list. (#3683)
- Minor: Sorted usernames in /vips message to be case-insensitive. (#3696)
- Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625)
- Minor: Added option to open a user's chat in a new tab/split/window by CTRL/ALT/SHIFT+Left Clicking (#3766)
- Minor: Fixed tag parsing for consecutive escaped characters. (#3711)
- Minor: Prevent user from entering incorrect characters in Live Notifications channels list. (#3715, #3730)
- Minor: Fixed automod caught message notice appearing twice for mods. (#3717)
Expand Down
10 changes: 1 addition & 9 deletions src/controllers/commands/CommandController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,15 +742,7 @@ void CommandController::initialize(Settings &, Paths &paths)
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->getOrAddChannel(target));

window.getNotebook().getOrAddSelectedPage()->appendSplit(split);
getApp()->windows->createChannelWindow(target);

return "";
});
Expand Down
26 changes: 26 additions & 0 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,32 @@ Window &WindowManager::createWindow(WindowType type, bool show)
return *window;
}

Window &WindowManager::createChannelWindow(ChannelPtr channel)
{
Window &window = this->createWindow(WindowType::Popup, true);
auto split =
window.getNotebook().getOrAddSelectedPage()->appendNewSplit(false);
split->setChannel(channel);
window.getNotebook().getOrAddSelectedPage()->refreshTab();
return window;
}

Window &WindowManager::createChannelWindow(QString channelName)
{
return this->createChannelWindow(
getApp()->twitch->getOrAddChannel(channelName));
}

Window &WindowManager::createChannelWindow(Split *split)
{
Window &window =
this->createChannelWindow(split->getIndirectChannel().get());
Split *_split = window.getNotebook().getOrAddSelectedPage()->getSplits()[0];
_split->setModerationMode(split->getModerationMode());
_split->setFilters(split->getFilters());
return window;
}

void WindowManager::select(Split *split)
{
this->selectSplit.invoke(split);
Expand Down
5 changes: 5 additions & 0 deletions src/singletons/WindowManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class WindowManager final : public Singleton
Window &getSelectedWindow();
Window &createWindow(WindowType type, bool show = true);

// Opens a channel in new popup window
Window &createChannelWindow(ChannelPtr channel);
Window &createChannelWindow(QString channelName);
Window &createChannelWindow(Split *split);

void select(Split *split);
void select(SplitContainer *container);

Expand Down
10 changes: 2 additions & 8 deletions src/widgets/dialogs/UserInfoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,8 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
menu->addAction(
"Open channel in a new popup window", this,
[loginName] {
auto app = getApp();
auto &window = app->windows->createWindow(
WindowType::Popup, true);
auto split = window.getNotebook()
.getOrAddSelectedPage()
->appendNewSplit(false);
split->setChannel(app->twitch->getOrAddChannel(
loginName.toLower()));
getApp()->windows->createChannelWindow(
loginName);
});

menu->addAction(
Expand Down
19 changes: 18 additions & 1 deletion src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,24 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
case Link::UserWhisper:
case Link::UserInfo: {
auto user = link.value;
this->showUserInfoPopup(user, layout->getMessage()->channelName);
switch (event->modifiers())
{
case Qt::ShiftModifier:
getApp()->windows->createChannelWindow(user);
break;
case Qt::ControlModifier:
this->openChannelIn.invoke(
user, FromTwitchLinkOpenChannelIn::Tab);
break;
case Qt::AltModifier:
this->openChannelIn.invoke(
user, FromTwitchLinkOpenChannelIn::Split);
break;
default:
this->showUserInfoPopup(user,
layout->getMessage()->channelName);
break;
}
}
break;

Expand Down
13 changes: 1 addition & 12 deletions src/widgets/splits/Split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,18 +874,7 @@ void Split::explainSplitting()

void Split::popup()
{
auto app = getApp();
Window &window = app->windows->createWindow(WindowType::Popup);

Split *split = new Split(static_cast<SplitContainer *>(
window.getNotebook().getOrAddSelectedPage()));

split->setChannel(this->getIndirectChannel());
split->setModerationMode(this->getModerationMode());
split->setFilters(this->getFilters());

window.getNotebook().getOrAddSelectedPage()->appendSplit(split);
window.show();
getApp()->windows->createChannelWindow(this);
}

void Split::clear()
Expand Down