From f2f5ae9c93f837041cbb1b21be2564518fbadf74 Mon Sep 17 00:00:00 2001
From: Mm2PL <jakis128@gmail.com>
Date: Thu, 22 Aug 2019 20:23:49 +0200
Subject: [PATCH] Add a copy button near the username in usercards

---
 src/widgets/dialogs/UserInfoPopup.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp
index 899a4aaf8..34008b43b 100644
--- a/src/widgets/dialogs/UserInfoPopup.cpp
+++ b/src/widgets/dialogs/UserInfoPopup.cpp
@@ -58,11 +58,26 @@ UserInfoPopup::UserInfoPopup()
         // items on the right
         auto vbox = head.emplace<QVBoxLayout>();
         {
-            auto name = vbox.emplace<Label>().assign(&this->ui_.nameLabel);
+            auto name_box = vbox.emplace<QHBoxLayout>();
+            name_box.withoutMargin();
+
+            auto name = name_box.emplace<Label>().assign(&this->ui_.nameLabel);
+
+            LayoutCreator<EffectLabel2> copy_user_name = name_box.emplace<EffectLabel2>(this);
+            copy_user_name->getLabel().setText("Copy");
+            copy_user_name->getLabel().setCentered(true);
 
             auto font = name->font();
             font.setBold(true);
             name->setFont(font);
+
+            name_box->addStretch(1);
+
+            QObject::connect(copy_user_name.getElement(), &Button::leftClicked, [this] {
+                QClipboard *clipboard = QGuiApplication::clipboard();
+                clipboard->setText(this->userName_);
+            });
+
             vbox.emplace<Label>(TEXT_VIEWS).assign(&this->ui_.viewCountLabel);
             vbox.emplace<Label>(TEXT_FOLLOWERS)
                 .assign(&this->ui_.followerCountLabel);