Add optional parameter to /usercard command for opening a usercard in a different channel context. (#3172)

Co-authored-by: apa420 <17131426+apa420@users.noreply.github.com>
Co-authored-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Co-authored-by: Leon Richardt <leon.richardt@gmail.com>
This commit is contained in:
LosFarmosCTL 2021-08-21 13:37:57 +02:00 committed by GitHub
parent a7ef7e6f7f
commit 773c4bb9e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 4 deletions

View file

@ -9,6 +9,7 @@
- Minor: Added a setting to hide similar messages by any user. (#2716)
- Minor: Duplicate spaces now count towards the display message length. (#3002)
- Minor: Commands are now backed up. (#3168)
- Minor: Added optional parameter to /usercard command for opening a usercard in a different channel context. (#3172)
- Bugfix: Fixed colored usernames sometimes not working. (#3170)
- Bugfix: Restored ability to send duplicate `/me` messages. (#3166)
- Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121)

View file

@ -476,12 +476,33 @@ void CommandController::initialize(Settings &, Paths &paths)
this->registerCommand("/usercard", [](const auto &words, auto channel) {
if (words.size() < 2)
{
channel->addMessage(makeSystemMessage("Usage /usercard [user]"));
channel->addMessage(
makeSystemMessage("Usage: /usercard <user> [channel]"));
return "";
}
QString userName = words[1];
stripUserName(userName);
if (words.size() > 2)
{
QString channelName = words[2];
stripChannelName(channelName);
ChannelPtr channelTemp =
getApp()->twitch2->getChannelOrEmpty(channelName);
if (channelTemp->isEmpty())
{
channel->addMessage(makeSystemMessage(
"A usercard can only be displayed for a channel that is "
"currently opened in Chatterino."));
return "";
}
channel = channelTemp;
}
auto *userPopup = new UserInfoPopup(
getSettings()->autoCloseUserPopup,
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())));

View file

@ -33,7 +33,7 @@
const QString TEXT_VIEWS("Views: %1");
const QString TEXT_FOLLOWERS("Followers: %1");
const QString TEXT_CREATED("Created: %1");
const QString TEXT_TITLE("%1's Usercard");
const QString TEXT_TITLE("%1's Usercard - #%2");
#define TEXT_USER_ID "ID: "
#define TEXT_UNAVAILABLE "(not available)"
@ -513,7 +513,7 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel)
{
this->userName_ = name;
this->channel_ = channel;
this->setWindowTitle(TEXT_TITLE.arg(name));
this->setWindowTitle(TEXT_TITLE.arg(name, channel->getName()));
this->ui_.nameLabel->setText(name);
this->ui_.nameLabel->setProperty("copy-text", name);
@ -598,7 +598,8 @@ void UserInfoPopup::updateUserData()
this->avatarUrl_ = user.profileImageUrl;
this->ui_.nameLabel->setText(user.displayName);
this->setWindowTitle(TEXT_TITLE.arg(user.displayName));
this->setWindowTitle(
TEXT_TITLE.arg(user.displayName, this->channel_->getName()));
this->ui_.viewCountLabel->setText(
TEXT_VIEWS.arg(localizeNumbers(user.viewCount)));
this->ui_.createdDateLabel->setText(