mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow disabling calls on tdesktop device.
This commit is contained in:
parent
ce5c19dfe9
commit
7da224d725
6 changed files with 52 additions and 13 deletions
|
@ -328,6 +328,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_events_title" = "Events";
|
"lng_settings_events_title" = "Events";
|
||||||
"lng_settings_events_joined" = "Contact joined Telegram";
|
"lng_settings_events_joined" = "Contact joined Telegram";
|
||||||
"lng_settings_events_pinned" = "Pinned messages";
|
"lng_settings_events_pinned" = "Pinned messages";
|
||||||
|
"lng_settings_notifications_calls_title" = "Calls";
|
||||||
|
|
||||||
"lng_notification_preview" = "You have a new message";
|
"lng_notification_preview" = "You have a new message";
|
||||||
"lng_notification_reply" = "Reply";
|
"lng_notification_reply" = "Reply";
|
||||||
|
@ -395,6 +396,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_call_stop_mic_test" = "Stop test";
|
"lng_settings_call_stop_mic_test" = "Stop test";
|
||||||
"lng_settings_call_section_other" = "Other settings";
|
"lng_settings_call_section_other" = "Other settings";
|
||||||
"lng_settings_call_open_system_prefs" = "Open system sound preferences";
|
"lng_settings_call_open_system_prefs" = "Open system sound preferences";
|
||||||
|
"lng_settings_call_accept_calls" = "Accept calls from this device";
|
||||||
"lng_settings_call_device_default" = "Same as the System";
|
"lng_settings_call_device_default" = "Same as the System";
|
||||||
"lng_settings_call_audio_ducking" = "Mute other sounds during calls";
|
"lng_settings_call_audio_ducking" = "Mute other sounds during calls";
|
||||||
|
|
||||||
|
|
|
@ -377,6 +377,8 @@ void Instance::handleCallUpdate(
|
||||||
} else if (phoneCall.vdate().v + (config.callRingTimeoutMs / 1000)
|
} else if (phoneCall.vdate().v + (config.callRingTimeoutMs / 1000)
|
||||||
< base::unixtime::now()) {
|
< base::unixtime::now()) {
|
||||||
LOG(("Ignoring too old call."));
|
LOG(("Ignoring too old call."));
|
||||||
|
} else if (Core::App().settings().disableCalls()) {
|
||||||
|
LOG(("Ignoring call because of 'accept calls' settings."));
|
||||||
} else {
|
} else {
|
||||||
createCall(user, Call::Type::Incoming, phoneCall.is_video());
|
createCall(user, Call::Type::Incoming, phoneCall.is_video());
|
||||||
_currentCall->handleUpdate(call);
|
_currentCall->handleUpdate(call);
|
||||||
|
|
|
@ -19,8 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
: _callAudioBackend(Webrtc::Backend::OpenAL)
|
: _sendSubmitWay(Ui::InputSubmitSettings::Enter)
|
||||||
, _sendSubmitWay(Ui::InputSubmitSettings::Enter)
|
|
||||||
, _floatPlayerColumn(Window::Column::Second)
|
, _floatPlayerColumn(Window::Column::Second)
|
||||||
, _floatPlayerCorner(RectPart::TopRight)
|
, _floatPlayerCorner(RectPart::TopRight)
|
||||||
, _dialogsWidthRatio(DefaultDialogsWidthRatio()) {
|
, _dialogsWidthRatio(DefaultDialogsWidthRatio()) {
|
||||||
|
@ -115,7 +114,8 @@ QByteArray Settings::serialize() const {
|
||||||
<< qint32(_groupCallPushToTalk ? 1 : 0)
|
<< qint32(_groupCallPushToTalk ? 1 : 0)
|
||||||
<< _groupCallPushToTalkShortcut
|
<< _groupCallPushToTalkShortcut
|
||||||
<< qint64(_groupCallPushToTalkDelay)
|
<< qint64(_groupCallPushToTalkDelay)
|
||||||
<< qint32(_callAudioBackend);
|
<< qint32(0) // Call audio backend
|
||||||
|
<< qint32(_disableCalls ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 groupCallPushToTalk = _groupCallPushToTalk ? 1 : 0;
|
qint32 groupCallPushToTalk = _groupCallPushToTalk ? 1 : 0;
|
||||||
QByteArray groupCallPushToTalkShortcut = _groupCallPushToTalkShortcut;
|
QByteArray groupCallPushToTalkShortcut = _groupCallPushToTalkShortcut;
|
||||||
qint64 groupCallPushToTalkDelay = _groupCallPushToTalkDelay;
|
qint64 groupCallPushToTalkDelay = _groupCallPushToTalkDelay;
|
||||||
qint32 callAudioBackend = static_cast<qint32>(_callAudioBackend);
|
qint32 callAudioBackend = 0;
|
||||||
|
qint32 disableCalls = _disableCalls ? 1 : 0;
|
||||||
|
|
||||||
stream >> themesAccentColors;
|
stream >> themesAccentColors;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -285,6 +286,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> callAudioBackend;
|
stream >> callAudioBackend;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> disableCalls;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -379,12 +383,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
_groupCallPushToTalk = (groupCallPushToTalk == 1);
|
_groupCallPushToTalk = (groupCallPushToTalk == 1);
|
||||||
_groupCallPushToTalkShortcut = groupCallPushToTalkShortcut;
|
_groupCallPushToTalkShortcut = groupCallPushToTalkShortcut;
|
||||||
_groupCallPushToTalkDelay = groupCallPushToTalkDelay;
|
_groupCallPushToTalkDelay = groupCallPushToTalkDelay;
|
||||||
auto uncheckedBackend = static_cast<Webrtc::Backend>(callAudioBackend);
|
_disableCalls = (disableCalls == 1);
|
||||||
switch (uncheckedBackend) {
|
|
||||||
case Webrtc::Backend::OpenAL:
|
|
||||||
case Webrtc::Backend::ADM:
|
|
||||||
case Webrtc::Backend::ADM2: _callAudioBackend = uncheckedBackend; break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::chatWide() const {
|
bool Settings::chatWide() const {
|
||||||
|
@ -495,6 +494,8 @@ void Settings::resetOnLastLogout() {
|
||||||
//_callInputVolume = 100;
|
//_callInputVolume = 100;
|
||||||
//_callAudioDuckingEnabled = true;
|
//_callAudioDuckingEnabled = true;
|
||||||
|
|
||||||
|
_disableCalls = false;
|
||||||
|
|
||||||
_groupCallPushToTalk = false;
|
_groupCallPushToTalk = false;
|
||||||
_groupCallPushToTalkShortcut = QByteArray();
|
_groupCallPushToTalkShortcut = QByteArray();
|
||||||
_groupCallPushToTalkDelay = 20;
|
_groupCallPushToTalkDelay = 20;
|
||||||
|
|
|
@ -222,8 +222,11 @@ public:
|
||||||
_callAudioDuckingEnabled = value;
|
_callAudioDuckingEnabled = value;
|
||||||
}
|
}
|
||||||
[[nodiscard]] Webrtc::Backend callAudioBackend() const;
|
[[nodiscard]] Webrtc::Backend callAudioBackend() const;
|
||||||
void setCallAudioBackend(Webrtc::Backend backend) {
|
void setDisableCalls(bool value) {
|
||||||
_callAudioBackend = backend;
|
_disableCalls = value;
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool disableCalls() const {
|
||||||
|
return _disableCalls;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool groupCallPushToTalk() const {
|
[[nodiscard]] bool groupCallPushToTalk() const {
|
||||||
return _groupCallPushToTalk;
|
return _groupCallPushToTalk;
|
||||||
|
@ -539,7 +542,7 @@ private:
|
||||||
int _callOutputVolume = 100;
|
int _callOutputVolume = 100;
|
||||||
int _callInputVolume = 100;
|
int _callInputVolume = 100;
|
||||||
bool _callAudioDuckingEnabled = true;
|
bool _callAudioDuckingEnabled = true;
|
||||||
Webrtc::Backend _callAudioBackend = Webrtc::Backend();
|
bool _disableCalls = false;
|
||||||
bool _groupCallPushToTalk = false;
|
bool _groupCallPushToTalk = false;
|
||||||
QByteArray _groupCallPushToTalkShortcut;
|
QByteArray _groupCallPushToTalkShortcut;
|
||||||
crl::time _groupCallPushToTalkDelay = 20;
|
crl::time _groupCallPushToTalkDelay = 20;
|
||||||
|
|
|
@ -275,6 +275,19 @@ void Calls::setupContent() {
|
||||||
//)->addClickHandler([] {
|
//)->addClickHandler([] {
|
||||||
// Ui::show(ChooseAudioBackendBox());
|
// Ui::show(ChooseAudioBackendBox());
|
||||||
//});
|
//});
|
||||||
|
AddButton(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_call_accept_calls(),
|
||||||
|
st::settingsButton
|
||||||
|
)->toggleOn(rpl::single(
|
||||||
|
!settings.disableCalls()
|
||||||
|
))->toggledChanges(
|
||||||
|
) | rpl::filter([&settings](bool value) {
|
||||||
|
return (settings.disableCalls() == value);
|
||||||
|
}) | rpl::start_with_next([=](bool value) {
|
||||||
|
Core::App().settings().setDisableCalls(!value);
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
}, content->lifetime());
|
||||||
AddButton(
|
AddButton(
|
||||||
content,
|
content,
|
||||||
tr::lng_settings_call_open_system_prefs(),
|
tr::lng_settings_call_open_system_prefs(),
|
||||||
|
@ -286,6 +299,7 @@ void Calls::setupContent() {
|
||||||
Ui::show(Box<InformBox>(tr::lng_linux_no_audio_prefs(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_linux_no_audio_prefs(tr::now)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AddSkip(content);
|
AddSkip(content);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
|
|
|
@ -676,6 +676,23 @@ void SetupNotificationsContent(
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
}, joined->lifetime());
|
}, joined->lifetime());
|
||||||
|
|
||||||
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
AddDivider(container);
|
||||||
|
AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
AddSubsectionTitle(
|
||||||
|
container,
|
||||||
|
tr::lng_settings_notifications_calls_title());
|
||||||
|
addCheckbox(
|
||||||
|
tr::lng_settings_call_accept_calls(tr::now),
|
||||||
|
!settings.disableCalls()
|
||||||
|
)->checkedChanges(
|
||||||
|
) | rpl::filter([&settings](bool value) {
|
||||||
|
return (settings.disableCalls() == value);
|
||||||
|
}) | rpl::start_with_next([=](bool value) {
|
||||||
|
Core::App().settings().setDisableCalls(!value);
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
const auto nativeText = [&] {
|
const auto nativeText = [&] {
|
||||||
if (!Platform::Notifications::Supported()
|
if (!Platform::Notifications::Supported()
|
||||||
|| Platform::Notifications::Enforced()) {
|
|| Platform::Notifications::Enforced()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue