start initial work on detaching chat to floating window

This commit is contained in:
2026-08-20 20:24:54 +02:00
parent 9657e5092a
commit 37c6a9986e
9 changed files with 190 additions and 29 deletions
@@ -5,6 +5,7 @@ import ZShell.Llm
import QtQuick
import QtQuick.Controls
import Quickshell
import qs.Helpers
import qs.Modules.Notifications.Sidebar
import qs.Components
import qs.Services
@@ -12,26 +13,49 @@ import qs.Services
Item {
id: root
property bool chatOpen: false
required property Props props
anchors.fill: parent
anchors.margins: Tokens.padding.small
Component.onCompleted: {
if (root.props.inChat) {
stack.push(chatList);
stack.push(chatContent, {
"chatData": root.props.chatSession
if (ChatState.inChat) {
stackLoader.item?.push(chatList);
stackLoader.item?.push(chatContent, {
"chatData": ChatState.chatSession
});
} else
stack.push(chatList);
stackLoader.item?.push(chatList);
}
StackView {
id: stack
Loader {
id: stackLoader
active: !ChatState.isWindow || root.width <= (ChatState.screen.width / 4)
anchors.fill: parent
sourceComponent: StackView {
id: stack
}
}
Loader {
id: sidebarViewLoader
active: ChatState.isWindow && root.width > (ChatState.screen.width / 4)
anchors.fill: parent
sourceComponent: SidebarView {
}
}
IconButton {
anchors.right: parent.right
icon: "close"
visible: !ChatState.isWindow
onClicked: {
Detach.create();
Visibilities.getForActive().sidebar = false;
}
}
Component {
@@ -46,19 +70,19 @@ Item {
Chat.chats.remove(chat);
}
onLoadChatRequest: chat => {
stack.push(chatContent, {
stackLoader.item?.push(chatContent, {
"chatData": chat
});
root.props.inChat = true;
root.props.chatSession = chat;
ChatState.inChat = true;
ChatState.chatSession = chat;
}
onNewChatRequest: {
const data = Chat.chats.insert();
stack.push(chatContent, {
stackLoader.item?.push(chatContent, {
"chatData": data
});
root.props.inChat = true;
root.props.chatSession = data;
ChatState.inChat = true;
ChatState.chatSession = data;
}
}
}
@@ -68,8 +92,8 @@ Item {
ChatContent {
onRequestClose: {
stack.pop();
root.props.inChat = false;
stackLoader.item?.pop();
ChatState.inChat = false;
}
}
}