mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add a basic 'Space page'
This commit is contained in:
parent
c69d2ef648
commit
884fb74d2d
7 changed files with 83 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() : ""
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue