Resized viewer list, added popup on doubleclick.

This commit is contained in:
Cranken 2017-09-12 11:00:40 +02:00
parent 6ec8f6e032
commit 2fbf8654f9
5 changed files with 32 additions and 9 deletions

View file

@ -1,5 +1,4 @@
#include "widgets/accountpopup.hpp" #include "widgets/accountpopup.hpp"
#include "channel.hpp"
#include "credentials.hpp" #include "credentials.hpp"
#include "ui_accountpopupform.h" #include "ui_accountpopupform.h"
@ -14,10 +13,9 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> &channel) AccountPopupWidget::AccountPopupWidget()
: QWidget(nullptr) : QWidget(nullptr)
, _ui(new Ui::AccountPopup) , _ui(new Ui::AccountPopup)
, _channel(channel)
{ {
_ui->setupUi(this); _ui->setupUi(this);

View file

@ -19,7 +19,7 @@ class AccountPopupWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
AccountPopupWidget(std::shared_ptr<Channel> &channel); AccountPopupWidget();
void setName(const QString &name); void setName(const QString &name);
@ -30,8 +30,6 @@ private:
void getUserData(); void getUserData();
void loadAvatar(const QUrl &avatarUrl); void loadAvatar(const QUrl &avatarUrl);
std::shared_ptr<Channel> &_channel;
QString userID; QString userID;
QPixmap avatar; QPixmap avatar;

View file

@ -1,3 +1,4 @@
#include "widgets/accountpopup.hpp"
#include "widgets/chatwidget.hpp" #include "widgets/chatwidget.hpp"
#include "channelmanager.hpp" #include "channelmanager.hpp"
#include "colorscheme.hpp" #include "colorscheme.hpp"
@ -363,8 +364,9 @@ void ChatWidget::doOpenViewerList()
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar | viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetClosable |
QDockWidget::DockWidgetFloatable); QDockWidget::DockWidgetFloatable);
viewerDock->setMaximumHeight(this->height()); viewerDock->setMaximumHeight(this->height() - this->header.height() - this->input.height());
viewerDock->resize(0.5*this->width(),this->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 multiWidget = new QWidget(viewerDock);
auto dockVbox = new QVBoxLayout(viewerDock); auto dockVbox = new QVBoxLayout(viewerDock);
@ -414,6 +416,7 @@ void ChatWidget::doOpenViewerList()
else else
{ {
resultList->hide(); resultList->hide();
chattersList->scrollToTop();
chattersList->show(); chattersList->show();
} }
}); });
@ -422,6 +425,20 @@ void ChatWidget::doOpenViewerList()
viewerDock->setMinimumWidth(300); 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(searchBar);
dockVbox->addWidget(loadingLabel); dockVbox->addWidget(loadingLabel);
dockVbox->addWidget(chattersList); dockVbox->addWidget(chattersList);
@ -434,5 +451,13 @@ void ChatWidget::doOpenViewerList()
viewerDock->show(); 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 widgets
} // namespace chatterino } // namespace chatterino

View file

@ -68,6 +68,7 @@ public:
private: private:
void setChannel(std::shared_ptr<Channel> newChannel); void setChannel(std::shared_ptr<Channel> newChannel);
void detachChannel(); void detachChannel();
void doOpenUserPopupWidget(QString user);
void channelNameUpdated(const std::string &newChannelName); void channelNameUpdated(const std::string &newChannelName);
@ -85,6 +86,8 @@ private:
boost::signals2::connection messageAppendedConnection; boost::signals2::connection messageAppendedConnection;
boost::signals2::connection messageRemovedConnection; boost::signals2::connection messageRemovedConnection;
AccountPopupWidget userPopupWidget;
public: public:
void load(const boost::property_tree::ptree &tree); void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save(); boost::property_tree::ptree save();

View file

@ -24,7 +24,6 @@ ChatWidgetView::ChatWidgetView(ChatWidget *_chatWidget)
: BaseWidget(_chatWidget) : BaseWidget(_chatWidget)
, chatWidget(_chatWidget) , chatWidget(_chatWidget)
, scrollBar(this) , scrollBar(this)
, userPopupWidget(_chatWidget->getChannelRef())
, selectionStart(0, 0) , selectionStart(0, 0)
, selectionEnd(0, 0) , selectionEnd(0, 0)
, selectionMin(0, 0) , selectionMin(0, 0)