Moved creating UserInfoPopup in one place. (#761)

* Moved creating UserInfoPopup in one place.

* Added forgotten 'this'.

Fixes #759
This commit is contained in:
23rd 2018-10-06 13:13:14 +03:00 committed by pajlada
parent b4683c5b35
commit 9f5da50bce
4 changed files with 21 additions and 31 deletions

View file

@ -1197,6 +1197,17 @@ void ChannelView::hideEvent(QHideEvent *)
this->messagesOnScreen_.clear(); 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, void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
MessageLayout *layout) MessageLayout *layout)
{ {
@ -1208,17 +1219,8 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
case Link::UserWhisper: case Link::UserWhisper:
case Link::UserInfo: { case Link::UserInfo: {
auto user = link.value; auto user = link.value;
this->showUserInfoPopup(user);
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();
qDebug() << "Clicked " << user << "s message"; qDebug() << "Clicked " << user << "s message";
} break; } break;
case Link::Url: { case Link::Url: {

View file

@ -56,6 +56,7 @@ public:
void layoutMessages(); void layoutMessages();
void clearMessages(); void clearMessages();
void showUserInfoPopup(const QString &userName);
pajlada::Signals::Signal<QMouseEvent *> mouseDown; pajlada::Signals::Signal<QMouseEvent *> mouseDown;
pajlada::Signals::NoArgSignal selectionChanged; pajlada::Signals::NoArgSignal selectionChanged;

View file

@ -527,16 +527,18 @@ void Split::showViewerList()
QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this, QObject::connect(viewerDock, &QDockWidget::topLevelChanged, this,
[=]() { viewerDock->setMinimumWidth(300); }); [=]() { viewerDock->setMinimumWidth(300); });
QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() { auto listDoubleClick = [=](QString userName) {
if (!labels.contains(chattersList->currentItem()->text())) { if (!labels.contains(userName)) {
showUserInfoPopup(chattersList->currentItem()->text()); this->view_->showUserInfoPopup(userName);
} }
};
QObject::connect(chattersList, &QListWidget::doubleClicked, this, [=]() {
listDoubleClick(chattersList->currentItem()->text());
}); });
QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() { QObject::connect(resultList, &QListWidget::doubleClicked, this, [=]() {
if (!labels.contains(resultList->currentItem()->text())) { listDoubleClick(resultList->currentItem()->text());
showUserInfoPopup(resultList->currentItem()->text());
}
}); });
dockVbox->addWidget(searchBar); dockVbox->addWidget(searchBar);
@ -551,16 +553,6 @@ void Split::showViewerList()
viewerDock->show(); 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() void Split::copyToClipboard()
{ {
QApplication::clipboard()->setText(this->view_->getSelectedText()); QApplication::clipboard()->setText(this->view_->getSelectedText());

View file

@ -88,11 +88,6 @@ protected:
void focusInEvent(QFocusEvent *event) override; void focusInEvent(QFocusEvent *event) override;
private: private:
void showUserInfoPopup(const QString &userName)
{
this->showUserInfoPopup(UserName{userName});
}
void showUserInfoPopup(const UserName &user);
void channelNameUpdated(const QString &newChannelName); void channelNameUpdated(const QString &newChannelName);
void handleModifiers(Qt::KeyboardModifiers modifiers); void handleModifiers(Qt::KeyboardModifiers modifiers);