From 4df320ed9f3c4659d7e43027197d3d5e681fb540 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Sat, 21 May 2022 13:03:42 -0400 Subject: [PATCH 1/6] Add opening channels in tab/split via username (#2881) --- src/widgets/helper/ChannelView.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index c938ceee231..2ea59b8e45d 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1718,6 +1718,22 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) else if (hoverLayoutElement->getFlags().has( MessageElementFlag::Username)) { + if (event->modifiers() == Qt::ShiftModifier) + { + this->openChannelIn.invoke( + hoverLayoutElement->getLink().value, + FromTwitchLinkOpenChannelIn::Tab); + return; + } + + if (event->modifiers() == Qt::AltModifier) + { + this->openChannelIn.invoke( + hoverLayoutElement->getLink().value, + FromTwitchLinkOpenChannelIn::Split); + return; + } + openTwitchUsercard(this->channel_->getName(), hoverLayoutElement->getLink().value); return; From cf5fe7d93dd65a96d45f83a975c34fba8b31cec8 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Mon, 23 May 2022 15:21:54 -0400 Subject: [PATCH 2/6] Add WindowManager#openNewChannelWindow to open a pop-up window with a channel - Clean up code re-use in place of WindowManager#openNewChannelWindow --- src/controllers/commands/CommandController.cpp | 10 +--------- src/singletons/WindowManager.cpp | 16 ++++++++++++++++ src/singletons/WindowManager.hpp | 4 ++++ src/widgets/dialogs/UserInfoPopup.cpp | 10 ++-------- src/widgets/splits/Split.cpp | 13 +++---------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index e4fe0f20e01..62498819be0 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -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( - window.getNotebook().getOrAddSelectedPage())); - - split->setChannel(app->twitch->getOrAddChannel(target)); - - window.getNotebook().getOrAddSelectedPage()->appendSplit(split); + getApp()->windows->openNewChannelWindow(target); return ""; }); diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 81d2af113a5..ad1abaf3c90 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -275,6 +275,22 @@ Window &WindowManager::createWindow(WindowType type, bool show) return *window; } +Window &WindowManager::openNewChannelWindow(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::openNewChannelWindow(QString channelName) +{ + return this->openNewChannelWindow( + getApp()->twitch->getOrAddChannel(channelName)); +} + void WindowManager::select(Split *split) { this->selectSplit.invoke(split); diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index c3d7c75f552..89b734f1a3f 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -59,6 +59,10 @@ class WindowManager final : public Singleton Window &getSelectedWindow(); Window &createWindow(WindowType type, bool show = true); + // Opens a channel in new popup window + Window &openNewChannelWindow(ChannelPtr channel); + Window &openNewChannelWindow(QString channelName); + void select(Split *split); void select(SplitContainer *container); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index b2c8bd4f579..925aadbdaa9 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -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->openNewChannelWindow( + loginName); }); menu->addAction( diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 8ee377f41ee..4d2e197018e 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -874,18 +874,11 @@ void Split::explainSplitting() void Split::popup() { - auto app = getApp(); - Window &window = app->windows->createWindow(WindowType::Popup); - - Split *split = new Split(static_cast( - window.getNotebook().getOrAddSelectedPage())); - - split->setChannel(this->getIndirectChannel()); + Window &window = getApp()->windows->openNewChannelWindow( + this->getIndirectChannel().get()); + Split *split = window.getNotebook().getOrAddSelectedPage()->getSplits()[0]; split->setModerationMode(this->getModerationMode()); split->setFilters(this->getFilters()); - - window.getNotebook().getOrAddSelectedPage()->appendSplit(split); - window.show(); } void Split::clear() From bf51775c0427a82266677228bc3a2695eeee7353 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Mon, 23 May 2022 15:22:41 -0400 Subject: [PATCH 3/6] Move logic to ChannelView::handleLinkClick, change modifiers, add popup support - Move changes from 4df320e to ChannelView::handleLinkClick method - Now properly opens channels in a new tab or split - Add ability to open in a new popup - Change keybindings and on middle mouse click to left click --- src/widgets/helper/ChannelView.cpp | 38 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 2ea59b8e45d..e7cfd42aea8 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1718,22 +1718,6 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) else if (hoverLayoutElement->getFlags().has( MessageElementFlag::Username)) { - if (event->modifiers() == Qt::ShiftModifier) - { - this->openChannelIn.invoke( - hoverLayoutElement->getLink().value, - FromTwitchLinkOpenChannelIn::Tab); - return; - } - - if (event->modifiers() == Qt::AltModifier) - { - this->openChannelIn.invoke( - hoverLayoutElement->getLink().value, - FromTwitchLinkOpenChannelIn::Split); - return; - } - openTwitchUsercard(this->channel_->getName(), hoverLayoutElement->getLink().value); return; @@ -2203,8 +2187,26 @@ 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: + // openChannelIn = FromTwitchLinkOpenChannelIn:: + getApp()->windows->openNewChannelWindow(link.value); + break; + case Qt::ControlModifier: + this->openChannelIn.invoke( + link.value, FromTwitchLinkOpenChannelIn::Tab); + break; + case Qt::AltModifier: + this->openChannelIn.invoke( + link.value, FromTwitchLinkOpenChannelIn::Split); + break; + default: + auto user = link.value; + this->showUserInfoPopup(user, + layout->getMessage()->channelName); + break; + } } break; From 95f41ab5f20a79abcf3d681c01ce8690785253b7 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Mon, 23 May 2022 15:40:00 -0400 Subject: [PATCH 4/6] Remove leftover comment --- src/widgets/helper/ChannelView.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index e7cfd42aea8..ed8b5fa3a14 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2190,7 +2190,6 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, switch (event->modifiers()) { case Qt::ShiftModifier: - // openChannelIn = FromTwitchLinkOpenChannelIn:: getApp()->windows->openNewChannelWindow(link.value); break; case Qt::ControlModifier: From 943c0ccd8a0cb6a41dcee6680b3f18747f9b7f02 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Mon, 23 May 2022 15:54:20 -0400 Subject: [PATCH 5/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c83a6d12b5..0cda2dbdf34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) From d3240012aeee91fdaef28d047c5287b9a2c0448b Mon Sep 17 00:00:00 2001 From: Infinitay Date: Sun, 29 May 2022 12:57:30 -0400 Subject: [PATCH 6/6] reorder, #openNewChannelWindow -> #createChannelWindow, overload Split* --- src/controllers/commands/CommandController.cpp | 2 +- src/singletons/WindowManager.cpp | 16 +++++++++++++--- src/singletons/WindowManager.hpp | 5 +++-- src/widgets/dialogs/UserInfoPopup.cpp | 2 +- src/widgets/helper/ChannelView.cpp | 8 ++++---- src/widgets/splits/Split.cpp | 6 +----- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 62498819be0..423c8be50fe 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -742,7 +742,7 @@ void CommandController::initialize(Settings &, Paths &paths) return ""; } - getApp()->windows->openNewChannelWindow(target); + getApp()->windows->createChannelWindow(target); return ""; }); diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index ad1abaf3c90..2c9c74ab070 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -275,7 +275,7 @@ Window &WindowManager::createWindow(WindowType type, bool show) return *window; } -Window &WindowManager::openNewChannelWindow(ChannelPtr channel) +Window &WindowManager::createChannelWindow(ChannelPtr channel) { Window &window = this->createWindow(WindowType::Popup, true); auto split = @@ -285,12 +285,22 @@ Window &WindowManager::openNewChannelWindow(ChannelPtr channel) return window; } -Window &WindowManager::openNewChannelWindow(QString channelName) +Window &WindowManager::createChannelWindow(QString channelName) { - return this->openNewChannelWindow( + 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); diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index 89b734f1a3f..e91054a4077 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -60,8 +60,9 @@ class WindowManager final : public Singleton Window &createWindow(WindowType type, bool show = true); // Opens a channel in new popup window - Window &openNewChannelWindow(ChannelPtr channel); - Window &openNewChannelWindow(QString channelName); + Window &createChannelWindow(ChannelPtr channel); + Window &createChannelWindow(QString channelName); + Window &createChannelWindow(Split *split); void select(Split *split); void select(SplitContainer *container); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 925aadbdaa9..743bc19e7de 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -295,7 +295,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent) menu->addAction( "Open channel in a new popup window", this, [loginName] { - getApp()->windows->openNewChannelWindow( + getApp()->windows->createChannelWindow( loginName); }); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index ed8b5fa3a14..072c487cff5 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2187,21 +2187,21 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, { case Link::UserWhisper: case Link::UserInfo: { + auto user = link.value; switch (event->modifiers()) { case Qt::ShiftModifier: - getApp()->windows->openNewChannelWindow(link.value); + getApp()->windows->createChannelWindow(user); break; case Qt::ControlModifier: this->openChannelIn.invoke( - link.value, FromTwitchLinkOpenChannelIn::Tab); + user, FromTwitchLinkOpenChannelIn::Tab); break; case Qt::AltModifier: this->openChannelIn.invoke( - link.value, FromTwitchLinkOpenChannelIn::Split); + user, FromTwitchLinkOpenChannelIn::Split); break; default: - auto user = link.value; this->showUserInfoPopup(user, layout->getMessage()->channelName); break; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 4d2e197018e..e1e8a27cf6e 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -874,11 +874,7 @@ void Split::explainSplitting() void Split::popup() { - Window &window = getApp()->windows->openNewChannelWindow( - this->getIndirectChannel().get()); - Split *split = window.getNotebook().getOrAddSelectedPage()->getSplits()[0]; - split->setModerationMode(this->getModerationMode()); - split->setFilters(this->getFilters()); + getApp()->windows->createChannelWindow(this); } void Split::clear()