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

Made Mute speakers button work

This commit is contained in:
Wouters Dorian 2014-10-28 13:50:30 +01:00
parent f9df6fc8f6
commit 50513e0fb4
8 changed files with 69 additions and 6 deletions

View File

@ -105,6 +105,7 @@ public slots:
void cancelCall(int callId, int friendId);
void micMuteToggle(int callId);
void volMuteToggle(int callId);
void setPassword(QString& password, PasswordType passtype, uint8_t* salt = nullptr);
void clearPassword(PasswordType passtype);

View File

@ -41,6 +41,7 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled
calls[callId].callId = callId;
calls[callId].friendId = friendId;
calls[callId].muteMic = false;
calls[callId].muteVol = false;
// the following three lines are also now redundant from startCall, but are
// necessary there for outbound and here for inbound
calls[callId].codecSettings = av_DefaultSettings;
@ -298,6 +299,14 @@ void Core::micMuteToggle(int callId)
}
}
void Core::volMuteToggle(int callId)
{
if (calls[callId].active) {
calls[callId].muteVol = !calls[callId].muteVol;
alSourcef(calls[callId].alSource, AL_GAIN, calls[callId].muteVol ? 0.f : 1.f);
}
}
void Core::onAvCancel(void* _toxav, int32_t callId, void* core)
{
ToxAv* toxav = static_cast<ToxAv*>(_toxav);

View File

@ -24,6 +24,7 @@ public:
bool videoEnabled;
bool active;
bool muteMic;
bool muteVol;
ALuint alSource;
NetVideoSource videoSource;
};

View File

@ -43,6 +43,7 @@
ChatForm::ChatForm(Friend* chatFriend)
: f(chatFriend)
, audioInputFlag(false)
, audioOutputFlag(false)
, callId(0)
{
nameLabel->setText(f->getName());
@ -68,6 +69,7 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered);
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
connect(Core::getInstance(), &Core::fileSendFailed, this, &ChatForm::onFileSendFailed);
@ -234,6 +236,7 @@ void ChatForm::onAvStart(int FriendId, int CallId, bool video)
return;
audioInputFlag = true;
audioOutputFlag = true;
callId = CallId;
callButton->disconnect();
videoButton->disconnect();
@ -263,8 +266,11 @@ void ChatForm::onAvCancel(int FriendId, int)
return;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -283,8 +289,11 @@ void ChatForm::onAvEnd(int FriendId, int)
return;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -356,8 +365,11 @@ void ChatForm::onAvEnding(int FriendId, int)
return;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -378,8 +390,11 @@ void ChatForm::onAvRequestTimeout(int FriendId, int)
return;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -400,8 +415,11 @@ void ChatForm::onAvPeerTimeout(int FriendId, int)
return;
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -434,28 +452,34 @@ void ChatForm::onAvMediaChange(int FriendId, int CallId, bool video)
void ChatForm::onAnswerCallTriggered()
{
audioInputFlag = true;
audioOutputFlag = true;
emit answerCall(callId);
}
void ChatForm::onHangupCallTriggered()
{
audioInputFlag = false;
audioOutputFlag = false;
emit hangupCall(callId);
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
}
void ChatForm::onCallTriggered()
{
audioInputFlag = true;
callButton->disconnect();
videoButton->disconnect();
emit startCall(f->friendId);
audioInputFlag = true;
audioOutputFlag = true;
callButton->disconnect();
videoButton->disconnect();
emit startCall(f->friendId);
}
void ChatForm::onVideoCallTriggered()
{
audioInputFlag = true;
audioOutputFlag = true;
callButton->disconnect();
videoButton->disconnect();
emit startVideoCall(f->friendId, true);
@ -467,6 +491,7 @@ void ChatForm::onAvCallFailed(int FriendId)
return;
audioInputFlag = false;
audioOutputFlag = false;
callButton->disconnect();
videoButton->disconnect();
connect(callButton, SIGNAL(clicked()), this, SLOT(onCallTriggered()));
@ -476,8 +501,11 @@ void ChatForm::onAvCallFailed(int FriendId)
void ChatForm::onCancelCallTriggered()
{
audioInputFlag = false;
audioOutputFlag = false;
micButton->setObjectName("green");
micButton->style()->polish(micButton);
volButton->setObjectName("green");
volButton->style()->polish(volButton);
callButton->disconnect();
videoButton->disconnect();
callButton->setObjectName("green");
@ -507,6 +535,21 @@ void ChatForm::onMicMuteToggle()
}
}
void ChatForm::onVolMuteToggle()
{
if (audioOutputFlag == true)
{
emit volMuteToggle(callId);
if (volButton->objectName() == "red")
volButton->setObjectName("green");
else
volButton->setObjectName("red");
Style::repolish(volButton);
}
}
void ChatForm::onFileTansBtnClicked(QString widgetName, QString buttonName)
{
uint id = widgetName.toUInt();

View File

@ -41,6 +41,7 @@ signals:
void hangupCall(int callId);
void cancelCall(int callId, int friendId);
void micMuteToggle(int callId);
void volMuteToggle(int callId);
public slots:
void startFileSend(ToxFile file);
@ -57,6 +58,7 @@ public slots:
void onAvMediaChange(int FriendId, int CallId, bool video);
void onAvCallFailed(int FriendId);
void onMicMuteToggle();
void onVolMuteToggle();
void onAvatarChange(int FriendId, const QPixmap& pic);
void onAvatarRemoved(int FriendId);
@ -82,6 +84,7 @@ private:
CroppingLabel *statusMessageLabel;
NetCamView* netcam;
bool audioInputFlag;
bool audioOutputFlag;
int callId;
QHash<uint, FileTransferInstance*> ftransWidgets;

View File

@ -610,6 +610,7 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(newfriend->chatForm, SIGNAL(startVideoCall(int,bool)), core, SLOT(startCall(int,bool)));
connect(newfriend->chatForm, SIGNAL(cancelCall(int,int)), core, SLOT(cancelCall(int,int)));
connect(newfriend->chatForm, SIGNAL(micMuteToggle(int)), core, SLOT(micMuteToggle(int)));
connect(newfriend->chatForm, SIGNAL(volMuteToggle(int)), core, SLOT(volMuteToggle(int)));
connect(core, &Core::fileReceiveRequested, newfriend->chatForm, &ChatForm::onFileRecvRequest);
connect(core, &Core::avInvite, newfriend->chatForm, &ChatForm::onAvInvite);
connect(core, &Core::avStart, newfriend->chatForm, &ChatForm::onAvStart);

View File

@ -13,9 +13,14 @@ QPushButton#green:hover
background-image: url(":/ui/volButton/volButtonHover.png");
}
QPushButton#green:pressed
QPushButton#red
{
background-image: url(":/ui/volButton/volButtonPressed.png");
background-color: transparent;
background-image: url(":/ui/volButton/volButtonPressed.png");
background-repeat: none;
border: none;
width: 25px;
height: 20px;
}
QPushButton:focus {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 603 B