diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-28 22:14:59 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-05-28 22:14:59 +0200 |
commit | 298822baeaffdc83386e003099e34819bcd7d18c (patch) | |
tree | 1caa2bc8475385b1743c9c82a8d98caae3e374fb /resources | |
parent | e2765212fb229e8d025d2255314a04a376207749 (diff) |
Move currentRoom/timeline handling to roomlist
Diffstat (limited to 'resources')
-rw-r--r-- | resources/qml/ChatPage.qml | 1 | ||||
-rw-r--r-- | resources/qml/Completer.qml | 6 | ||||
-rw-r--r-- | resources/qml/ForwardCompleter.qml | 4 | ||||
-rw-r--r-- | resources/qml/MessageInput.qml | 62 | ||||
-rw-r--r-- | resources/qml/MessageView.qml | 140 | ||||
-rw-r--r-- | resources/qml/QuickSwitcher.qml | 3 | ||||
-rw-r--r-- | resources/qml/Reactions.qml | 2 | ||||
-rw-r--r-- | resources/qml/ReplyPopup.qml | 2 | ||||
-rw-r--r-- | resources/qml/RoomList.qml | 21 | ||||
-rw-r--r-- | resources/qml/Root.qml | 147 | ||||
-rw-r--r-- | resources/qml/StatusIndicator.qml | 2 | ||||
-rw-r--r-- | resources/qml/TimelineView.qml | 22 | ||||
-rw-r--r-- | resources/qml/TopBar.qml | 14 | ||||
-rw-r--r-- | resources/qml/TypingIndicator.qml | 2 | ||||
-rw-r--r-- | resources/qml/delegates/FileMessage.qml | 2 | ||||
-rw-r--r-- | resources/qml/delegates/MessageDelegate.qml | 10 | ||||
-rw-r--r-- | resources/qml/delegates/PlayableMediaMessage.qml | 4 | ||||
-rw-r--r-- | resources/qml/emoji/EmojiButton.qml | 2 | ||||
-rw-r--r-- | resources/qml/voip/ActiveCallBar.qml | 2 | ||||
-rw-r--r-- | resources/qml/voip/CallInviteBar.qml | 2 | ||||
-rw-r--r-- | resources/qml/voip/PlaceCall.qml | 12 | ||||
-rw-r--r-- | resources/qml/voip/ScreenShare.qml | 4 |
22 files changed, 236 insertions, 230 deletions
diff --git a/resources/qml/ChatPage.qml b/resources/qml/ChatPage.qml index fc6137a6..966f169b 100644 --- a/resources/qml/ChatPage.qml +++ b/resources/qml/ChatPage.qml @@ -31,6 +31,7 @@ Rectangle { TimelineView { id: timeline + room: Rooms.currentRoom SplitView.fillWidth: true SplitView.minimumWidth: 400 diff --git a/resources/qml/Completer.qml b/resources/qml/Completer.qml index 2609371b..0cdd789d 100644 --- a/resources/qml/Completer.qml +++ b/resources/qml/Completer.qml @@ -70,7 +70,7 @@ Popup { onCompleterNameChanged: { if (completerName) { if (completerName == "user") - completer = TimelineManager.completerFor(completerName, TimelineManager.timeline.roomId()); + completer = TimelineManager.completerFor(completerName, room.roomId()); else completer = TimelineManager.completerFor(completerName); completer.setSearchString(""); @@ -83,8 +83,8 @@ Popup { height: listView.contentHeight + 2 // + 2 for the padding on top and bottom Connections { - onTimelineChanged: completer = null - target: TimelineManager + onRoomChanged: completer = null + target: timelineView } ListView { diff --git a/resources/qml/ForwardCompleter.qml b/resources/qml/ForwardCompleter.qml index 1ec18540..eee3879c 100644 --- a/resources/qml/ForwardCompleter.qml +++ b/resources/qml/ForwardCompleter.qml @@ -50,7 +50,7 @@ Popup { Reply { id: replyPreview - modelData: TimelineManager.timeline ? TimelineManager.timeline.getDump(mid, "") : { + modelData: room ? room.getDump(mid, "") : { } userColor: TimelineManager.userColor(modelData.userId, Nheko.colors.window) } @@ -95,7 +95,7 @@ Popup { Connections { onCompletionSelected: { - TimelineManager.timeline.forwardMessage(messageContextMenu.eventId, id); + room.forwardMessage(messageContextMenu.eventId, id); forwardMessagePopup.close(); } onCountChanged: { diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index f4e253ad..24f9b0e8 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -28,7 +28,7 @@ Rectangle { RowLayout { id: row - visible: (TimelineManager.timeline ? TimelineManager.timeline.permissions.canSend(MtxEvent.TextMessage) : false) || messageContextMenu.isSender + visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false anchors.fill: parent ImageButton { @@ -43,7 +43,7 @@ Rectangle { ToolTip.text: CallManager.isOnCall ? qsTr("Hang up") : qsTr("Place a call") Layout.margins: 8 onClicked: { - if (TimelineManager.timeline) { + if (room) { if (CallManager.haveCallInvite) { return ; } else if (CallManager.isOnCall) { @@ -63,14 +63,14 @@ Rectangle { height: 22 image: ":/icons/icons/ui/paper-clip-outline.png" Layout.margins: 8 - onClicked: TimelineManager.timeline.input.openFileSelection() + onClicked: room.input.openFileSelection() ToolTip.visible: hovered ToolTip.text: qsTr("Send a file") Rectangle { anchors.fill: parent color: Nheko.colors.window - visible: TimelineManager.timeline && TimelineManager.timeline.input.uploading + visible: room && room.input.uploading NhekoBusyIndicator { anchors.fill: parent @@ -123,16 +123,16 @@ Rectangle { padding: 8 focus: true onTextChanged: { - if (TimelineManager.timeline) - TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text); + if (room) + room.input.updateState(selectionStart, selectionEnd, cursorPosition, text); forceActiveFocus(); } onCursorPositionChanged: { - if (!TimelineManager.timeline) + if (!room) return ; - TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text); + room.input.updateState(selectionStart, selectionEnd, cursorPosition, text); if (cursorPosition <= completerTriggeredAt) { completerTriggeredAt = -1; popup.close(); @@ -141,13 +141,13 @@ Rectangle { popup.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)); } - onSelectionStartChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) - onSelectionEndChanged: TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) + onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text) // Ensure that we get escape key press events first. Keys.onShortcutOverride: event.accepted = (completerTriggeredAt != -1 && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter)) Keys.onPressed: { if (event.matches(StandardKey.Paste)) { - TimelineManager.timeline.input.paste(false); + room.input.paste(false); event.accepted = true; } else if (event.key == Qt.Key_Space) { // close popup if user enters space after colon @@ -160,9 +160,9 @@ Rectangle { } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_U) { messageInput.clear(); } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_P) { - messageInput.text = TimelineManager.timeline.input.previousText(); + messageInput.text = room.input.previousText(); } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) { - messageInput.text = TimelineManager.timeline.input.nextText(); + messageInput.text = room.input.nextText(); } else if (event.key == Qt.Key_At) { messageInput.openCompleter(cursorPosition, "user"); popup.open(); @@ -188,7 +188,7 @@ Rectangle { return ; } } - TimelineManager.timeline.input.send(); + room.input.send(); event.accepted = true; } else if (event.key == Qt.Key_Tab) { event.accepted = true; @@ -223,11 +223,11 @@ Rectangle { } else if (event.key == Qt.Key_Up && event.modifiers == Qt.NoModifier) { if (cursorPosition == 0) { event.accepted = true; - var idx = TimelineManager.timeline.edit ? TimelineManager.timeline.idToIndex(TimelineManager.timeline.edit) + 1 : 0; + var idx = room.edit ? room.idToIndex(room.edit) + 1 : 0; while (true) { - var id = TimelineManager.timeline.indexToId(idx); - if (!id || TimelineManager.timeline.getDump(id, "").isEditable) { - TimelineManager.timeline.edit = id; + var id = room.indexToId(idx); + if (!id || room.getDump(id, "").isEditable) { + room.edit = id; cursorPosition = 0; Qt.callLater(positionCursorAtEnd); break; @@ -239,13 +239,13 @@ Rectangle { positionCursorAtStart(); } } else if (event.key == Qt.Key_Down && event.modifiers == Qt.NoModifier) { - if (cursorPosition == messageInput.length && TimelineManager.timeline.edit) { + if (cursorPosition == messageInput.length && room.edit) { event.accepted = true; - var idx = TimelineManager.timeline.idToIndex(TimelineManager.timeline.edit) - 1; + var idx = room.idToIndex(room.edit) - 1; while (true) { - var id = TimelineManager.timeline.indexToId(idx); - if (!id || TimelineManager.timeline.getDump(id, "").isEditable) { - TimelineManager.timeline.edit = id; + var id = room.indexToId(idx); + if (!id || room.getDump(id, "").isEditable) { + room.edit = id; Qt.callLater(positionCursorAtStart); break; } @@ -260,14 +260,14 @@ Rectangle { background: null Connections { - onActiveTimelineChanged: { + onRoomChanged: { messageInput.clear(); - messageInput.append(TimelineManager.timeline.input.text()); + messageInput.append(room.input.text()); messageInput.completerTriggeredAt = -1; popup.completerName = ""; messageInput.forceActiveFocus(); } - target: TimelineManager + target: timelineView } Connections { @@ -292,14 +292,14 @@ Rectangle { messageInput.text = newText; messageInput.cursorPosition = newText.length; } - target: TimelineManager.timeline ? TimelineManager.timeline.input : null + target: room ? room.input : null } Connections { ignoreUnknownSignals: true onReplyChanged: messageInput.forceActiveFocus() onEditChanged: messageInput.forceActiveFocus() - target: TimelineManager.timeline + target: room } Connections { @@ -312,7 +312,7 @@ Rectangle { anchors.fill: parent acceptedButtons: Qt.MiddleButton cursorShape: Qt.IBeamCursor - onClicked: TimelineManager.timeline.input.paste(true) + onClicked: room.input.paste(true) } } @@ -347,7 +347,7 @@ Rectangle { ToolTip.visible: hovered ToolTip.text: qsTr("Send") onClicked: { - TimelineManager.timeline.input.send(); + room.input.send(); } } @@ -355,7 +355,7 @@ Rectangle { Text { anchors.centerIn: parent - visible: TimelineManager.timeline ? (!TimelineManager.timeline.permissions.canSend(MtxEvent.TextMessage)) : false + visible: room ? (!room.permissions.canSend(MtxEvent.TextMessage)) : false text: qsTr("You don't have permission to send messages in this room") color: Nheko.colors.text } diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 5af4e4de..176905db 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -4,6 +4,7 @@ import "./delegates" import "./emoji" +import Qt.labs.platform 1.1 as Platform import QtGraphicalEffects 1.0 import QtQuick 2.12 import QtQuick.Controls 2.3 @@ -22,7 +23,7 @@ ScrollView { property int delegateMaxWidth: ((Settings.timelineMaxWidth > 100 && Settings.timelineMaxWidth < parent.availableWidth) ? Settings.timelineMaxWidth : parent.availableWidth) - parent.padding * 2 - model: TimelineManager.timeline + model: room boundsBehavior: Flickable.StopAtBounds pixelAligned: true spacing: 4 @@ -413,4 +414,141 @@ ScrollView { } + Platform.Menu { + id: messageContextMenu + + property string eventId + property string link + property string text + property int eventType + property bool isEncrypted + property bool isEditable + property bool isSender + + function show(eventId_, eventType_, isSender_, isEncrypted_, isEditable_, link_, text_, showAt_) { + eventId = eventId_; + eventType = eventType_; + isEncrypted = isEncrypted_; + isEditable = isEditable_; + isSender = isSender_; + if (text_) + text = text_; + else + text = ""; + if (link_) + link = link_; + else + link = ""; + if (showAt_) + open(showAt_); + else + open(); + } + + Platform.MenuItem { + visible: messageContextMenu.text + enabled: visible + text: qsTr("Copy") + onTriggered: Clipboard.text = messageContextMenu.text + } + + Platform.MenuItem { + visible: messageContextMenu.link + enabled: visible + text: qsTr("Copy link location") + onTriggered: Clipboard.text = messageContextMenu.link + } + + Platform.MenuItem { + id: reactionOption + + visible: room ? room.permissions.canSend(MtxEvent.Reaction) : false + text: qsTr("React") + onTriggered: emojiPopup.show(null, function(emoji) { + room.input.reaction(messageContextMenu.eventId, emoji); + }) + } + + Platform.MenuItem { + visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false + text: qsTr("Reply") + onTriggered: room.replyAction(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: messageContextMenu.isEditable && (room ? room.permissions.canSend(MtxEvent.TextMessage) : false) + enabled: visible + text: qsTr("Edit") + onTriggered: room.editAction(messageContextMenu.eventId) + } + + Platform.MenuItem { + text: qsTr("Read receipts") + onTriggered: room.readReceiptsAction(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker || messageContextMenu.eventType == MtxEvent.TextMessage || messageContextMenu.eventType == MtxEvent.LocationMessage || messageContextMenu.eventType == MtxEvent.EmoteMessage || messageContextMenu.eventType == MtxEvent.NoticeMessage + text: qsTr("Forward") + onTriggered: { + var forwardMess = forwardCompleterComponent.createObject(timelineRoot); + forwardMess.setMessageEventId(messageContextMenu.eventId); + forwardMess.open(); + } + } + + Platform.MenuItem { + text: qsTr("Mark as read") + } + + Platform.MenuItem { + text: qsTr("View raw message") + onTriggered: room.viewRawMessage(messageContextMenu.eventId) + } + + Platform.MenuItem { + // TODO(Nico): Fix this still being iterated over, when using keyboard to select options + visible: messageContextMenu.isEncrypted + enabled: visible + text: qsTr("View decrypted raw message") + onTriggered: room.viewDecryptedRawMessage(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: (room ? room.permissions.canRedact() : false) || messageContextMenu.isSender + text: qsTr("Remove message") + onTriggered: room.redactEvent(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker + enabled: visible + text: qsTr("Save as") + onTriggered: room.saveMedia(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker + enabled: visible + text: qsTr("Open in external program") + onTriggered: room.openMedia(messageContextMenu.eventId) + } + + Platform.MenuItem { + visible: messageContextMenu.eventId + enabled: visible + text: qsTr("Copy link to event") + onTriggered: room.copyLinkToEvent(messageContextMenu.eventId) + } + + } + + Component { + id: forwardCompleterComponent + + ForwardCompleter { + } + + } + } diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml index a6373b1c..8c4f47ca 100644 --- a/resources/qml/QuickSwitcher.qml +++ b/resources/qml/QuickSwitcher.qml @@ -72,8 +72,7 @@ Popup { Connections { onCompletionSelected: { - TimelineManager.setHistoryView(id); - TimelineManager.highlightRoom(id); + Rooms.setCurrentRoom(id); quickSwitcher.close(); } onCountChanged: { diff --git a/resources/qml/Reactions.qml b/resources/qml/Reactions.qml index 064df543..def87f75 100644 --- a/resources/qml/Reactions.qml +++ b/resources/qml/Reactions.qml @@ -35,7 +35,7 @@ Flow { ToolTip.text: modelData.users onClicked: { console.debug("Picked " + modelData.key + "in response to " + reactionFlow.eventId + ". selfReactedEvent: " + modelData.selfReactedEvent); - TimelineManager.queueReactionMessage(reactionFlow.eventId, modelData.key); + room.input.reaction(reactionFlow.eventId, modelData.key); } contentItem: Row { diff --git a/resources/qml/ReplyPopup.qml b/resources/qml/ReplyPopup.qml index 1d85acb0..0de68fe8 100644 --- a/resources/qml/ReplyPopup.qml +++ b/resources/qml/ReplyPopup.qml @@ -11,8 +11,6 @@ import im.nheko 1.0 Rectangle { id: replyPopup - property var room: TimelineManager.timeline - Layout.fillWidth: true visible: room && (room.reply || room.edit) // Height of child, plus margins, plus border diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml index b184aef0..c5e07032 100644 --- a/resources/qml/RoomList.qml +++ b/resources/qml/RoomList.qml @@ -149,7 +149,7 @@ Page { }, State { name: "selected" - when: TimelineManager.timeline && model.roomId == TimelineManager.timeline.roomId() + when: Rooms.currentRoom && model.roomId == Rooms.currentRoom.roomId() PropertyChanges { target: roomItem @@ -165,16 +165,25 @@ Page { TapHandler { acceptedButtons: Qt.RightButton - onSingleTapped: roomContextMenu.show(model.roomId, model.tags) + onSingleTapped: { + if (!TimelineManager.isInvite) { + roomContextMenu.show(model.roomId, model.tags); + } + } gesturePolicy: TapHandler.ReleaseWithinBounds } - HoverHandler { - id: hovered + TapHandler { + onSingleTapped: Rooms.setCurrentRoom(model.roomId) + onLongPressed: { + if (!TimelineManager.isInvite) { + roomContextMenu.show(model.roomId, model.tags); + } + } } - TapHandler { - onSingleTapped: TimelineManager.setHistoryView(model.roomId) + HoverHandler { + id: hovered } RowLayout { diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index 35b81a1f..a8b6fa52 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -63,14 +63,6 @@ Page { } - Component { - id: forwardCompleterComponent - - ForwardCompleter { - } - - } - Shortcut { sequence: "Ctrl+K" onActivated: { @@ -80,135 +72,6 @@ Page { } } - Platform.Menu { - id: messageContextMenu - - property string eventId - property string link - property string text - property int eventType - property bool isEncrypted - property bool isEditable - property bool isSender - - function show(eventId_, eventType_, isSender_, isEncrypted_, isEditable_, link_, text_, showAt_) { - eventId = eventId_; - eventType = eventType_; - isEncrypted = isEncrypted_; - isEditable = isEditable_; - isSender = isSender_; - if (text_) - text = text_; - else - text = ""; - if (link_) - link = link_; - else - link = ""; - if (showAt_) - open(showAt_); - else - open(); - } - - Platform.MenuItem { - visible: messageContextMenu.text - enabled: visible - text: qsTr("Copy") - onTriggered: Clipboard.text = messageContextMenu.text - } - - Platform.MenuItem { - visible: messageContextMenu.link - enabled: visible - text: qsTr("Copy link location") - onTriggered: Clipboard.text = messageContextMenu.link - } - - Platform.MenuItem { - id: reactionOption - - visible: TimelineManager.timeline ? TimelineManager.timeline.permissions.canSend(MtxEvent.Reaction) : false - text: qsTr("React") - onTriggered: emojiPopup.show(null, function(emoji) { - TimelineManager.queueReactionMessage(messageContextMenu.eventId, emoji); - }) - } - - Platform.MenuItem { - visible: TimelineManager.timeline ? TimelineManager.timeline.permissions.canSend(MtxEvent.TextMessage) : false - text: qsTr("Reply") - onTriggered: TimelineManager.timeline.replyAction(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: messageContextMenu.isEditable && (TimelineManager.timeline ? TimelineManager.timeline.permissions.canSend(MtxEvent.TextMessage) : false) - enabled: visible - text: qsTr("Edit") - onTriggered: TimelineManager.timeline.editAction(messageContextMenu.eventId) - } - - Platform.MenuItem { - text: qsTr("Read receipts") - onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker || messageContextMenu.eventType == MtxEvent.TextMessage || messageContextMenu.eventType == MtxEvent.LocationMessage || messageContextMenu.eventType == MtxEvent.EmoteMessage || messageContextMenu.eventType == MtxEvent.NoticeMessage - text: qsTr("Forward") - onTriggered: { - var forwardMess = forwardCompleterComponent.createObject(timelineRoot); - forwardMess.setMessageEventId(messageContextMenu.eventId); - forwardMess.open(); - } - } - - Platform.MenuItem { - text: qsTr("Mark as read") - } - - Platform.MenuItem { - text: qsTr("View raw message") - onTriggered: TimelineManager.timeline.viewRawMessage(messageContextMenu.eventId) - } - - Platform.MenuItem { - // TODO(Nico): Fix this still being iterated over, when using keyboard to select options - visible: messageContextMenu.isEncrypted - enabled: visible - text: qsTr("View decrypted raw message") - onTriggered: TimelineManager.timeline.viewDecryptedRawMessage(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: (TimelineManager.timeline ? TimelineManager.timeline.permissions.canRedact() : false) || messageContextMenu.isSender - text: qsTr("Remove message") - onTriggered: TimelineManager.timeline.redactEvent(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker - enabled: visible - text: qsTr("Save as") - onTriggered: TimelineManager.timeline.saveMedia(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: messageContextMenu.eventType == MtxEvent.ImageMessage || messageContextMenu.eventType == MtxEvent.VideoMessage || messageContextMenu.eventType == MtxEvent.AudioMessage || messageContextMenu.eventType == MtxEvent.FileMessage || messageContextMenu.eventType == MtxEvent.Sticker - enabled: visible - text: qsTr("Open in external program") - onTriggered: TimelineManager.timeline.openMedia(messageContextMenu.eventId) - } - - Platform.MenuItem { - visible: messageContextMenu.eventId - enabled: visible - text: qsTr("Copy link to event") - onTriggered: TimelineManager.timeline.copyLinkToEvent(messageContextMenu.eventId) - } - - } - Component { id: deviceVerificationDialog @@ -234,16 +97,6 @@ Page { } Connections { - target: TimelineManager.timeline - onOpenRoomSettingsDialog: { - var roomSettings = roomSettingsComponent.createObject(timelineRoot, { - "roomSettings": settings - }); - roomSettings.show(); - } - } - - Connections { target: CallManager onNewInviteState: { if (CallManager.haveCallInvite && Settings.mobileMode) { diff --git a/resources/qml/StatusIndicator.qml b/resources/qml/StatusIndicator.qml index 3d2d8278..739cc007 100644 --- a/resources/qml/StatusIndicator.qml +++ b/resources/qml/StatusIndicator.qml @@ -31,7 +31,7 @@ ImageButton { } onClicked: { if (model.state == MtxEvent.Read) - TimelineManager.timeline.readReceiptsAction(model.id); + room.readReceiptsAction(model.id); } image: { diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 257d670d..747be61e 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -18,8 +18,10 @@ import im.nheko.EmojiModel 1.0 Item { id: timelineView + property var room: null + Label { - visible: !TimelineManager.timeline && !TimelineManager.isInitialSync + visible: !room && !TimelineManager.isInitialSync anchors.centerIn: parent text: qsTr("No room open") font.pointSize: 24 @@ -38,7 +40,7 @@ Item { ColumnLayout { id: timelineLayout - visible: TimelineManager.timeline != null + visible: room != null anchors.fill: parent spacing: 0 @@ -69,11 +71,11 @@ Item { currentIndex: 0 Connections { - function onActiveTimelineChanged() { + function onRoomChanged() { stackLayout.currentIndex = 0; } - target: TimelineManager + target: timelineView } MessageView { @@ -125,7 +127,17 @@ Item { NhekoDropArea { anchors.fill: parent - roomid: TimelineManager.timeline ? TimelineManager.timeline.roomId() : "" + roomid: room ? room.roomId() : "" + } + + Connections { + target: room + onOpenRoomSettingsDialog: { + var roomSettings = roomSettingsComponent.createObject(timelineRoot, { + "roomSettings": settings + }); + roomSettings.show(); + } } } diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index bda5ce14..65e27939 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -11,8 +11,6 @@ import im.nheko 1.0 Rectangle { id: topBar - property var room: TimelineManager.timeline - Layout.fillWidth: true implicitHeight: topLayout.height + Nheko.paddingMedium * 2 z: 3 @@ -20,7 +18,7 @@ Rectangle { TapHandler { onSingleTapped: { - TimelineManager.timeline.openRoomSettings(); + room.openRoomSettings(); eventPoint.accepted = true; } gesturePolicy: TapHandler.ReleaseWithinBounds @@ -61,7 +59,7 @@ Rectangle { height: Nheko.avatarSize url: room ? room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") : "" displayName: room ? room.roomName : qsTr("No room selected") - onClicked: TimelineManager.timeline.openRoomSettings() + onClicked: room.openRoomSettings() } Label { @@ -101,24 +99,24 @@ Rectangle { id: roomOptionsMenu Platform.MenuItem { - visible: TimelineManager.timeline ? TimelineManager.timeline.permissions.canInvite() : false + visible: room ? room.permissions.canInvite() : false text: qsTr("Invite users") onTriggered: TimelineManager.openInviteUsersDialog() } Platform.MenuItem { text: qsTr("Members") - onTriggered: TimelineManager.openMemberListDialog() + onTriggered: TimelineManager.openMemberListDialog(room.roomId()) } Platform.MenuItem { text: qsTr("Leave room") - onTriggered: TimelineManager.openLeaveRoomDialog() + onTriggered: TimelineManager.openLeaveRoomDialog(room.roomId()) } Platform.MenuItem { text: qsTr("Settings") - onTriggered: TimelineManager.timeline.openRoomSettings() + onTriggered: room.openRoomSettings() } } diff --git a/resources/qml/TypingIndicator.qml b/resources/qml/TypingIndicator.qml index 783a9ebc..974d1840 100644 --- a/resources/qml/TypingIndicator.qml +++ b/resources/qml/TypingIndicator.qml @@ -8,8 +8,6 @@ import QtQuick.Layouts 1.2 import im.nheko 1.0 Item { - property var room: TimelineManager.timeline - implicitHeight: Math.max(fontMetrics.height * 1.2, typingDisplay.height) Layout.fillWidth: true diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 2e5f33c2..0392c73a 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -34,7 +34,7 @@ Item { } TapHandler { - onSingleTapped: TimelineManager.timeline.saveMedia(model.data.id) + onSingleTapped: room.saveMedia(model.data.id) gesturePolicy: TapHandler.ReleaseWithinBounds } diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 4e6a73fe..9e076a7a 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -207,7 +207,7 @@ Item { roleValue: MtxEvent.PowerLevels NoticeMessage { - text: TimelineManager.timeline.formatPowerLevelEvent(model.data.id) + text: room.formatPowerLevelEvent(model.data.id) } } @@ -216,7 +216,7 @@ Item { roleValue: MtxEvent.RoomJoinRules NoticeMessage { - text: TimelineManager.timeline.formatJoinRuleEvent(model.data.id) + text: room.formatJoinRuleEvent(model.data.id) } } @@ -225,7 +225,7 @@ Item { roleValue: MtxEvent.RoomHistoryVisibility NoticeMessage { - text: TimelineManager.timeline.formatHistoryVisibilityEvent(model.data.id) + text: room.formatHistoryVisibilityEvent(model.data.id) } } @@ -234,7 +234,7 @@ Item { roleValue: MtxEvent.RoomGuestAccess NoticeMessage { - text: TimelineManager.timeline.formatGuestAccessEvent(model.data.id) + text: room.formatGuestAccessEvent(model.data.id) } } @@ -243,7 +243,7 @@ Item { roleValue: MtxEvent.Member NoticeMessage { - text: TimelineManager.timeline.formatMemberEvent(model.data.id) + text: room.formatMemberEvent(model.data.id) } } diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index 0234495d..83864db9 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -121,7 +121,7 @@ Rectangle { onClicked: { switch (button.state) { case "": - TimelineManager.timeline.cacheMedia(model.data.id); + room.cacheMedia(model.data.id); break; case "stopped": media.play(); @@ -174,7 +174,7 @@ Rectangle { } Connections { - target: TimelineManager.timeline + target: room onMediaCached: { if (mxcUrl == model.data.url) { media.source = cacheUrl; diff --git a/resources/qml/emoji/EmojiButton.qml b/resources/qml/emoji/EmojiButton.qml index cec51d75..5f4d23d3 100644 --- a/resources/qml/emoji/EmojiButton.qml +++ b/resources/qml/emoji/EmojiButton.qml @@ -17,7 +17,7 @@ ImageButton { image: ":/icons/icons/ui/smile.png" onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, function(emoji) { - TimelineManager.queueReactionMessage(event_id, emoji); + room.input.reaction(event_id, emoji); TimelineManager.focusMessageInput(); }) } diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 5798433a..3106c382 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -35,7 +35,7 @@ Rectangle { height: Nheko.avatarSize url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: CallManager.callParty - onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) + onClicked: TimelineManager.openImageOverlay(room.avatarUrl(userid), room.data.id) } Label { diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index a169aca9..2d8e3040 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -42,7 +42,7 @@ Rectangle { height: Nheko.avatarSize url: CallManager.callPartyAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: CallManager.callParty - onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) + onClicked: TimelineManager.openImageOverlay(room.avatarUrl(userid), room.data.id) } Label { diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 7e2146cb..97e39e02 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -45,7 +45,7 @@ Popup { Layout.leftMargin: 8 Label { - text: qsTr("Place a call to %1?").arg(TimelineManager.timeline.roomName) + text: qsTr("Place a call to %1?").arg(room.roomName) color: Nheko.colors.windowText } @@ -77,9 +77,9 @@ Popup { Layout.rightMargin: cameraCombo.visible ? 16 : 64 width: Nheko.avatarSize height: Nheko.avatarSize - url: TimelineManager.timeline.roomAvatarUrl.replace("mxc://", "image://MxcImage/") - displayName: TimelineManager.timeline.roomName - onClicked: TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id) + url: room.roomAvatarUrl.replace("mxc://", "image://MxcImage/") + displayName: room.roomName + onClicked: TimelineManager.openImageOverlay(room.avatarUrl(userid), room.data.id) } Button { @@ -88,7 +88,7 @@ Popup { onClicked: { if (buttonLayout.validateMic()) { Settings.microphone = micCombo.currentText; - CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.VOICE); + CallManager.sendInvite(room.roomId(), CallType.VOICE); close(); } } @@ -102,7 +102,7 @@ Popup { if (buttonLayout.validateMic()) { Settings.microphone = micCombo.currentText; Settings.camera = cameraCombo.currentText; - CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.VIDEO); + CallManager.sendInvite(room.roomId(), CallType.VIDEO); close(); } } diff --git a/resources/qml/voip/ScreenShare.qml b/resources/qml/voip/ScreenShare.qml index 258ac9b0..a10057b2 100644 --- a/resources/qml/voip/ScreenShare.qml +++ b/resources/qml/voip/ScreenShare.qml @@ -27,7 +27,7 @@ Popup { Layout.leftMargin: 8 Layout.rightMargin: 8 Layout.alignment: Qt.AlignLeft - text: qsTr("Share desktop with %1?").arg(TimelineManager.timeline.roomName) + text: qsTr("Share desktop with %1?").arg(room.roomName) color: Nheko.colors.windowText } @@ -136,7 +136,7 @@ Popup { Settings.screenSharePiP = pipCheckBox.checked; Settings.screenShareRemoteVideo = remoteVideoCheckBox.checked; Settings.screenShareHideCursor = hideCursorCheckBox.checked; - CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.SCREEN, windowCombo.currentIndex); + CallManager.sendInvite(room.roomId(), CallType.SCREEN, windowCombo.currentIndex); close(); } } |