mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Allow removing chats.
This commit is contained in:
parent
412cad99f2
commit
118e0bdc44
@ -87,6 +87,7 @@ qt_add_qml_module(chat
|
|||||||
icons/copy.svg
|
icons/copy.svg
|
||||||
icons/settings.svg
|
icons/settings.svg
|
||||||
icons/edit.svg
|
icons/edit.svg
|
||||||
|
icons/trash.svg
|
||||||
icons/network.svg
|
icons/network.svg
|
||||||
icons/thumbs_up.svg
|
icons/thumbs_up.svg
|
||||||
icons/thumbs_down.svg
|
icons/thumbs_down.svg
|
||||||
|
@ -72,14 +72,22 @@ public:
|
|||||||
const bool chatIsCurrent = chat == m_currentChat;
|
const bool chatIsCurrent = chat == m_currentChat;
|
||||||
emit disconnectChat(chat);
|
emit disconnectChat(chat);
|
||||||
const int index = m_chats.indexOf(chat);
|
const int index = m_chats.indexOf(chat);
|
||||||
|
if (m_chats.count() < 2) {
|
||||||
|
addChat();
|
||||||
|
} else {
|
||||||
|
int nextIndex;
|
||||||
|
if (index == m_chats.count() - 1)
|
||||||
|
nextIndex = index - 1;
|
||||||
|
else
|
||||||
|
nextIndex = index + 1;
|
||||||
|
Chat *nextChat = get(nextIndex);
|
||||||
|
Q_ASSERT(nextChat);
|
||||||
|
setCurrentChat(nextChat);
|
||||||
|
}
|
||||||
beginRemoveRows(QModelIndex(), index, index);
|
beginRemoveRows(QModelIndex(), index, index);
|
||||||
m_chats.removeAll(chat);
|
m_chats.removeAll(chat);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
delete chat;
|
delete chat;
|
||||||
if (m_chats.isEmpty())
|
|
||||||
addChat();
|
|
||||||
else
|
|
||||||
setCurrentChat(m_chats.first());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Chat *currentChat() const
|
Chat *currentChat() const
|
||||||
|
5
icons/trash.svg
Normal file
5
icons/trash.svg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="#7d7d8e" viewBox="0 0 448 512"><path d="M0 84V56c0-13.3 10.7-24 24-24h112l9.4-18.7c4-8.2 12.3-13.3 21.4-13.3h114.3c9.1 0 17.4 5.1 21.5 13.3L312 32h112c13.3 0 24 10.7 24 24v28c0 6.6-5.4 12-12 12H12C5.4 96 0 90.6 0 84zm416 56v324c0 26.5-21.5 48-48 48H80c-26.5 0-48-21.5-48-48V140c0-6.6 5.4-12 12-12h360c6.6 0 12 5.4 12 12zm-272 68c0-8.8-7.2-16-16-16s-16 7.2-16 16v224c0 8.8 7.2 16 16 16s16-7.2 16-16V208zm96 0c0-8.8-7.2-16-16-16s-16 7.2-16 16v224c0 8.8 7.2 16 16 16s16-7.2 16-16V208zm96 0c0-8.8-7.2-16-16-16s-16 7.2-16 16v224c0 8.8 7.2 16 16 16s16-7.2 16-16V208z"/></svg>
|
||||||
|
<!--
|
||||||
|
Font Awesome Free 5.2.0 by @fontawesome - https://fontawesome.com
|
||||||
|
License - https://fontawesome.com/license (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||||
|
-->
|
After Width: | Height: | Size: 791 B |
@ -77,8 +77,7 @@ Drawer {
|
|||||||
|
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
id: chatRectangle
|
id: chatRectangle
|
||||||
anchors.left: parent.left
|
width: conversationList.width
|
||||||
anchors.right: parent.right
|
|
||||||
height: chatName.height
|
height: chatName.height
|
||||||
opacity: 0.9
|
opacity: 0.9
|
||||||
property bool isCurrent: LLM.chatListModel.currentChat === LLM.chatListModel.get(index)
|
property bool isCurrent: LLM.chatListModel.currentChat === LLM.chatListModel.get(index)
|
||||||
@ -88,7 +87,7 @@ Drawer {
|
|||||||
TextArea {
|
TextArea {
|
||||||
id: chatName
|
id: chatName
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: editButton.left
|
anchors.right: buttons.left
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
padding: 15
|
padding: 15
|
||||||
focus: false
|
focus: false
|
||||||
@ -121,11 +120,14 @@ Drawer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button {
|
Row {
|
||||||
id: editButton
|
id: buttons
|
||||||
anchors.verticalCenter: chatName.verticalCenter
|
anchors.verticalCenter: chatName.verticalCenter
|
||||||
anchors.right: chatRectangle.right
|
anchors.right: chatRectangle.right
|
||||||
anchors.rightMargin: 10
|
anchors.rightMargin: 10
|
||||||
|
spacing: 10
|
||||||
|
Button {
|
||||||
|
id: editButton
|
||||||
width: 30
|
width: 30
|
||||||
height: 30
|
height: 30
|
||||||
visible: isCurrent
|
visible: isCurrent
|
||||||
@ -139,6 +141,21 @@ Drawer {
|
|||||||
chatName.readOnly = false
|
chatName.readOnly = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
id: trashButton
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
visible: isCurrent
|
||||||
|
background: Image {
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
source: "qrc:/gpt4all/icons/trash.svg"
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
LLM.chatListModel.removeChat(LLM.chatListModel.get(index))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessible.role: Accessible.List
|
Accessible.role: Accessible.List
|
||||||
|
Loading…
Reference in New Issue
Block a user