From 1c83ac98a0918dc93b20dcbf3ed91b10bf6d6a48 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 4 Jan 2021 16:06:38 -0500 Subject: [PATCH] feat: add search engine settings in the profile --- .../Profile/Sections/BrowserContainer.qml | 14 ++-- .../BrowserModals/SearchEngineModal.qml | 71 +++++++++++++++++++ ui/imports/Constants.qml | 5 ++ ui/main.qml | 2 + ui/nim-status-client.pro | 1 + 5 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 ui/app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml index e52d591405..ddc6171471 100644 --- a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml @@ -14,8 +14,8 @@ Item { property Component dappListPopup: DappList { onClosed: destroy() } - property Component homePagePopup: HomepageModal {} + property Component searchEngineModal: SearchEngineModal {} Column { id: generalColumn @@ -48,10 +48,16 @@ Item { StatusSettingsLineButton { text: qsTr("Search engine used in the address bar") - currentValue: qsTr("None") - onClicked: function () { - console.log('Change search engine') + currentValue: { + switch (appSettings.browserSearchEngine) { + case Constants.browserSearchEngineGoogle: return "Google" + case Constants.browserSearchEngineYahoo: return "Yahoo!" + case Constants.browserSearchEngineDuckDuckGo: return "DuckDuckGo" + case Constants.browserSearchEngineNone: + default: return qsTr("None") + } } + onClicked: searchEngineModal.createObject(root).open() } Item { diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml b/ui/app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml new file mode 100644 index 0000000000..dcd1d73cc5 --- /dev/null +++ b/ui/app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml @@ -0,0 +1,71 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import "../../../../../imports" +import "../../../../../shared" +import "../../../../../shared/status" + +ModalPopup { + id: popup + + title: qsTr("Search engine") + + onClosed: { + destroy() + } + + Column { + spacing: Style.current.bigPadding + width: parent.width + + ButtonGroup { + id: searchEnginGroup + } + + StatusRadioButton { + text: qsTr("None") + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserSearchEngine === Constants.browserSearchEngineNone + onCheckedChanged: { + if (checked) { + appSettings.browserSearchEngine = Constants.browserSearchEngineNone + } + } + } + + StatusRadioButton { + text: "Google" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserSearchEngine === Constants.browserSearchEngineGoogle + onCheckedChanged: { + if (checked) { + appSettings.browserSearchEngine = Constants.browserSearchEngineGoogle + } + } + } + + StatusRadioButton { + text: "Yahoo!" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserSearchEngine === Constants.browserSearchEngineYahoo + onCheckedChanged: { + if (checked) { + appSettings.browserSearchEngine = Constants.browserSearchEngineYahoo + } + } + } + + StatusRadioButton { + text: "DuckDuckGo" + ButtonGroup.group: searchEnginGroup + checked: appSettings.browserSearchEngine === Constants.browserSearchEngineDuckDuckGo + onCheckedChanged: { + if (checked) { + appSettings.browserSearchEngine = Constants.browserSearchEngineDuckDuckGo + } + } + } + + + } +} + diff --git a/ui/imports/Constants.qml b/ui/imports/Constants.qml index 01d3242f9d..0e50f42bdd 100644 --- a/ui/imports/Constants.qml +++ b/ui/imports/Constants.qml @@ -100,4 +100,9 @@ QtObject { readonly property string eth_prod: "eth.prod" readonly property string eth_staging: "eth.staging" readonly property string eth_test: "eth.test" + + readonly property int browserSearchEngineNone: 0 + readonly property int browserSearchEngineGoogle: 1 + readonly property int browserSearchEngineYahoo: 2 + readonly property int browserSearchEngineDuckDuckGo: 3 } diff --git a/ui/main.qml b/ui/main.qml index d5fb403fc0..2128438559 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -118,6 +118,7 @@ ApplicationWindow { property bool openLinksInStatus: true property bool showFavoritesBar: false property string browserHomepage: "" + property int browserSearchEngine: Constants.browserSearchEngineNone property bool autoLoadImages: true property bool javaScriptEnabled: true property bool errorPageEnabled: true @@ -160,6 +161,7 @@ ApplicationWindow { property bool openLinksInStatus: defaultAppSettings.openLinksInStatus property bool showFavoritesBar: defaultAppSettings.showFavoritesBar property string browserHomepage: defaultAppSettings.browserHomepage + property int browserSearchEngine: defaultAppSettings.browserSearchEngine property bool autoLoadImages: defaultAppSettings.autoLoadImages property bool javaScriptEnabled: defaultAppSettings.javaScriptEnabled property bool errorPageEnabled: defaultAppSettings.errorPageEnabled diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index ccf346da8d..d3c0020e4c 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -186,6 +186,7 @@ DISTFILES += \ app/AppLayouts/Profile/Sections/BackupSeedModal.qml \ app/AppLayouts/Profile/Sections/BrowserContainer.qml \ app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml \ + app/AppLayouts/Profile/Sections/BrowserModals/SearchEngineModal.qml \ app/AppLayouts/Profile/Sections/ChangeProfilePicModal.qml \ app/AppLayouts/Profile/Sections/MyProfileContainer.qml \ app/AppLayouts/Profile/Sections/OpenLinksWithModal.qml \