Add copy button for user ids

This commit is contained in:
Mm2PL 2019-08-31 21:30:48 +02:00 committed by fourtf
parent 6732aab323
commit b441e3e159

View file

@ -63,7 +63,8 @@ UserInfoPopup::UserInfoPopup()
name_box.withoutMargin();
auto name = name_box.emplace<Label>().assign(&this->ui_.nameLabel);
LayoutCreator<EffectLabel2> copyUserName = name_box.emplace<EffectLabel2>(this);
LayoutCreator<EffectLabel2> copyUserName =
name_box.emplace<EffectLabel2>(this);
copyUserName->setPixmap(app->resources->buttons.copyDark);
// TODO(mm2pl): change this when the card get themed.
@ -75,7 +76,8 @@ UserInfoPopup::UserInfoPopup()
name_box->addStretch(1);
QObject::connect(copyUserName.getElement(), &Button::leftClicked, [this] {
QObject::connect(
copyUserName.getElement(), &Button::leftClicked, [this] {
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(this->userName_);
});
@ -85,7 +87,22 @@ UserInfoPopup::UserInfoPopup()
.assign(&this->ui_.followerCountLabel);
vbox.emplace<Label>(TEXT_CREATED)
.assign(&this->ui_.createdDateLabel);
vbox.emplace<Label>(TEXT_USER_ID).assign(&this->ui_.userIDLabel);
auto userIDBox = vbox.emplace<QHBoxLayout>().withoutMargin();
userIDBox.emplace<Label>(TEXT_USER_ID)
.assign(&this->ui_.userIDLabel);
LayoutCreator<EffectLabel2> copyUserID =
userIDBox.emplace<EffectLabel2>(this);
copyUserID->setPixmap(app->resources->buttons.copyDark);
// this will need to be changed too if there will be theming.
copyUserID->setScaleIndependantSize(32, 32);
userIDBox->addStretch(1);
QObject::connect(
copyUserID.getElement(), &Button::leftClicked, [this] {
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(this->userId_);
});
}
}