diff --git a/CMakeLists.txt b/CMakeLists.txt index 47219ea35..75304fb75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/imports/NeoChat/Page/AccountsPage.qml b/imports/NeoChat/Page/AccountsPage.qml index 9f30ff9ed..a152288d1 100644 --- a/imports/NeoChat/Page/AccountsPage.qml +++ b/imports/NeoChat/Page/AccountsPage.qml @@ -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) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 38cea044b..6fc603101 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -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"); diff --git a/src/neochatuser.cpp b/src/neochatuser.cpp index 16c16417b..c07484ca1 100644 --- a/src/neochatuser.cpp +++ b/src/neochatuser.cpp @@ -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(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; -} diff --git a/src/neochatuser.h b/src/neochatuser.h index f4a29579e..1773d6f01 100644 --- a/src/neochatuser.h +++ b/src/neochatuser.h @@ -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; }; diff --git a/src/userlistmodel.cpp b/src/userlistmodel.cpp index 30ea1dcb1..5042a0be6 100644 --- a/src/userlistmodel.cpp +++ b/src/userlistmodel.cpp @@ -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 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 diff --git a/src/userlistmodel.h b/src/userlistmodel.h index 2dc907b13..cdfa66304 100644 --- a/src/userlistmodel.h +++ b/src/userlistmodel.h @@ -67,7 +67,7 @@ private Q_SLOTS: void userAdded(Quotient::User *user); void userRemoved(Quotient::User *user); void refresh(Quotient::User *user, QVector roles = {}); - void avatarChanged(Quotient::User *user); + void avatarChanged(Quotient::User *user, const Quotient::Room *context); private: Quotient::Room *m_currentRoom;