diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 8c1f13b70..6d0ab0be3 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -188,7 +188,7 @@ void ChatForm::onFileRecvRequest(ToxFile file) Widget* w = Widget::getInstance(); if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow()) { - w->newMessageAlert(); + w->newMessageAlert(f->getFriendWidget()); f->setEventFlag(true); f->getFriendWidget()->updateStatusLight(); } @@ -240,7 +240,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video) Widget* w = Widget::getInstance(); if (!w->isFriendWidgetCurActiveWidget(f)|| w->isMinimized() || !w->isActiveWindow()) { - w->newMessageAlert(); + w->newMessageAlert(f->getFriendWidget()); f->setEventFlag(true); f->getFriendWidget()->updateStatusLight(); } diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 3114f667a..1aa47e9f0 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -675,7 +675,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) //won't print the message if there were no messages before if(!f->getChatForm()->isEmpty() - && Settings::getInstance().getStatusChangeNotificationEnabled() == true) + && Settings::getInstance().getStatusChangeNotificationEnabled()) { QString fStatus = ""; switch(f->getStatus()){ @@ -750,26 +750,27 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool if ((static_cast(f->getFriendWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow()) { f->setEventFlag(true); - newMessageAlert(); + newMessageAlert(f->getFriendWidget()); } } else { f->setEventFlag(true); - newMessageAlert(); + newMessageAlert(f->getFriendWidget()); } f->getFriendWidget()->updateStatusLight(); } -void Widget::newMessageAlert() +void Widget::newMessageAlert(GenericChatroomWidget* chat) { QApplication::alert(this); static QFile sndFile(":audio/notification.pcm"); - if(Settings::getInstance().getShowInFront() == true) + if ((isMinimized() || !isActiveWindow()) && Settings::getInstance().getShowInFront()) { this->show(); + emit chat->chatroomWidgetClicked(chat); } static QByteArray sndData; if (sndData.isEmpty()) @@ -882,7 +883,7 @@ void Widget::onGroupMessageReceived(int groupnumber, const QString& message, con g->hasNewMessages = 1; if (targeted) { - newMessageAlert(); + newMessageAlert(g->widget); g->userWasMentioned = 1; // useful for highlighting line or desktop notifications } g->widget->updateStatusLight(); diff --git a/src/widget/widget.h b/src/widget/widget.h index d94283d2d..22e7f4667 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -57,7 +57,7 @@ public: QThread* getCoreThread(); Camera* getCamera(); static Widget* getInstance(); - void newMessageAlert(); + void newMessageAlert(GenericChatroomWidget* chat); bool isFriendWidgetCurActiveWidget(Friend* f); bool getIsWindowMinimized(); static QList searchProfiles();