diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 5649410b6..e74d0e793 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -260,6 +260,8 @@ PRIVATE boxes/pin_messages_box.h boxes/reactions_settings_box.cpp boxes/reactions_settings_box.h + boxes/report_messages_box.cpp + boxes/report_messages_box.h boxes/ringtones_box.cpp boxes/ringtones_box.h boxes/self_destruction_box.cpp diff --git a/Telegram/SourceFiles/boxes/report_messages_box.cpp b/Telegram/SourceFiles/boxes/report_messages_box.cpp new file mode 100644 index 000000000..b0e5d993e --- /dev/null +++ b/Telegram/SourceFiles/boxes/report_messages_box.cpp @@ -0,0 +1,75 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "boxes/report_messages_box.h" + +#include "api/api_report.h" +#include "boxes/abstract_box.h" +#include "data/data_peer.h" +#include "facades.h" +#include "lang/lang_keys.h" +#include "ui/boxes/report_box.h" +#include "ui/layers/generic_box.h" +#include "window/window_controller.h" +#include "window/window_session_controller.h" + +void ShowReportItemsBox(not_null peer, MessageIdsList ids) { + const auto chosen = [=](Ui::ReportReason reason) { + Ui::show(Box(Ui::ReportDetailsBox, [=](const QString &text) { + Api::SendReport(peer, reason, text, ids); + Ui::hideLayer(); + })); + }; + Ui::show(Box( + Ui::ReportReasonBox, + Ui::ReportSource::Message, + chosen)); +} + +void ShowReportPeerBox( + not_null window, + not_null peer) { + struct State { + QPointer reasonBox; + QPointer detailsBox; + MessageIdsList ids; + }; + const auto state = std::make_shared(); + const auto chosen = [=](Ui::ReportReason reason) { + const auto send = [=](const QString &text) { + window->clearChooseReportMessages(); + Api::SendReport(peer, reason, text, std::move(state->ids)); + if (const auto strong = state->reasonBox.data()) { + strong->closeBox(); + } + if (const auto strong = state->detailsBox.data()) { + strong->closeBox(); + } + }; + if (reason == Ui::ReportReason::Fake + || reason == Ui::ReportReason::Other) { + state->ids = {}; + state->detailsBox = window->window().show( + Box(Ui::ReportDetailsBox, send)); + return; + } + window->showChooseReportMessages(peer, reason, [=]( + MessageIdsList ids) { + state->ids = std::move(ids); + state->detailsBox = window->window().show( + Box(Ui::ReportDetailsBox, send)); + }); + }; + state->reasonBox = window->window().show(Box( + Ui::ReportReasonBox, + (peer->isBroadcast() + ? Ui::ReportSource::Channel + : peer->isUser() + ? Ui::ReportSource::Bot + : Ui::ReportSource::Group), + chosen)); +} diff --git a/Telegram/SourceFiles/boxes/report_messages_box.h b/Telegram/SourceFiles/boxes/report_messages_box.h new file mode 100644 index 000000000..40f80d1b9 --- /dev/null +++ b/Telegram/SourceFiles/boxes/report_messages_box.h @@ -0,0 +1,24 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +namespace Ui { +class GenericBox; +} // namespace Ui + +namespace Window { +class SessionController; +} // namespace Main + +class PeerData; + +void ShowReportItemsBox( + not_null peer, MessageIdsList ids); +void ShowReportPeerBox( + not_null window, + not_null peer); diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 0dad26284..a99a26eff 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/notifications_manager.h" #include "boxes/about_sponsored_box.h" #include "boxes/delete_messages_box.h" +#include "boxes/report_messages_box.h" #include "boxes/sticker_set_box.h" #include "chat_helpers/message_field.h" #include "chat_helpers/emoji_interactions.h" @@ -3864,13 +3865,13 @@ void HistoryInner::deleteAsGroup(FullMsgId itemId) { } void HistoryInner::reportItem(FullMsgId itemId) { - HistoryView::ShowReportItemsBox(_peer, { 1, itemId }); + ShowReportItemsBox(_peer, { 1, itemId }); } void HistoryInner::reportAsGroup(FullMsgId itemId) { if (const auto item = session().data().message(itemId)) { const auto group = session().data().groups().find(item); - HistoryView::ShowReportItemsBox( + ShowReportItemsBox( _peer, (group ? session().data().itemsToIds(group->items) diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index c471be3ed..1619eda2a 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "menu/menu_send.h" #include "ui/boxes/confirm_box.h" #include "boxes/delete_messages_box.h" +#include "boxes/report_messages_box.h" #include "boxes/sticker_set_box.h" #include "data/data_photo.h" #include "data/data_photo_media.h" @@ -1205,61 +1206,4 @@ void ShowWhoReactedMenu( }, lifetime); } -void ShowReportItemsBox(not_null peer, MessageIdsList ids) { - const auto chosen = [=](Ui::ReportReason reason) { - Ui::show(Box(Ui::ReportDetailsBox, [=](const QString &text) { - Api::SendReport(peer, reason, text, ids); - Ui::hideLayer(); - })); - }; - Ui::show(Box( - Ui::ReportReasonBox, - Ui::ReportSource::Message, - chosen)); -} - -void ShowReportPeerBox( - not_null window, - not_null peer) { - struct State { - QPointer reasonBox; - QPointer detailsBox; - MessageIdsList ids; - }; - const auto state = std::make_shared(); - const auto chosen = [=](Ui::ReportReason reason) { - const auto send = [=](const QString &text) { - window->clearChooseReportMessages(); - Api::SendReport(peer, reason, text, std::move(state->ids)); - if (const auto strong = state->reasonBox.data()) { - strong->closeBox(); - } - if (const auto strong = state->detailsBox.data()) { - strong->closeBox(); - } - }; - if (reason == Ui::ReportReason::Fake - || reason == Ui::ReportReason::Other) { - state->ids = {}; - state->detailsBox = window->window().show( - Box(Ui::ReportDetailsBox, send)); - return; - } - window->showChooseReportMessages(peer, reason, [=]( - MessageIdsList ids) { - state->ids = std::move(ids); - state->detailsBox = window->window().show( - Box(Ui::ReportDetailsBox, send)); - }); - }; - state->reasonBox = window->window().show(Box( - Ui::ReportReasonBox, - (peer->isBroadcast() - ? Ui::ReportSource::Channel - : peer->isUser() - ? Ui::ReportSource::Bot - : Ui::ReportSource::Group), - chosen)); -} - } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index dab8c4ff6..fc15f956e 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -79,9 +79,4 @@ void ShowWhoReactedMenu( not_null controller, rpl::lifetime &lifetime); -void ShowReportItemsBox(not_null peer, MessageIdsList ids); -void ShowReportPeerBox( - not_null window, - not_null peer); - } // namespace HistoryView diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 6358fa013..4cb94cba1 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/add_contact_box.h" #include "boxes/peers/add_bot_to_chat_box.h" #include "boxes/peers/edit_contact_box.h" +#include "boxes/report_messages_box.h" #include "lang/lang_keys.h" #include "menu/menu_mute.h" #include "info/info_controller.h" @@ -619,7 +620,7 @@ void ActionsFiller::addReportAction() { const auto peer = _peer; const auto controller = _controller->parentController(); const auto report = [=] { - HistoryView::ShowReportPeerBox(controller, peer); + ShowReportPeerBox(controller, peer); }; AddActionButton( _wrap, diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 7aa4f66c6..48ff57233 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/choose_filter_box.h" #include "boxes/create_poll_box.h" #include "boxes/pin_messages_box.h" +#include "boxes/report_messages_box.h" #include "boxes/peers/add_bot_to_chat_box.h" #include "boxes/peers/add_participants_box.h" #include "boxes/peers/edit_contact_box.h" @@ -631,7 +632,7 @@ void Filler::addReport() { const auto peer = _peer; const auto navigation = _controller; _addAction(tr::lng_profile_report(tr::now), [=] { - HistoryView::ShowReportPeerBox(navigation, peer); + ShowReportPeerBox(navigation, peer); }, &st::menuIconReport); }