1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-09-26 21:23:20 +02:00
parent dfc40aa8e8
commit d684fca868
7 changed files with 26 additions and 1 deletions

View File

@ -460,7 +460,10 @@ void Core::onAvatarInfoCallback(Tox*, int32_t friendnumber, uint8_t format,
qDebug() << "Core: Got avatar info from "<<friendnumber
<<": format "<<format;
tox_request_avatar_data(static_cast<Core*>(core)->tox, friendnumber);
if (format == TOX_AVATARFORMAT_NONE)
emit static_cast<Core*>(core)->friendAvatarRemoved(friendnumber);
else
tox_request_avatar_data(static_cast<Core*>(core)->tox, friendnumber);
}
void Core::onAvatarDataCallback(Tox*, int32_t friendnumber, uint8_t,

1
core.h
View File

@ -107,6 +107,7 @@ signals:
void friendUsernameChanged(int friendId, const QString& username);
void friendTypingChanged(int friendId, bool isTyping);
void friendAvatarChanged(int friendId, const QPixmap& pic);
void friendAvatarRemoved(int friendId);
void friendStatusMessageLoaded(int friendId, const QString& message);
void friendUsernameLoaded(int friendId, const QString& username);

View File

@ -498,3 +498,11 @@ void ChatForm::dropEvent(QDropEvent *ev)
}
}
}
void ChatForm::onAvatarRemoved(int FriendId)
{
if (FriendId != f->friendId)
return;
avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png"));
}

View File

@ -57,6 +57,7 @@ public slots:
void onAvMediaChange(int FriendId, int CallId, bool video);
void onMicMuteToggle();
void onAvatarChange(int FriendId, const QPixmap& pic);
void onAvatarRemoved(int FriendId);
private slots:
void onSendTriggered();

View File

@ -207,6 +207,15 @@ void FriendWidget::onAvatarChange(int FriendId, const QPixmap& pic)
avatar.setPixmap(scaled);
}
void FriendWidget::onAvatarRemoved(int FriendId)
{
if (FriendId != friendId)
return;
isDefaultAvatar = true;
avatar.setPixmap(QPixmap(":img/contact.png"));
}
void FriendWidget::mousePressEvent(QMouseEvent *ev)
{
if (ev->button() == Qt::LeftButton)

View File

@ -43,6 +43,7 @@ signals:
public slots:
void onAvatarChange(int FriendId, const QPixmap& pic);
void onAvatarRemoved(int FriendId);
protected:
void mousePressEvent(QMouseEvent* ev);

View File

@ -468,6 +468,8 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(core, &Core::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
connect(core, &Core::friendAvatarChanged, newfriend->widget, &FriendWidget::onAvatarChange);
connect(core, &Core::friendAvatarRemoved, newfriend->chatForm, &ChatForm::onAvatarRemoved);
connect(core, &Core::friendAvatarRemoved, newfriend->widget, &FriendWidget::onAvatarRemoved);
// Try to get the avatar from the cache
QPixmap avatar = Settings::getInstance().getSavedAvatar(userId);