From 06bb6960d47e849d57c64bd3035e81a7091830b0 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Fri, 5 May 2023 10:47:05 -0400 Subject: [PATCH] Add about dialog. --- CMakeLists.txt | 1 + chatlistmodel.cpp | 5 +- main.qml | 8 ++++ qml/AboutDialog.qml | 113 ++++++++++++++++++++++++++++++++++++++++++++ qml/ChatDrawer.qml | 68 +++++++++++++------------- 5 files changed, 158 insertions(+), 37 deletions(-) create mode 100644 qml/AboutDialog.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fe03ed6..f5c32f26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ qt_add_qml_module(chat qml/SettingsDialog.qml qml/StartupDialog.qml qml/PopupDialog.qml + qml/AboutDialog.qml qml/Theme.qml RESOURCES icons/send_message.svg diff --git a/chatlistmodel.cpp b/chatlistmodel.cpp index 5114e02d..fec9c7e4 100644 --- a/chatlistmodel.cpp +++ b/chatlistmodel.cpp @@ -22,13 +22,15 @@ void ChatListModel::saveChats() const QFileInfo settingsInfo(settings.fileName()); QString settingsPath = settingsInfo.absolutePath(); for (Chat *chat : m_chats) { - QFile file(settingsPath + "/gpt4all-" + chat->id() + ".chat"); + QString fileName = "gpt4all-" + chat->id() + ".chat"; + QFile file(settingsPath + "/" + fileName); bool success = file.open(QIODevice::WriteOnly); if (!success) { qWarning() << "ERROR: Couldn't save chat to file:" << file.fileName(); continue; } QDataStream out(&file); + qDebug() << "serializing chat" << fileName; if (!chat->serialize(out)) { qWarning() << "ERROR: Couldn't serialize chat to file:" << file.fileName(); file.remove(); @@ -63,6 +65,7 @@ void ChatListModel::restoreChats() connect(chat, &Chat::nameChanged, this, &ChatListModel::nameChanged); m_chats.append(chat); } + qDebug() << "deserializing chat" << f; file.close(); } std::sort(m_chats.begin(), m_chats.end(), [](const Chat* a, const Chat* b) { diff --git a/main.qml b/main.qml index a41730bb..8144649e 100644 --- a/main.qml +++ b/main.qml @@ -87,6 +87,11 @@ Window { anchors.centerIn: parent } + AboutDialog { + id: aboutDialog + anchors.centerIn: parent + } + Item { Accessible.role: Accessible.Window Accessible.name: title @@ -533,6 +538,9 @@ Window { onDownloadClicked: { downloadNewModels.open() } + onAboutClicked: { + aboutDialog.open() + } } Rectangle { diff --git a/qml/AboutDialog.qml b/qml/AboutDialog.qml new file mode 100644 index 00000000..35d1ee43 --- /dev/null +++ b/qml/AboutDialog.qml @@ -0,0 +1,113 @@ +import QtCore +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic +import QtQuick.Layouts +import download +import network +import llm + +Dialog { + id: abpoutDialog + anchors.centerIn: parent + modal: false + opacity: 0.9 + padding: 20 + width: 1024 + height: column.height + 40 + + Theme { + id: theme + } + + Column { + id: column + spacing: 20 + Item { + width: childrenRect.width + height: childrenRect.height + Image { + id: img + anchors.top: parent.top + anchors.left: parent.left + width: 60 + height: 60 + source: "qrc:/gpt4all/icons/logo.svg" + } + Text { + anchors.left: img.right + anchors.leftMargin: 30 + anchors.verticalCenter: img.verticalCenter + text: qsTr("About GPT4All") + color: theme.textColor + } + } + + ScrollView { + clip: true + height: 200 + width: 1024 - 40 + ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + + TextArea { + id: welcome + wrapMode: Text.Wrap + width: 1024 - 40 + padding: 20 + textFormat: TextEdit.MarkdownText + text: qsTr("### Release notes\n") + + Download.releaseInfo.notes + + qsTr("### Contributors\n") + + Download.releaseInfo.contributors + color: theme.textColor + focus: false + readOnly: true + Accessible.role: Accessible.Paragraph + Accessible.name: qsTr("Release notes") + Accessible.description: qsTr("Release notes for this version") + background: Rectangle { + color: theme.backgroundLight + radius: 10 + } + } + } + + Label { + id: discordLink + width: parent.width + textFormat: Text.RichText + wrapMode: Text.WordWrap + text: qsTr("Check out our discord channel https://discord.gg/4M2QFmTt2k") + onLinkActivated: { Qt.openUrlExternally("https://discord.gg/4M2QFmTt2k") } + color: theme.textColor + linkColor: theme.linkColor + + Accessible.role: Accessible.Link + Accessible.name: qsTr("Discord link") + } + + Label { + id: nomicProps + width: parent.width + textFormat: Text.RichText + wrapMode: Text.WordWrap + text: qsTr("Thank you to Nomic AI and the community for contributing so much great data, code, ideas, and energy to the growing open source AI ecosystem!") + onLinkActivated: { Qt.openUrlExternally("https://home.nomic.ai") } + color: theme.textColor + linkColor: theme.linkColor + + Accessible.role: Accessible.Paragraph + Accessible.name: qsTr("Thank you blurb") + Accessible.description: qsTr("Contains embedded link to https://home.nomic.ai") + } + } + + background: Rectangle { + anchors.fill: parent + color: theme.backgroundDarkest + border.width: 1 + border.color: theme.dialogBorder + radius: 10 + } +} diff --git a/qml/ChatDrawer.qml b/qml/ChatDrawer.qml index 1bf37548..783d0838 100644 --- a/qml/ChatDrawer.qml +++ b/qml/ChatDrawer.qml @@ -17,6 +17,7 @@ Drawer { } signal downloadClicked + signal aboutClicked background: Rectangle { height: parent.height @@ -259,41 +260,6 @@ Drawer { } } - /*Label { - id: discordLink - textFormat: Text.RichText - anchors.left: parent.left - anchors.right: parent.right - anchors.top: conversationList.bottom - anchors.topMargin: 20 - wrapMode: Text.WordWrap - text: qsTr("Check out our discord channel https://discord.gg/4M2QFmTt2k") - onLinkActivated: { Qt.openUrlExternally("https://discord.gg/4M2QFmTt2k") } - color: theme.textColor - linkColor: theme.linkColor - - Accessible.role: Accessible.Link - Accessible.name: qsTr("Discord link") - } - - Label { - id: nomicProps - textFormat: Text.RichText - anchors.left: parent.left - anchors.right: parent.right - anchors.top: discordLink.bottom - anchors.topMargin: 20 - wrapMode: Text.WordWrap - text: qsTr("Thanks to Nomic AI and the community for contributing so much great data and energy!") - onLinkActivated: { Qt.openUrlExternally("https://home.nomic.ai") } - color: theme.textColor - linkColor: theme.linkColor - - Accessible.role: Accessible.Paragraph - Accessible.name: qsTr("Thank you blurb") - Accessible.description: qsTr("Contains embedded link to https://home.nomic.ai") - }*/ - Button { id: checkForUpdatesButton anchors.left: parent.left @@ -329,7 +295,8 @@ Drawer { id: downloadButton anchors.left: parent.left anchors.right: parent.right - anchors.bottom: parent.bottom + anchors.bottom: aboutButton.top + anchors.bottomMargin: 10 padding: 15 contentItem: Text { text: qsTr("Download new models...") @@ -353,5 +320,34 @@ Drawer { downloadClicked() } } + + Button { + id: aboutButton + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + padding: 15 + contentItem: Text { + text: qsTr("About") + horizontalAlignment: Text.AlignHCenter + color: theme.textColor + + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Use this to launch a dialog to show the about page") + } + + background: Rectangle { + opacity: .5 + border.color: theme.backgroundLightest + border.width: 1 + radius: 10 + color: theme.backgroundLight + } + + onClicked: { + aboutClicked() + } + } } } \ No newline at end of file