mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-19 14:36:58 +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 }};
|
infoPremiumStar: icon {{ "profile_premium", profileVerifiedCheckBg }};
|
||||||
|
|
||||||
|
infoIconFg: windowBoldFg;
|
||||||
|
|
||||||
infoProfileSkip: 7px;
|
infoProfileSkip: 7px;
|
||||||
|
|
||||||
infoProfileLabeledPadding: margins(79px, 9px, 30px, 7px);
|
infoProfileLabeledPadding: margins(79px, 9px, 30px, 7px);
|
||||||
|
infoProfileLabeledUsernamePadding: margins(79px, 9px, 20px, 7px);
|
||||||
infoProfileSeparatorPadding: margins(
|
infoProfileSeparatorPadding: margins(
|
||||||
77px,
|
77px,
|
||||||
infoProfileSkip,
|
infoProfileSkip,
|
||||||
0px,
|
0px,
|
||||||
infoProfileSkip);
|
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 }};
|
infoIconInformation: icon {{ "info/info_information", infoIconFg }};
|
||||||
infoIconAddMember: icon {{ "info/info_add_member", infoIconFg }};
|
infoIconAddMember: icon {{ "info/info_add_member", infoIconFg }};
|
||||||
infoIconNotifications: icon {{ "info/info_notifications", infoIconFg }};
|
infoIconNotifications: icon {{ "info/info_notifications", infoIconFg }};
|
||||||
|
@ -244,43 +244,49 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto addInfoLineGeneric = [&](
|
const auto addInfoLineGeneric = [&](
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<QString> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
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(
|
auto line = CreateTextWithLabel(
|
||||||
result,
|
result,
|
||||||
std::move(label) | Ui::Text::ToWithEntities(),
|
std::move(label) | Ui::Text::ToWithEntities(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
textSt,
|
textSt,
|
||||||
st::infoProfileLabeledPadding);
|
padding);
|
||||||
tracker.track(result->add(std::move(line.wrap)));
|
tracker.track(result->add(std::move(line.wrap)));
|
||||||
|
|
||||||
line.text->setClickHandlerFilter(infoClickFilter);
|
line.text->setClickHandlerFilter(infoClickFilter);
|
||||||
return line.text;
|
return line.text;
|
||||||
};
|
};
|
||||||
auto addInfoLine = [&](
|
const auto addInfoLine = [&](
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<QString> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
const style::FlatLabel &textSt = st::infoLabeled,
|
||||||
|
const style::margins &padding = st::infoProfileLabeledPadding) {
|
||||||
return addInfoLineGeneric(
|
return addInfoLineGeneric(
|
||||||
std::move(label),
|
std::move(label),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
textSt);
|
textSt,
|
||||||
|
padding);
|
||||||
};
|
};
|
||||||
auto addInfoOneLine = [&](
|
const auto addInfoOneLine = [&](
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<QString> &&label,
|
||||||
rpl::producer<TextWithEntities> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const QString &contextCopyText) {
|
const QString &contextCopyText,
|
||||||
auto result = addInfoLine(
|
const style::margins &padding = st::infoProfileLabeledPadding) {
|
||||||
|
const auto result = addInfoLine(
|
||||||
std::move(label),
|
std::move(label),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
st::infoLabeledOneLine);
|
st::infoLabeledOneLine,
|
||||||
|
padding);
|
||||||
result->setDoubleClickSelectsParagraph(true);
|
result->setDoubleClickSelectsParagraph(true);
|
||||||
result->setContextCopyText(contextCopyText);
|
result->setContextCopyText(contextCopyText);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
if (const auto user = _peer->asUser()) {
|
if (const auto user = _peer->asUser()) {
|
||||||
|
const auto controller = _controller->parentController();
|
||||||
if (user->session().supportMode()) {
|
if (user->session().supportMode()) {
|
||||||
addInfoLineGeneric(
|
addInfoLineGeneric(
|
||||||
user->session().supportHelper().infoLabelValue(user),
|
user->session().supportHelper().infoLabelValue(user),
|
||||||
@ -295,12 +301,36 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||||||
? tr::lng_info_about_label()
|
? tr::lng_info_about_label()
|
||||||
: tr::lng_info_bio_label();
|
: tr::lng_info_bio_label();
|
||||||
addInfoLine(std::move(label), AboutValue(user));
|
addInfoLine(std::move(label), AboutValue(user));
|
||||||
addInfoOneLine(
|
|
||||||
|
const auto usernameLabel = addInfoOneLine(
|
||||||
tr::lng_info_username_label(),
|
tr::lng_info_username_label(),
|
||||||
UsernameValue(user),
|
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(
|
AddMainButton(
|
||||||
result,
|
result,
|
||||||
tr::lng_info_add_as_contact(),
|
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/boxes/report_box.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_entity.h"
|
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
@ -197,7 +196,6 @@ private:
|
|||||||
void addExportChat();
|
void addExportChat();
|
||||||
void addReport();
|
void addReport();
|
||||||
void addNewContact();
|
void addNewContact();
|
||||||
void addShareUsername();
|
|
||||||
void addShareContact();
|
void addShareContact();
|
||||||
void addEditContact();
|
void addEditContact();
|
||||||
void addBotToGroup();
|
void addBotToGroup();
|
||||||
@ -653,27 +651,6 @@ void Filler::addNewContact() {
|
|||||||
&st::menuIconInvite);
|
&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() {
|
void Filler::addShareContact() {
|
||||||
const auto user = _peer->asUser();
|
const auto user = _peer->asUser();
|
||||||
if (!user || !user->canShareThisContact()) {
|
if (!user || !user->canShareThisContact()) {
|
||||||
@ -880,7 +857,6 @@ void Filler::fillProfileActions() {
|
|||||||
addSupportInfo();
|
addSupportInfo();
|
||||||
addNewContact();
|
addNewContact();
|
||||||
addShareContact();
|
addShareContact();
|
||||||
addShareUsername();
|
|
||||||
addEditContact();
|
addEditContact();
|
||||||
addBotToGroup();
|
addBotToGroup();
|
||||||
addNewMembers();
|
addNewMembers();
|
||||||
|
Loading…
Reference in New Issue
Block a user