mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +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 {
|
AdaptiveLayoutElement {
|
||||||
id: timlineViewC
|
id: timlineViewC
|
||||||
|
|
||||||
minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2* Nheko.paddingMedium
|
minimumWidth: fontMetrics.averageCharacterWidth * 40 + Nheko.avatarSize + 2 * Nheko.paddingMedium
|
||||||
|
|
||||||
TimelineView {
|
TimelineView {
|
||||||
id: timeline
|
id: timeline
|
||||||
|
|
|
@ -254,9 +254,9 @@ Page {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: timestamp
|
id: timestamp
|
||||||
|
|
||||||
visible: !model.isInvite && !model.isSpace
|
visible: !model.isInvite && !model.isSpace
|
||||||
width: visible ? 0 : undefined
|
width: visible ? 0 : undefined
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
||||||
font.pixelSize: fontMetrics.font.pixelSize * 0.9
|
font.pixelSize: fontMetrics.font.pixelSize * 0.9
|
||||||
color: roomItem.unimportantText
|
color: roomItem.unimportantText
|
||||||
|
|
|
@ -41,7 +41,8 @@ Item {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: timelineLayout
|
id: timelineLayout
|
||||||
|
|
||||||
visible: room != null
|
visible: room != null && !room.isSpace
|
||||||
|
enabled: visible
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
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 {
|
NhekoDropArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
roomid: room ? room.roomId() : ""
|
roomid: room ? room.roomId() : ""
|
||||||
|
|
|
@ -1772,6 +1772,13 @@ Cache::relatedEvents(const std::string &room_id, const std::string &event_id)
|
||||||
return related_ids;
|
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>
|
QMap<QString, RoomInfo>
|
||||||
Cache::roomInfo(bool withInvites)
|
Cache::roomInfo(bool withInvites)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,6 +101,7 @@ public:
|
||||||
std::vector<RoomMember> getMembers(const std::string &room_id,
|
std::vector<RoomMember> getMembers(const std::string &room_id,
|
||||||
std::size_t startIndex = 0,
|
std::size_t startIndex = 0,
|
||||||
std::size_t len = 30);
|
std::size_t len = 30);
|
||||||
|
size_t memberCount(const std::string &room_id);
|
||||||
|
|
||||||
void saveState(const mtx::responses::Sync &res);
|
void saveState(const mtx::responses::Sync &res);
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
|
|
|
@ -774,6 +774,7 @@ TimelineModel::syncState(const mtx::responses::State &s)
|
||||||
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
|
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
|
||||||
emit roomAvatarUrlChanged();
|
emit roomAvatarUrlChanged();
|
||||||
emit roomNameChanged();
|
emit roomNameChanged();
|
||||||
|
emit roomMemberCountChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -830,6 +831,7 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
|
||||||
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
|
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
|
||||||
emit roomAvatarUrlChanged();
|
emit roomAvatarUrlChanged();
|
||||||
emit roomNameChanged();
|
emit roomNameChanged();
|
||||||
|
emit roomMemberCountChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateLastMessage();
|
updateLastMessage();
|
||||||
|
@ -1935,3 +1937,9 @@ TimelineModel::roomTopic() const
|
||||||
return utils::replaceEmoji(utils::linkifyMessage(
|
return utils::replaceEmoji(utils::linkifyMessage(
|
||||||
QString::fromStdString(info[room_id_].topic).toHtmlEscaped()));
|
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 roomName READ roomName NOTIFY roomNameChanged)
|
||||||
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
||||||
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
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(bool isSpace READ isSpace CONSTANT)
|
||||||
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
||||||
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
|
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
|
||||||
|
@ -264,6 +265,7 @@ public:
|
||||||
|
|
||||||
DescInfo lastMessage() const { return lastMessage_; }
|
DescInfo lastMessage() const { return lastMessage_; }
|
||||||
bool isSpace() const { return isSpace_; }
|
bool isSpace() const { return isSpace_; }
|
||||||
|
int roomMemberCount() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
|
@ -350,6 +352,7 @@ signals:
|
||||||
void roomNameChanged();
|
void roomNameChanged();
|
||||||
void roomTopicChanged();
|
void roomTopicChanged();
|
||||||
void roomAvatarUrlChanged();
|
void roomAvatarUrlChanged();
|
||||||
|
void roomMemberCountChanged();
|
||||||
void permissionsChanged();
|
void permissionsChanged();
|
||||||
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue