From 88039083213a37ad132461429f7122e651874717 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 13 Jun 2021 01:48:11 +0200 Subject: Try to be compatible with Qt 5.12 --- resources/qml/TimelineView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'resources/qml/TimelineView.qml') diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 095103fa..90e28166 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -9,7 +9,7 @@ import "./voip" import Qt.labs.platform 1.1 as Platform import QtGraphicalEffects 1.0 import QtQuick 2.9 -import QtQuick.Controls 2.13 +import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 import im.nheko 1.0 -- cgit 1.5.1 From 884fb74d2d1386c7355a709b3972619f5bd0f78a Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 18 Jun 2021 16:22:06 +0200 Subject: Add a basic 'Space page' --- resources/qml/ChatPage.qml | 2 +- resources/qml/RoomList.qml | 2 +- resources/qml/TimelineView.qml | 63 +++++++++++++++++++++++++++++++++++++++++- src/Cache.cpp | 7 +++++ src/Cache_p.h | 1 + src/timeline/TimelineModel.cpp | 8 ++++++ src/timeline/TimelineModel.h | 3 ++ 7 files changed, 83 insertions(+), 3 deletions(-) (limited to 'resources/qml/TimelineView.qml') 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 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 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>(e)) { emit roomAvatarUrlChanged(); emit roomNameChanged(); + emit roomMemberCountChanged(); } } } @@ -830,6 +831,7 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) } else if (std::holds_alternative>(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); -- cgit 1.5.1 From 847e52a6afeb14c102a7ed22d028aa9b40f65acd Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 18 Jun 2021 16:23:09 +0200 Subject: Fix null warning for space avatars --- resources/qml/TimelineView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'resources/qml/TimelineView.qml') diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 703f2fac..7bbb803b 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -138,7 +138,7 @@ Item { spacing: Nheko.paddingLarge Avatar { - url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") + url: room ? room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") : "" displayName: room ? room.roomName : "" height: 130 width: 130 -- cgit 1.5.1 From eb6baf619a8cf149046b3846dd4424a728378393 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 18 Jun 2021 16:40:40 +0200 Subject: Fix missing back button on spaces page in narrow mode as well as topic not resizing properly --- resources/qml/TimelineView.qml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'resources/qml/TimelineView.qml') diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 7bbb803b..2c7c943a 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -129,8 +129,6 @@ Item { } ColumnLayout { - id: contentLayout1 - visible: room != null && room.isSpace enabled: visible anchors.fill: parent @@ -158,9 +156,8 @@ Item { } ScrollView { - //Layout.maximumHeight: 75 Layout.alignment: Qt.AlignHCenter - width: parent.width + width: timelineView.width - Nheko.paddingLarge * 2 TextArea { text: TimelineManager.escapeEmoji(room ? room.roomTopic : "") @@ -188,6 +185,22 @@ Item { } + ImageButton { + id: backToRoomsButton + + anchors.top: parent.top + anchors.left: parent.left + anchors.margins: Nheko.paddingMedium + width: Nheko.avatarSize + height: Nheko.avatarSize + visible: room != null && room.isSpace && showBackButton + enabled: visible + image: ":/icons/icons/ui/angle-pointing-to-left.png" + ToolTip.visible: hovered + ToolTip.text: qsTr("Back to room list") + onClicked: Rooms.resetCurrentRoom() + } + NhekoDropArea { anchors.fill: parent roomid: room ? room.roomId() : "" -- cgit 1.5.1