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
3
core.cpp
3
core.cpp
|
@ -460,6 +460,9 @@ void Core::onAvatarInfoCallback(Tox*, int32_t friendnumber, uint8_t format,
|
||||||
qDebug() << "Core: Got avatar info from "<<friendnumber
|
qDebug() << "Core: Got avatar info from "<<friendnumber
|
||||||
<<": format "<<format;
|
<<": format "<<format;
|
||||||
|
|
||||||
|
if (format == TOX_AVATARFORMAT_NONE)
|
||||||
|
emit static_cast<Core*>(core)->friendAvatarRemoved(friendnumber);
|
||||||
|
else
|
||||||
tox_request_avatar_data(static_cast<Core*>(core)->tox, friendnumber);
|
tox_request_avatar_data(static_cast<Core*>(core)->tox, friendnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
core.h
1
core.h
|
@ -107,6 +107,7 @@ signals:
|
||||||
void friendUsernameChanged(int friendId, const QString& username);
|
void friendUsernameChanged(int friendId, const QString& username);
|
||||||
void friendTypingChanged(int friendId, bool isTyping);
|
void friendTypingChanged(int friendId, bool isTyping);
|
||||||
void friendAvatarChanged(int friendId, const QPixmap& pic);
|
void friendAvatarChanged(int friendId, const QPixmap& pic);
|
||||||
|
void friendAvatarRemoved(int friendId);
|
||||||
|
|
||||||
void friendStatusMessageLoaded(int friendId, const QString& message);
|
void friendStatusMessageLoaded(int friendId, const QString& message);
|
||||||
void friendUsernameLoaded(int friendId, const QString& username);
|
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 onAvMediaChange(int FriendId, int CallId, bool video);
|
||||||
void onMicMuteToggle();
|
void onMicMuteToggle();
|
||||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||||
|
void onAvatarRemoved(int FriendId);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSendTriggered();
|
void onSendTriggered();
|
||||||
|
|
|
@ -207,6 +207,15 @@ void FriendWidget::onAvatarChange(int FriendId, const QPixmap& pic)
|
||||||
avatar.setPixmap(scaled);
|
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)
|
void FriendWidget::mousePressEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
|
|
|
@ -43,6 +43,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAvatarChange(int FriendId, const QPixmap& pic);
|
void onAvatarChange(int FriendId, const QPixmap& pic);
|
||||||
|
void onAvatarRemoved(int FriendId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent* ev);
|
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::avMediaChange, newfriend->chatForm, &ChatForm::onAvMediaChange);
|
||||||
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
|
connect(core, &Core::friendAvatarChanged, newfriend->chatForm, &ChatForm::onAvatarChange);
|
||||||
connect(core, &Core::friendAvatarChanged, newfriend->widget, &FriendWidget::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
|
// Try to get the avatar from the cache
|
||||||
QPixmap avatar = Settings::getInstance().getSavedAvatar(userId);
|
QPixmap avatar = Settings::getInstance().getSavedAvatar(userId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user