void Widget::onFriendStatusChanged(int friendId, Status status) { Friend* f = FriendList::findFriend(friendId); if (!f) return; bool isActualChange = f->getStatus() != status; if (isActualChange) { if (f->getStatus() == Status::Offline) { contactListWidget->moveWidget(f->getFriendWidget(), Status::Online, f->getEventFlag()); } else if (status == Status::Offline) { contactListWidget->moveWidget(f->getFriendWidget(), Status::Offline, f->getEventFlag()); } } f->setStatus(status); f->getFriendWidget()->updateStatusLight(); //won't print the message if there were no messages before if (!f->getChatForm()->isEmpty() && Settings::getInstance().getStatusChangeNotificationEnabled()) { QString fStatus = ""; switch(f->getStatus()){ case Status::Away: fStatus = tr("away", "contact status"); break; case Status::Busy: fStatus = tr("busy", "contact status"); break; case Status::Offline: fStatus = tr("offline", "contact status"); f->getChatForm()->setFriendTyping(false); // Hide the "is typing" message when a friend goes offline break; default: fStatus = tr("online", "contact status"); break; } if (isActualChange) f->getChatForm()->addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"").arg(f->getDisplayedName()).arg(fStatus), ChatMessage::INFO, QDateTime::currentDateTime()); } if (isActualChange && status != Status::Offline) { // wait a little QTimer::singleShot(250, f->getChatForm()->getOfflineMsgEngine(), SLOT(deliverOfflineMsgs())); } }
void FriendWidget::updateStatusLight() { Friend* f = FriendList::findFriend(friendId); Status status = f->getStatus(); if (status == Status::Online && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_online.svg")); else if (status == Status::Online && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.svg")); else if (status == Status::Away && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_away.svg")); else if (status == Status::Away && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.svg")); else if (status == Status::Busy && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_busy.svg")); else if (status == Status::Busy && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.svg")); else if (status == Status::Offline && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_offline.svg")); else if (status == Status::Offline && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_offline_notification.svg")); if (f->getEventFlag()) { CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId())); if (circleWidget != nullptr) circleWidget->setExpanded(true); Widget::getInstance()->updateFriendActivity(FriendList::findFriend(friendId)); } if (!f->getEventFlag()) statusPic.setMargin(3); else statusPic.setMargin(0); }
QString FriendWidget::getStatusString() const { Friend* f = FriendList::findFriend(friendId); Status status = f->getStatus(); if (f->getEventFlag() == 1) return tr("New message"); else if (status == Status::Online) return tr("Online"); else if (status == Status::Away) return tr("Away"); else if (status == Status::Busy) return tr("Busy"); else if (status == Status::Offline) return tr("Offline"); return QString::null; }
void FriendWidget::updateStatusLight() { Friend* f = FriendList::findFriend(friendId); Status status = f->getStatus(); if (status == Status::Online && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_online.png")); else if (status == Status::Online && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png")); else if (status == Status::Away && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_idle.png")); else if (status == Status::Away && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_idle_notification.png")); else if (status == Status::Busy && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_busy.png")); else if (status == Status::Busy && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.png")); else if (status == Status::Offline && f->getEventFlag() == 0) statusPic.setPixmap(QPixmap(":img/status/dot_away.png")); else if (status == Status::Offline && f->getEventFlag() == 1) statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png")); }