Make Neochat compile against libQuotient 0.6
This commit is contained in:
committed by
Carl Schwan
parent
516ad863b8
commit
4e2b68dc0a
@@ -317,17 +317,17 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
||||
}
|
||||
QString text {};
|
||||
if (e.isRename()) {
|
||||
if (e.newDisplayName()->isEmpty())
|
||||
if (e.displayName().isEmpty())
|
||||
text = i18n("cleared their display name");
|
||||
else
|
||||
text = i18n("changed their display name to %1", e.newDisplayName()->toHtmlEscaped());
|
||||
text = i18n("changed their display name to %1", e.displayName().toHtmlEscaped());
|
||||
}
|
||||
if (e.isAvatarUpdate()) {
|
||||
if (!text.isEmpty())
|
||||
text += i18n(" and ");
|
||||
if (!e.newAvatarUrl())
|
||||
if (e.avatarUrl().isEmpty())
|
||||
text += i18n("cleared their avatar");
|
||||
else if (!e.prevContent()->avatarUrl)
|
||||
else if (e.prevContent()->avatarUrl.isEmpty())
|
||||
text += i18n("set an avatar");
|
||||
else
|
||||
text += i18n("updated their avatar");
|
||||
|
||||
@@ -11,27 +11,3 @@ QColor NeoChatUser::color()
|
||||
{
|
||||
return QColor::fromHslF(hueF(), 0.7, 0.5, 1);
|
||||
}
|
||||
// TODO libQuotient 0.7: remove default name
|
||||
void NeoChatUser::setDefaultName(QString defaultName)
|
||||
{
|
||||
rename(defaultName);
|
||||
connect(this, &Quotient::User::defaultNameChanged, this, [this]() {
|
||||
m_defaultName = "";
|
||||
Q_EMIT nameChanged();
|
||||
});
|
||||
}
|
||||
|
||||
QString NeoChatUser::defaultName()
|
||||
{
|
||||
if (m_defaultName.isEmpty()) {
|
||||
GetDisplayNameJob *job = connection()->callApi<GetDisplayNameJob>(id());
|
||||
connect(job, &BaseJob::success, this, [this, job] {
|
||||
if (job->displayname().isEmpty())
|
||||
m_defaultName = id();
|
||||
else
|
||||
m_defaultName = job->displayname();
|
||||
Q_EMIT nameChanged();
|
||||
});
|
||||
}
|
||||
return m_defaultName;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class NeoChatUser : public User
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QColor color READ color CONSTANT)
|
||||
Q_PROPERTY(QString defaultName READ defaultName WRITE setDefaultName NOTIFY nameChanged)
|
||||
public:
|
||||
NeoChatUser(QString userId, Connection *connection)
|
||||
: User(userId, connection)
|
||||
@@ -24,14 +23,4 @@ public:
|
||||
}
|
||||
|
||||
QColor color();
|
||||
|
||||
// TODO libQuotient 0.7: remove
|
||||
void setDefaultName(QString defaultName);
|
||||
QString defaultName();
|
||||
|
||||
Q_SIGNALS:
|
||||
void nameChanged();
|
||||
|
||||
private:
|
||||
QString m_defaultName;
|
||||
};
|
||||
|
||||
@@ -48,9 +48,7 @@ void UserListModel::setRoom(Quotient::Room *room)
|
||||
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
||||
}
|
||||
for (User *user : qAsConst(m_users)) {
|
||||
connect(user, &User::defaultAvatarChanged, this, [user, this]() {
|
||||
avatarChanged(user);
|
||||
});
|
||||
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||
}
|
||||
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
||||
setRoom(nullptr);
|
||||
@@ -146,9 +144,7 @@ void UserListModel::userAdded(Quotient::User *user)
|
||||
beginInsertRows(QModelIndex(), pos, pos);
|
||||
m_users.insert(pos, user);
|
||||
endInsertRows();
|
||||
connect(user, &Quotient::User::defaultAvatarChanged, this, [user, this]() {
|
||||
avatarChanged(user);
|
||||
});
|
||||
connect(user, &Quotient::User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||
}
|
||||
|
||||
void UserListModel::userRemoved(Quotient::User *user)
|
||||
@@ -172,9 +168,10 @@ void UserListModel::refresh(Quotient::User *user, QVector<int> roles)
|
||||
qWarning() << "Trying to access a room member not in the user list";
|
||||
}
|
||||
|
||||
void UserListModel::avatarChanged(Quotient::User *user)
|
||||
void UserListModel::avatarChanged(Quotient::User *user, const Quotient::Room *context)
|
||||
{
|
||||
refresh(user, {AvatarRole});
|
||||
if(context == m_currentRoom)
|
||||
refresh(user, {AvatarRole});
|
||||
}
|
||||
|
||||
int UserListModel::findUserPos(User *user) const
|
||||
|
||||
@@ -67,7 +67,7 @@ private Q_SLOTS:
|
||||
void userAdded(Quotient::User *user);
|
||||
void userRemoved(Quotient::User *user);
|
||||
void refresh(Quotient::User *user, QVector<int> roles = {});
|
||||
void avatarChanged(Quotient::User *user);
|
||||
void avatarChanged(Quotient::User *user, const Quotient::Room *context);
|
||||
|
||||
private:
|
||||
Quotient::Room *m_currentRoom;
|
||||
|
||||
Reference in New Issue
Block a user