mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: use message's original channel name when usercard popout is opened (#3623)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
3afdb3367f
commit
04c355f7e9
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
- Minor: Added quotation marks in the permitted/blocked Automod messages for clarity. (#3654)
|
- Minor: Added quotation marks in the permitted/blocked Automod messages for clarity. (#3654)
|
||||||
- Minor: Adjust large stream thumbnail to 16:9 (#3655)
|
- Minor: Adjust large stream thumbnail to 16:9 (#3655)
|
||||||
|
- Minor: Fixed being unable to load Twitch Usercards from the `/mentions` tab. (#3623)
|
||||||
- Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646)
|
- Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646)
|
||||||
|
|
||||||
## 2.3.5
|
## 2.3.5
|
||||||
|
|
|
@ -226,7 +226,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
||||||
.arg(this->userName_)
|
.arg(this->userName_)
|
||||||
.arg(calculateTimeoutDuration(button));
|
.arg(calculateTimeoutDuration(button));
|
||||||
}
|
}
|
||||||
this->channel_->sendMessage(msg);
|
this->underlyingChannel_->sendMessage(msg);
|
||||||
return "";
|
return "";
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
@ -385,28 +385,28 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
||||||
|
|
||||||
QObject::connect(usercard.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(usercard.getElement(), &Button::leftClicked, [this] {
|
||||||
QDesktopServices::openUrl("https://www.twitch.tv/popout/" +
|
QDesktopServices::openUrl("https://www.twitch.tv/popout/" +
|
||||||
this->channel_->getName() +
|
this->underlyingChannel_->getName() +
|
||||||
"/viewercard/" + this->userName_);
|
"/viewercard/" + this->userName_);
|
||||||
});
|
});
|
||||||
|
|
||||||
QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
|
||||||
this->channel_->sendMessage("/mod " + this->userName_);
|
this->underlyingChannel_->sendMessage("/mod " + this->userName_);
|
||||||
});
|
});
|
||||||
QObject::connect(unmod.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(unmod.getElement(), &Button::leftClicked, [this] {
|
||||||
this->channel_->sendMessage("/unmod " + this->userName_);
|
this->underlyingChannel_->sendMessage("/unmod " + this->userName_);
|
||||||
});
|
});
|
||||||
QObject::connect(vip.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(vip.getElement(), &Button::leftClicked, [this] {
|
||||||
this->channel_->sendMessage("/vip " + this->userName_);
|
this->underlyingChannel_->sendMessage("/vip " + this->userName_);
|
||||||
});
|
});
|
||||||
QObject::connect(unvip.getElement(), &Button::leftClicked, [this] {
|
QObject::connect(unvip.getElement(), &Button::leftClicked, [this] {
|
||||||
this->channel_->sendMessage("/unvip " + this->userName_);
|
this->underlyingChannel_->sendMessage("/unvip " + this->userName_);
|
||||||
});
|
});
|
||||||
|
|
||||||
// userstate
|
// userstate
|
||||||
this->userStateChanged_.connect([this, mod, unmod, vip,
|
this->userStateChanged_.connect([this, mod, unmod, vip,
|
||||||
unvip]() mutable {
|
unvip]() mutable {
|
||||||
TwitchChannel *twitchChannel =
|
TwitchChannel *twitchChannel =
|
||||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
dynamic_cast<TwitchChannel *>(this->underlyingChannel_.get());
|
||||||
|
|
||||||
bool visibilityModButtons = false;
|
bool visibilityModButtons = false;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
||||||
|
|
||||||
this->userStateChanged_.connect([this, lineMod, timeout]() mutable {
|
this->userStateChanged_.connect([this, lineMod, timeout]() mutable {
|
||||||
TwitchChannel *twitchChannel =
|
TwitchChannel *twitchChannel =
|
||||||
dynamic_cast<TwitchChannel *>(this->channel_.get());
|
dynamic_cast<TwitchChannel *>(this->underlyingChannel_.get());
|
||||||
|
|
||||||
bool hasModRights =
|
bool hasModRights =
|
||||||
twitchChannel ? twitchChannel->hasModRights() : false;
|
twitchChannel ? twitchChannel->hasModRights() : false;
|
||||||
|
@ -452,25 +452,26 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case TimeoutWidget::Ban: {
|
case TimeoutWidget::Ban: {
|
||||||
if (this->channel_)
|
if (this->underlyingChannel_)
|
||||||
{
|
{
|
||||||
this->channel_->sendMessage("/ban " + this->userName_);
|
this->underlyingChannel_->sendMessage("/ban " +
|
||||||
|
this->userName_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TimeoutWidget::Unban: {
|
case TimeoutWidget::Unban: {
|
||||||
if (this->channel_)
|
if (this->underlyingChannel_)
|
||||||
{
|
{
|
||||||
this->channel_->sendMessage("/unban " +
|
this->underlyingChannel_->sendMessage("/unban " +
|
||||||
this->userName_);
|
this->userName_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TimeoutWidget::Timeout: {
|
case TimeoutWidget::Timeout: {
|
||||||
if (this->channel_)
|
if (this->underlyingChannel_)
|
||||||
{
|
{
|
||||||
this->channel_->sendMessage("/timeout " +
|
this->underlyingChannel_->sendMessage(
|
||||||
this->userName_ + " " +
|
"/timeout " + this->userName_ + " " +
|
||||||
QString::number(arg));
|
QString::number(arg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,10 +681,28 @@ void UserInfoPopup::installEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
|
void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
|
||||||
|
{
|
||||||
|
this->setData(name, channel, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInfoPopup::setData(const QString &name,
|
||||||
|
const ChannelPtr &contextChannel,
|
||||||
|
const ChannelPtr &openingChannel)
|
||||||
{
|
{
|
||||||
this->userName_ = name;
|
this->userName_ = name;
|
||||||
this->channel_ = channel;
|
this->channel_ = openingChannel;
|
||||||
this->setWindowTitle(TEXT_TITLE.arg(name, channel->getName()));
|
|
||||||
|
if (!contextChannel->isEmpty())
|
||||||
|
{
|
||||||
|
this->underlyingChannel_ = contextChannel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->underlyingChannel_ = openingChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setWindowTitle(
|
||||||
|
TEXT_TITLE.arg(name, this->underlyingChannel_->getName()));
|
||||||
|
|
||||||
this->ui_.nameLabel->setText(name);
|
this->ui_.nameLabel->setText(name);
|
||||||
this->ui_.nameLabel->setProperty("copy-text", name);
|
this->ui_.nameLabel->setProperty("copy-text", name);
|
||||||
|
@ -700,9 +719,10 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
|
||||||
|
|
||||||
void UserInfoPopup::updateLatestMessages()
|
void UserInfoPopup::updateLatestMessages()
|
||||||
{
|
{
|
||||||
auto filteredChannel = filterMessages(this->userName_, this->channel_);
|
auto filteredChannel =
|
||||||
|
filterMessages(this->userName_, this->underlyingChannel_);
|
||||||
this->ui_.latestMessages->setChannel(filteredChannel);
|
this->ui_.latestMessages->setChannel(filteredChannel);
|
||||||
this->ui_.latestMessages->setSourceChannel(this->channel_);
|
this->ui_.latestMessages->setSourceChannel(this->underlyingChannel_);
|
||||||
|
|
||||||
const bool hasMessages = filteredChannel->hasMessages();
|
const bool hasMessages = filteredChannel->hasMessages();
|
||||||
this->ui_.latestMessages->setVisible(hasMessages);
|
this->ui_.latestMessages->setVisible(hasMessages);
|
||||||
|
@ -713,15 +733,16 @@ void UserInfoPopup::updateLatestMessages()
|
||||||
|
|
||||||
this->refreshConnection_ =
|
this->refreshConnection_ =
|
||||||
std::make_unique<pajlada::Signals::ScopedConnection>(
|
std::make_unique<pajlada::Signals::ScopedConnection>(
|
||||||
this->channel_->messageAppended.connect([this, hasMessages](
|
this->underlyingChannel_->messageAppended.connect(
|
||||||
auto message, auto) {
|
[this, hasMessages](auto message, auto) {
|
||||||
if (!checkMessageUserName(this->userName_, message))
|
if (!checkMessageUserName(this->userName_, message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (hasMessages)
|
if (hasMessages)
|
||||||
{
|
{
|
||||||
// display message in ChannelView
|
// display message in ChannelView
|
||||||
this->ui_.latestMessages->channel()->addMessage(message);
|
this->ui_.latestMessages->channel()->addMessage(
|
||||||
|
message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -781,8 +802,8 @@ void UserInfoPopup::updateUserData()
|
||||||
this->ui_.nameLabel->setProperty("copy-text", user.displayName);
|
this->ui_.nameLabel->setProperty("copy-text", user.displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setWindowTitle(
|
this->setWindowTitle(TEXT_TITLE.arg(
|
||||||
TEXT_TITLE.arg(user.displayName, this->channel_->getName()));
|
user.displayName, this->underlyingChannel_->getName()));
|
||||||
this->ui_.viewCountLabel->setText(
|
this->ui_.viewCountLabel->setText(
|
||||||
TEXT_VIEWS.arg(localizeNumbers(user.viewCount)));
|
TEXT_VIEWS.arg(localizeNumbers(user.viewCount)));
|
||||||
this->ui_.createdDateLabel->setText(
|
this->ui_.createdDateLabel->setText(
|
||||||
|
@ -849,7 +870,7 @@ void UserInfoPopup::updateUserData()
|
||||||
|
|
||||||
// get followage and subage
|
// get followage and subage
|
||||||
getIvr()->getSubage(
|
getIvr()->getSubage(
|
||||||
this->userName_, this->channel_->getName(),
|
this->userName_, this->underlyingChannel_->getName(),
|
||||||
[this, hack](const IvrSubage &subageInfo) {
|
[this, hack](const IvrSubage &subageInfo) {
|
||||||
if (!hack.lock())
|
if (!hack.lock())
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
UserInfoPopup(bool closeAutomatically, QWidget *parent);
|
UserInfoPopup(bool closeAutomatically, QWidget *parent);
|
||||||
|
|
||||||
void setData(const QString &name, const ChannelPtr &channel);
|
void setData(const QString &name, const ChannelPtr &channel);
|
||||||
|
void setData(const QString &name, const ChannelPtr &contextChannel,
|
||||||
|
const ChannelPtr &openingChannel);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void themeChangedEvent() override;
|
virtual void themeChangedEvent() override;
|
||||||
|
@ -44,7 +46,10 @@ private:
|
||||||
QString userName_;
|
QString userName_;
|
||||||
QString userId_;
|
QString userId_;
|
||||||
QString avatarUrl_;
|
QString avatarUrl_;
|
||||||
|
// The channel the popup was opened from (e.g. /mentions or #forsen). Can be a special channel.
|
||||||
ChannelPtr channel_;
|
ChannelPtr channel_;
|
||||||
|
// The channel the messages are rendered from (e.g. #forsen). Can be a special channel, but will try to not be where possible.
|
||||||
|
ChannelPtr underlyingChannel_;
|
||||||
|
|
||||||
// isMoving_ is set to true if the user is holding the left mouse button down and has moved the mouse a small amount away from the original click point (startPosDrag_)
|
// isMoving_ is set to true if the user is holding the left mouse button down and has moved the mouse a small amount away from the original click point (startPosDrag_)
|
||||||
bool isMoving_ = false;
|
bool isMoving_ = false;
|
||||||
|
|
|
@ -2153,15 +2153,20 @@ void ChannelView::hideEvent(QHideEvent *)
|
||||||
this->messagesOnScreen_.clear();
|
this->messagesOnScreen_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::showUserInfoPopup(const QString &userName)
|
void ChannelView::showUserInfoPopup(const QString &userName,
|
||||||
|
QString alternativePopoutChannel)
|
||||||
{
|
{
|
||||||
QWidget *userCardParent =
|
auto *userCardParent =
|
||||||
static_cast<QWidget *>(&(getApp()->windows->getMainWindow()));
|
static_cast<QWidget *>(&(getApp()->windows->getMainWindow()));
|
||||||
auto *userPopup =
|
auto *userPopup =
|
||||||
new UserInfoPopup(getSettings()->autoCloseUserPopup, userCardParent);
|
new UserInfoPopup(getSettings()->autoCloseUserPopup, userCardParent);
|
||||||
userPopup->setData(userName, this->hasSourceChannel()
|
|
||||||
? this->sourceChannel_
|
auto contextChannel =
|
||||||
: this->underlyingChannel_);
|
getApp()->twitch->getChannelOrEmpty(alternativePopoutChannel);
|
||||||
|
auto openingChannel = this->hasSourceChannel() ? this->sourceChannel_
|
||||||
|
: this->underlyingChannel_;
|
||||||
|
userPopup->setData(userName, contextChannel, openingChannel);
|
||||||
|
|
||||||
QPoint offset(int(150 * this->scale()), int(70 * this->scale()));
|
QPoint offset(int(150 * this->scale()), int(70 * this->scale()));
|
||||||
userPopup->move(QCursor::pos() - offset);
|
userPopup->move(QCursor::pos() - offset);
|
||||||
userPopup->show();
|
userPopup->show();
|
||||||
|
@ -2181,7 +2186,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
||||||
case Link::UserWhisper:
|
case Link::UserWhisper:
|
||||||
case Link::UserInfo: {
|
case Link::UserInfo: {
|
||||||
auto user = link.value;
|
auto user = link.value;
|
||||||
this->showUserInfoPopup(user);
|
this->showUserInfoPopup(user, layout->getMessage()->channelName);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,15 @@ public:
|
||||||
void queueLayout();
|
void queueLayout();
|
||||||
|
|
||||||
void clearMessages();
|
void clearMessages();
|
||||||
void showUserInfoPopup(const QString &userName);
|
|
||||||
|
/**
|
||||||
|
* @brief Creates and shows a UserInfoPopup dialog
|
||||||
|
*
|
||||||
|
* @param userName The login name of the user
|
||||||
|
* @param alternativePopoutChannel Optional parameter containing the channel name to use for context
|
||||||
|
**/
|
||||||
|
void showUserInfoPopup(const QString &userName,
|
||||||
|
QString alternativePopoutChannel = QString());
|
||||||
|
|
||||||
pajlada::Signals::Signal<QMouseEvent *> mouseDown;
|
pajlada::Signals::Signal<QMouseEvent *> mouseDown;
|
||||||
pajlada::Signals::NoArgSignal selectionChanged;
|
pajlada::Signals::NoArgSignal selectionChanged;
|
||||||
|
|
Loading…
Reference in a new issue