mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Delegated display of ShareInviteLinkBox to caller.
This commit is contained in:
parent
d9cdff3e6e
commit
972b421fc6
3 changed files with 38 additions and 19 deletions
|
@ -345,7 +345,9 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
CopyInviteLink(delegate()->peerListToastParent(), link);
|
CopyInviteLink(delegate()->peerListToastParent(), link);
|
||||||
});
|
});
|
||||||
const auto shareLink = crl::guard(weak, [=] {
|
const auto shareLink = crl::guard(weak, [=] {
|
||||||
ShareInviteLinkBox(_peer, link);
|
delegate()->peerListShowBox(
|
||||||
|
ShareInviteLinkBox(_peer, link),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
});
|
});
|
||||||
const auto getLinkQr = crl::guard(weak, [=] {
|
const auto getLinkQr = crl::guard(weak, [=] {
|
||||||
delegate()->peerListShowBox(
|
delegate()->peerListShowBox(
|
||||||
|
@ -954,7 +956,9 @@ void AddPermanentLinkBlock(
|
||||||
});
|
});
|
||||||
const auto shareLink = crl::guard(weak, [=] {
|
const auto shareLink = crl::guard(weak, [=] {
|
||||||
if (const auto current = value->current(); !current.link.isEmpty()) {
|
if (const auto current = value->current(); !current.link.isEmpty()) {
|
||||||
ShareInviteLinkBox(peer, current.link);
|
show->showBox(
|
||||||
|
ShareInviteLinkBox(peer, current.link),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const auto getLinkQr = crl::guard(weak, [=] {
|
const auto getLinkQr = crl::guard(weak, [=] {
|
||||||
|
@ -1116,13 +1120,21 @@ void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link) {
|
||||||
Ui::Toast::Show(toastParent, tr::lng_group_invite_copied(tr::now));
|
Ui::Toast::Show(toastParent, tr::lng_group_invite_copied(tr::now));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link) {
|
object_ptr<Ui::BoxContent> ShareInviteLinkBox(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const QString &link) {
|
||||||
const auto sending = std::make_shared<bool>();
|
const auto sending = std::make_shared<bool>();
|
||||||
const auto box = std::make_shared<QPointer<ShareBox>>();
|
const auto box = std::make_shared<QPointer<ShareBox>>();
|
||||||
|
|
||||||
|
const auto showToast = [=](const QString &text) {
|
||||||
|
if (*box) {
|
||||||
|
Ui::Toast::Show(Ui::BoxShow(*box).toastParent(), text);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
auto copyCallback = [=] {
|
auto copyCallback = [=] {
|
||||||
QGuiApplication::clipboard()->setText(link);
|
QGuiApplication::clipboard()->setText(link);
|
||||||
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
showToast(tr::lng_group_invite_copied(tr::now));
|
||||||
};
|
};
|
||||||
auto submitCallback = [=](
|
auto submitCallback = [=](
|
||||||
std::vector<not_null<PeerData*>> &&result,
|
std::vector<not_null<PeerData*>> &&result,
|
||||||
|
@ -1153,9 +1165,11 @@ void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link) {
|
||||||
).append("\n\n");
|
).append("\n\n");
|
||||||
}
|
}
|
||||||
text.append(error.first);
|
text.append(error.first);
|
||||||
Ui::show(
|
if (*box) {
|
||||||
Ui::MakeInformBox(text),
|
Ui::BoxShow(*box).showBox(
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::MakeInformBox(text),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,24 +1187,25 @@ void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link) {
|
||||||
auto &api = peer->session().api();
|
auto &api = peer->session().api();
|
||||||
for (const auto peer : result) {
|
for (const auto peer : result) {
|
||||||
const auto history = owner->history(peer);
|
const auto history = owner->history(peer);
|
||||||
auto message = Api::MessageToSend(Api::SendAction(history, options));
|
auto message = Api::MessageToSend(
|
||||||
|
Api::SendAction(history, options));
|
||||||
message.textWithTags = comment;
|
message.textWithTags = comment;
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
api.sendMessage(std::move(message));
|
api.sendMessage(std::move(message));
|
||||||
}
|
}
|
||||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
|
||||||
if (*box) {
|
if (*box) {
|
||||||
|
showToast(tr::lng_share_done(tr::now));
|
||||||
(*box)->closeBox();
|
(*box)->closeBox();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
*box = Ui::show(
|
auto object = Box<ShareBox>(ShareBox::Descriptor{
|
||||||
Box<ShareBox>(ShareBox::Descriptor{
|
.session = &peer->session(),
|
||||||
.session = &peer->session(),
|
.copyCallback = std::move(copyCallback),
|
||||||
.copyCallback = std::move(copyCallback),
|
.submitCallback = std::move(submitCallback),
|
||||||
.submitCallback = std::move(submitCallback),
|
.filterCallback = [](auto peer) { return peer->canWrite(); },
|
||||||
.filterCallback = [](auto peer) { return peer->canWrite(); },
|
.navigation = App::wnd()->sessionController() });
|
||||||
.navigation = App::wnd()->sessionController() }),
|
*box = Ui::MakeWeak(object.data());
|
||||||
Ui::LayerOption::KeepOther);
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link) {
|
object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link) {
|
||||||
|
|
|
@ -35,7 +35,9 @@ void AddPermanentLinkBlock(
|
||||||
rpl::producer<Api::InviteLink> fromList);
|
rpl::producer<Api::InviteLink> fromList);
|
||||||
|
|
||||||
void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link);
|
void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link);
|
||||||
void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link);
|
[[nodiscard]] object_ptr<Ui::BoxContent> ShareInviteLinkBox(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const QString &link);
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link);
|
[[nodiscard]] object_ptr<Ui::BoxContent> InviteLinkQrBox(const QString &link);
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> RevokeLinkBox(
|
[[nodiscard]] object_ptr<Ui::BoxContent> RevokeLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
|
|
@ -588,7 +588,9 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
|
||||||
CopyInviteLink(delegate()->peerListToastParent(), link);
|
CopyInviteLink(delegate()->peerListToastParent(), link);
|
||||||
}, &st::menuIconCopy);
|
}, &st::menuIconCopy);
|
||||||
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
|
||||||
ShareInviteLinkBox(_peer, link);
|
delegate()->peerListShowBox(
|
||||||
|
ShareInviteLinkBox(_peer, link),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
}, &st::menuIconShare);
|
}, &st::menuIconShare);
|
||||||
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
|
||||||
delegate()->peerListShowBox(
|
delegate()->peerListShowBox(
|
||||||
|
|
Loading…
Add table
Reference in a new issue