@@ -40,6 +40,7 @@ For license and copyright information please follow this link:
40
40
#include " ui/text/text_utilities.h"
41
41
#include " ui/dynamic_image.h"
42
42
#include " ui/painter.h"
43
+ #include " ui/widgets/fields/input_field.h" // ShouldSubmit.
43
44
#include " ui/widgets/tooltip.h"
44
45
#include " ui/rect.h"
45
46
#include " ui/ui_utility.h"
@@ -1943,6 +1944,40 @@ void VoiceRecordBar::startRecording() {
1943
1944
stop (_inField.current ());
1944
1945
}
1945
1946
}, _recordingLifetime);
1947
+
1948
+ _listenChanges.events_starting_with (
1949
+ rpl::empty_value ()
1950
+ ) | rpl::filter ([=] {
1951
+ return _listen == nullptr ;
1952
+ }) | rpl::start_with_next ([=] {
1953
+ auto keyFilterCallback = [=](not_null<QEvent*> e) {
1954
+ using Result = base::EventFilterResult;
1955
+ if (_send->type () != Ui::SendButton::Type::Record
1956
+ && _send->type () != Ui::SendButton::Type::Round) {
1957
+ return Result::Continue;
1958
+ }
1959
+ switch (e->type ()) {
1960
+ case QEvent::KeyPress: {
1961
+ if (!_warningShown
1962
+ && isRecordingLocked ()
1963
+ && Ui::ShouldSubmit (
1964
+ static_cast <QKeyEvent*>(e.get ()),
1965
+ Core::App ().settings ().sendSubmitWay ())) {
1966
+ stop (true );
1967
+ return Result::Cancel;
1968
+ }
1969
+ return Result::Continue;
1970
+ }
1971
+ default : return Result::Continue;
1972
+ }
1973
+ };
1974
+
1975
+ _keyFilterInRecordingState = base::unique_qptr{
1976
+ base::install_event_filter (
1977
+ QCoreApplication::instance (),
1978
+ std::move (keyFilterCallback)).get ()
1979
+ };
1980
+ }, lifetime ());
1946
1981
}
1947
1982
1948
1983
void VoiceRecordBar::checkTipRequired () {
@@ -2016,6 +2051,7 @@ void VoiceRecordBar::hideFast() {
2016
2051
_lock->hide ();
2017
2052
_level->hide ();
2018
2053
[[maybe_unused]] const auto s = takeTTLState ();
2054
+ _keyFilterInRecordingState = nullptr ;
2019
2055
}
2020
2056
2021
2057
void VoiceRecordBar::stopRecording (StopType type, bool ttlBeforeHide) {
@@ -2353,6 +2389,7 @@ void VoiceRecordBar::orderControls() {
2353
2389
}
2354
2390
2355
2391
void VoiceRecordBar::installListenStateFilter () {
2392
+ _keyFilterInRecordingState = nullptr ;
2356
2393
auto keyFilterCallback = [=](not_null<QEvent*> e) {
2357
2394
using Result = base::EventFilterResult;
2358
2395
if (!(_send->type () == Ui::SendButton::Type::Send
0 commit comments