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>
|
||||||
<item row="0" column="0" rowspan="3">
|
<item row="0" column="0" rowspan="3">
|
||||||
<widget class="QLabel" name="lblAvatar">
|
<widget class="QLabel" name="lblAvatar">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
|
||||||
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> &channel)
|
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> channel)
|
||||||
: QWidget(nullptr)
|
: QWidget(nullptr)
|
||||||
, _ui(new Ui::AccountPopup)
|
, _ui(new Ui::AccountPopup)
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
|
@ -37,8 +37,14 @@ void AccountPopupWidget::setName(const QString &name)
|
||||||
getUserId();
|
getUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountPopupWidget::setChannel(std::shared_ptr<Channel> channel)
|
||||||
|
{
|
||||||
|
this->_channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
void AccountPopupWidget::getUserId()
|
void AccountPopupWidget::getUserId()
|
||||||
{
|
{
|
||||||
|
qDebug() << this->_channel.get()->name;
|
||||||
QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text());
|
QUrl nameUrl("https://api.twitch.tv/kraken/users?login=" + _ui->lblUsername->text());
|
||||||
|
|
||||||
QNetworkRequest req(nameUrl);
|
QNetworkRequest req(nameUrl);
|
||||||
|
|
|
@ -19,9 +19,10 @@ class AccountPopupWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AccountPopupWidget(std::shared_ptr<Channel> &channel);
|
AccountPopupWidget(std::shared_ptr<Channel> channel);
|
||||||
|
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
void setChannel(std::shared_ptr<Channel> channel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AccountPopup *_ui;
|
Ui::AccountPopup *_ui;
|
||||||
|
@ -30,7 +31,7 @@ private:
|
||||||
void getUserData();
|
void getUserData();
|
||||||
void loadAvatar(const QUrl &avatarUrl);
|
void loadAvatar(const QUrl &avatarUrl);
|
||||||
|
|
||||||
std::shared_ptr<Channel> &_channel;
|
std::shared_ptr<Channel> _channel;
|
||||||
|
|
||||||
QString userID;
|
QString userID;
|
||||||
QPixmap avatar;
|
QPixmap avatar;
|
||||||
|
|
|
@ -104,6 +104,8 @@ void ChatWidget::setChannel(std::shared_ptr<Channel> _newChannel)
|
||||||
this->header.checkLive();
|
this->header.checkLive();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this->view.userPopupWidget.setChannel(_newChannel);
|
||||||
|
|
||||||
// on new message
|
// on new message
|
||||||
this->messageAppendedConnection =
|
this->messageAppendedConnection =
|
||||||
this->channel->messageAppended.connect([this](SharedMessage &message) {
|
this->channel->messageAppended.connect([this](SharedMessage &message) {
|
||||||
|
@ -267,6 +269,12 @@ void ChatWidget::doCloseSplit()
|
||||||
void ChatWidget::doChangeChannel()
|
void ChatWidget::doChangeChannel()
|
||||||
{
|
{
|
||||||
this->showChangeChannelPopup("Change channel");
|
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()
|
void ChatWidget::doPopup()
|
||||||
|
@ -371,9 +379,10 @@ void ChatWidget::doOpenViewerList()
|
||||||
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar |
|
||||||
QDockWidget::DockWidgetClosable |
|
QDockWidget::DockWidgetClosable |
|
||||||
QDockWidget::DockWidgetFloatable);
|
QDockWidget::DockWidgetFloatable);
|
||||||
viewerDock->setMaximumHeight(this->height());
|
viewerDock->resize(0.5*this->width(),this->height() - this->header.height() - this->input.height());
|
||||||
viewerDock->resize(0.5*this->width(),this->height());
|
viewerDock->move(0,this->header.height());
|
||||||
|
|
||||||
|
auto accountPopup = new AccountPopupWidget(this->channel);
|
||||||
auto multiWidget = new QWidget(viewerDock);
|
auto multiWidget = new QWidget(viewerDock);
|
||||||
auto dockVbox = new QVBoxLayout(viewerDock);
|
auto dockVbox = new QVBoxLayout(viewerDock);
|
||||||
auto searchBar = new QLineEdit(viewerDock);
|
auto searchBar = new QLineEdit(viewerDock);
|
||||||
|
@ -430,6 +439,20 @@ void ChatWidget::doOpenViewerList()
|
||||||
viewerDock->setMinimumWidth(300);
|
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(searchBar);
|
||||||
dockVbox->addWidget(loadingLabel);
|
dockVbox->addWidget(loadingLabel);
|
||||||
dockVbox->addWidget(chattersList);
|
dockVbox->addWidget(chattersList);
|
||||||
|
@ -442,6 +465,14 @@ void ChatWidget::doOpenViewerList()
|
||||||
viewerDock->show();
|
viewerDock->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatWidget::doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user)
|
||||||
|
{
|
||||||
|
widget->setName(user);
|
||||||
|
widget->move(QCursor::pos());
|
||||||
|
widget->show();
|
||||||
|
widget->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatWidget::doCopy()
|
void ChatWidget::doCopy()
|
||||||
{
|
{
|
||||||
QApplication::clipboard()->setText(this->view.getSelectedText());
|
QApplication::clipboard()->setText(this->view.getSelectedText());
|
||||||
|
|
|
@ -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 doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user);
|
||||||
|
|
||||||
void channelNameUpdated(const std::string &newChannelName);
|
void channelNameUpdated(const std::string &newChannelName);
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
|
||||||
void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
this->chatWidget->showChangeChannelPopup("Change channel");
|
this->chatWidget->doChangeChannel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue