mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-16 04:07:02 +00:00
Moved copy link of public user from context menu to button in profile.
This commit is contained in:
parent
b750908dff
commit
fe2455dea6
@ -306,16 +306,27 @@ infoVerifiedCheck: icon {
|
||||
};
|
||||
infoPremiumStar: icon {{ "profile_premium", profileVerifiedCheckBg }};
|
||||
|
||||
infoIconFg: windowBoldFg;
|
||||
|
||||
infoProfileSkip: 7px;
|
||||
|
||||
infoProfileLabeledPadding: margins(79px, 9px, 30px, 7px);
|
||||
infoProfileLabeledUsernamePadding: margins(79px, 9px, 20px, 7px);
|
||||
infoProfileSeparatorPadding: margins(
|
||||
77px,
|
||||
infoProfileSkip,
|
||||
0px,
|
||||
infoProfileSkip);
|
||||
infoProfileLabeledButtonCopy: IconButton(defaultIconButton) {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
icon: icon {{ "menu/copy", infoIconFg }};
|
||||
iconOver: icon {{ "menu/copy", infoIconFg }};
|
||||
rippleAreaPosition: point(0px, 0px);
|
||||
rippleAreaSize: 34px;
|
||||
ripple: defaultRippleAnimation;
|
||||
}
|
||||
|
||||
infoIconFg: windowBoldFg;
|
||||
infoIconInformation: icon {{ "info/info_information", infoIconFg }};
|
||||
infoIconAddMember: icon {{ "info/info_add_member", infoIconFg }};
|
||||
infoIconNotifications: icon {{ "info/info_notifications", infoIconFg }};
|
||||
|
@ -244,43 +244,49 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto addInfoLineGeneric = [&](
|
||||
const auto addInfoLineGeneric = [&](
|
||||
rpl::producer<QString> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
||||
const style::FlatLabel &textSt = st::infoLabeled,
|
||||
const style::margins &padding = st::infoProfileLabeledPadding) {
|
||||
auto line = CreateTextWithLabel(
|
||||
result,
|
||||
std::move(label) | Ui::Text::ToWithEntities(),
|
||||
std::move(text),
|
||||
textSt,
|
||||
st::infoProfileLabeledPadding);
|
||||
padding);
|
||||
tracker.track(result->add(std::move(line.wrap)));
|
||||
|
||||
line.text->setClickHandlerFilter(infoClickFilter);
|
||||
return line.text;
|
||||
};
|
||||
auto addInfoLine = [&](
|
||||
const auto addInfoLine = [&](
|
||||
rpl::producer<QString> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
||||
const style::FlatLabel &textSt = st::infoLabeled,
|
||||
const style::margins &padding = st::infoProfileLabeledPadding) {
|
||||
return addInfoLineGeneric(
|
||||
std::move(label),
|
||||
std::move(text),
|
||||
textSt);
|
||||
textSt,
|
||||
padding);
|
||||
};
|
||||
auto addInfoOneLine = [&](
|
||||
const auto addInfoOneLine = [&](
|
||||
rpl::producer<QString> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const QString &contextCopyText) {
|
||||
auto result = addInfoLine(
|
||||
const QString &contextCopyText,
|
||||
const style::margins &padding = st::infoProfileLabeledPadding) {
|
||||
const auto result = addInfoLine(
|
||||
std::move(label),
|
||||
std::move(text),
|
||||
st::infoLabeledOneLine);
|
||||
st::infoLabeledOneLine,
|
||||
padding);
|
||||
result->setDoubleClickSelectsParagraph(true);
|
||||
result->setContextCopyText(contextCopyText);
|
||||
return result;
|
||||
};
|
||||
if (const auto user = _peer->asUser()) {
|
||||
const auto controller = _controller->parentController();
|
||||
if (user->session().supportMode()) {
|
||||
addInfoLineGeneric(
|
||||
user->session().supportHelper().infoLabelValue(user),
|
||||
@ -295,12 +301,36 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||
? tr::lng_info_about_label()
|
||||
: tr::lng_info_bio_label();
|
||||
addInfoLine(std::move(label), AboutValue(user));
|
||||
addInfoOneLine(
|
||||
|
||||
const auto usernameLabel = addInfoOneLine(
|
||||
tr::lng_info_username_label(),
|
||||
UsernameValue(user),
|
||||
tr::lng_context_copy_mention(tr::now));
|
||||
tr::lng_context_copy_mention(tr::now),
|
||||
st::infoProfileLabeledUsernamePadding);
|
||||
if (user->isBot()) {
|
||||
const auto copyUsername = Ui::CreateChild<Ui::IconButton>(
|
||||
usernameLabel->parentWidget(),
|
||||
st::infoProfileLabeledButtonCopy);
|
||||
result->sizeValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto s = usernameLabel->parentWidget()->size();
|
||||
copyUsername->moveToRight(
|
||||
0,
|
||||
(s.height() - copyUsername->height()) / 2);
|
||||
}, copyUsername->lifetime());
|
||||
copyUsername->setClickedCallback([=] {
|
||||
const auto link = user->session().createInternalLinkFull(
|
||||
user->userName());
|
||||
if (!link.isEmpty()) {
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_username_copied(tr::now));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
const auto controller = _controller->parentController();
|
||||
AddMainButton(
|
||||
result,
|
||||
tr::lng_info_add_as_contact(),
|
||||
|
@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/boxes/report_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_entity.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
@ -197,7 +196,6 @@ private:
|
||||
void addExportChat();
|
||||
void addReport();
|
||||
void addNewContact();
|
||||
void addShareUsername();
|
||||
void addShareContact();
|
||||
void addEditContact();
|
||||
void addBotToGroup();
|
||||
@ -653,27 +651,6 @@ void Filler::addNewContact() {
|
||||
&st::menuIconInvite);
|
||||
}
|
||||
|
||||
void Filler::addShareUsername() {
|
||||
const auto user = _peer->asUser();
|
||||
if (!user || user->userName().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
_addAction(
|
||||
tr::lng_group_invite_share(tr::now),
|
||||
[=, controller = _controller] {
|
||||
const auto link = controller->session().createInternalLinkFull(
|
||||
user->userName());
|
||||
if (link.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
TextUtilities::SetClipboardText(TextForMimeData::Simple(link));
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_username_copied(tr::now));
|
||||
},
|
||||
&st::menuIconShare);
|
||||
}
|
||||
|
||||
void Filler::addShareContact() {
|
||||
const auto user = _peer->asUser();
|
||||
if (!user || !user->canShareThisContact()) {
|
||||
@ -880,7 +857,6 @@ void Filler::fillProfileActions() {
|
||||
addSupportInfo();
|
||||
addNewContact();
|
||||
addShareContact();
|
||||
addShareUsername();
|
||||
addEditContact();
|
||||
addBotToGroup();
|
||||
addNewMembers();
|
||||
|
Loading…
Reference in New Issue
Block a user