From 85f3d3b63310cf24d285e1bc10d1dc7b9b9a967d Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Sat, 26 Apr 2025 21:15:23 +0200 Subject: [PATCH] RoomList: Change room on drag enter With a delay. Allows to drag a file to NeoChat and switch rooms. In the future we might want to allow dropping a file onto a room to send it. --- src/rooms/RoomDelegate.qml | 20 ++++++++++++++++++++ src/rooms/RoomListPage.qml | 1 + 2 files changed, 21 insertions(+) diff --git a/src/rooms/RoomDelegate.qml b/src/rooms/RoomDelegate.qml index 932551857..cccd38408 100644 --- a/src/rooms/RoomDelegate.qml +++ b/src/rooms/RoomDelegate.qml @@ -26,12 +26,15 @@ Delegates.RoundedItemDelegate { required property string displayName property bool openOnClick: true + property bool openOnDrag: false property bool showConfigure: true property bool collapsed: false readonly property bool hasNotifications: contextNotificationCount > 0 + dropAreaHovered: dropArea.containsDrag + Accessible.name: root.displayName Accessible.onPressAction: clicked() @@ -57,6 +60,23 @@ Delegates.RoundedItemDelegate { onLongPressed: root.createRoomListContextMenu() } + DropArea { + id: dropArea + enabled: root.openOnDrag + anchors.fill: parent + } + + Timer { + id: dragOpenTimer + running: dropArea.containsDrag + interval: Application.styleHints.mousePressAndHoldInterval + repeat: false + onTriggered: { + RoomManager.resolveResource(currentRoom.id); + pageStack.currentIndex = 1; + } + } + contentItem: RowLayout { spacing: Kirigami.Units.largeSpacing diff --git a/src/rooms/RoomListPage.qml b/src/rooms/RoomListPage.qml index ffb0b1cb5..bcc64fc25 100644 --- a/src/rooms/RoomListPage.qml +++ b/src/rooms/RoomListPage.qml @@ -163,6 +163,7 @@ Kirigami.Page { connection: root.connection collapsed: root.collapsed highlighted: RoomManager.currentRoom === currentRoom + openOnDrag: true } }