mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: Add copy button for both login & display name inside the user info popout (#3335)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
67eff75873
commit
a40677f4cd
|
@ -28,6 +28,7 @@
|
|||
- Minor: Added `flags.first_message` filter variable (#3292)
|
||||
- Minor: Removed duplicate setting for toggling `Channel Point Redeemed Message` highlights (#3296)
|
||||
- Minor: Clean up chat messages of special line characters prior to sending. (#3312)
|
||||
- Minor: Added button & label for copying login name of user instead of display name in the user info popout. (#3335)
|
||||
- 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)
|
||||
|
|
|
@ -39,13 +39,19 @@ const QString TEXT_TITLE("%1's Usercard - #%2");
|
|||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
Label *addCopyableLabel(LayoutCreator<QHBoxLayout> box)
|
||||
Label *addCopyableLabel(LayoutCreator<QHBoxLayout> box, const char *tooltip,
|
||||
Button **copyButton = nullptr)
|
||||
{
|
||||
auto label = box.emplace<Label>();
|
||||
auto button = box.emplace<Button>();
|
||||
if (copyButton != nullptr)
|
||||
{
|
||||
button.assign(copyButton);
|
||||
}
|
||||
button->setPixmap(getApp()->themes->buttons.copy);
|
||||
button->setScaleIndependantSize(18, 18);
|
||||
button->setDim(Button::Dim::Lots);
|
||||
button->setToolTip(tooltip);
|
||||
QObject::connect(
|
||||
button.getElement(), &Button::leftClicked,
|
||||
[label = label.getElement()] {
|
||||
|
@ -205,13 +211,27 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
|
|||
auto box = vbox.emplace<QHBoxLayout>()
|
||||
.withoutMargin()
|
||||
.withoutSpacing();
|
||||
this->ui_.nameLabel = addCopyableLabel(box);
|
||||
|
||||
this->ui_.nameLabel = addCopyableLabel(box, "Copy name");
|
||||
this->ui_.nameLabel->setFontStyle(FontStyle::UiMediumBold);
|
||||
box->addSpacing(5);
|
||||
box->addStretch(1);
|
||||
|
||||
this->ui_.localizedNameLabel =
|
||||
addCopyableLabel(box, "Copy localized name",
|
||||
&this->ui_.localizedNameCopyButton);
|
||||
this->ui_.localizedNameLabel->setFontStyle(
|
||||
FontStyle::UiMediumBold);
|
||||
box->addSpacing(5);
|
||||
box->addStretch(1);
|
||||
|
||||
auto palette = QPalette();
|
||||
palette.setColor(QPalette::WindowText, QColor("#aaa"));
|
||||
this->ui_.userIDLabel = addCopyableLabel(box);
|
||||
this->ui_.userIDLabel = addCopyableLabel(box, "Copy ID");
|
||||
this->ui_.userIDLabel->setPalette(palette);
|
||||
|
||||
this->ui_.localizedNameLabel->setVisible(false);
|
||||
this->ui_.localizedNameCopyButton->setVisible(false);
|
||||
}
|
||||
|
||||
// items on the left
|
||||
|
@ -598,7 +618,21 @@ void UserInfoPopup::updateUserData()
|
|||
this->userId_ = user.id;
|
||||
this->avatarUrl_ = user.profileImageUrl;
|
||||
|
||||
// copyable button for login name of users with a localized username
|
||||
if (user.displayName.toLower() != user.login)
|
||||
{
|
||||
this->ui_.localizedNameLabel->setText(user.displayName);
|
||||
this->ui_.localizedNameLabel->setProperty("copy-text",
|
||||
user.displayName);
|
||||
this->ui_.localizedNameLabel->setVisible(true);
|
||||
this->ui_.localizedNameCopyButton->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui_.nameLabel->setText(user.displayName);
|
||||
this->ui_.nameLabel->setProperty("copy-text", user.displayName);
|
||||
}
|
||||
|
||||
this->setWindowTitle(
|
||||
TEXT_TITLE.arg(user.displayName, this->channel_->getName()));
|
||||
this->ui_.viewCountLabel->setText(
|
||||
|
|
|
@ -50,8 +50,10 @@ private:
|
|||
|
||||
struct {
|
||||
Button *avatarButton = nullptr;
|
||||
Button *localizedNameCopyButton = nullptr;
|
||||
|
||||
Label *nameLabel = nullptr;
|
||||
Label *localizedNameLabel = nullptr;
|
||||
Label *viewCountLabel = nullptr;
|
||||
Label *followerCountLabel = nullptr;
|
||||
Label *createdDateLabel = nullptr;
|
||||
|
|
Loading…
Reference in a new issue