Update libqmatrixclient && fix broken avatar && fix broken image provider.
This commit is contained in:
parent
2992804472
commit
7c426e254b
|
@ -1 +1 @@
|
||||||
Subproject commit d9ff200ff62fb7f5b6b51082dc3979d5454a1bec
|
Subproject commit 3dfcd0f4f4501dba5925d894b7f0fbc9414549c8
|
|
@ -103,12 +103,12 @@ Drawer {
|
||||||
anchors.margins: 8
|
anchors.margins: 8
|
||||||
spacing: 12
|
spacing: 12
|
||||||
|
|
||||||
ImageStatus {
|
ImageItem {
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
source: avatar != "" ? "image://mxc/" + avatar : ""
|
image: avatar
|
||||||
displayText: name
|
hint: name
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|
|
@ -112,12 +112,13 @@ ApplicationWindow {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
ImageStatus {
|
ImageItem {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 12
|
anchors.margins: 12
|
||||||
|
|
||||||
// source: matriqueController.isLogin ? connection.localUser && connection.localUser.avatarUrl ? "image://mxc/" + connection.localUser.avatarUrl : "" : "qrc:/asset/img/avatar.png"
|
hint: name
|
||||||
displayText: name
|
image: avatar
|
||||||
|
defaultColor: Material.accent
|
||||||
}
|
}
|
||||||
|
|
||||||
page: roomPage
|
page: roomPage
|
||||||
|
@ -289,6 +290,6 @@ ApplicationWindow {
|
||||||
Binding {
|
Binding {
|
||||||
target: imageProvider
|
target: imageProvider
|
||||||
property: "connection"
|
property: "connection"
|
||||||
value: matriqueController.connection
|
value: accountListView.currentConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "accountlistmodel.h"
|
#include "accountlistmodel.h"
|
||||||
|
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
AccountListModel::AccountListModel(QObject* parent)
|
AccountListModel::AccountListModel(QObject* parent)
|
||||||
: QAbstractListModel(parent) {}
|
: QAbstractListModel(parent) {}
|
||||||
|
|
||||||
|
@ -10,7 +12,18 @@ void AccountListModel::setController(Controller* value) {
|
||||||
|
|
||||||
m_controller = value;
|
m_controller = value;
|
||||||
|
|
||||||
for (auto c : m_controller->connections()) m_connections.append(c);
|
for (auto c : m_controller->connections()) {
|
||||||
|
connect(c->user(), &User::avatarChanged, [=] {
|
||||||
|
const auto it =
|
||||||
|
std::find(m_connections.begin(), m_connections.end(), c);
|
||||||
|
if (it == m_connections.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto idx = index(it - m_connections.begin());
|
||||||
|
emit dataChanged(idx, idx, {AvatarRole});
|
||||||
|
});
|
||||||
|
m_connections.append(c);
|
||||||
|
};
|
||||||
|
|
||||||
connect(m_controller, &Controller::connectionAdded, this,
|
connect(m_controller, &Controller::connectionAdded, this,
|
||||||
[=](Connection* conn) {
|
[=](Connection* conn) {
|
||||||
|
@ -59,7 +72,7 @@ QVariant AccountListModel::data(const QModelIndex& index, int role) const {
|
||||||
int AccountListModel::rowCount(const QModelIndex& parent) const {
|
int AccountListModel::rowCount(const QModelIndex& parent) const {
|
||||||
if (parent.isValid()) return 0;
|
if (parent.isValid()) return 0;
|
||||||
|
|
||||||
return m_controller->connections().count();
|
return m_connections.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> AccountListModel::roleNames() const {
|
QHash<int, QByteArray> AccountListModel::roleNames() const {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ImageItem : public QQuickPaintedItem {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QImage m_image;
|
QImage m_image;
|
||||||
QString m_hint;
|
QString m_hint = "H";
|
||||||
QString m_color = "#000000";
|
QString m_color = "#000000";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,6 @@ void RoomListModel::setConnection(Connection* connection) {
|
||||||
using QMatrixClient::Room;
|
using QMatrixClient::Room;
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
|
|
||||||
doResetModel();
|
|
||||||
|
|
||||||
connect(connection, &Connection::connected, this,
|
connect(connection, &Connection::connected, this,
|
||||||
&RoomListModel::doResetModel);
|
&RoomListModel::doResetModel);
|
||||||
connect(connection, &Connection::invitedRoom, this,
|
connect(connection, &Connection::invitedRoom, this,
|
||||||
|
@ -30,6 +28,8 @@ void RoomListModel::setConnection(Connection* connection) {
|
||||||
connect(connection, &Connection::leftRoom, this, &RoomListModel::updateRoom);
|
connect(connection, &Connection::leftRoom, this, &RoomListModel::updateRoom);
|
||||||
connect(connection, &Connection::aboutToDeleteRoom, this,
|
connect(connection, &Connection::aboutToDeleteRoom, this,
|
||||||
&RoomListModel::deleteRoom);
|
&RoomListModel::deleteRoom);
|
||||||
|
|
||||||
|
doResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoomListModel::doResetModel() {
|
void RoomListModel::doResetModel() {
|
||||||
|
@ -139,7 +139,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
|
||||||
MatriqueRoom* room = m_rooms.at(index.row());
|
MatriqueRoom* room = m_rooms.at(index.row());
|
||||||
if (role == NameRole) return room->displayName();
|
if (role == NameRole) return room->displayName();
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
if (room->avatarUrl().toString() != "") return room->avatar(64, 64);
|
if (!room->avatarUrl().isEmpty()) return room->avatar(64, 64);
|
||||||
return QImage();
|
return QImage();
|
||||||
}
|
}
|
||||||
if (role == TopicRole) return room->topic();
|
if (role == TopicRole) return room->topic();
|
||||||
|
|
|
@ -68,7 +68,9 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
|
||||||
return user->displayname(m_currentRoom);
|
return user->displayname(m_currentRoom);
|
||||||
}
|
}
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
return user->avatarUrl(m_currentRoom);
|
if (!user->avatarUrl(m_currentRoom).isEmpty())
|
||||||
|
return user->avatar(32, m_currentRoom);
|
||||||
|
return QImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -110,7 +112,7 @@ void UserListModel::refresh(QMatrixClient::User* user, QVector<int> roles) {
|
||||||
|
|
||||||
void UserListModel::avatarChanged(QMatrixClient::User* user,
|
void UserListModel::avatarChanged(QMatrixClient::User* user,
|
||||||
const QMatrixClient::Room* context) {
|
const QMatrixClient::Room* context) {
|
||||||
if (context == m_currentRoom) refresh(user, {Qt::DecorationRole});
|
if (context == m_currentRoom) refresh(user, {AvatarRole});
|
||||||
}
|
}
|
||||||
|
|
||||||
int UserListModel::findUserPos(User* user) const {
|
int UserListModel::findUserPos(User* user) const {
|
||||||
|
|
Loading…
Reference in New Issue