Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(audio):OutgoingCallSound
Browse files Browse the repository at this point in the history
Adds outgoing call sound when call is started
  • Loading branch information
AliceGrey committed Jun 14, 2017
1 parent 23ed1a3 commit a06ad70
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 1 deletion.
Binary file added audio/ToxOutgoingCall.pcm
Binary file not shown.
1 change: 1 addition & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<qresource prefix="/">
<file>audio/notification.pcm</file>
<file>audio/ToxIncomingCall.pcm</file>
<file>audio/ToxOutgoingCall.pcm</file>
<file>img/add.svg</file>
<file>img/avatar_mask.svg</file>
<file>img/contact.svg</file>
Expand Down
1 change: 1 addition & 0 deletions src/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* @value NewMessage Returns the new message notification sound.
* @value Test Returns the test sound.
* @value IncomingCall Returns the incoming call sound.
* @value OutgoingCall Returns the outgoing call sound.
*
* @fn QString Audio::getSound(Sound s)
* @brief Function to get the path of the requested sound.
Expand Down
5 changes: 4 additions & 1 deletion src/audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class Audio : public QObject
{
NewMessage,
Test,
IncomingCall
IncomingCall,
OutgoingCall
};

inline static QString getSound(Sound s)
Expand All @@ -51,6 +52,8 @@ class Audio : public QObject
return QStringLiteral(":/audio/notification.pcm");
case Sound::IncomingCall:
return QStringLiteral(":/audio/ToxIncomingCall.pcm");
case Sound::OutgoingCall:
return QStringLiteral(":/audio/ToxOutgoingCall.pcm");
}
assert(false);
return QString();
Expand Down
2 changes: 2 additions & 0 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ void ChatForm::onAvStart(uint32_t friendId, bool video)
hideNetcam();
}

Audio::getInstance().stopLoop();
updateCallButtons();
startCounter();
}
Expand Down Expand Up @@ -399,6 +400,7 @@ void ChatForm::showOutgoingCall(bool video)
btn->setToolTip(video ? tr("Cancel video call") : tr("Cancel audio call"));
addSystemInfoMessage(tr("Calling %1").arg(f->getDisplayedName()), ChatMessage::INFO,
QDateTime::currentDateTime());
emit outgoingNotification();
Widget::getInstance()->updateFriendActivity(f);
}

Expand Down
1 change: 1 addition & 0 deletions src/widget/form/chatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ChatForm : public GenericChatForm
signals:
void aliasChanged(const QString& alias);
void incomingNotification(uint32_t friendId);
void outgoingNotification();
void rejectCall(uint32_t friendId);
void acceptCall(uint32_t friendId);

Expand Down
8 changes: 8 additions & 0 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,13 @@ void Widget::incomingNotification(uint32_t friendId)
audio.playMono16Sound(Audio::getSound(Audio::Sound::IncomingCall));
}

void Widget::outgoingNotification()
{
Audio& audio = Audio::getInstance();
audio.startLoop();
audio.playMono16Sound(Audio::getSound(Audio::Sound::OutgoingCall));
}

void Widget::onRejectCall(uint32_t friendId)
{
Audio::getInstance().stopLoop();
Expand Down Expand Up @@ -977,6 +984,7 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk)
connect(newfriend, &Friend::nameChanged, this, &Widget::onFriendAliasChanged);

connect(friendForm, &ChatForm::incomingNotification, this, &Widget::incomingNotification);
connect(friendForm, &ChatForm::outgoingNotification, this, &Widget::outgoingNotification);
connect(friendForm, &ChatForm::rejectCall, this, &Widget::onRejectCall);
connect(friendForm, &ChatForm::acceptCall, this, &Widget::onAcceptCall);

Expand Down
1 change: 1 addition & 0 deletions src/widget/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ private slots:
void groupInvitesUpdate();
void groupInvitesClear();
void onDialogShown(GenericChatroomWidget* widget);
void outgoingNotification();
void incomingNotification(uint32_t friendId);
void onRejectCall(uint32_t friendId);
void onAcceptCall(uint32_t friendId);
Expand Down

0 comments on commit a06ad70

Please sign in to comment.