diff --git a/audio/notification.wav b/audio/notification.wav new file mode 100644 index 000000000..2be40fd7f Binary files /dev/null and b/audio/notification.wav differ diff --git a/widget/widget.cpp b/widget/widget.cpp index 4987b443c..b20da4422 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -11,6 +11,7 @@ #include "widget/form/groupchatform.h" #include #include +#include Widget *Widget::instance{nullptr}; @@ -346,10 +347,16 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message) { Friend* f2 = FriendList::findFriend(activeFriendWidget->friendId); if ((f->friendId != f2->friendId) || isFriendWidgetActive == 0) + { f->hasNewMessages = 1; + playMessageNotification(); + } } else + { f->hasNewMessages = 1; + playMessageNotification(); + } updateFriendStatusLights(friendId); } @@ -372,6 +379,11 @@ void Widget::updateFriendStatusLights(int friendId) f->widget->statusPic.setPixmap(QPixmap("img/status/dot_away_notification.png")); } +void Widget::playMessageNotification() +{ + QSound::play("audio/notification.wav"); +} + void Widget::onFriendRequestReceived(const QString& userId, const QString& message) { FriendRequestDialog dialog(this, userId, message); diff --git a/widget/widget.h b/widget/widget.h index f51e6b47f..a082da09a 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -84,6 +84,7 @@ private: GroupWidget* activeGroupWidget; void updateFriendStatusLights(int friendId); int isFriendWidgetActive, isGroupWidgetActive; + void playMessageNotification(); }; #endif // WIDGET_H