mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixed popups in viewer list. (#110)
This commit is contained in:
parent
6ce13db443
commit
4ac811f2a9
|
@ -71,6 +71,12 @@
|
|||
</item>
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="QLabel" name="lblAvatar">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> &channel)
|
||||
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
|
||||
: QWidget(nullptr)
|
||||
, _ui(new Ui::AccountPopup)
|
||||
, _channel(channel)
|
||||
|
@ -37,8 +37,14 @@ void AccountPopupWidget::setName(const QString &name)
|
|||
getUserId();
|
||||
}
|
||||
|
||||
void AccountPopupWidget::setChannel(std::shared_ptr<Channel> channel)
|
||||
{
|
||||
this->_channel = channel;
|
||||
}
|
||||
|
||||
void AccountPopupWidget::getUserId()
|
||||
{
|
||||
qDebug() << this->_channel.get()->name;
|
||||
QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text());
|
||||
|
||||
QNetworkRequest req(nameUrl);
|
||||
|
|
|
@ -19,9 +19,10 @@ class AccountPopupWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AccountPopupWidget(std::shared_ptr<Channel> &channel);
|
||||
AccountPopupWidget(std::shared_ptr<Channel> channel);
|
||||
|
||||
void setName(const QString &name);
|
||||
void setChannel(std::shared_ptr<Channel> channel);
|
||||
|
||||
private:
|
||||
Ui::AccountPopup *_ui;
|
||||
|
@ -30,7 +31,7 @@ private:
|
|||
void getUserData();
|
||||
void loadAvatar(const QUrl &avatarUrl);
|
||||
|
||||
std::shared_ptr<Channel> &_channel;
|
||||
std::shared_ptr<Channel> _channel;
|
||||
|
||||
QString userID;
|
||||
QPixmap avatar;
|
||||
|
|
|
@ -104,6 +104,8 @@ void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
|
|||
this->header.checkLive();
|
||||
});
|
||||
|
||||
this->view.userPopupWidget.setChannel(_newChannel);
|
||||
|
||||
// on new message
|
||||
this->messageAppendedConnection =
|
||||
this->channel->messageAppended.connect([this](SharedMessage &message) {
|
||||
|
@ -267,6 +269,12 @@ void ChatWidget::doCloseSplit()
|
|||
void ChatWidget::doChangeChannel()
|
||||
{
|
||||
this->showChangeChannelPopup("Change channel");
|
||||
auto popup = this->findChildren<QDockWidget*>();
|
||||
if(popup.at(0)->isVisible() && !popup.at(0)->isFloating())
|
||||
{
|
||||
popup.at(0)->hide();
|
||||
doOpenViewerList();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatWidget::doPopup()
|
||||
|
@ -371,9 +379,10 @@ void ChatWidget::doOpenViewerList()
|
|||
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
||||
QDockWidget::DockWidgetClosable |
|
||||
QDockWidget::DockWidgetFloatable);
|
||||
viewerDock->setMaximumHeight(this->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 accountPopup = new AccountPopupWidget(this->channel);
|
||||
auto multiWidget = new QWidget(viewerDock);
|
||||
auto dockVbox = new QVBoxLayout(viewerDock);
|
||||
auto searchBar = new QLineEdit(viewerDock);
|
||||
|
@ -430,6 +439,20 @@ void ChatWidget::doOpenViewerList()
|
|||
viewerDock->setMinimumWidth(300);
|
||||
});
|
||||
|
||||
QObject::connect(chattersList,&QListWidget::doubleClicked,this,[=](){
|
||||
if(!labels.contains(chattersList->currentItem()->text()))
|
||||
{
|
||||
doOpenAccountPopupWidget(accountPopup,chattersList->currentItem()->text());
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(resultList,&QListWidget::doubleClicked,this,[=](){
|
||||
if(!labels.contains(resultList->currentItem()->text()))
|
||||
{
|
||||
doOpenAccountPopupWidget(accountPopup,resultList->currentItem()->text());
|
||||
}
|
||||
});
|
||||
|
||||
dockVbox->addWidget(searchBar);
|
||||
dockVbox->addWidget(loadingLabel);
|
||||
dockVbox->addWidget(chattersList);
|
||||
|
@ -442,6 +465,14 @@ void ChatWidget::doOpenViewerList()
|
|||
viewerDock->show();
|
||||
}
|
||||
|
||||
void ChatWidget::doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user)
|
||||
{
|
||||
widget->setName(user);
|
||||
widget->move(QCursor::pos());
|
||||
widget->show();
|
||||
widget->setFocus();
|
||||
}
|
||||
|
||||
void ChatWidget::doCopy()
|
||||
{
|
||||
QApplication::clipboard()->setText(this->view.getSelectedText());
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
private:
|
||||
void setChannel(std::shared_ptr<Channel> newChannel);
|
||||
void detachChannel();
|
||||
void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||
|
||||
void channelNameUpdated(const std::string &newChannelName);
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
|
|||
void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
this->chatWidget->showChangeChannelPopup("Change channel");
|
||||
this->chatWidget->doChangeChannel();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue