Per-room avatar and displayname.
This commit is contained in:
@@ -17,7 +17,7 @@ import Spectral.Effect 2.0
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property bool avatarVisible: !sentByMe && showAuthor
|
readonly property bool avatarVisible: !sentByMe && showAuthor
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author.isLocalUser
|
||||||
|
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ RowLayout {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import Spectral.Effect 2.0
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property bool avatarVisible: !sentByMe && showAuthor
|
readonly property bool avatarVisible: !sentByMe && showAuthor
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author.isLocalUser
|
||||||
|
|
||||||
property bool openOnFinished: false
|
property bool openOnFinished: false
|
||||||
readonly property bool downloaded: progressInfo && progressInfo.completed
|
readonly property bool downloaded: progressInfo && progressInfo.completed
|
||||||
@@ -50,7 +50,7 @@ RowLayout {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import Spectral.Font 0.1
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property bool avatarVisible: showAuthor && !sentByMe
|
readonly property bool avatarVisible: showAuthor && !sentByMe
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author.isLocalUser
|
||||||
readonly property bool isAnimated: contentType === "image/gif"
|
readonly property bool isAnimated: contentType === "image/gif"
|
||||||
|
|
||||||
property bool openOnFinished: false
|
property bool openOnFinished: false
|
||||||
@@ -56,7 +56,7 @@ RowLayout {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import Spectral.Effect 2.0
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
readonly property bool avatarVisible: !sentByMe && showAuthor
|
readonly property bool avatarVisible: !sentByMe && showAuthor
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author.isLocalUser
|
||||||
readonly property bool darkBackground: !sentByMe
|
readonly property bool darkBackground: !sentByMe
|
||||||
readonly property bool replyVisible: reply || false
|
readonly property bool replyVisible: reply || false
|
||||||
readonly property bool failed: marks === EventStatus.SendingFailed
|
readonly property bool failed: marks === EventStatus.SendingFailed
|
||||||
@@ -57,7 +57,7 @@ ColumnLayout {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ Control {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import Spectral.Font 0.1
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
readonly property bool avatarVisible: showAuthor && !sentByMe
|
readonly property bool avatarVisible: showAuthor && !sentByMe
|
||||||
readonly property bool sentByMe: author === currentRoom.localUser
|
readonly property bool sentByMe: author.isLocalUser
|
||||||
|
|
||||||
property bool openOnFinished: false
|
property bool openOnFinished: false
|
||||||
property bool playOnFinished: false
|
property bool playOnFinished: false
|
||||||
@@ -67,7 +67,7 @@ RowLayout {
|
|||||||
|
|
||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author}).open()
|
onClicked: userDetailDialog.createObject(ApplicationWindow.overlay, {"room": currentRoom, "user": author.object, "displayName": author.displayName, "avatarMediaId": author.avatarMediaId, "avatarUrl": author.avatarUrl}).open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ Dialog {
|
|||||||
property var room
|
property var room
|
||||||
property var user
|
property var user
|
||||||
|
|
||||||
|
property string displayName: user.displayName
|
||||||
|
property string avatarMediaId: user.avatarMediaId
|
||||||
|
property string avatarUrl: user.avatarUrl
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: 360
|
width: 360
|
||||||
|
|
||||||
@@ -27,8 +31,8 @@ Dialog {
|
|||||||
Layout.preferredWidth: 72
|
Layout.preferredWidth: 72
|
||||||
Layout.preferredHeight: 72
|
Layout.preferredHeight: 72
|
||||||
|
|
||||||
hint: user.displayName
|
hint: displayName
|
||||||
source: user.avatarMediaId
|
source: avatarMediaId
|
||||||
|
|
||||||
RippleEffect {
|
RippleEffect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -36,8 +40,8 @@ Dialog {
|
|||||||
circular: true
|
circular: true
|
||||||
|
|
||||||
onPrimaryClicked: {
|
onPrimaryClicked: {
|
||||||
if (user.avatarMediaId) {
|
if (avatarMediaId) {
|
||||||
fullScreenImage.createObject(parent, {"filename": user.diaplayName, "localPath": room.urlToMxcUrl(user.avatarUrl)}).showFullScreen()
|
fullScreenImage.createObject(parent, {"filename": displayName, "localPath": room.urlToMxcUrl(avatarUrl)}).showFullScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,19 +58,10 @@ Dialog {
|
|||||||
|
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
text: user.displayName
|
text: displayName
|
||||||
color: MPalette.foreground
|
color: MPalette.foreground
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
visible: user.bridgeName
|
|
||||||
|
|
||||||
text: user.bridgeName
|
|
||||||
color: MPalette.lighter
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,18 @@ int MessageEventModel::rowCount(const QModelIndex& parent) const {
|
|||||||
return m_currentRoom->timelineSize();
|
return m_currentRoom->timelineSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QVariantMap userAtEvent(SpectralUser* user, SpectralRoom* room, const RoomEvent& evt) {
|
||||||
|
return QVariantMap{
|
||||||
|
{"isLocalUser", user->id() == room->localUser()->id()},
|
||||||
|
{"id", user->id()},
|
||||||
|
{"avatarMediaId", user->avatarMediaId(room)},
|
||||||
|
{"avatarUrl", user->avatarUrl(room)},
|
||||||
|
{"displayName", user->displayname(room)},
|
||||||
|
{"color", user->color()},
|
||||||
|
{"object", QVariant::fromValue(user)},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
||||||
const auto row = idx.row();
|
const auto row = idx.row();
|
||||||
|
|
||||||
@@ -328,9 +340,9 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
|||||||
return EventTypeRegistry::getMatrixType(evt.type());
|
return EventTypeRegistry::getMatrixType(evt.type());
|
||||||
|
|
||||||
if (role == AuthorRole) {
|
if (role == AuthorRole) {
|
||||||
// FIXME: It shouldn't be User, it should be its state "as of event"
|
auto author = static_cast<SpectralUser*>(isPending ? m_currentRoom->localUser()
|
||||||
return QVariant::fromValue(isPending ? m_currentRoom->localUser()
|
: m_currentRoom->user(evt.senderId()));
|
||||||
: m_currentRoom->user(evt.senderId()));
|
return userAtEvent(author, m_currentRoom, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == ContentTypeRole) {
|
if (role == ContentTypeRole) {
|
||||||
@@ -444,7 +456,7 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
|||||||
{"eventId", replyEventId},
|
{"eventId", replyEventId},
|
||||||
{"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)},
|
{"display", m_currentRoom->eventToString(replyEvt, Qt::RichText)},
|
||||||
{"author",
|
{"author",
|
||||||
QVariant::fromValue(m_currentRoom->user(replyEvt.senderId()))}};
|
userAtEvent(static_cast<SpectralUser*>(m_currentRoom->user(replyEvt.senderId())), m_currentRoom, evt)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == ShowAuthorRole) {
|
if (role == ShowAuthorRole) {
|
||||||
@@ -522,12 +534,11 @@ QVariant MessageEventModel::data(const QModelIndex& idx, int role) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariantList res = {};
|
QVariantList res = {};
|
||||||
QMap<QString, QList<SpectralUser*>>::const_iterator i =
|
auto i = reactions.constBegin();
|
||||||
reactions.constBegin();
|
|
||||||
while (i != reactions.constEnd()) {
|
while (i != reactions.constEnd()) {
|
||||||
QVariantList authors;
|
QVariantList authors;
|
||||||
for (auto author : i.value()) {
|
for (auto author : i.value()) {
|
||||||
authors.append(QVariant::fromValue(author));
|
authors.append(userAtEvent(author, m_currentRoom, evt));
|
||||||
}
|
}
|
||||||
bool hasLocalUser = i.value().contains(
|
bool hasLocalUser = i.value().contains(
|
||||||
static_cast<SpectralUser*>(m_currentRoom->localUser()));
|
static_cast<SpectralUser*>(m_currentRoom->localUser()));
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
|
|||||||
return user->id();
|
return user->id();
|
||||||
}
|
}
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
return user->avatarMediaId();
|
return user->avatarMediaId(m_currentRoom);
|
||||||
}
|
}
|
||||||
if (role == ObjectRole) {
|
if (role == ObjectRole) {
|
||||||
return QVariant::fromValue(user);
|
return QVariant::fromValue(user);
|
||||||
|
|||||||
Reference in New Issue
Block a user