diff --git a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp index 37baecfa90..bdd887c413 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_voice_record_bar.cpp @@ -207,6 +207,8 @@ public: rpl::producer<> stopRequests() const; ::Media::Capture::Result *data() const; + void playPause(); + rpl::lifetime &lifetime(); private: @@ -556,6 +558,10 @@ bool ListenWrap::isInPlayer() const { return isInPlayer(::Media::Player::instance()->getState(Type::Voice)); } +void ListenWrap::playPause() { + _playPauseButton->clicked(Qt::NoModifier, Qt::LeftButton); +} + QRect ListenWrap::computeWaveformRect(const QRect ¢erRect) const { const auto top = computeTopMargin(st::msgWaveformMax); const auto left = (_playPauseSt.playOuter.width() + centerRect.height()) @@ -1482,10 +1488,16 @@ void VoiceRecordBar::installListenStateFilter() { } switch(e->type()) { case QEvent::KeyPress: { - const auto key = static_cast(e.get())->key(); + const auto keyEvent = static_cast(e.get()); + const auto key = keyEvent->key(); + const auto isSpace = (key == Qt::Key_Space); const auto isEsc = (key == Qt::Key_Escape); const auto isEnter = (key == Qt::Key_Enter || key == Qt::Key_Return); + if (isSpace && !keyEvent->isAutoRepeat() && _listen) { + _listen->playPause(); + return Result::Cancel; + } if (isEnter) { requestToSendWithOptions({}); return Result::Cancel;