diff --git a/resources/qml/ChatPage.qml b/resources/qml/ChatPage.qml
index df2bf41f..cd323a97 100644
--- a/resources/qml/ChatPage.qml
+++ b/resources/qml/ChatPage.qml
@@ -71,7 +71,7 @@ Rectangle {
AdaptiveLayoutElement {
id: timlineViewC
- minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2* Nheko.paddingMedium
+ minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2 * Nheko.paddingMedium
TimelineView {
id: timeline
diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index 99e0ed41..d69f608b 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -254,9 +254,9 @@ Page {
Label {
id: timestamp
+
visible: !model.isInvite && !model.isSpace
width: visible ? 0 : undefined
-
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
font.pixelSize: fontMetrics.font.pixelSize * 0.9
color: roomItem.unimportantText
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 90e28166..703f2fac 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -41,7 +41,8 @@ Item {
ColumnLayout {
id: timelineLayout
- visible: room != null
+ visible: room != null && !room.isSpace
+ enabled: visible
anchors.fill: parent
spacing: 0
@@ -127,6 +128,66 @@ Item {
}
+ ColumnLayout {
+ id: contentLayout1
+
+ visible: room != null && room.isSpace
+ enabled: visible
+ anchors.fill: parent
+ anchors.margins: Nheko.paddingLarge
+ spacing: Nheko.paddingLarge
+
+ Avatar {
+ url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/")
+ displayName: room ? room.roomName : ""
+ height: 130
+ width: 130
+ Layout.alignment: Qt.AlignHCenter
+ enabled: false
+ }
+
+ MatrixText {
+ text: room ? room.roomName : ""
+ font.pixelSize: 24
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ MatrixText {
+ text: qsTr("%1 member(s)").arg(room ? room.roomMemberCount : 0)
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ ScrollView {
+ //Layout.maximumHeight: 75
+ Layout.alignment: Qt.AlignHCenter
+ width: parent.width
+
+ TextArea {
+ text: TimelineManager.escapeEmoji(room ? room.roomTopic : "")
+ wrapMode: TextEdit.WordWrap
+ textFormat: TextEdit.RichText
+ readOnly: true
+ background: null
+ selectByMouse: true
+ color: Nheko.colors.text
+ horizontalAlignment: TextEdit.AlignHCenter
+ onLinkActivated: Nheko.openLink(link)
+
+ CursorShape {
+ anchors.fill: parent
+ cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
+ }
+
+ }
+
+ }
+
+ Item {
+ Layout.fillHeight: true
+ }
+
+ }
+
NhekoDropArea {
anchors.fill: parent
roomid: room ? room.roomId() : ""
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 8b1798d6..144a2d9a 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -1772,6 +1772,13 @@ Cache::relatedEvents(const std::string &room_id, const std::string &event_id)
return related_ids;
}
+size_t
+Cache::memberCount(const std::string &room_id)
+{
+ auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY);
+ return getMembersDb(txn, room_id).size(txn);
+}
+
QMap<QString, RoomInfo>
Cache::roomInfo(bool withInvites)
{
diff --git a/src/Cache_p.h b/src/Cache_p.h
index e35e78ec..cfcf9c9e 100644
--- a/src/Cache_p.h
+++ b/src/Cache_p.h
@@ -101,6 +101,7 @@ public:
std::vector<RoomMember> getMembers(const std::string &room_id,
std::size_t startIndex = 0,
std::size_t len = 30);
+ size_t memberCount(const std::string &room_id);
void saveState(const mtx::responses::Sync &res);
bool isInitialized();
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 1ecb6cdf..13919e6d 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -774,6 +774,7 @@ TimelineModel::syncState(const mtx::responses::State &s)
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
emit roomAvatarUrlChanged();
emit roomNameChanged();
+ emit roomMemberCountChanged();
}
}
}
@@ -830,6 +831,7 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
emit roomAvatarUrlChanged();
emit roomNameChanged();
+ emit roomMemberCountChanged();
}
}
updateLastMessage();
@@ -1935,3 +1937,9 @@ TimelineModel::roomTopic() const
return utils::replaceEmoji(utils::linkifyMessage(
QString::fromStdString(info[room_id_].topic).toHtmlEscaped()));
}
+
+int
+TimelineModel::roomMemberCount() const
+{
+ return (int)cache::client()->memberCount(room_id_.toStdString());
+}
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 42aa136f..3392d474 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -161,6 +161,7 @@ class TimelineModel : public QAbstractListModel
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
+ Q_PROPERTY(int roomMemberCount READ roomMemberCount NOTIFY roomMemberCountChanged)
Q_PROPERTY(bool isSpace READ isSpace CONSTANT)
Q_PROPERTY(InputBar *input READ input CONSTANT)
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
@@ -264,6 +265,7 @@ public:
DescInfo lastMessage() const { return lastMessage_; }
bool isSpace() const { return isSpace_; }
+ int roomMemberCount() const;
public slots:
void setCurrentIndex(int index);
@@ -350,6 +352,7 @@ signals:
void roomNameChanged();
void roomTopicChanged();
void roomAvatarUrlChanged();
+ void roomMemberCountChanged();
void permissionsChanged();
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|