From eb6a7cca4760da997e90de9216e10eacf273a972 Mon Sep 17 00:00:00 2001 From: Justin Wang Date: Tue, 23 May 2023 15:53:32 +0200 Subject: [PATCH] dedup qml: convert more buttons to MyButton --- gpt4all-chat/qml/ModelDownloaderDialog.qml | 49 ++++------------------ gpt4all-chat/qml/NetworkDialog.qml | 30 ++----------- gpt4all-chat/qml/NewVersionDialog.qml | 21 +--------- gpt4all-chat/qml/ThumbsDownDialog.qml | 34 +++++---------- 4 files changed, 24 insertions(+), 110 deletions(-) diff --git a/gpt4all-chat/qml/ModelDownloaderDialog.qml b/gpt4all-chat/qml/ModelDownloaderDialog.qml index bc5671fe..a9ad4363 100644 --- a/gpt4all-chat/qml/ModelDownloaderDialog.qml +++ b/gpt4all-chat/qml/ModelDownloaderDialog.qml @@ -229,21 +229,11 @@ Dialog { Accessible.description: qsTr("Whether the file is already installed on your system") } - Button { + MyButton { id: removeButton - contentItem: Text { - color: theme.textColor - text: "Remove" - } + text: "Remove" anchors.right: parent.right anchors.rightMargin: 20 - background: Rectangle { - opacity: .5 - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } onClicked: { Download.removeModel(modelData.filename); } @@ -300,12 +290,9 @@ Dialog { } } - Button { + MyButton { id: downloadButton - contentItem: Text { - color: theme.textColor - text: downloading ? "Cancel" : "Download" - } + text: downloading ? qsTr("Cancel") : qsTr("Download") anchors.top: modelName.top anchors.right: parent.right anchors.topMargin: 15 @@ -320,17 +307,9 @@ Dialog { Download.cancelDownload(modelData.filename); } } - background: Rectangle { - opacity: .5 - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } Accessible.role: Accessible.Button Accessible.name: text Accessible.description: qsTr("Cancel/Download button to stop/start the download") - } } @@ -439,23 +418,11 @@ Dialog { radius: 10 } } - Button { + MyButton { text: qsTr("Browse") - contentItem: Text { - text: qsTr("Browse") - horizontalAlignment: Text.AlignHCenter - color: theme.textColor - Accessible.role: Accessible.Button - Accessible.name: text - Accessible.description: qsTr("Opens a folder picker dialog to choose where to save model files") - } - background: Rectangle { - opacity: .5 - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Opens a folder picker dialog to choose where to save model files") onClicked: modelPathDialog.open() } } diff --git a/gpt4all-chat/qml/NetworkDialog.qml b/gpt4all-chat/qml/NetworkDialog.qml index 10b97bf9..546b16cf 100644 --- a/gpt4all-chat/qml/NetworkDialog.qml +++ b/gpt4all-chat/qml/NetworkDialog.qml @@ -117,40 +117,18 @@ NOTE: By turning on this feature, you will be sending your data to the GPT4All O padding: 20 alignment: Qt.AlignRight spacing: 10 - Button { - contentItem: Text { - color: theme.textColor - text: qsTr("Enable") - } - background: Rectangle { - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } + MyButton { + text: qsTr("Enable") Accessible.role: Accessible.Button Accessible.name: text Accessible.description: qsTr("Enable opt-in button") - - padding: 15 DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole } - Button { - contentItem: Text { - color: theme.textColor - text: qsTr("Cancel") - } - background: Rectangle { - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } + MyButton { + text: qsTr("Cancel") Accessible.role: Accessible.Button Accessible.name: text Accessible.description: qsTr("Cancel opt-in button") - - padding: 15 DialogButtonBox.buttonRole: DialogButtonBox.RejectRole } background: Rectangle { diff --git a/gpt4all-chat/qml/NewVersionDialog.qml b/gpt4all-chat/qml/NewVersionDialog.qml index 8da15f31..baffe559 100644 --- a/gpt4all-chat/qml/NewVersionDialog.qml +++ b/gpt4all-chat/qml/NewVersionDialog.qml @@ -43,30 +43,13 @@ Dialog { color: theme.textColor } - Button { + MyButton { id: button anchors.left: label.right anchors.leftMargin: 10 anchors.verticalCenter: label.verticalCenter padding: 20 - contentItem: Text { - text: qsTr("Update") - 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 - } - + text: qsTr("Update") onClicked: { if (!LLM.checkForUpdates()) checkForUpdatesError.open() diff --git a/gpt4all-chat/qml/ThumbsDownDialog.qml b/gpt4all-chat/qml/ThumbsDownDialog.qml index 8cb1d115..090c4969 100644 --- a/gpt4all-chat/qml/ThumbsDownDialog.qml +++ b/gpt4all-chat/qml/ThumbsDownDialog.qml @@ -77,32 +77,18 @@ Dialog { padding: 20 alignment: Qt.AlignRight spacing: 10 - Button { - contentItem: Text { - color: theme.textColor - text: qsTr("Submit") - } - background: Rectangle { - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } - padding: 15 + MyButton { + text: qsTr("Submit") + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Submits the user's response") DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole } - Button { - contentItem: Text { - color: theme.textColor - text: qsTr("Cancel") - } - background: Rectangle { - border.color: theme.backgroundLightest - border.width: 1 - radius: 10 - color: theme.backgroundLight - } - padding: 15 + MyButton { + text: qsTr("Cancel") + Accessible.role: Accessible.Button + Accessible.name: text + Accessible.description: qsTr("Closes the response dialog") DialogButtonBox.buttonRole: DialogButtonBox.RejectRole } background: Rectangle {