mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Separate settings for calls.
This commit is contained in:
parent
65a80766f4
commit
e5b89b1572
3 changed files with 93 additions and 19 deletions
|
@ -630,6 +630,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_call_accept_calls" = "Accept calls from this device";
|
"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_section_devices" = "Speakers and Camera";
|
||||||
|
"lng_settings_devices_calls" = "Calls and video chats";
|
||||||
|
"lng_settings_devices_calls_same" = "Use the same devices for calls";
|
||||||
|
|
||||||
"lng_settings_language" = "Language";
|
"lng_settings_language" = "Language";
|
||||||
"lng_settings_default_scale" = "Default interface scale";
|
"lng_settings_default_scale" = "Default interface scale";
|
||||||
"lng_settings_connection_type" = "Connection type";
|
"lng_settings_connection_type" = "Connection type";
|
||||||
|
|
|
@ -71,7 +71,7 @@ Calls::Calls(
|
||||||
Calls::~Calls() = default;
|
Calls::~Calls() = default;
|
||||||
|
|
||||||
rpl::producer<QString> Calls::title() {
|
rpl::producer<QString> Calls::title() {
|
||||||
return tr::lng_settings_section_call_settings();
|
return tr::lng_settings_section_devices();
|
||||||
}
|
}
|
||||||
|
|
||||||
Webrtc::VideoTrack *Calls::AddCameraSubsection(
|
Webrtc::VideoTrack *Calls::AddCameraSubsection(
|
||||||
|
@ -229,16 +229,13 @@ void Calls::sectionSaveChanges(FnMut<void()> done) {
|
||||||
|
|
||||||
void Calls::setupContent() {
|
void Calls::setupContent() {
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
const auto settings = &Core::App().settings();
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSubsectionTitle(content, tr::lng_settings_call_section_output());
|
Ui::AddSubsectionTitle(content, tr::lng_settings_call_section_output());
|
||||||
|
|
||||||
//auto playbackIdWithFallback = DeviceIdValueWithFallback(
|
const auto playbackIdWithFallback = [=] {
|
||||||
// Core::App().settings().callPlaybackDeviceIdValue(),
|
return DeviceIdOrDefault(settings->playbackDeviceIdValue());
|
||||||
// Core::App().settings().playbackDeviceIdValue());
|
|
||||||
auto playbackIdWithFallback = [] {
|
|
||||||
return DeviceIdOrDefault(
|
|
||||||
Core::App().settings().playbackDeviceIdValue());
|
|
||||||
};
|
};
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
content,
|
content,
|
||||||
|
@ -249,8 +246,7 @@ void Calls::setupContent() {
|
||||||
_controller->show(ChoosePlaybackDeviceBox(
|
_controller->show(ChoosePlaybackDeviceBox(
|
||||||
playbackIdWithFallback(),
|
playbackIdWithFallback(),
|
||||||
crl::guard(this, [=](const QString &id) {
|
crl::guard(this, [=](const QString &id) {
|
||||||
//Core::App().settings().setCallPlaybackDeviceId(id);
|
settings->setPlaybackDeviceId(id);
|
||||||
Core::App().settings().setPlaybackDeviceId(id);
|
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
})));
|
})));
|
||||||
});
|
});
|
||||||
|
@ -259,12 +255,8 @@ void Calls::setupContent() {
|
||||||
Ui::AddDivider(content);
|
Ui::AddDivider(content);
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSubsectionTitle(content, tr::lng_settings_call_section_input());
|
Ui::AddSubsectionTitle(content, tr::lng_settings_call_section_input());
|
||||||
//auto captureIdWithFallback = DeviceIdValueWithFallback(
|
const auto captureIdWithFallback = [=] {
|
||||||
// Core::App().settings().callCaptureDeviceIdValue(),
|
return DeviceIdOrDefault(settings->captureDeviceIdValue());
|
||||||
// Core::App().settings().captureDeviceIdValue());
|
|
||||||
auto captureIdWithFallback = [] {
|
|
||||||
return DeviceIdOrDefault(
|
|
||||||
Core::App().settings().captureDeviceIdValue());
|
|
||||||
};
|
};
|
||||||
AddButtonWithLabel(
|
AddButtonWithLabel(
|
||||||
content,
|
content,
|
||||||
|
@ -275,8 +267,7 @@ void Calls::setupContent() {
|
||||||
_controller->show(ChooseCaptureDeviceBox(
|
_controller->show(ChooseCaptureDeviceBox(
|
||||||
captureIdWithFallback(),
|
captureIdWithFallback(),
|
||||||
crl::guard(this, [=](const QString &id) {
|
crl::guard(this, [=](const QString &id) {
|
||||||
//Core::App().settings().setCallCaptureDeviceId(id);
|
settings->setCaptureDeviceId(id);
|
||||||
Core::App().settings().setCaptureDeviceId(id);
|
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
if (_micTester) {
|
if (_micTester) {
|
||||||
_micTester->setDeviceId(id);
|
_micTester->setDeviceId(id);
|
||||||
|
@ -302,6 +293,85 @@ void Calls::setupContent() {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddDivider(content);
|
Ui::AddDivider(content);
|
||||||
|
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
Ui::AddSubsectionTitle(content, tr::lng_settings_devices_calls());
|
||||||
|
const auto orDefault = [](const QString &value) {
|
||||||
|
return value.isEmpty() ? kDefaultDeviceId : value;
|
||||||
|
};
|
||||||
|
const auto same = content->add(object_ptr<Ui::SettingsButton>(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_devices_calls_same(),
|
||||||
|
st::settingsButtonNoIcon));
|
||||||
|
same->toggleOn(rpl::combine(
|
||||||
|
settings->callPlaybackDeviceIdValue(),
|
||||||
|
settings->callCaptureDeviceIdValue()
|
||||||
|
) | rpl::map([](const QString &playback, const QString &capture) {
|
||||||
|
return playback.isEmpty() && capture.isEmpty();
|
||||||
|
}));
|
||||||
|
same->toggledValue() | rpl::filter([=](bool toggled) {
|
||||||
|
const auto empty = settings->callPlaybackDeviceId().isEmpty()
|
||||||
|
&& settings->callCaptureDeviceId().isEmpty();
|
||||||
|
return (empty != toggled);
|
||||||
|
}) | rpl::start_with_next([=](bool toggled) {
|
||||||
|
if (toggled) {
|
||||||
|
settings->setCallPlaybackDeviceId(QString());
|
||||||
|
settings->setCallCaptureDeviceId(QString());
|
||||||
|
} else {
|
||||||
|
settings->setCallPlaybackDeviceId(
|
||||||
|
orDefault(settings->playbackDeviceId()));
|
||||||
|
settings->setCallCaptureDeviceId(
|
||||||
|
orDefault(settings->captureDeviceId()));
|
||||||
|
}
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
}, same->lifetime());
|
||||||
|
const auto different = content->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
content,
|
||||||
|
object_ptr<Ui::VerticalLayout>(content)));
|
||||||
|
const auto calls = different->entity();
|
||||||
|
const auto callPlaybackIdWithFallback = [=] {
|
||||||
|
return DeviceIdValueWithFallback(
|
||||||
|
settings->callPlaybackDeviceIdValue(),
|
||||||
|
settings->playbackDeviceIdValue());
|
||||||
|
};
|
||||||
|
AddButtonWithLabel(
|
||||||
|
calls,
|
||||||
|
tr::lng_group_call_speakers(),
|
||||||
|
PlaybackDeviceNameValue(callPlaybackIdWithFallback()),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->addClickHandler([=] {
|
||||||
|
_controller->show(ChoosePlaybackDeviceBox(
|
||||||
|
callPlaybackIdWithFallback(),
|
||||||
|
crl::guard(this, [=](const QString &id) {
|
||||||
|
settings->setCallPlaybackDeviceId(orDefault(id));
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
})));
|
||||||
|
});
|
||||||
|
const auto callCaptureIdWithFallback = [=] {
|
||||||
|
return DeviceIdValueWithFallback(
|
||||||
|
settings->callCaptureDeviceIdValue(),
|
||||||
|
settings->captureDeviceIdValue());
|
||||||
|
};
|
||||||
|
AddButtonWithLabel(
|
||||||
|
calls,
|
||||||
|
tr::lng_group_call_microphone(),
|
||||||
|
CaptureDeviceNameValue(callCaptureIdWithFallback()),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
)->addClickHandler([=] {
|
||||||
|
_controller->show(ChooseCaptureDeviceBox(
|
||||||
|
callCaptureIdWithFallback(),
|
||||||
|
crl::guard(this, [=](const QString &id) {
|
||||||
|
settings->setCallCaptureDeviceId(orDefault(id));
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
//if (_micTester) {
|
||||||
|
// _micTester->setDeviceId(id);
|
||||||
|
//}
|
||||||
|
})));
|
||||||
|
});
|
||||||
|
different->toggleOn(same->toggledValue() | rpl::map(!rpl::mappers::_1));
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
Ui::AddDivider(content);
|
||||||
|
|
||||||
if (!GetVideoInputList().empty()) {
|
if (!GetVideoInputList().empty()) {
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSubsectionTitle(content, tr::lng_settings_call_camera());
|
Ui::AddSubsectionTitle(content, tr::lng_settings_call_camera());
|
||||||
|
|
|
@ -390,9 +390,9 @@ void SetupSections(
|
||||||
Advanced::Id(),
|
Advanced::Id(),
|
||||||
{ &st::menuIconManage });
|
{ &st::menuIconManage });
|
||||||
addSection(
|
addSection(
|
||||||
tr::lng_settings_section_call_settings(),
|
tr::lng_settings_section_devices(),
|
||||||
Calls::Id(),
|
Calls::Id(),
|
||||||
{ &st::menuIconPhone });
|
{ &st::menuIconUnmute });
|
||||||
|
|
||||||
SetupPowerSavingButton(&controller->window(), container);
|
SetupPowerSavingButton(&controller->window(), container);
|
||||||
SetupLanguageButton(&controller->window(), container);
|
SetupLanguageButton(&controller->window(), container);
|
||||||
|
|
Loading…
Add table
Reference in a new issue