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

refactor(chatform): Remove Audio::play usage from ChatForm

This commit is contained in:
Diadlo 2017-05-04 21:17:54 +03:00
parent 28c2298ad9
commit 695abadd7c
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 15 additions and 7 deletions

View File

@ -353,10 +353,7 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
auto msg = ChatMessage::createChatInfoMessage(tr("%1 calling").arg(displayedName),
ChatMessage::INFO, QDateTime::currentDateTime());
insertChatMessage(msg);
Widget::getInstance()->newFriendMessageAlert(friendId, false);
Audio& audio = Audio::getInstance();
audio.startLoop();
audio.playMono16Sound(Audio::getSound(Audio::Sound::IncomingCall));
emit incomingNotification(friendId);
}
}

View File

@ -57,6 +57,7 @@ public:
signals:
void aliasChanged(const QString& alias);
void incomingNotification(uint32_t friendId);
public slots:
void startFileSend(ToxFile file);

View File

@ -919,6 +919,15 @@ void Widget::reloadHistory()
}
}
void Widget::incomingNotification(uint32_t friendId)
{
newFriendMessageAlert(friendId, false);
Audio& audio = Audio::getInstance();
audio.startLoop();
audio.playMono16Sound(Audio::getSound(Audio::Sound::IncomingCall));
}
void Widget::addFriend(int friendId, const ToxPk& friendPk)
{
Friend* newfriend = FriendList::addFriend(friendId, friendPk);
@ -944,6 +953,8 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk)
connect(newfriend, &Friend::aliasChanged, this, &Widget::onFriendAliasChanged);
connect(newfriend, &Friend::nameChanged, this, &Widget::onFriendAliasChanged);
connect(friendForm, &ChatForm::incomingNotification, this, &Widget::incomingNotification);
connect(widget, &FriendWidget::chatroomWidgetClicked, this, &Widget::onChatroomWidgetClicked);
connect(widget, &FriendWidget::chatroomWidgetClicked, friendForm, &ChatForm::focusInput);
connect(widget, &FriendWidget::copyFriendIdToClipboard, this, &Widget::copyFriendIdToClipboard);

View File

@ -217,9 +217,7 @@ private slots:
void groupInvitesUpdate();
void groupInvitesClear();
void onDialogShown(GenericChatroomWidget* widget);
private:
int icon_size;
void incomingNotification(uint32_t friendId);
private:
bool newMessageAlert(QWidget* currentWindow, bool isActive, bool sound = true, bool notify = true);
@ -287,6 +285,7 @@ private:
QPushButton* friendRequestsButton;
QPushButton* groupInvitesButton;
unsigned int unreadGroupInvites;
int icon_size;
QMap<int, FriendWidget*> friendWidgets;