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

View file

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

View file

@ -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

View file

@ -68,6 +68,7 @@ public:
private:
void setChannel(std::shared_ptr<Channel> 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();

View file

@ -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)