diff options
Diffstat (limited to 'desktop/island')
| -rw-r--r-- | desktop/island/Island.qml | 54 | ||||
| -rw-r--r-- | desktop/island/README.md | 9 |
2 files changed, 63 insertions, 0 deletions
diff --git a/desktop/island/Island.qml b/desktop/island/Island.qml index 3dbd36d..4fba033 100644 --- a/desktop/island/Island.qml +++ b/desktop/island/Island.qml @@ -17,6 +17,7 @@ import QtQuick import ".." import "../modules/sound" import "Logic.js" as Logic +import "../assistant/Files.js" as Files // The island: a sliver at the top centre of DP-1 that the two pills slide // out of. The window is a fixed overlay strip that never resizes; the pills @@ -27,6 +28,7 @@ PanelWindow { required property QtObject sound // the sound module's Service required property QtObject drawer // Drawer, for the sound page link + property QtObject asst: null // the assistant canvas, for dropped files screen: Quickshell.screens.find(s => s.name === "DP-1") ?? Quickshell.screens[0] anchors { top: true; left: true; right: true } @@ -147,6 +149,7 @@ PanelWindow { mask: Region { item: sliverHit + Region { item: receptor; intersection: Intersection.Combine } Region { item: clock; intersection: Intersection.Combine } Region { item: status; intersection: Intersection.Combine } Region { item: media.visible ? media : null; intersection: Intersection.Combine } @@ -187,6 +190,57 @@ PanelWindow { hoverEnabled: true } + // --- file drop --------------------------------------------------------- + + // A file dragged onto the sliver opens a bubble to drop it on; the drop + // hands it to the assistant canvas. Wayland reports a drag only once it + // enters an input region, so the receptor is the sliver's width at rest + // and grows to hold the bubble while a drag is over it. + property bool dropHold: false + + Item { + id: receptor + x: win.cx - width / 2 + y: 0 + z: 10 + width: 260 + height: win.dropHold ? 100 : 10 + + DropArea { + anchors.fill: parent + enabled: win.asst !== null + onEntered: drag => { + drag.accepted = drag.hasUrls && (drag.supportedActions & Qt.CopyAction); + if (drag.accepted) { win.dropHold = true; drag.accept(Qt.CopyAction); } + } + onExited: win.dropHold = false + onDropped: drop => { + win.dropHold = false; + const paths = drop.urls.map(u => Files.fromUrl(u)).filter(p => p !== ""); + if (!paths.length) { drop.accepted = false; return; } + win.asst.attach(paths); + drop.accept(Qt.CopyAction); + } + } + + Rectangle { + visible: win.dropHold + anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 14 } + width: parent.width + height: 72 + radius: 16 + color: Qt.alpha(Theme.base, 0.9) + border.width: 1 + border.color: Qt.alpha(Theme.accent, 0.6) + Text { + anchors.centerIn: parent + text: "Drop for the assistant" + color: Theme.text + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + } + } + } + // Both pills start overlapped at the sliver, above the screen edge, and // travel down and apart. At reveal 1 the clock ends gap/2 left of the // centre and the status gap/2 right of it; the status pill's left edge diff --git a/desktop/island/README.md b/desktop/island/README.md index 1511279..3387e2b 100644 --- a/desktop/island/README.md +++ b/desktop/island/README.md @@ -131,3 +131,12 @@ The window sets namespace `quickshell-island`. For frosting, add to }) Without it the island renders flat translucent. + +## File drop + +A file dragged onto the sliver opens a bubble, "Drop for the assistant"; +dropping on it hands the file to the assistant canvas, which opens in its +file state with a new conversation. Wayland reports a drag only once it +enters one of the surface's input regions, so the receptor is the sliver's +width at rest and grows to hold the bubble while a drag is over it. Only +`file://` URLs are taken. |
