mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-01-11 01:10:13 +00:00
Add some more actions to three dot menu.
This commit is contained in:
parent
fcf2b9d1a7
commit
9743dc1ffb
@ -570,6 +570,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
"lng_profile_add_participant" = "Add Members";
|
||||
"lng_profile_view_channel" = "View Channel";
|
||||
"lng_profile_join_channel" = "Join Channel";
|
||||
"lng_profile_join_group" = "Join Group";
|
||||
"lng_profile_delete_and_exit" = "Leave";
|
||||
"lng_profile_kick" = "Remove";
|
||||
"lng_profile_sure_kick" = "Remove {user} from the group?";
|
||||
@ -627,6 +628,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
"lng_profile_common_groups_section" = "Groups in common";
|
||||
"lng_profile_share_contact" = "Share Contact";
|
||||
"lng_info_edit_contact" = "Edit contact";
|
||||
"lng_info_delete_contact" = "Delete contact";
|
||||
"lng_info_share_contact" = "Share contact";
|
||||
"lng_profile_clear_history" = "Clear history";
|
||||
"lng_profile_delete_conversation" = "Delete conversation";
|
||||
"lng_profile_block_user" = "Block user";
|
||||
@ -943,7 +946,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
"lng_from_draft" = "Draft";
|
||||
"lng_bot_description" = "What can this bot do?";
|
||||
"lng_unblock_button" = "Unblock";
|
||||
"lng_channel_join" = "Join Channel";
|
||||
"lng_channel_mute" = "Mute";
|
||||
"lng_channel_unmute" = "Unmute";
|
||||
|
||||
|
@ -860,3 +860,21 @@ void AddBotToGroupBoxController::prepareViewHook() {
|
||||
updateLabels();
|
||||
subscribe(Auth().data().allChatsLoaded(), [this](bool) { updateLabels(); });
|
||||
}
|
||||
|
||||
ChooseRecipientBoxController::ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback)
|
||||
: _callback(std::move(callback)) {
|
||||
}
|
||||
|
||||
void ChooseRecipientBoxController::prepareViewHook() {
|
||||
delegate()->peerListSetTitle(langFactory(lng_forward_choose));
|
||||
}
|
||||
|
||||
void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
_callback(row->peer());
|
||||
}
|
||||
|
||||
auto ChooseRecipientBoxController::createRow(
|
||||
not_null<History*> history) -> std::unique_ptr<Row> {
|
||||
return std::make_unique<Row>(history);
|
||||
}
|
||||
|
@ -228,3 +228,19 @@ private:
|
||||
not_null<UserData*> _bot;
|
||||
|
||||
};
|
||||
|
||||
class ChooseRecipientBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback);
|
||||
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
protected:
|
||||
void prepareViewHook() override;
|
||||
std::unique_ptr<Row> createRow(
|
||||
not_null<History*> history) override;
|
||||
|
||||
base::lambda<void(not_null<PeerData*>)> _callback;
|
||||
|
||||
};
|
||||
|
@ -20,7 +20,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#include "facades.h"
|
||||
|
||||
#include "profile/profile_section_memento.h"
|
||||
#include "info/info_memento.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "media/media_clip_reader.h"
|
||||
|
@ -526,7 +526,7 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
|
||||
, _send(this)
|
||||
, _unblock(this, lang(lng_unblock_button).toUpper(), st::historyUnblock)
|
||||
, _botStart(this, lang(lng_bot_start).toUpper(), st::historyComposeButton)
|
||||
, _joinChannel(this, lang(lng_channel_join).toUpper(), st::historyComposeButton)
|
||||
, _joinChannel(this, lang(lng_profile_join_channel).toUpper(), st::historyComposeButton)
|
||||
, _muteUnmute(this, lang(lng_channel_mute).toUpper(), st::historyComposeButton)
|
||||
, _attachToggle(this, st::historyAttach)
|
||||
, _tabbedSelectorToggle(this, st::historyAttachEmoji)
|
||||
@ -1739,7 +1739,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
|
||||
|
||||
if (_peer && _peer->isChannel()) {
|
||||
_peer->asChannel()->updateFull();
|
||||
_joinChannel->setText(lang(_peer->isMegagroup() ? lng_group_invite_join : lng_channel_join).toUpper());
|
||||
_joinChannel->setText(lang(_peer->isMegagroup()
|
||||
? lng_profile_join_group
|
||||
: lng_profile_join_channel).toUpper());
|
||||
}
|
||||
|
||||
_unblockRequest = _reportSpamRequest = 0;
|
||||
|
@ -35,24 +35,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
|
||||
namespace Info {
|
||||
|
||||
ChooseRecipientBoxController::ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback)
|
||||
: _callback(std::move(callback)) {
|
||||
}
|
||||
|
||||
void ChooseRecipientBoxController::prepareViewHook() {
|
||||
delegate()->peerListSetTitle(langFactory(lng_forward_choose));
|
||||
}
|
||||
|
||||
void ChooseRecipientBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||
_callback(row->peer());
|
||||
}
|
||||
|
||||
auto ChooseRecipientBoxController::createRow(
|
||||
not_null<History*> history) -> std::unique_ptr<Row> {
|
||||
return std::make_unique<Row>(history);
|
||||
}
|
||||
|
||||
TopBarOverride::TopBarOverride(
|
||||
QWidget *parent,
|
||||
const style::InfoTopBar &st,
|
||||
|
@ -35,22 +35,6 @@ class FlatLabel;
|
||||
|
||||
namespace Info {
|
||||
|
||||
class ChooseRecipientBoxController : public ChatsListBoxController {
|
||||
public:
|
||||
ChooseRecipientBoxController(
|
||||
base::lambda<void(not_null<PeerData*>)> callback);
|
||||
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
protected:
|
||||
void prepareViewHook() override;
|
||||
std::unique_ptr<Row> createRow(
|
||||
not_null<History*> history) override;
|
||||
|
||||
base::lambda<void(not_null<PeerData*>)> _callback;
|
||||
|
||||
};
|
||||
|
||||
class TopBarOverride : public Ui::RpWidget {
|
||||
public:
|
||||
TopBarOverride(
|
||||
|
@ -34,7 +34,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "window/main_window.h"
|
||||
#include "styles/style_overview.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "info/info_top_bar_override.h"
|
||||
#include "core/file_utilities.h"
|
||||
|
@ -39,6 +39,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "info/profile/info_profile_button.h"
|
||||
#include "info/profile/info_profile_text.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_peer_menu.h"
|
||||
#include "mainwidget.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
@ -95,36 +96,6 @@ auto AddMainButton(
|
||||
st::infoMainButton));
|
||||
}
|
||||
|
||||
void ShareContactBox(not_null<UserData*> user) {
|
||||
auto callback = [user](not_null<PeerData*> peer) {
|
||||
if (!peer->canWrite()) {
|
||||
Ui::show(Box<InformBox>(
|
||||
lang(lng_forward_share_cant)),
|
||||
LayerOption::KeepOther);
|
||||
return;
|
||||
}
|
||||
auto recipient = peer->isUser()
|
||||
? peer->name
|
||||
: '\xAB' + peer->name + '\xBB';
|
||||
Ui::show(Box<ConfirmBox>(
|
||||
lng_forward_share_contact(lt_recipient, recipient),
|
||||
lang(lng_forward_send),
|
||||
[peer, user] {
|
||||
App::main()->onShareContact(
|
||||
peer->id,
|
||||
user);
|
||||
Ui::hideLayer();
|
||||
}), LayerOption::KeepOther);
|
||||
};
|
||||
Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
|
||||
[](not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_cancel), [box] {
|
||||
box->closeBox();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
class DetailsFiller {
|
||||
public:
|
||||
DetailsFiller(
|
||||
@ -314,20 +285,11 @@ Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
|
||||
std::move(sendMessageVisible),
|
||||
std::move(sendMessage),
|
||||
tracker);
|
||||
|
||||
auto addContact = [user] {
|
||||
auto firstName = user->firstName;
|
||||
auto lastName = user->lastName;
|
||||
auto phone = user->phone().isEmpty()
|
||||
? App::phoneFromSharedContact(user->bareId())
|
||||
: user->phone();
|
||||
Ui::show(Box<AddContactBox>(firstName, lastName, phone));
|
||||
};
|
||||
AddMainButton(
|
||||
_wrap,
|
||||
Lang::Viewer(lng_info_add_as_contact),
|
||||
CanAddContactValue(user),
|
||||
std::move(addContact),
|
||||
[user] { Window::PeerMenuAddContact(user); },
|
||||
tracker);
|
||||
|
||||
return tracker;
|
||||
@ -387,9 +349,9 @@ void ActionsFiller::addInviteToGroupAction(
|
||||
void ActionsFiller::addShareContactAction(not_null<UserData*> user) {
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
Lang::Viewer(lng_profile_share_contact),
|
||||
Lang::Viewer(lng_info_share_contact),
|
||||
CanShareContactValue(user),
|
||||
[user] { ShareContactBox(user); });
|
||||
[user] { Window::PeerMenuShareContactBox(user); });
|
||||
}
|
||||
|
||||
void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
||||
@ -402,30 +364,11 @@ void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
||||
|
||||
void ActionsFiller::addDeleteContactAction(
|
||||
not_null<UserData*> user) {
|
||||
auto callback = [=] {
|
||||
auto text = lng_sure_delete_contact(
|
||||
lt_contact,
|
||||
App::peerName(user));
|
||||
auto deleteSure = [=] {
|
||||
Ui::showChatsList();
|
||||
Ui::hideLayer();
|
||||
MTP::send(
|
||||
MTPcontacts_DeleteContact(user->inputUser),
|
||||
App::main()->rpcDone(
|
||||
&MainWidget::deletedContact,
|
||||
user.get()));
|
||||
};
|
||||
auto box = Box<ConfirmBox>(
|
||||
text,
|
||||
lang(lng_box_delete),
|
||||
std::move(deleteSure));
|
||||
Ui::show(std::move(box));
|
||||
};
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
Lang::Viewer(lng_profile_delete_contact),
|
||||
Lang::Viewer(lng_info_delete_contact),
|
||||
IsContactValue(user),
|
||||
std::move(callback));
|
||||
[user] { Window::PeerMenuDeleteContact(user); });
|
||||
}
|
||||
|
||||
void ActionsFiller::addClearHistoryAction(not_null<UserData*> user) {
|
||||
|
@ -55,7 +55,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "data/data_shared_media.h"
|
||||
#include "profile/profile_common_groups_section.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Profile {
|
||||
|
@ -28,7 +28,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "info/profile/info_profile_members_controllers.h"
|
||||
#include "info/info_content_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "profile/profile_block_group_members.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
|
@ -154,10 +154,12 @@ void ChatMembersController::restoreState(
|
||||
|
||||
void ChatMembersController::rebuildRows() {
|
||||
if (_chat->participants.empty()) {
|
||||
while (delegate()->peerListFullRowsCount() > 0) {
|
||||
delegate()->peerListRemoveRow(
|
||||
delegate()->peerListRowAt(0));
|
||||
}
|
||||
// We get such updates often
|
||||
// (when participants list was invalidated).
|
||||
//while (delegate()->peerListFullRowsCount() > 0) {
|
||||
// delegate()->peerListRemoveRow(
|
||||
// delegate()->peerListRowAt(0));
|
||||
//}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "lang/lang_keys.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/mute_settings_box.h"
|
||||
#include "boxes/add_contact_box.h"
|
||||
#include "boxes/report_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
#include "mainwidget.h"
|
||||
@ -32,14 +34,37 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "window/window_controller.h"
|
||||
|
||||
namespace Window {
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
void AddChatMembers(not_null<ChatData*> chat) {
|
||||
if (chat->count >= Global::ChatSizeMax() && chat->amCreator()) {
|
||||
Ui::show(Box<ConvertToSupergroupBox>(chat));
|
||||
} else {
|
||||
AddParticipantsBoxController::Start(chat);
|
||||
}
|
||||
}
|
||||
|
||||
void AddChannelMembers(not_null<ChannelData*> channel) {
|
||||
if (channel->isMegagroup()) {
|
||||
auto &participants = channel->mgInfo->lastParticipants;
|
||||
AddParticipantsBoxController::Start(
|
||||
channel,
|
||||
{ participants.cbegin(), participants.cend() });
|
||||
} else if (channel->membersCount() >= Global::ChatSizeMax()) {
|
||||
Ui::show(
|
||||
Box<MaxInviteBox>(channel),
|
||||
LayerOption::KeepOther);
|
||||
} else {
|
||||
AddParticipantsBoxController::Start(channel, { });
|
||||
}
|
||||
}
|
||||
|
||||
class Filler {
|
||||
public:
|
||||
Filler(
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
const PeerMenuCallback &callback,
|
||||
const PeerMenuCallback &addAction,
|
||||
const PeerMenuOptions &options);
|
||||
void fill();
|
||||
|
||||
@ -55,7 +80,7 @@ private:
|
||||
|
||||
not_null<Controller*> _controller;
|
||||
not_null<PeerData*> _peer;
|
||||
const PeerMenuCallback &_callback;
|
||||
const PeerMenuCallback &_addAction;
|
||||
const PeerMenuOptions &_options;
|
||||
|
||||
};
|
||||
@ -116,11 +141,11 @@ auto DeleteAndLeaveHandler(not_null<PeerData*> peer) {
|
||||
Filler::Filler(
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
const PeerMenuCallback &callback,
|
||||
const PeerMenuCallback &addAction,
|
||||
const PeerMenuOptions &options)
|
||||
: _controller(controller)
|
||||
, _peer(peer)
|
||||
, _callback(callback)
|
||||
, _addAction(addAction)
|
||||
, _options(options) {
|
||||
}
|
||||
|
||||
@ -167,7 +192,7 @@ void Filler::addPinToggle() {
|
||||
}
|
||||
}
|
||||
};
|
||||
auto pinAction = _callback(pinText(isPinned), pinToggle);
|
||||
auto pinAction = _addAction(pinText(isPinned), pinToggle);
|
||||
|
||||
auto lifetime = Notify::PeerUpdateViewer(
|
||||
peer,
|
||||
@ -188,7 +213,7 @@ void Filler::addInfo() {
|
||||
: (peer->isUser()
|
||||
? lng_context_view_profile
|
||||
: lng_context_view_channel);
|
||||
_callback(lang(infoKey), [=] {
|
||||
_addAction(lang(infoKey), [=] {
|
||||
controller->showPeerInfo(peer);
|
||||
});
|
||||
}
|
||||
@ -200,7 +225,7 @@ void Filler::addNotifications() {
|
||||
? lng_enable_notifications_from_tray
|
||||
: lng_disable_notifications_from_tray);
|
||||
};
|
||||
auto muteAction = _callback(muteText(peer->isMuted()), [peer] {
|
||||
auto muteAction = _addAction(muteText(peer->isMuted()), [peer] {
|
||||
if (!peer->isMuted()) {
|
||||
Ui::show(Box<MuteSettingsBox>(peer));
|
||||
} else {
|
||||
@ -221,7 +246,7 @@ void Filler::addNotifications() {
|
||||
}
|
||||
|
||||
void Filler::addSearch() {
|
||||
_callback(lang(lng_profile_search_messages), [peer = _peer] {
|
||||
_addAction(lang(lng_profile_search_messages), [peer = _peer] {
|
||||
App::main()->searchInPeer(peer);
|
||||
});
|
||||
}
|
||||
@ -236,7 +261,7 @@ void Filler::addBlockUser(not_null<UserData*> user) {
|
||||
? lng_profile_block_bot
|
||||
: lng_profile_block_user));
|
||||
};
|
||||
auto blockAction = _callback(blockText(user), [user] {
|
||||
auto blockAction = _addAction(blockText(user), [user] {
|
||||
auto willBeBlocked = !user->isBlocked();
|
||||
auto handler = ::rpcDone([user, willBeBlocked](const MTPBool &result) {
|
||||
user->setBlockStatus(willBeBlocked
|
||||
@ -269,17 +294,34 @@ void Filler::addBlockUser(not_null<UserData*> user) {
|
||||
}
|
||||
|
||||
void Filler::addUserActions(not_null<UserData*> user) {
|
||||
if (!_options.fromChatsList) {
|
||||
if (user->isContact()) {
|
||||
// edit contact
|
||||
// share contact
|
||||
_addAction(
|
||||
lang(lng_info_share_contact),
|
||||
[user] { PeerMenuShareContactBox(user); });
|
||||
_addAction(
|
||||
lang(lng_info_edit_contact),
|
||||
[user] { Ui::show(Box<AddContactBox>(user)); });
|
||||
_addAction(
|
||||
lang(lng_info_delete_contact),
|
||||
[user] { PeerMenuDeleteContact(user); });
|
||||
} else if (user->canShareThisContact()) {
|
||||
// add contact
|
||||
// share contact
|
||||
_addAction(
|
||||
lang(lng_info_add_as_contact),
|
||||
[user] { PeerMenuAddContact(user); });
|
||||
_addAction(
|
||||
lang(lng_info_share_contact),
|
||||
[user] { PeerMenuShareContactBox(user); });
|
||||
} else if (user->botInfo && !user->botInfo->cantJoinGroups) {
|
||||
_addAction(
|
||||
lang(lng_profile_invite_to_group),
|
||||
[user] { AddBotToGroupBoxController::Start(user); });
|
||||
}
|
||||
_callback(
|
||||
}
|
||||
_addAction(
|
||||
lang(lng_profile_delete_conversation),
|
||||
DeleteAndLeaveHandler(user));
|
||||
_callback(
|
||||
_addAction(
|
||||
lang(lng_profile_clear_history),
|
||||
ClearHistoryHandler(user));
|
||||
if (!user->isInaccessible() && user != App::self()) {
|
||||
@ -288,26 +330,62 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
||||
}
|
||||
|
||||
void Filler::addChatActions(not_null<ChatData*> chat) {
|
||||
_callback(
|
||||
if (!_options.fromChatsList) {
|
||||
if (chat->canEdit()) {
|
||||
_addAction(
|
||||
lang(lng_profile_edit_contact),
|
||||
[chat] { Ui::show(Box<EditNameTitleBox>(chat)); });
|
||||
}
|
||||
if (chat->amCreator()
|
||||
&& !chat->isDeactivated()) {
|
||||
_addAction(
|
||||
lang(lng_profile_manage_admins),
|
||||
[chat] { EditChatAdminsBoxController::Start(chat); });
|
||||
_addAction(
|
||||
lang(lng_profile_migrate_button),
|
||||
[chat] { Ui::show(Box<ConvertToSupergroupBox>(chat)); });
|
||||
}
|
||||
if (chat->canEdit()) {
|
||||
_addAction(
|
||||
lang(lng_profile_add_participant),
|
||||
[chat] { AddChatMembers(chat); });
|
||||
}
|
||||
}
|
||||
_addAction(
|
||||
lang(lng_profile_clear_and_exit),
|
||||
DeleteAndLeaveHandler(_peer));
|
||||
_callback(
|
||||
_addAction(
|
||||
lang(lng_profile_clear_history),
|
||||
ClearHistoryHandler(_peer));
|
||||
}
|
||||
|
||||
void Filler::addChannelActions(not_null<ChannelData*> channel) {
|
||||
if (!_options.fromChatsList) {
|
||||
//_addAction(manage);
|
||||
if (channel->canAddMembers()) {
|
||||
_addAction(
|
||||
lang(lng_channel_add_members),
|
||||
[channel] { AddChannelMembers(channel); });
|
||||
}
|
||||
}
|
||||
if (channel->amIn()) {
|
||||
auto leaveText = lang(channel->isMegagroup()
|
||||
? lng_profile_leave_group
|
||||
: lng_profile_leave_channel);
|
||||
_callback(leaveText, DeleteAndLeaveHandler(channel));
|
||||
_addAction(leaveText, DeleteAndLeaveHandler(channel));
|
||||
} else {
|
||||
auto joinText = lang(channel->isMegagroup()
|
||||
? lng_profile_join_group
|
||||
: lng_profile_join_channel);
|
||||
_addAction(
|
||||
joinText,
|
||||
[channel] { Auth().api().joinChannel(channel); });
|
||||
}
|
||||
if (!_options.fromChatsList) {
|
||||
auto needReport = !channel->amCreator()
|
||||
&& (!channel->isMegagroup() || channel->isPublic());
|
||||
if (needReport) {
|
||||
_callback(lang(lng_profile_report), [channel] {
|
||||
_addAction(lang(lng_profile_report), [channel] {
|
||||
Ui::show(Box<ReportBox>(channel));
|
||||
});
|
||||
}
|
||||
@ -337,6 +415,65 @@ void Filler::fill() {
|
||||
|
||||
} // namespace
|
||||
|
||||
void PeerMenuDeleteContact(not_null<UserData*> user) {
|
||||
auto text = lng_sure_delete_contact(
|
||||
lt_contact,
|
||||
App::peerName(user));
|
||||
auto deleteSure = [=] {
|
||||
Ui::showChatsList();
|
||||
Ui::hideLayer();
|
||||
MTP::send(
|
||||
MTPcontacts_DeleteContact(user->inputUser),
|
||||
App::main()->rpcDone(
|
||||
&MainWidget::deletedContact,
|
||||
user.get()));
|
||||
};
|
||||
auto box = Box<ConfirmBox>(
|
||||
text,
|
||||
lang(lng_box_delete),
|
||||
std::move(deleteSure));
|
||||
Ui::show(std::move(box));
|
||||
}
|
||||
|
||||
void PeerMenuAddContact(not_null<UserData*> user) {
|
||||
auto firstName = user->firstName;
|
||||
auto lastName = user->lastName;
|
||||
auto phone = user->phone().isEmpty()
|
||||
? App::phoneFromSharedContact(user->bareId())
|
||||
: user->phone();
|
||||
Ui::show(Box<AddContactBox>(firstName, lastName, phone));
|
||||
}
|
||||
|
||||
void PeerMenuShareContactBox(not_null<UserData*> user) {
|
||||
auto callback = [user](not_null<PeerData*> peer) {
|
||||
if (!peer->canWrite()) {
|
||||
Ui::show(Box<InformBox>(
|
||||
lang(lng_forward_share_cant)),
|
||||
LayerOption::KeepOther);
|
||||
return;
|
||||
}
|
||||
auto recipient = peer->isUser()
|
||||
? peer->name
|
||||
: '\xAB' + peer->name + '\xBB';
|
||||
Ui::show(Box<ConfirmBox>(
|
||||
lng_forward_share_contact(lt_recipient, recipient),
|
||||
lang(lng_forward_send),
|
||||
[peer, user] {
|
||||
App::main()->onShareContact(
|
||||
peer->id,
|
||||
user);
|
||||
Ui::hideLayer();
|
||||
}), LayerOption::KeepOther);
|
||||
};
|
||||
Ui::show(Box<PeerListBox>(
|
||||
std::make_unique<ChooseRecipientBoxController>(std::move(callback)),
|
||||
[](not_null<PeerListBox*> box) {
|
||||
box->addButton(langFactory(lng_cancel), [box] {
|
||||
box->closeBox();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
void FillPeerMenu(
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
|
@ -36,7 +36,11 @@ using PeerMenuCallback = base::lambda<QAction*(
|
||||
void FillPeerMenu(
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
const PeerMenuCallback &callback,
|
||||
const PeerMenuCallback &addAction,
|
||||
const PeerMenuOptions &options);
|
||||
|
||||
void PeerMenuDeleteContact(not_null<UserData*> user);
|
||||
void PeerMenuShareContactBox(not_null<UserData*> user);
|
||||
void PeerMenuAddContact(not_null<UserData*> user);
|
||||
|
||||
} // namespace Window
|
||||
|
Loading…
Reference in New Issue
Block a user