Make Neochat compile against libQuotient 0.6

This commit is contained in:
Tobias Fella
2020-11-18 22:20:01 +01:00
committed by Carl Schwan
parent 516ad863b8
commit 4e2b68dc0a
7 changed files with 15 additions and 53 deletions

View File

@@ -33,7 +33,7 @@ else()
find_package(Qt5Keychain REQUIRED)
endif()
find_package(Quotient 0.7 REQUIRED)
find_package(Quotient 0.6 REQUIRED)
find_package(cmark REQUIRED)
install(PROGRAMS org.kde.neochat.desktop DESTINATION ${KDE_INSTALL_APPDIR})

View File

@@ -24,7 +24,7 @@ Kirigami.ScrollablePage {
anchors.top: parent.top
anchors.bottom: parent.bottom
text: model.user.defaultName
text: model.user.displayName
subtitle: model.user.id
icon: model.connection.user.avatarMediaId ? "image://mxc/" + model.connection.user.avatarMediaId : "im-user"
@@ -90,7 +90,7 @@ Kirigami.ScrollablePage {
anchors.top: passwordsMessage.bottom
Controls.TextField {
id: name
text: userEditSheet.connection.localUser.defaultName
text: userEditSheet.connection.localUser.displayName
Kirigami.FormData.label: i18n("Name:")
}
Controls.TextField {
@@ -113,8 +113,8 @@ Kirigami.ScrollablePage {
Controls.Button {
text: i18n("Save")
onClicked: {
if(userEditSheet.connection.localUser.defaultName !== name.text)
userEditSheet.connection.localUser.user.defaultName = name.text
if(userEditSheet.connection.localUser.displayName !== name.text)
userEditSheet.connection.localUser.rename(name.text)
if(currentPassword.text !== "" && newPassword.text !== "" && confirmPassword.text !== "") {
if(newPassword.text === confirmPassword.text) {
Controller.changePassword(userEditSheet.connection, currentPassword.text, newPassword.text)

View File

@@ -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");

View File

@@ -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;
}

View File

@@ -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;
};

View File

@@ -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

View File

@@ -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;