Make Neochat compile against libQuotient 0.6
This commit is contained in:
committed by
Carl Schwan
parent
516ad863b8
commit
4e2b68dc0a
@@ -33,7 +33,7 @@ else()
|
|||||||
find_package(Qt5Keychain REQUIRED)
|
find_package(Qt5Keychain REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Quotient 0.7 REQUIRED)
|
find_package(Quotient 0.6 REQUIRED)
|
||||||
find_package(cmark REQUIRED)
|
find_package(cmark REQUIRED)
|
||||||
|
|
||||||
install(PROGRAMS org.kde.neochat.desktop DESTINATION ${KDE_INSTALL_APPDIR})
|
install(PROGRAMS org.kde.neochat.desktop DESTINATION ${KDE_INSTALL_APPDIR})
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Kirigami.ScrollablePage {
|
|||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
text: model.user.defaultName
|
text: model.user.displayName
|
||||||
subtitle: model.user.id
|
subtitle: model.user.id
|
||||||
icon: model.connection.user.avatarMediaId ? "image://mxc/" + model.connection.user.avatarMediaId : "im-user"
|
icon: model.connection.user.avatarMediaId ? "image://mxc/" + model.connection.user.avatarMediaId : "im-user"
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ Kirigami.ScrollablePage {
|
|||||||
anchors.top: passwordsMessage.bottom
|
anchors.top: passwordsMessage.bottom
|
||||||
Controls.TextField {
|
Controls.TextField {
|
||||||
id: name
|
id: name
|
||||||
text: userEditSheet.connection.localUser.defaultName
|
text: userEditSheet.connection.localUser.displayName
|
||||||
Kirigami.FormData.label: i18n("Name:")
|
Kirigami.FormData.label: i18n("Name:")
|
||||||
}
|
}
|
||||||
Controls.TextField {
|
Controls.TextField {
|
||||||
@@ -113,8 +113,8 @@ Kirigami.ScrollablePage {
|
|||||||
Controls.Button {
|
Controls.Button {
|
||||||
text: i18n("Save")
|
text: i18n("Save")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(userEditSheet.connection.localUser.defaultName !== name.text)
|
if(userEditSheet.connection.localUser.displayName !== name.text)
|
||||||
userEditSheet.connection.localUser.user.defaultName = name.text
|
userEditSheet.connection.localUser.rename(name.text)
|
||||||
if(currentPassword.text !== "" && newPassword.text !== "" && confirmPassword.text !== "") {
|
if(currentPassword.text !== "" && newPassword.text !== "" && confirmPassword.text !== "") {
|
||||||
if(newPassword.text === confirmPassword.text) {
|
if(newPassword.text === confirmPassword.text) {
|
||||||
Controller.changePassword(userEditSheet.connection, currentPassword.text, newPassword.text)
|
Controller.changePassword(userEditSheet.connection, currentPassword.text, newPassword.text)
|
||||||
|
|||||||
@@ -317,17 +317,17 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
|||||||
}
|
}
|
||||||
QString text {};
|
QString text {};
|
||||||
if (e.isRename()) {
|
if (e.isRename()) {
|
||||||
if (e.newDisplayName()->isEmpty())
|
if (e.displayName().isEmpty())
|
||||||
text = i18n("cleared their display name");
|
text = i18n("cleared their display name");
|
||||||
else
|
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 (e.isAvatarUpdate()) {
|
||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
text += i18n(" and ");
|
text += i18n(" and ");
|
||||||
if (!e.newAvatarUrl())
|
if (e.avatarUrl().isEmpty())
|
||||||
text += i18n("cleared their avatar");
|
text += i18n("cleared their avatar");
|
||||||
else if (!e.prevContent()->avatarUrl)
|
else if (e.prevContent()->avatarUrl.isEmpty())
|
||||||
text += i18n("set an avatar");
|
text += i18n("set an avatar");
|
||||||
else
|
else
|
||||||
text += i18n("updated their avatar");
|
text += i18n("updated their avatar");
|
||||||
|
|||||||
@@ -11,27 +11,3 @@ QColor NeoChatUser::color()
|
|||||||
{
|
{
|
||||||
return QColor::fromHslF(hueF(), 0.7, 0.5, 1);
|
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_OBJECT
|
||||||
Q_PROPERTY(QColor color READ color CONSTANT)
|
Q_PROPERTY(QColor color READ color CONSTANT)
|
||||||
Q_PROPERTY(QString defaultName READ defaultName WRITE setDefaultName NOTIFY nameChanged)
|
|
||||||
public:
|
public:
|
||||||
NeoChatUser(QString userId, Connection *connection)
|
NeoChatUser(QString userId, Connection *connection)
|
||||||
: User(userId, connection)
|
: User(userId, connection)
|
||||||
@@ -24,14 +23,4 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QColor color();
|
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());
|
std::sort(m_users.begin(), m_users.end(), room->memberSorter());
|
||||||
}
|
}
|
||||||
for (User *user : qAsConst(m_users)) {
|
for (User *user : qAsConst(m_users)) {
|
||||||
connect(user, &User::defaultAvatarChanged, this, [user, this]() {
|
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||||
avatarChanged(user);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
||||||
setRoom(nullptr);
|
setRoom(nullptr);
|
||||||
@@ -146,9 +144,7 @@ void UserListModel::userAdded(Quotient::User *user)
|
|||||||
beginInsertRows(QModelIndex(), pos, pos);
|
beginInsertRows(QModelIndex(), pos, pos);
|
||||||
m_users.insert(pos, user);
|
m_users.insert(pos, user);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
connect(user, &Quotient::User::defaultAvatarChanged, this, [user, this]() {
|
connect(user, &Quotient::User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||||
avatarChanged(user);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserListModel::userRemoved(Quotient::User *user)
|
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";
|
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
|
int UserListModel::findUserPos(User *user) const
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ private Q_SLOTS:
|
|||||||
void userAdded(Quotient::User *user);
|
void userAdded(Quotient::User *user);
|
||||||
void userRemoved(Quotient::User *user);
|
void userRemoved(Quotient::User *user);
|
||||||
void refresh(Quotient::User *user, QVector<int> roles = {});
|
void refresh(Quotient::User *user, QVector<int> roles = {});
|
||||||
void avatarChanged(Quotient::User *user);
|
void avatarChanged(Quotient::User *user, const Quotient::Room *context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Quotient::Room *m_currentRoom;
|
Quotient::Room *m_currentRoom;
|
||||||
|
|||||||
Reference in New Issue
Block a user