diff --git a/CHANGELOG.md b/CHANGELOG.md index d77657086..01c7faf31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 13368917e..1ca76023f 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -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 [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(&(getApp()->windows->getMainWindow()))); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 706ca839d..6138962e2 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -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(