From 8f80f8e3a237a3bf5b51c6fcc477225a707c2748 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Mon, 1 May 2023 13:51:46 -0400 Subject: [PATCH] Break out the drawer into own component. --- CMakeLists.txt | 1 + main.qml | 128 +--------------------------------------- qml/ChatDrawer.qml | 141 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 125 deletions(-) create mode 100644 qml/ChatDrawer.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index 57561c6b..8d64e9f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ qt_add_qml_module(chat VERSION 1.0 QML_FILES main.qml + qml/ChatDrawer.qml qml/ModelDownloaderDialog.qml qml/NetworkDialog.qml qml/NewVersionDialog.qml diff --git a/main.qml b/main.qml index c6b8ad84..c1ed3232 100644 --- a/main.qml +++ b/main.qml @@ -514,135 +514,13 @@ Window { } } - Drawer { + ChatDrawer { id: drawer y: header.height width: 0.3 * window.width height: window.height - y - modal: false - opacity: 0.9 - - background: Rectangle { - height: parent.height - color: theme.backgroundDarkest - } - - Item { - anchors.fill: parent - anchors.margins: 30 - - Accessible.role: Accessible.Pane - Accessible.name: qsTr("Drawer on the left of the application") - Accessible.description: qsTr("Drawer that is revealed by pressing the hamburger button") - - Label { - id: conversationList - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - wrapMode: Text.WordWrap - text: qsTr("Chat lists of specific conversations coming soon! Check back often for new features :)") - color: theme.textColor - - Accessible.role: Accessible.Paragraph - Accessible.name: qsTr("Coming soon") - Accessible.description: text - } - - 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 { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: downloadButton.top - anchors.bottomMargin: 20 - padding: 15 - contentItem: Text { - text: qsTr("Check for updates...") - horizontalAlignment: Text.AlignHCenter - color: theme.textColor - - Accessible.role: Accessible.Button - Accessible.name: text - Accessible.description: qsTr("Use this to launch an external application that will check for updates to the installer") - } - - background: Rectangle { - opacity: .5 - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } - - onClicked: { - if (!LLM.checkForUpdates()) - checkForUpdatesError.open() - } - } - - Button { - id: downloadButton - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - padding: 15 - contentItem: Text { - text: qsTr("Download new models...") - horizontalAlignment: Text.AlignHCenter - color: theme.textColor - - Accessible.role: Accessible.Button - Accessible.name: text - Accessible.description: qsTr("Use this to launch a dialog to download new models") - } - - background: Rectangle { - opacity: .5 - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } - - onClicked: { - downloadNewModels.open() - } - } - + onDownloadClicked: { + downloadNewModels.open() } } diff --git a/qml/ChatDrawer.qml b/qml/ChatDrawer.qml new file mode 100644 index 00000000..eb2e1f64 --- /dev/null +++ b/qml/ChatDrawer.qml @@ -0,0 +1,141 @@ +import QtCore +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic +import QtQuick.Layouts +import llm +import download +import network + +Drawer { + id: chatDrawer + modal: false + opacity: 0.9 + + Theme { + id: theme + } + + signal downloadClicked + + background: Rectangle { + height: parent.height + color: theme.backgroundDarkest + } + + Item { + anchors.fill: parent + anchors.margins: 30 + + Accessible.role: Accessible.Pane + Accessible.name: qsTr("Drawer on the left of the application") + Accessible.description: qsTr("Drawer that is revealed by pressing the hamburger button") + + Label { + id: conversationList + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + wrapMode: Text.WordWrap + text: qsTr("Chat lists of specific conversations coming soon! Check back often for new features :)") + color: theme.textColor + + Accessible.role: Accessible.Paragraph + Accessible.name: qsTr("Coming soon") + Accessible.description: text + } + + 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 { + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: downloadButton.top + anchors.bottomMargin: 20 + padding: 15 + contentItem: Text { + text: qsTr("Check for updates...") + horizontalAlignment: Text.AlignHCenter + color: theme.textColor + + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Use this to launch an external application that will check for updates to the installer") + } + + background: Rectangle { + opacity: .5 + border.color: theme.backgroundLightest + border.width: 1 + radius: 10 + color: theme.backgroundLight + } + + onClicked: { + if (!LLM.checkForUpdates()) + checkForUpdatesError.open() + } + } + + Button { + id: downloadButton + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + padding: 15 + contentItem: Text { + text: qsTr("Download new models...") + horizontalAlignment: Text.AlignHCenter + color: theme.textColor + + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Use this to launch a dialog to download new models") + } + + background: Rectangle { + opacity: .5 + border.color: theme.backgroundLightest + border.width: 1 + radius: 10 + color: theme.backgroundLight + } + + onClicked: { + downloadClicked() } + } + } +} \ No newline at end of file