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

Widget::updateFriendStatusLights moved to FriendWidget

This commit is contained in:
apprb 2014-08-31 21:19:16 +07:00
parent 7fe938a7ca
commit a3785f3c27
5 changed files with 31 additions and 28 deletions

View File

@ -408,7 +408,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video)
{ {
w->newMessageAlert(); w->newMessageAlert();
f->hasNewMessages=true; f->hasNewMessages=true;
w->updateFriendStatusLights(f->friendId); f->widget->updateStatusLight();
} }
} }

View File

@ -19,6 +19,8 @@
#include "grouplist.h" #include "grouplist.h"
#include "groupwidget.h" #include "groupwidget.h"
#include "widget.h" #include "widget.h"
#include "friendlist.h"
#include "friend.h"
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
@ -203,3 +205,26 @@ int FriendWidget::isActive()
{ {
return isActiveWidget; return isActiveWidget;
} }
void FriendWidget::updateStatusLight()
{
Friend* f = FriendList::findFriend(friendId);
Status status = f->friendStatus;
if (status == Status::Online && f->hasNewMessages == 0)
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
else if (status == Status::Online && f->hasNewMessages == 1)
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
else if (status == Status::Away && f->hasNewMessages == 0)
statusPic.setPixmap(QPixmap(":img/status/dot_idle.png"));
else if (status == Status::Away && f->hasNewMessages == 1)
statusPic.setPixmap(QPixmap(":img/status/dot_idle_notification.png"));
else if (status == Status::Busy && f->hasNewMessages == 0)
statusPic.setPixmap(QPixmap(":img/status/dot_busy.png"));
else if (status == Status::Busy && f->hasNewMessages == 1)
statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.png"));
else if (status == Status::Offline && f->hasNewMessages == 0)
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
else if (status == Status::Offline && f->hasNewMessages == 1)
statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png"));
}

View File

@ -37,6 +37,7 @@ public:
void setAsActiveChatroom(); void setAsActiveChatroom();
void setAsInactiveChatroom(); void setAsInactiveChatroom();
int isActive(); int isActive();
void updateStatusLight();
signals: signals:
void friendWidgetClicked(FriendWidget* widget); void friendWidgetClicked(FriendWidget* widget);

View File

@ -451,7 +451,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
contactListWidget->moveWidget(f->widget, status); contactListWidget->moveWidget(f->widget, status);
f->friendStatus = status; f->friendStatus = status;
updateFriendStatusLights(friendId); f->widget->updateStatusLight();
// Workaround widget style after returning to list // Workaround widget style after returning to list
if (f->widget->isActive()) if (f->widget->isActive())
@ -514,7 +514,7 @@ void Widget::onFriendWidgetClicked(FriendWidget *widget)
if (f->hasNewMessages != 0) if (f->hasNewMessages != 0)
f->hasNewMessages = 0; f->hasNewMessages = 0;
updateFriendStatusLights(f->friendId); f->widget->updateStatusLight();
} }
void Widget::onFriendMessageReceived(int friendId, const QString& message) void Widget::onFriendMessageReceived(int friendId, const QString& message)
@ -540,29 +540,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message)
newMessageAlert(); newMessageAlert();
} }
updateFriendStatusLights(friendId); f->widget->updateStatusLight();
}
void Widget::updateFriendStatusLights(int friendId)
{
Friend* f = FriendList::findFriend(friendId);
Status status = f->friendStatus;
if (status == Status::Online && f->hasNewMessages == 0)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
else if (status == Status::Online && f->hasNewMessages == 1)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
else if (status == Status::Away && f->hasNewMessages == 0)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_idle.png"));
else if (status == Status::Away && f->hasNewMessages == 1)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_idle_notification.png"));
else if (status == Status::Busy && f->hasNewMessages == 0)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_busy.png"));
else if (status == Status::Busy && f->hasNewMessages == 1)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_busy_notification.png"));
else if (status == Status::Offline && f->hasNewMessages == 0)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
else if (status == Status::Offline && f->hasNewMessages == 1)
f->widget->statusPic.setPixmap(QPixmap(":img/status/dot_away_notification.png"));
} }
void Widget::newMessageAlert() void Widget::newMessageAlert()
@ -791,7 +769,7 @@ bool Widget::event(QEvent * e)
{ {
Friend* f = FriendList::findFriend(activeFriendWidget->friendId); Friend* f = FriendList::findFriend(activeFriendWidget->friendId);
f->hasNewMessages = 0; f->hasNewMessages = 0;
updateFriendStatusLights(f->friendId); f->widget->updateStatusLight();
} }
else if (isGroupWidgetActive && activeGroupWidget != nullptr) else if (isGroupWidgetActive && activeGroupWidget != nullptr)
{ {

View File

@ -58,7 +58,6 @@ public:
void showTestCamview(); void showTestCamview();
void newMessageAlert(); void newMessageAlert();
bool isFriendWidgetCurActiveWidget(Friend* f); bool isFriendWidgetCurActiveWidget(Friend* f);
void updateFriendStatusLights(int friendId);
~Widget(); ~Widget();
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);