mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Hide push to talk release delay option by default.
This commit is contained in:
parent
bfce832a7a
commit
628a02d99c
3 changed files with 56 additions and 55 deletions
|
@ -746,13 +746,8 @@ auto GroupCall::ensureGlobalShortcutManager()
|
||||||
|
|
||||||
void GroupCall::applyGlobalShortcutChanges() {
|
void GroupCall::applyGlobalShortcutChanges() {
|
||||||
auto &settings = Core::App().settings();
|
auto &settings = Core::App().settings();
|
||||||
if (!settings.groupCallPushToTalk()) {
|
if (!settings.groupCallPushToTalk()
|
||||||
_shortcutManager = nullptr;
|
|| settings.groupCallPushToTalkShortcut().isEmpty()) {
|
||||||
_pushToTalk = nullptr;
|
|
||||||
return;
|
|
||||||
} else if (settings.groupCallPushToTalkShortcut().isEmpty()) {
|
|
||||||
settings.setGroupCallPushToTalk(false);
|
|
||||||
Core::App().saveSettingsDelayed();
|
|
||||||
_shortcutManager = nullptr;
|
_shortcutManager = nullptr;
|
||||||
_pushToTalk = nullptr;
|
_pushToTalk = nullptr;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -200,38 +200,25 @@ void GroupCallSettingsBox(
|
||||||
tr::lng_group_call_push_to_talk(),
|
tr::lng_group_call_push_to_talk(),
|
||||||
st::groupCallSettingsButton
|
st::groupCallSettingsButton
|
||||||
)->toggleOn(rpl::single(settings.groupCallPushToTalk()));
|
)->toggleOn(rpl::single(settings.groupCallPushToTalk()));
|
||||||
const auto recordingWrap = layout->add(
|
const auto pushToTalkWrap = layout->add(
|
||||||
object_ptr<Ui::SlideWrap<Button>>(
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
layout,
|
layout,
|
||||||
object_ptr<Button>(
|
object_ptr<Ui::VerticalLayout>(layout)));
|
||||||
layout,
|
const auto pushToTalkInner = pushToTalkWrap->entity();
|
||||||
state->recordText.value(),
|
const auto recording = pushToTalkInner->add(
|
||||||
st::groupCallSettingsButton)));
|
object_ptr<Button>(
|
||||||
const auto recording = recordingWrap->entity();
|
layout,
|
||||||
|
state->recordText.value(),
|
||||||
|
st::groupCallSettingsButton));
|
||||||
CreateRightLabel(
|
CreateRightLabel(
|
||||||
recording,
|
recording,
|
||||||
state->shortcutText.value(),
|
state->shortcutText.value(),
|
||||||
st::groupCallSettingsButton,
|
st::groupCallSettingsButton,
|
||||||
state->recordText.value());
|
state->recordText.value());
|
||||||
const auto startRecording = [=] {
|
|
||||||
state->recording = true;
|
const auto applyAndSave = [=] {
|
||||||
state->recordText = tr::lng_group_call_ptt_recording();
|
call->applyGlobalShortcutChanges();
|
||||||
auto progress = crl::guard(box, [=](GlobalShortcut shortcut) {
|
Core::App().saveSettingsDelayed();
|
||||||
state->shortcutText = shortcut->toDisplayString();
|
|
||||||
});
|
|
||||||
auto done = crl::guard(box, [=](GlobalShortcut shortcut) {
|
|
||||||
state->recording = false;
|
|
||||||
state->shortcut = shortcut;
|
|
||||||
state->shortcutText = shortcut
|
|
||||||
? shortcut->toDisplayString()
|
|
||||||
: QString();
|
|
||||||
state->recordText = tr::lng_group_call_ptt_shortcut();
|
|
||||||
Core::App().settings().setGroupCallPushToTalkShortcut(shortcut
|
|
||||||
? shortcut->serialize()
|
|
||||||
: QByteArray());
|
|
||||||
Core::App().saveSettingsDelayed();
|
|
||||||
});
|
|
||||||
manager->startRecording(std::move(progress), std::move(done));
|
|
||||||
};
|
};
|
||||||
const auto stopRecording = [=] {
|
const auto stopRecording = [=] {
|
||||||
state->recording = false;
|
state->recording = false;
|
||||||
|
@ -239,8 +226,27 @@ void GroupCallSettingsBox(
|
||||||
state->shortcutText = state->shortcut
|
state->shortcutText = state->shortcut
|
||||||
? state->shortcut->toDisplayString()
|
? state->shortcut->toDisplayString()
|
||||||
: QString();
|
: QString();
|
||||||
|
recording->setColorOverride(std::nullopt);
|
||||||
manager->stopRecording();
|
manager->stopRecording();
|
||||||
};
|
};
|
||||||
|
const auto startRecording = [=] {
|
||||||
|
state->recording = true;
|
||||||
|
state->recordText = tr::lng_group_call_ptt_recording();
|
||||||
|
recording->setColorOverride(
|
||||||
|
st::groupCallSettingsAttentionButton.textFg->c);
|
||||||
|
auto progress = crl::guard(box, [=](GlobalShortcut shortcut) {
|
||||||
|
state->shortcutText = shortcut->toDisplayString();
|
||||||
|
});
|
||||||
|
auto done = crl::guard(box, [=](GlobalShortcut shortcut) {
|
||||||
|
state->shortcut = shortcut;
|
||||||
|
Core::App().settings().setGroupCallPushToTalkShortcut(shortcut
|
||||||
|
? shortcut->serialize()
|
||||||
|
: QByteArray());
|
||||||
|
applyAndSave();
|
||||||
|
stopRecording();
|
||||||
|
});
|
||||||
|
manager->startRecording(std::move(progress), std::move(done));
|
||||||
|
};
|
||||||
recording->addClickHandler([=] {
|
recording->addClickHandler([=] {
|
||||||
if (state->recording) {
|
if (state->recording) {
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
@ -248,21 +254,11 @@ void GroupCallSettingsBox(
|
||||||
startRecording();
|
startRecording();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recordingWrap->toggle(
|
|
||||||
settings.groupCallPushToTalk(),
|
|
||||||
anim::type::instant);
|
|
||||||
pushToTalk->toggledChanges(
|
|
||||||
) | rpl::start_with_next([=](bool toggled) {
|
|
||||||
if (!toggled) {
|
|
||||||
stopRecording();
|
|
||||||
}
|
|
||||||
Core::App().settings().setGroupCallPushToTalk(toggled);
|
|
||||||
Core::App().saveSettingsDelayed();
|
|
||||||
recordingWrap->toggle(toggled, anim::type::normal);
|
|
||||||
}, pushToTalk->lifetime());
|
|
||||||
|
|
||||||
const auto label = layout->add(
|
const auto label = pushToTalkInner->add(
|
||||||
object_ptr<Ui::LabelSimple>(layout, st::groupCallDelayLabel),
|
object_ptr<Ui::LabelSimple>(
|
||||||
|
pushToTalkInner,
|
||||||
|
st::groupCallDelayLabel),
|
||||||
st::groupCallDelayLabelMargin);
|
st::groupCallDelayLabelMargin);
|
||||||
const auto value = std::clamp(
|
const auto value = std::clamp(
|
||||||
state->delay,
|
state->delay,
|
||||||
|
@ -275,11 +271,13 @@ void GroupCallSettingsBox(
|
||||||
lt_delay,
|
lt_delay,
|
||||||
FormatDelay(delay)));
|
FormatDelay(delay)));
|
||||||
Core::App().settings().setGroupCallPushToTalkDelay(delay);
|
Core::App().settings().setGroupCallPushToTalkDelay(delay);
|
||||||
Core::App().saveSettingsDelayed();
|
applyAndSave();
|
||||||
};
|
};
|
||||||
callback(value);
|
callback(value);
|
||||||
const auto slider = layout->add(
|
const auto slider = pushToTalkInner->add(
|
||||||
object_ptr<Ui::MediaSlider>(layout, st::groupCallDelaySlider),
|
object_ptr<Ui::MediaSlider>(
|
||||||
|
pushToTalkInner,
|
||||||
|
st::groupCallDelaySlider),
|
||||||
st::groupCallDelayMargin);
|
st::groupCallDelayMargin);
|
||||||
slider->resize(st::groupCallDelaySlider.seekSize);
|
slider->resize(st::groupCallDelaySlider.seekSize);
|
||||||
slider->setPseudoDiscrete(
|
slider->setPseudoDiscrete(
|
||||||
|
@ -288,10 +286,18 @@ void GroupCallSettingsBox(
|
||||||
value,
|
value,
|
||||||
callback);
|
callback);
|
||||||
|
|
||||||
box->boxClosing(
|
pushToTalkWrap->toggle(
|
||||||
) | rpl::start_with_next([=] {
|
settings.groupCallPushToTalk(),
|
||||||
call->applyGlobalShortcutChanges();
|
anim::type::instant);
|
||||||
}, box->lifetime());
|
pushToTalk->toggledChanges(
|
||||||
|
) | rpl::start_with_next([=](bool toggled) {
|
||||||
|
if (!toggled) {
|
||||||
|
stopRecording();
|
||||||
|
}
|
||||||
|
Core::App().settings().setGroupCallPushToTalk(toggled);
|
||||||
|
applyAndSave();
|
||||||
|
pushToTalkWrap->toggle(toggled, anim::type::normal);
|
||||||
|
}, pushToTalk->lifetime());
|
||||||
|
|
||||||
auto boxKeyFilter = [=](not_null<QEvent*> e) {
|
auto boxKeyFilter = [=](not_null<QEvent*> e) {
|
||||||
return (e->type() == QEvent::KeyPress && state->recording)
|
return (e->type() == QEvent::KeyPress && state->recording)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 79b9ed178aa1fa9779afb51470f571c4153866fc
|
Subproject commit aadebb110e2fe3438cf99b64427b604564ea4ade
|
Loading…
Add table
Reference in a new issue