mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-24 14:33:02 +02:00
Added ability to play/pause recorded voice data with Space key.
This commit is contained in:
parent
d2defabd4b
commit
7dac42b523
1 changed files with 13 additions and 1 deletions
|
@ -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<QKeyEvent*>(e.get())->key();
|
||||
const auto keyEvent = static_cast<QKeyEvent*>(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;
|
||||
|
|
Loading…
Add table
Reference in a new issue