void Widget::onFriendMessageReceived(int friendId, const QString& message, bool isAction) { Friend* f = FriendList::findFriend(friendId); if (!f) return; QDateTime timestamp = QDateTime::currentDateTime(); f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp); if (isAction) HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, "/me " + message, f->getToxID().publicKey, timestamp); else HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, message, f->getToxID().publicKey, timestamp); if (activeChatroomWidget != nullptr) { if ((static_cast<GenericChatroomWidget*>(f->getFriendWidget()) != activeChatroomWidget) || isMinimized() || !isActiveWindow()) { f->setEventFlag(true); newMessageAlert(); } } else { f->setEventFlag(true); newMessageAlert(); } f->getFriendWidget()->updateStatusLight(); }
void Widget::onFriendMessageReceived(int friendId, const QString& message, bool isAction) { Friend* f = FriendList::findFriend(friendId); if (!f) return; QDateTime timestamp = QDateTime::currentDateTime(); f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true); HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + message : message, f->getToxID().publicKey, timestamp, true); f->setEventFlag(f->getFriendWidget() != activeChatroomWidget); newMessageAlert(f->getFriendWidget()); f->getFriendWidget()->updateStatusLight(); }
void FriendWidget::resetEventFlags() { Friend* f = FriendList::findFriend(friendId); f->setEventFlag(false); }