diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 8c63358ea..0f4701974 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1197,6 +1197,17 @@ void ChannelView::hideEvent(QHideEvent *) this->messagesOnScreen_.clear(); } +void ChannelView::showUserInfoPopup(const QString &userName) +{ + auto *userPopup = new UserInfoPopup; + userPopup->setData(userName, this->channel_); + userPopup->setActionOnFocusLoss(BaseWindow::Delete); + QPoint offset(int(150 * this->getScale()), + int(70 * this->getScale())); + userPopup->move(QCursor::pos() - offset); + userPopup->show(); +} + void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout) { @@ -1208,17 +1219,8 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, case Link::UserWhisper: case Link::UserInfo: { auto user = link.value; - - auto *userPopup = new UserInfoPopup; - userPopup->setData(user, this->channel_); - userPopup->setActionOnFocusLoss(BaseWindow::Delete); - QPoint offset(int(150 * this->getScale()), - int(70 * this->getScale())); - userPopup->move(QCursor::pos() - offset); - userPopup->show(); - + this->showUserInfoPopup(user); qDebug() << "Clicked " << user << "s message"; - } break; case Link::Url: { diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index e34c0dc85..48d7712d0 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -56,6 +56,7 @@ public: void layoutMessages(); void clearMessages(); + void showUserInfoPopup(const QString &userName); pajlada::Signals::Signal mouseDown; pajlada::Signals::NoArgSignal selectionChanged; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 499403d8f..225e526fd 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -527,16 +527,18 @@ void Split::showViewerList() QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this, [=]() { viewerDock->setMinimumWidth(300); }); - QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() { - if (!labels.contains(chattersList->currentItem()->text())) { - showUserInfoPopup(chattersList->currentItem()->text()); + auto listDoubleClick = [=](QString userName) { + if (!labels.contains(userName)) { + this->view_->showUserInfoPopup(userName); } + }; + + QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() { + listDoubleClick(chattersList->currentItem()->text()); }); QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() { - if (!labels.contains(resultList->currentItem()->text())) { - showUserInfoPopup(resultList->currentItem()->text()); - } + listDoubleClick(resultList->currentItem()->text()); }); dockVbox->addWidget(searchBar); @@ -551,16 +553,6 @@ void Split::showViewerList() viewerDock->show(); } -void Split::showUserInfoPopup(const UserName &user) -{ - auto *userPopup = new UserInfoPopup; - userPopup->setData(user.string, this->getChannel()); - userPopup->setAttribute(Qt::WA_DeleteOnClose); - userPopup->move(QCursor::pos() - QPoint(int(150 * this->getScale()), - int(70 * this->getScale()))); - userPopup->show(); -} - void Split::copyToClipboard() { QApplication::clipboard()->setText(this->view_->getSelectedText()); diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index 6b7e6d057..d9499b9b2 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -88,11 +88,6 @@ protected: void focusInEvent(QFocusEvent *event) override; private: - void showUserInfoPopup(const QString &userName) - { - this->showUserInfoPopup(UserName{userName}); - } - void showUserInfoPopup(const UserName &user); void channelNameUpdated(const QString &newChannelName); void handleModifiers(Qt::KeyboardModifiers modifiers);