From 1370995b925ede8fd88482197440b81a79c3970f Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Wed, 31 May 2023 19:28:09 -0400 Subject: [PATCH] Add a custom busy indicator to further align look and feel across platforms. --- gpt4all-chat/CMakeLists.txt | 1 + gpt4all-chat/main.qml | 8 +-- gpt4all-chat/qml/LocalDocs.qml | 2 +- gpt4all-chat/qml/ModelDownloaderDialog.qml | 2 +- gpt4all-chat/qml/MyBusyIndicator.qml | 64 ++++++++++++++++++++++ gpt4all-chat/qml/PopupDialog.qml | 2 +- 6 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 gpt4all-chat/qml/MyBusyIndicator.qml diff --git a/gpt4all-chat/CMakeLists.txt b/gpt4all-chat/CMakeLists.txt index 4eabe985..1a283bc9 100644 --- a/gpt4all-chat/CMakeLists.txt +++ b/gpt4all-chat/CMakeLists.txt @@ -95,6 +95,7 @@ qt_add_qml_module(chat qml/MyComboBox.qml qml/MyTextField.qml qml/MyCheckBox.qml + qml/MyBusyIndicator.qml RESOURCES icons/send_message.svg icons/stop_generating.svg diff --git a/gpt4all-chat/main.qml b/gpt4all-chat/main.qml index f8776601..d5a1ba5d 100644 --- a/gpt4all-chat/main.qml +++ b/gpt4all-chat/main.qml @@ -163,7 +163,7 @@ Window { height: childrenRect.height Row { spacing: 5 - BusyIndicator { + MyBusyIndicator { anchors.verticalCenter: parent.verticalCenter running: parent.visible Accessible.role: Accessible.Animation @@ -174,7 +174,7 @@ Window { Label { anchors.verticalCenter: parent.verticalCenter text: qsTr("Loading model...") - color: theme.mutedTextColor + color: theme.textAccent } } } @@ -649,7 +649,7 @@ Window { height: childrenRect.height Row { spacing: 5 - BusyIndicator { + MyBusyIndicator { anchors.verticalCenter: parent.verticalCenter running: (currentResponse ? true : false) && value === "" && currentChat.responseInProgress Accessible.role: Accessible.Animation @@ -659,7 +659,7 @@ Window { Label { anchors.verticalCenter: parent.verticalCenter text: currentChat.responseState + "..." - color: theme.mutedTextColor + color: theme.textAccent } } } diff --git a/gpt4all-chat/qml/LocalDocs.qml b/gpt4all-chat/qml/LocalDocs.qml index b6ef9ede..699293f7 100644 --- a/gpt4all-chat/qml/LocalDocs.qml +++ b/gpt4all-chat/qml/LocalDocs.qml @@ -177,7 +177,7 @@ Item { LocalDocs.removeFolder(collection, folder_path) } } - BusyIndicator { + MyBusyIndicator { id: busyIndicator anchors.centerIn: parent visible: item.removing diff --git a/gpt4all-chat/qml/ModelDownloaderDialog.qml b/gpt4all-chat/qml/ModelDownloaderDialog.qml index e9b25eac..e3bd048e 100644 --- a/gpt4all-chat/qml/ModelDownloaderDialog.qml +++ b/gpt4all-chat/qml/ModelDownloaderDialog.qml @@ -199,7 +199,7 @@ Dialog { Accessible.description: qsTr("Whether the file hash is being calculated") } - BusyIndicator { + MyBusyIndicator { id: busyCalcHash anchors.right: parent.right padding: 20 diff --git a/gpt4all-chat/qml/MyBusyIndicator.qml b/gpt4all-chat/qml/MyBusyIndicator.qml new file mode 100644 index 00000000..5ce360b1 --- /dev/null +++ b/gpt4all-chat/qml/MyBusyIndicator.qml @@ -0,0 +1,64 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Basic + +BusyIndicator { + id: control + + contentItem: Item { + implicitWidth: 48 + implicitHeight: 48 + + Item { + id: item + x: parent.width / 2 - 24 + y: parent.height / 2 - 24 + width: 48 + height: 48 + opacity: control.running ? 1 : 0 + + Behavior on opacity { + OpacityAnimator { + duration: 250 + } + } + + RotationAnimator { + target: item + running: control.visible && control.running + from: 0 + to: 360 + loops: Animation.Infinite + duration: 1750 + } + + Repeater { + id: repeater + model: 6 + + Rectangle { + id: delegate + x: item.width / 2 - width / 2 + y: item.height / 2 - height / 2 + implicitWidth: 10 + implicitHeight: 10 + radius: 5 + color: theme.textAccent + + required property int index + + transform: [ + Translate { + y: -Math.min(item.width, item.height) * 0.5 + 5 + }, + Rotation { + angle: delegate.index / repeater.count * 360 + origin.x: 5 + origin.y: 5 + } + ] + } + } + } + } +} diff --git a/gpt4all-chat/qml/PopupDialog.qml b/gpt4all-chat/qml/PopupDialog.qml index 6df8be5d..57f69e9e 100644 --- a/gpt4all-chat/qml/PopupDialog.qml +++ b/gpt4all-chat/qml/PopupDialog.qml @@ -37,7 +37,7 @@ Dialog { Accessible.description: qsTr("Reveals a shortlived help balloon") } - BusyIndicator { + MyBusyIndicator { id: busyIndicator visible: shouldShowBusy running: shouldShowBusy