mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added avatar context menu to usercard (#2517)
This commit is contained in:
parent
7002954aa9
commit
382462f465
|
@ -56,6 +56,7 @@
|
|||
- Minor: Remove EmojiOne 2 and 3 due to license restrictions. (#1555)
|
||||
- Minor: Added `/streamlink` command. Usage: `/streamlink <channel>`. You can also use the command without arguments in any twitch channel to open it in streamlink. (#2443, #2495)
|
||||
- Minor: Humanized all numbers visible to end-users. (#2488)
|
||||
- Minor: Added a context menu to avatar in usercard. It opens on right-clicking the avatar in usercard. (#2517)
|
||||
- Bugfix: Fix crash occurring when pressing Escape in the Color Picker Dialog (#1843)
|
||||
- Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906)
|
||||
- Bugfix: /usercard command will now respect the "Automatically close user popup" setting (#1918)
|
||||
|
|
|
@ -149,9 +149,53 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
|||
head.emplace<Button>(nullptr).assign(&this->ui_.avatarButton);
|
||||
avatar->setScaleIndependantSize(100, 100);
|
||||
avatar->setDim(Button::Dim::None);
|
||||
QObject::connect(avatar.getElement(), &Button::leftClicked, [this] {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl("https://twitch.tv/" + this->userName_.toLower()));
|
||||
QObject::connect(
|
||||
avatar.getElement(), &Button::clicked,
|
||||
[this](Qt::MouseButton button) {
|
||||
switch (button)
|
||||
{
|
||||
case Qt::LeftButton: {
|
||||
QDesktopServices::openUrl(QUrl(
|
||||
"https://twitch.tv/" + this->userName_.toLower()));
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::RightButton: {
|
||||
// don't raise open context menu if there's no avatar (probably in cases when invalid user's usercard was opened)
|
||||
if (this->avatarUrl_.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static QMenu *previousMenu = nullptr;
|
||||
if (previousMenu != nullptr)
|
||||
{
|
||||
previousMenu->deleteLater();
|
||||
previousMenu = nullptr;
|
||||
}
|
||||
|
||||
auto menu = new QMenu;
|
||||
previousMenu = menu;
|
||||
|
||||
// add context menu actions
|
||||
menu->addAction(
|
||||
"Open avatar in browser",
|
||||
[avatarUrl = this->avatarUrl_] {
|
||||
QDesktopServices::openUrl(QUrl(avatarUrl));
|
||||
});
|
||||
|
||||
menu->addAction("Copy avatar link",
|
||||
[avatarUrl = this->avatarUrl_] {
|
||||
crossPlatformCopy(avatarUrl);
|
||||
});
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
menu->raise();
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
});
|
||||
|
||||
auto vbox = head.emplace<QVBoxLayout>();
|
||||
|
@ -604,6 +648,7 @@ void UserInfoPopup::updateUserData()
|
|||
}
|
||||
|
||||
this->userId_ = user.id;
|
||||
this->avatarUrl_ = user.profileImageUrl;
|
||||
|
||||
this->ui_.nameLabel->setText(user.displayName);
|
||||
this->setWindowTitle(TEXT_TITLE.arg(user.displayName));
|
||||
|
|
|
@ -38,6 +38,7 @@ private:
|
|||
|
||||
QString userName_;
|
||||
QString userId_;
|
||||
QString avatarUrl_;
|
||||
ChannelPtr channel_;
|
||||
|
||||
pajlada::Signals::NoArgSignal userStateChanged_;
|
||||
|
|
Loading…
Reference in a new issue