diff --git a/qml/Room.qml b/qml/Room.qml index b82483b..9a8e3f7 100644 --- a/qml/Room.qml +++ b/qml/Room.qml @@ -31,6 +31,8 @@ Page { Layout.maximumWidth: 360 listModel: roomListModel + + onEnterRoom: roomForm.currentRoom = currentRoom } RoomForm { @@ -38,8 +40,6 @@ Page { Layout.fillWidth: true Layout.fillHeight: true - - currentRoom: roomListForm.currentRoom } } } diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index 767e100..11fdd3c 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -10,7 +10,7 @@ import "qrc:/js/md.js" as Markdown Item { id: item - property var currentRoom + property var currentRoom: null Pane { anchors.fill: parent diff --git a/qml/form/RoomListForm.qml b/qml/form/RoomListForm.qml index 754a4e9..1cef370 100644 --- a/qml/form/RoomListForm.qml +++ b/qml/form/RoomListForm.qml @@ -14,6 +14,7 @@ Item { readonly property int currentIndex: roomListProxyModel.mapToSource(listView.currentIndex) readonly property var currentRoom: currentIndex != -1 ? listModel.roomAt(currentIndex) : null readonly property bool mini: setting.miniMode // Used as an indicator of whether the listform should be displayed as "Mini mode". + signal enterRoom() ColumnLayout { anchors.fill: parent @@ -37,7 +38,7 @@ Item { bottomPadding: 0 anchors.verticalCenter: parent.verticalCenter - background: Item { + background: Item { Row { anchors.fill: parent @@ -137,6 +138,7 @@ Item { width: parent.width height: 80 onPressed: listView.currentIndex = index + onClicked: enterRoom() onPressAndHold: menuComponent.createObject(this) ToolTip.visible: mini && hovered @@ -208,6 +210,10 @@ Item { onTriggered: currentRoom.isLowPriority ? currentRoom.removeTag("m.lowpriority") : currentRoom.addTag("m.lowpriority", "1") } MenuSeparator {} + MenuItem { + text: "Mark as Read" + onTriggered: currentRoom.markAllMessagesAsRead() + } MenuItem { text: "Leave Room" onTriggered: matriqueController.forgetRoom(currentRoom.id) diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index 8b65951..49029f3 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -60,19 +60,20 @@ void RoomListModel::connectRoomSignals(Room* room) { connect(room, &Room::avatarChanged, this, [=] { refresh(room, {AvatarRole}); }); - connect(room, &Room::unreadMessagesChanged, this, [=](Room* r) { - if (r->hasUnreadMessages()) emit newMessage(r); - }); -// connect( -// room, &QMatrixClient::Room::aboutToAddNewMessages, this, -// [=](QMatrixClient::RoomEventsRange eventsRange) { -// for (QMatrixClient::RoomEvents events : eventsRange.const_iterator) { -// for (QMatrixClient::RoomEvent event : events) { -// qDebug() << event.fullJson(); -// } -// } -// emit newMessage(room); -// }); + connect(room, &Room::unreadMessagesChanged, this, [=](Room* r) { + if (r->hasUnreadMessages()) emit newMessage(r); + }); + // connect( + // room, &QMatrixClient::Room::aboutToAddNewMessages, this, + // [=](QMatrixClient::RoomEventsRange eventsRange) { + // for (QMatrixClient::RoomEvents events : eventsRange.const_iterator) + // { + // for (QMatrixClient::RoomEvent event : events) { + // qDebug() << event.fullJson(); + // } + // } + // emit newMessage(room); + // }); } void RoomListModel::updateRoom(Room* room, Room* prev) { @@ -160,7 +161,7 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const { return QVariant(); } if (role == UnreadCountRole) { - return room->unreadCount(); + return room->unreadCount(); } return QVariant(); } diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 5f619fa..fb4d02f 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -18,7 +18,7 @@ class RoomListModel : public QAbstractListModel { TopicRole, CategoryRole, HighlightRole, - UnreadCountRole, + UnreadCountRole }; RoomListModel(QObject* parent = 0);