mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #322
This commit is contained in:
parent
dfc40aa8e8
commit
d684fca868
5
core.cpp
5
core.cpp
|
@ -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
1
core.h
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -43,6 +43,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||
void onAvatarRemoved(int FriendId);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user