101 lines
1.7 KiB
QML
101 lines
1.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import ZShell.Config
|
|
import ZShell.Llm
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import Quickshell
|
|
import qs.Helpers
|
|
import qs.Modules.Notifications.Sidebar
|
|
import qs.Components
|
|
import qs.Services
|
|
|
|
Item {
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
anchors.margins: Tokens.padding.small
|
|
|
|
Component.onCompleted: {
|
|
if (ChatState.inChat) {
|
|
stackLoader.item?.push(chatList);
|
|
stackLoader.item?.push(chatContent, {
|
|
"chatData": ChatState.chatSession
|
|
});
|
|
} else
|
|
stackLoader.item?.push(chatList);
|
|
}
|
|
|
|
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 {
|
|
id: chatList
|
|
|
|
ChatList {
|
|
model: ScriptModel {
|
|
values: Chat.chats.values
|
|
}
|
|
|
|
onDeleteChatRequest: chat => {
|
|
Chat.chats.remove(chat);
|
|
}
|
|
onLoadChatRequest: chat => {
|
|
stackLoader.item?.push(chatContent, {
|
|
"chatData": chat
|
|
});
|
|
ChatState.inChat = true;
|
|
ChatState.chatSession = chat;
|
|
}
|
|
onNewChatRequest: {
|
|
const data = Chat.chats.insert();
|
|
stackLoader.item?.push(chatContent, {
|
|
"chatData": data
|
|
});
|
|
ChatState.inChat = true;
|
|
ChatState.chatSession = data;
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: chatContent
|
|
|
|
ChatContent {
|
|
onRequestClose: {
|
|
stackLoader.item?.pop();
|
|
ChatState.inChat = false;
|
|
}
|
|
}
|
|
}
|
|
}
|