Added ability to create box for share QR code without peer.
This commit is contained in:
parent
0916836ff9
commit
c47f5e9995
3 changed files with 35 additions and 27 deletions
|
@ -1127,9 +1127,8 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
fitLabelToButton(copyUsername, usernameLine.text);
|
fitLabelToButton(copyUsername, usernameLine.text);
|
||||||
copyUsername->setClickedCallback([=] {
|
copyUsername->setClickedCallback([=] {
|
||||||
if (!user->isBot()) {
|
if (!user->isBot()) {
|
||||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
controller->show(
|
||||||
Ui::FillPeerQrBox(box, user);
|
Box(Ui::FillPeerQrBox, user, std::nullopt, nullptr));
|
||||||
}));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto link = user->session().createInternalLinkFull(
|
const auto link = user->session().createInternalLinkFull(
|
||||||
|
@ -1209,9 +1208,8 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
st::infoProfileLabeledButtonQr);
|
st::infoProfileLabeledButtonQr);
|
||||||
fitLabelToButton(qr, linkLine.text);
|
fitLabelToButton(qr, linkLine.text);
|
||||||
qr->setClickedCallback([=, peer = _peer] {
|
qr->setClickedCallback([=, peer = _peer] {
|
||||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
controller->show(
|
||||||
Ui::FillPeerQrBox(box, peer);
|
Box(Ui::FillPeerQrBox, peer, std::nullopt, nullptr));
|
||||||
}));
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
#include "info/channel_statistics/boosts/giveaway/boost_badge.h" // InfiniteRadialAnimationWidget.
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -375,7 +376,7 @@ void Paint(
|
||||||
|
|
||||||
void FillPeerQrBox(
|
void FillPeerQrBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
PeerData *peer,
|
||||||
std::optional<QString> customLink,
|
std::optional<QString> customLink,
|
||||||
rpl::producer<QString> about) {
|
rpl::producer<QString> about) {
|
||||||
const auto window = Core::App().findWindow(box);
|
const auto window = Core::App().findWindow(box);
|
||||||
|
@ -400,6 +401,7 @@ void FillPeerQrBox(
|
||||||
style::font font;
|
style::font font;
|
||||||
};
|
};
|
||||||
const auto state = box->lifetime().make_state<State>();
|
const auto state = box->lifetime().make_state<State>();
|
||||||
|
state->userpicToggled = !(customLink || !peer);
|
||||||
const auto createFont = [=](int scale) {
|
const auto createFont = [=](int scale) {
|
||||||
return style::font(
|
return style::font(
|
||||||
style::ConvertScale(30, scale),
|
style::ConvertScale(30, scale),
|
||||||
|
@ -409,7 +411,7 @@ void FillPeerQrBox(
|
||||||
state->font = createFont(style::Scale());
|
state->font = createFont(style::Scale());
|
||||||
|
|
||||||
const auto usernameValue = [=] {
|
const auto usernameValue = [=] {
|
||||||
return customLink
|
return (customLink || !peer)
|
||||||
? rpl::single(QString())
|
? rpl::single(QString())
|
||||||
: Info::Profile::UsernameValue(peer, true) | rpl::map(
|
: Info::Profile::UsernameValue(peer, true) | rpl::map(
|
||||||
[](const auto &username) { return username.text; });
|
[](const auto &username) { return username.text; });
|
||||||
|
@ -417,14 +419,17 @@ void FillPeerQrBox(
|
||||||
const auto linkValue = [=] {
|
const auto linkValue = [=] {
|
||||||
return customLink
|
return customLink
|
||||||
? rpl::single(*customLink)
|
? rpl::single(*customLink)
|
||||||
: Info::Profile::LinkValue(peer, true) | rpl::map(
|
: peer
|
||||||
[](const auto &link) { return link.text; });
|
? Info::Profile::LinkValue(peer, true) | rpl::map(
|
||||||
|
[](const auto &link) { return link.text; })
|
||||||
|
: rpl::single(QString());
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||||
box,
|
box,
|
||||||
peer,
|
peer ? peer : controller->session().user().get(),
|
||||||
st::defaultUserpicButton);
|
st::defaultUserpicButton);
|
||||||
|
userpic->setVisible(peer != nullptr);
|
||||||
const auto qr = PrepareQrWidget(
|
const auto qr = PrepareQrWidget(
|
||||||
box->verticalLayout(),
|
box->verticalLayout(),
|
||||||
userpic,
|
userpic,
|
||||||
|
@ -696,6 +701,7 @@ void FillPeerQrBox(
|
||||||
}
|
}
|
||||||
Ui::AddSkip(box->verticalLayout());
|
Ui::AddSkip(box->verticalLayout());
|
||||||
Ui::AddSkip(box->verticalLayout());
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
if (peer) {
|
||||||
const auto userpicToggle = box->verticalLayout()->add(
|
const auto userpicToggle = box->verticalLayout()->add(
|
||||||
object_ptr<Ui::SettingsButton>(
|
object_ptr<Ui::SettingsButton>(
|
||||||
box->verticalLayout(),
|
box->verticalLayout(),
|
||||||
|
@ -709,6 +715,7 @@ void FillPeerQrBox(
|
||||||
userpicToggle->setClickedCallback([=] {
|
userpicToggle->setClickedCallback([=] {
|
||||||
state->userpicToggled = !state->userpicToggled.current();
|
state->userpicToggled = !state->userpicToggled.current();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
Ui::AddSkip(box->verticalLayout());
|
Ui::AddSkip(box->verticalLayout());
|
||||||
Ui::AddSkip(box->verticalLayout());
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
|
||||||
|
@ -718,6 +725,9 @@ void FillPeerQrBox(
|
||||||
tr::lng_chat_link_copy());
|
tr::lng_chat_link_copy());
|
||||||
const auto show = controller->uiShow();
|
const auto show = controller->uiShow();
|
||||||
state->saveButton = box->addButton(std::move(buttonText), [=] {
|
state->saveButton = box->addButton(std::move(buttonText), [=] {
|
||||||
|
if (state->saveButtonBusy.current()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto buttonWidth = state->saveButton
|
const auto buttonWidth = state->saveButton
|
||||||
? state->saveButton->width()
|
? state->saveButton->width()
|
||||||
: 0;
|
: 0;
|
||||||
|
|
|
@ -15,8 +15,8 @@ class GenericBox;
|
||||||
|
|
||||||
void FillPeerQrBox(
|
void FillPeerQrBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
PeerData *peer,
|
||||||
std::optional<QString> customLink = std::nullopt,
|
std::optional<QString> customLink,
|
||||||
rpl::producer<QString> about = nullptr);
|
rpl::producer<QString> about);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
Loading…
Reference in a new issue