mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 06:07:45 +00:00
Confirm before calling
This commit is contained in:
parent
86fc9d37f2
commit
72a6fd4dd8
@ -14,5 +14,6 @@
|
||||
// "show_chat_id": false,
|
||||
// "net_speed_boost": null,
|
||||
// "show_phone_in_drawer": true,
|
||||
// "scales": []
|
||||
// "scales": [],
|
||||
// "confirm_before_calls": false
|
||||
}
|
||||
|
@ -2354,6 +2354,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"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_user_status_unaccessible" = "account inaccessible";
|
||||
|
||||
"ktg_chat_status_subscribers#one" = "{count} subscriber";
|
||||
|
@ -81,5 +81,8 @@
|
||||
"ktg_profile_supergroup_id": "ID супергруппы",
|
||||
"ktg_profile_channel_id": "ID канала",
|
||||
"ktg_settings_show_phone_number": "Показывать телефон в боковом меню",
|
||||
"ktg_settings_call_confirm": "Подтверждение перед звонком",
|
||||
"ktg_call_sure": "Вы уверены, что хотите позвонить этому пользователю?",
|
||||
"ktg_call_button": "Позвонить",
|
||||
"ktg_settings_adaptive_bubbles": "Адаптивные пузырьки сообщений"
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "calls/calls_box_controller.h"
|
||||
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "styles/style_calls.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "lang/lang_keys.h"
|
||||
@ -314,7 +315,14 @@ void BoxController::rowActionClicked(not_null<PeerListRow*> row) {
|
||||
auto user = row->peer()->asUser();
|
||||
Assert(user != nullptr);
|
||||
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
if (cConfirmBeforeCall()) {
|
||||
Ui::show(Box<ConfirmBox>(tr::ktg_call_sure(tr::now), tr::ktg_call_button(tr::now), [=] {
|
||||
Ui::hideLayer();
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}));
|
||||
} else {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}
|
||||
}
|
||||
|
||||
void BoxController::receivedCalls(const QVector<MTPMessage> &result) {
|
||||
|
@ -258,6 +258,11 @@ bool Manager::readCustomFile() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const auto settingsCallConfirmIt = settings.constFind(qsl("confirm_before_calls"));
|
||||
if (settingsCallConfirmIt != settings.constEnd() && (*settingsCallConfirmIt).isBool()) {
|
||||
cSetConfirmBeforeCall((*settingsCallConfirmIt).toBool());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -295,6 +300,7 @@ void Manager::writeDefaultFile() {
|
||||
settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer());
|
||||
settings.insert(qsl("chat_list_lines"), DialogListLines());
|
||||
settings.insert(qsl("disable_up_edit"), cDisableUpEdit());
|
||||
settings.insert(qsl("confirm_before_calls"), cConfirmBeforeCall());
|
||||
|
||||
auto settingsScales = QJsonArray();
|
||||
settings.insert(qsl("scales"), settingsScales);
|
||||
@ -353,6 +359,7 @@ void Manager::writeCurrentSettings() {
|
||||
settings.insert(qsl("show_phone_in_drawer"), cShowPhoneInDrawer());
|
||||
settings.insert(qsl("chat_list_lines"), DialogListLines());
|
||||
settings.insert(qsl("disable_up_edit"), cDisableUpEdit());
|
||||
settings.insert(qsl("confirm_before_calls"), cConfirmBeforeCall());
|
||||
|
||||
auto settingsScales = QJsonArray();
|
||||
auto currentScales = cInterfaceScales();
|
||||
|
@ -189,7 +189,14 @@ void TopBarWidget::onSearch() {
|
||||
void TopBarWidget::onCall() {
|
||||
if (const auto peer = _activeChat.peer()) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
if (cConfirmBeforeCall()) {
|
||||
Ui::show(Box<ConfirmBox>(tr::ktg_call_sure(tr::now), tr::ktg_call_button(tr::now), [=] {
|
||||
Ui::hideLayer();
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}));
|
||||
} else {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "history/view/media/history_view_call.h"
|
||||
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "layout.h"
|
||||
#include "history/history.h"
|
||||
@ -50,7 +51,14 @@ QSize Call::countOptimalSize() {
|
||||
const auto user = _parent->data()->history()->peer->asUser();
|
||||
_link = std::make_shared<LambdaClickHandler>([=] {
|
||||
if (user) {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
if (cConfirmBeforeCall()) {
|
||||
Ui::show(Box<ConfirmBox>(tr::ktg_call_sure(tr::now), tr::ktg_call_button(tr::now), [=] {
|
||||
Ui::hideLayer();
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}));
|
||||
} else {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -497,7 +497,14 @@ void WrapWidget::addProfileCallsButton() {
|
||||
? st::infoLayerTopBarCall
|
||||
: st::infoTopBarCall))
|
||||
)->addClickHandler([=] {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
if (cConfirmBeforeCall()) {
|
||||
Ui::show(Box<ConfirmBox>(tr::ktg_call_sure(tr::now), tr::ktg_call_button(tr::now), [=] {
|
||||
Ui::hideLayer();
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}));
|
||||
} else {
|
||||
user->session().calls().startOutgoingCall(user);
|
||||
}
|
||||
});
|
||||
}, _topBar->lifetime());
|
||||
|
||||
|
@ -295,3 +295,5 @@ bool AddCustomReplace(QString from, QString to) {
|
||||
gCustomReplaces.insert(from, to);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool gConfirmBeforeCall = false;
|
||||
|
@ -236,3 +236,4 @@ DeclareSetting(bool, DisableUpEdit);
|
||||
using CustomReplacementsMap = QMap<QString, QString>;
|
||||
DeclareRefSetting(CustomReplacementsMap, CustomReplaces);
|
||||
bool AddCustomReplace(QString from, QString to);
|
||||
DeclareSetting(bool, ConfirmBeforeCall);
|
||||
|
@ -188,6 +188,20 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
||||
KotatoSettings::Write();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ktg_settings_call_confirm(),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
rpl::single(cConfirmBeforeCall())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([](bool enabled) {
|
||||
return (enabled != cConfirmBeforeCall());
|
||||
}) | rpl::start_with_next([](bool enabled) {
|
||||
cSetConfirmBeforeCall(enabled);
|
||||
KotatoSettings::Write();
|
||||
}, container->lifetime());
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user