diff --git a/src/widgets/accountpopup.cpp b/src/widgets/accountpopup.cpp index a58a8a493..5c6288274 100644 --- a/src/widgets/accountpopup.cpp +++ b/src/widgets/accountpopup.cpp @@ -1,5 +1,4 @@ #include "widgets/accountpopup.hpp" -#include "channel.hpp" #include "credentials.hpp" #include "ui_accountpopupform.h" @@ -14,10 +13,9 @@ namespace chatterino { namespace widgets { -AccountPopupWidget::AccountPopupWidget(std::shared_ptr &channel) +AccountPopupWidget::AccountPopupWidget() : QWidget(nullptr) , _ui(new Ui::AccountPopup) - , _channel(channel) { _ui->setupUi(this); diff --git a/src/widgets/accountpopup.hpp b/src/widgets/accountpopup.hpp index ee102f558..346ac934b 100644 --- a/src/widgets/accountpopup.hpp +++ b/src/widgets/accountpopup.hpp @@ -19,7 +19,7 @@ class AccountPopupWidget : public QWidget { Q_OBJECT public: - AccountPopupWidget(std::shared_ptr &channel); + AccountPopupWidget(); void setName(const QString &name); @@ -30,8 +30,6 @@ private: void getUserData(); void loadAvatar(const QUrl &avatarUrl); - std::shared_ptr &_channel; - QString userID; QPixmap avatar; diff --git a/src/widgets/chatwidget.cpp b/src/widgets/chatwidget.cpp index e7c0481ce..6c0f6cc41 100644 --- a/src/widgets/chatwidget.cpp +++ b/src/widgets/chatwidget.cpp @@ -1,3 +1,4 @@ +#include "widgets/accountpopup.hpp" #include "widgets/chatwidget.hpp" #include "channelmanager.hpp" #include "colorscheme.hpp" @@ -363,8 +364,9 @@ void ChatWidget::doOpenViewerList() viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); - viewerDock->setMaximumHeight(this->height()); - viewerDock->resize(0.5*this->width(),this->height()); + viewerDock->setMaximumHeight(this->height() - this->header.height() - this->input.height()); + viewerDock->resize(0.5*this->width(), this->height() - this->header.height() - this->input.height()); + viewerDock->move(0,this->header.height()); auto multiWidget = new QWidget(viewerDock); auto dockVbox = new QVBoxLayout(viewerDock); @@ -414,6 +416,7 @@ void ChatWidget::doOpenViewerList() else { resultList->hide(); + chattersList->scrollToTop(); chattersList->show(); } }); @@ -422,6 +425,20 @@ void ChatWidget::doOpenViewerList() viewerDock->setMinimumWidth(300); }); + QObject::connect(chattersList,&QListWidget::doubleClicked, this, [=](){ + if(!labels.contains(chattersList->currentItem()->text())) + { + doOpenUserPopupWidget(chattersList->currentItem()->text()); + } + }); + + QObject::connect(resultList,&QListWidget::doubleClicked, this, [=](){ + if(!labels.contains(resultList->currentItem()->text())) + { + doOpenUserPopupWidget(resultList->currentItem()->text()); + } + }); + dockVbox->addWidget(searchBar); dockVbox->addWidget(loadingLabel); dockVbox->addWidget(chattersList); @@ -434,5 +451,13 @@ void ChatWidget::doOpenViewerList() viewerDock->show(); } +void ChatWidget::doOpenUserPopupWidget(QString user) +{ + this->userPopupWidget.setName(user); + this->userPopupWidget.move(QCursor::pos()); + this->userPopupWidget.show(); + this->userPopupWidget.setFocus(); +} + } // namespace widgets } // namespace chatterino diff --git a/src/widgets/chatwidget.hpp b/src/widgets/chatwidget.hpp index 5defc2d6e..9e5d69e36 100644 --- a/src/widgets/chatwidget.hpp +++ b/src/widgets/chatwidget.hpp @@ -68,6 +68,7 @@ public: private: void setChannel(std::shared_ptr newChannel); void detachChannel(); + void doOpenUserPopupWidget(QString user); void channelNameUpdated(const std::string &newChannelName); @@ -85,6 +86,8 @@ private: boost::signals2::connection messageAppendedConnection; boost::signals2::connection messageRemovedConnection; + AccountPopupWidget userPopupWidget; + public: void load(const boost::property_tree::ptree &tree); boost::property_tree::ptree save(); diff --git a/src/widgets/chatwidgetview.cpp b/src/widgets/chatwidgetview.cpp index 70f1dc2c9..a05d3f7ed 100644 --- a/src/widgets/chatwidgetview.cpp +++ b/src/widgets/chatwidgetview.cpp @@ -24,7 +24,6 @@ ChatWidgetView::ChatWidgetView(ChatWidget *_chatWidget) : BaseWidget(_chatWidget) , chatWidget(_chatWidget) , scrollBar(this) - , userPopupWidget(_chatWidget->getChannelRef()) , selectionStart(0, 0) , selectionEnd(0, 0) , selectionMin(0, 0)