1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Add simple push to talk with P

Fixes #734
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-13 19:20:06 +01:00
parent 211005e8de
commit 0c393e717a
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
4 changed files with 51 additions and 0 deletions

View File

@ -123,6 +123,8 @@ public slots:
static void disableGroupCallVol(int groupId);
static void enableGroupCallMic(int groupId);
static void enableGroupCallVol(int groupId);
static bool isGroupCallMicEnabled(int groupId);
static bool isGroupCallVolEnabled(int groupId);
void setPassword(QString& password, PasswordType passtype, uint8_t* salt = nullptr);
void clearPassword(PasswordType passtype);

View File

@ -690,3 +690,13 @@ void Core::enableGroupCallVol(int groupId)
{
groupCalls[groupId].muteVol = false;
}
bool Core::isGroupCallMicEnabled(int groupId)
{
return !groupCalls[groupId].muteMic;
}
bool Core::isGroupCallVolEnabled(int groupId)
{
return !groupCalls[groupId].muteVol;
}

View File

@ -28,6 +28,7 @@
#include <QDragEnterEvent>
#include "src/historykeeper.h"
#include "src/misc/flowlayout.h"
#include <QDebug>
GroupChatForm::GroupChatForm(Group* chatGroup)
: group(chatGroup), inCall{false}
@ -203,3 +204,39 @@ void GroupChatForm::onCallClicked()
inCall = false;
}
}
void GroupChatForm::keyPressEvent(QKeyEvent* ev)
{
qDebug() << "Press:"<<ev->key();
// Push to talk
if (ev->key() == Qt::Key_P && inCall)
{
qDebug() << "Press:"<<ev->key();
Core* core = Core::getInstance();
if (!core->isGroupCallMicEnabled(group->groupId))
{
qDebug() << "Press:"<<ev->key();
core->enableGroupCallMic(group->groupId);
micButton->setObjectName("green");
micButton->style()->polish(micButton);
Style::repolish(micButton);
}
}
}
void GroupChatForm::keyReleaseEvent(QKeyEvent* ev)
{
qDebug() << "Release:"<<ev->key();
// Push to talk
if (ev->key() == Qt::Key_P && inCall)
{
Core* core = Core::getInstance();
if (core->isGroupCallMicEnabled(group->groupId))
{
core->disableGroupCallMic(group->groupId);
micButton->setObjectName("red");
micButton->style()->polish(micButton);
Style::repolish(micButton);
}
}
}

View File

@ -42,6 +42,8 @@ protected:
// drag & drop
void dragEnterEvent(QDragEnterEvent* ev);
void dropEvent(QDropEvent* ev);
void keyPressEvent(QKeyEvent* ev);
void keyReleaseEvent(QKeyEvent* ev);
private:
Group* group;