Files
z-bar-qt/Modules/Notifications/Sidebar/Chat/ChatPanel.qml
T

90 lines
1.5 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) {
stack.push(chatList);
stack.push(chatContent, {
"chatData": ChatState.chatSession
});
} else
stack.push(chatList);
}
StackView {
id: stack
anchors.fill: parent
}
IconButton {
anchors.left: parent.left
anchors.bottom: parent.bottom
icon: "open_in_new"
anchors.margins: Tokens.padding.small
isRound: true
padding: 8
font.pointSize: Math.round(18 * 1.2)
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, index) => {
stack.push(chatContent, {
"chatData": chat
});
ChatState.inChat = true;
ChatState.chatSession = chat;
}
onNewChatRequest: {
const data = Chat.chats.insert();
stack.push(chatContent, {
"chatData": data
});
ChatState.inChat = true;
ChatState.chatSession = data;
}
}
}
Component {
id: chatContent
ChatContent {
onRequestClose: {
stack.pop();
ChatState.inChat = false;
}
}
}
}