1
0
Fork 0
forked from blue/squawk

pal avatars in one on one dialogs

This commit is contained in:
Blue 2019-12-23 09:28:23 +03:00
parent f13b43d38b
commit dd62f84acc
9 changed files with 87 additions and 2 deletions

View file

@ -25,6 +25,7 @@ Chat::Chat(Models::Account* acc, Models::Contact* p_contact, QWidget* parent):
setName(p_contact->getContactName());
updateState();
setStatus(p_contact->getStatus());
setAvatar(p_contact->getAvatarPath());
connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged);
}
@ -46,6 +47,9 @@ void Chat::onContactChanged(Models::Item* item, int row, int col)
case 5:
setStatus(contact->getStatus());
break;
case 7:
setAvatar(contact->getAvatarPath());
break;
}
}
}
@ -89,3 +93,13 @@ void Chat::setName(const QString& name)
line->setPalName(getJid(), name);
}
void Chat::setAvatar(const QString& path)
{
Conversation::setAvatar(path);
if (path.size() == 0) {
line->dropPalAvatar(contact->getJid());
} else {
line->setPalAvatar(contact->getJid(), path);
}
}

View file

@ -34,6 +34,7 @@ public:
~Chat();
void addMessage(const Shared::Message & data) override;
void setAvatar(const QString& path) override;
protected slots:
void onContactChanged(Models::Item* item, int row, int col);

View file

@ -384,6 +384,11 @@ void Conversation::onClearButton()
m_ui->messageEditor->clear();
}
void Conversation::setAvatar(const QString& path)
{
m_ui->avatar->setPixmap(path.size() == 0 ? Shared::iconPath("user", true) : path);
}
void Conversation::onAttachResize(const QSize& oldSize, const QSize& newSize)
{
int oh = oldSize.height();
@ -419,4 +424,3 @@ VisibilityCatcher::VisibilityCatcher(QWidget* parent):
QObject(parent)
{
}

View file

@ -78,6 +78,7 @@ public:
void responseLocalFile(const QString& messageId, const QString& path);
void fileError(const QString& messageId, const QString& error);
void responseFileProgress(const QString& messageId, qreal progress);
virtual void setAvatar(const QString& path);
signals:
void sendMessage(const Shared::Message& message);

View file

@ -71,6 +71,12 @@
</property>
<item>
<widget class="QWidget" name="widget_3" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
@ -92,6 +98,9 @@
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -140,9 +149,18 @@
</item>
<item>
<widget class="QLabel" name="avatar">
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -25,6 +25,7 @@ Room::Room(Models::Account* acc, Models::Room* p_room, QWidget* parent):
setName(p_room->getName());
line->setMyName(room->getNick());
setStatus(room->getSubject());
setAvatar(room->getAvatarPath());
connect(room, &Models::Room::childChanged, this, &Room::onRoomChanged);
}