diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index f68b897f8..51f11e960 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -61,6 +61,9 @@ "ktg_profile_group_id": "Group ID", "ktg_profile_supergroup_id": "Supergroup ID", "ktg_profile_channel_id": "Channel ID", + "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 66a4e01f5..86b8546b9 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" @@ -593,7 +596,18 @@ 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(Ui::MakeConfirmBox({ + .text = ktr("ktg_call_sure"), + .confirmed = [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + }, + .confirmText = ktr("ktg_call_button"), + })); + } 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 fa0d6ed7f..06027648c 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/history_view_top_bar_widget.h" +#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" @@ -253,7 +255,18 @@ void TopBarWidget::refreshLang() { 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(Ui::MakeConfirmBox({ + .text = ktr("ktg_call_sure"), + .confirmed = [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + }, + .confirmText = ktr("ktg_call_button"), + })); + } 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 954ce579e..d387a0d0c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_call.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_call.cpp @@ -7,6 +7,10 @@ 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 "boxes/abstract_box.h" // Ui::hideLayer(). +#include "ui/boxes/confirm_box.h" #include "lang/lang_keys.h" #include "ui/chat/chat_style.h" #include "ui/text/format_values.h" @@ -64,7 +68,18 @@ 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(Ui::MakeConfirmBox({ + .text = ktr("ktg_call_sure"), + .confirmed = [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + }, + .confirmText = ktr("ktg_call_button"), + })); + } 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 34c81d118..6e257c749 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 "kotato/kotato_settings_menu.h" #include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_values.h" @@ -415,7 +417,18 @@ void WrapWidget::addProfileCallsButton() { ? st::infoLayerTopBarCall : st::infoTopBarCall)) )->addClickHandler([=] { - Core::App().calls().startOutgoingCall(user, false); + if (::Kotato::JsonSettings::GetBool("confirm_before_calls")) { + Ui::show(Ui::MakeConfirmBox({ + .text = ktr("ktg_call_sure"), + .confirmed = [=] { + Ui::hideLayer(); + Core::App().calls().startOutgoingCall(user, false); + }, + .confirmText = ktr("ktg_call_button"), + })); + } 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 c1617f753..9a0bd8dce 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -322,6 +322,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 96c3a9bd6..7ea98605c 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -328,6 +328,8 @@ void SetupKotatoOther( ::Kotato::JsonSettings::Write(); })); }); + + SettingsMenuJsonSwitch(ktg_settings_call_confirm, confirm_before_calls); } Kotato::Kotato(