From 50513e0fb47b3ba0a2691a95c1a77fa2fb64f69a Mon Sep 17 00:00:00 2001 From: Wouters Dorian Date: Tue, 28 Oct 2014 13:50:30 +0100 Subject: [PATCH] Made Mute speakers button work --- src/core.h | 1 + src/coreav.cpp | 9 ++++++ src/coreav.h | 1 + src/widget/form/chatform.cpp | 51 +++++++++++++++++++++++++++--- src/widget/form/chatform.h | 3 ++ src/widget/widget.cpp | 1 + ui/volButton/volButton.css | 9 ++++-- ui/volButton/volButtonPressed.png | Bin 630 -> 603 bytes 8 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/core.h b/src/core.h index 5f67ec0c3..301b8525a 100644 --- a/src/core.h +++ b/src/core.h @@ -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); diff --git a/src/coreav.cpp b/src/coreav.cpp index f64e79ddf..00998ed16 100644 --- a/src/coreav.cpp +++ b/src/coreav.cpp @@ -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); diff --git a/src/coreav.h b/src/coreav.h index cdf4cfe2e..bbb2a62f8 100644 --- a/src/coreav.h +++ b/src/coreav.h @@ -24,6 +24,7 @@ public: bool videoEnabled; bool active; bool muteMic; + bool muteVol; ALuint alSource; NetVideoSource videoSource; }; diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 76fc68774..46e5087ce 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -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(); diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index dea18e8b7..f9c824b72 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -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 ftransWidgets; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index b5a54bae4..9de668dfe 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -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); diff --git a/ui/volButton/volButton.css b/ui/volButton/volButton.css index 066d9ae66..3bf4d64a8 100644 --- a/ui/volButton/volButton.css +++ b/ui/volButton/volButton.css @@ -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 { diff --git a/ui/volButton/volButtonPressed.png b/ui/volButton/volButtonPressed.png index fc9b67a27d95abd9ab6fdc3974d520e374896b76..a45dabd6922fab98ba4002b656de4bff634d482a 100644 GIT binary patch delta 578 zcmV-I0=@nA1lt6VB!2{RLP=Bz2nYy#2xN!=000SaNLh0L01FcU01FcV0GgZ_0005~ zNklDXcMW zKG2yhxuwwR)wEDx2({MD7iApP;x`Io!~cQS7aK%Lg7v@${p`A$779>g2V8mlgi8+} zVe;H9T$W4?F0+i}LW>j4CTDKnWp;iZTb9l_KUjoff1g3GH?s0HWvG=!7S{<}- z^6C<%C>%uKRe#m*b8TgXD6W9Wp#-7qA28Q!Qg18*7Ns@y#(AuD-QfkBqTuxMP2waO z$y)=W1+afQ3u`s6JG@|EsNzWNVTi|+DhRR01^Z{L1Uqos^9m3UPky3e!6M?TYyW!J zS_Wy?>1-lcM3HW8l6O0!$f6`l5@yey8x}BzJnbOb6@TCb2h}Q{UavYr$}A^oUF7n! zr<}U6j4ce^tt~{m!=Ly;lv0R{uAo|_`}GU!Yis=6Zes>H-#0c;+SM2QW1jJOcnj*8 z8Tz}s?7V+RZDD~yuSZa=I+hDWYwwplE>sk;_j#S2j~~!+?Deq{rMG<>$Au`xk9M0p zO_A}=tUE=Ax}!`{KG0FPCrY8h0LEYV=%UETc&ss~AQ%OU5L7DP%rA52H{zzm74lv0 Q0000007*qoM6N<$g6EhBod5s; delta 586 zcmV-Q0=50y1oi}wBo78+OGiWi{{a60|De66laVnOe*gz`Nliru-Ut&C3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