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;
|
rpl::producer<> stopRequests() const;
|
||||||
::Media::Capture::Result *data() const;
|
::Media::Capture::Result *data() const;
|
||||||
|
|
||||||
|
void playPause();
|
||||||
|
|
||||||
rpl::lifetime &lifetime();
|
rpl::lifetime &lifetime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -556,6 +558,10 @@ bool ListenWrap::isInPlayer() const {
|
||||||
return isInPlayer(::Media::Player::instance()->getState(Type::Voice));
|
return isInPlayer(::Media::Player::instance()->getState(Type::Voice));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListenWrap::playPause() {
|
||||||
|
_playPauseButton->clicked(Qt::NoModifier, Qt::LeftButton);
|
||||||
|
}
|
||||||
|
|
||||||
QRect ListenWrap::computeWaveformRect(const QRect ¢erRect) const {
|
QRect ListenWrap::computeWaveformRect(const QRect ¢erRect) const {
|
||||||
const auto top = computeTopMargin(st::msgWaveformMax);
|
const auto top = computeTopMargin(st::msgWaveformMax);
|
||||||
const auto left = (_playPauseSt.playOuter.width() + centerRect.height())
|
const auto left = (_playPauseSt.playOuter.width() + centerRect.height())
|
||||||
|
|
@ -1482,10 +1488,16 @@ void VoiceRecordBar::installListenStateFilter() {
|
||||||
}
|
}
|
||||||
switch(e->type()) {
|
switch(e->type()) {
|
||||||
case QEvent::KeyPress: {
|
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 isEsc = (key == Qt::Key_Escape);
|
||||||
const auto isEnter = (key == Qt::Key_Enter
|
const auto isEnter = (key == Qt::Key_Enter
|
||||||
|| key == Qt::Key_Return);
|
|| key == Qt::Key_Return);
|
||||||
|
if (isSpace && !keyEvent->isAutoRepeat() && _listen) {
|
||||||
|
_listen->playPause();
|
||||||
|
return Result::Cancel;
|
||||||
|
}
|
||||||
if (isEnter) {
|
if (isEnter) {
|
||||||
requestToSendWithOptions({});
|
requestToSendWithOptions({});
|
||||||
return Result::Cancel;
|
return Result::Cancel;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue