diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index db908093d..24606ae3f 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -63,6 +63,9 @@ "ktg_profile_supergroup_id": "Supergroup ID", "ktg_profile_channel_id": "Channel ID", "ktg_settings_show_phone_number": "Show phone in drawer", + "ktg_settings_call_confirm": "Confirm before calling", + "ktg_call_sure": "Are you sure you want to call this user?", + "ktg_call_button": "Call", "ktg_settings_adaptive_bubbles": "Adaptive bubbles", "ktg_settings_filters": "Folders", "ktg_settings_messages": "Messages", diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 2fc5122b7..055a08f10 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -7,7 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "calls/calls_box_controller.h" +#include "kotato/kotato_lang.h" +#include "kotato/kotato_settings.h" #include "lang/lang_keys.h" +#include "ui/boxes/confirm_box.h" #include "ui/effects/ripple_animation.h" #include "ui/widgets/labels.h" #include "ui/widgets/checkbox.h" @@ -388,7 +391,14 @@ void BoxController::rowRightActionClicked(not_null row) { auto user = row->peer()->asUser(); Assert(user != nullptr); - Core::App().calls().startOutgoingCall(user, false); + if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) { + Ui::show(Box(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + })); + } else { + Core::App().calls().startOutgoingCall(user, false); + } } void BoxController::receivedCalls(const QVector &result) { diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index c108edd1b..708e5edc1 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include "kotato/kotato_lang.h" +#include "kotato/kotato_settings.h" #include "history/history.h" #include "history/view/history_view_send_action.h" #include "boxes/add_contact_box.h" @@ -238,7 +240,14 @@ void TopBarWidget::search() { void TopBarWidget::call() { if (const auto peer = _activeChat.key.peer()) { if (const auto user = peer->asUser()) { - Core::App().calls().startOutgoingCall(user, false); + if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) { + Ui::show(Box(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + })); + } else { + Core::App().calls().startOutgoingCall(user, false); + } } } } diff --git a/Telegram/SourceFiles/history/view/media/history_view_call.cpp b/Telegram/SourceFiles/history/view/media/history_view_call.cpp index 96c56df1a..03a1c8832 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_call.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_call.cpp @@ -7,6 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/media/history_view_call.h" +#include "kotato/kotato_settings.h" +#include "kotato/kotato_lang.h" +#include "ui/boxes/confirm_box.h" #include "lang/lang_keys.h" #include "ui/chat/chat_style.h" #include "ui/text/format_values.h" @@ -61,7 +64,14 @@ QSize Call::countOptimalSize() { const auto video = _video; _link = std::make_shared([=] { if (user) { - Core::App().calls().startOutgoingCall(user, video); + if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) { + Ui::show(Box(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, video); + })); + } else { + Core::App().calls().startOutgoingCall(user, video); + } } }); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index ac4f39024..30c871793 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/info_wrap_widget.h" +#include "kotato/kotato_lang.h" +#include "kotato/kotato_settings.h" #include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_values.h" #include "info/media/info_media_widget.h" @@ -483,7 +485,14 @@ void WrapWidget::addProfileCallsButton() { ? st::infoLayerTopBarCall : st::infoTopBarCall)) )->addClickHandler([=] { - Core::App().calls().startOutgoingCall(user, false); + if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) { + Ui::show(Box(ktr("ktg_call_sure"), ktr("ktg_call_button"), [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + })); + } else { + Core::App().calls().startOutgoingCall(user, false); + } }); }, _topBar->lifetime()); diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 1f96547f2..de28699fa 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -349,6 +349,9 @@ const std::map> DefinitionMap { { "replaces", { .type = SettingType::QJsonArraySetting, .limitHandler = ReplacesLimit(), }}, + { "confirm_before_calls", { + .type = SettingType::BoolSetting, + .defaultValue = true, }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index c3201e546..2328f6fca 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -355,6 +355,8 @@ void SetupKotatoOther( ::Kotato::JsonSettings::Write(); })); }); + + SettingsMenuJsonSwitch(ktg_settings_call_confirm, confirm_before_calls); } Kotato::Kotato(