From 36b6e76a2e1a389b4d82598382ed3e4b717d9a43 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 4 Jan 2021 15:34:46 -0500 Subject: [PATCH] feat: add browserHomepage setting that can be changed --- .../Profile/Sections/BrowserContainer.qml | 9 +-- .../Sections/BrowserModals/HomepageModal.qml | 56 +++++++++++++++++++ ui/main.qml | 2 + ui/nim-status-client.pro | 1 + ui/shared/status/StatusSettingsLineButton.qml | 4 ++ 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 ui/app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml index bf95624815..e52d591405 100644 --- a/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml +++ b/ui/app/AppLayouts/Profile/Sections/BrowserContainer.qml @@ -4,6 +4,7 @@ import "../../../../imports" import "../../../../shared" import "../../../../shared/status" import "Privileges/" +import "BrowserModals" Item { id: root @@ -14,6 +15,8 @@ Item { onClosed: destroy() } + property Component homePagePopup: HomepageModal {} + Column { id: generalColumn spacing: Style.current.bigPadding @@ -30,10 +33,8 @@ Item { StatusSettingsLineButton { text: qsTr("Homepage") - currentValue: qsTr("Default") - onClicked: function () { - console.log('Change Homepage') - } + currentValue: appSettings.browserHomepage === "" ? qsTr("Default") : appSettings.browserHomepage + onClicked: homePagePopup.createObject(root).open() } StatusSettingsLineButton { diff --git a/ui/app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml b/ui/app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml new file mode 100644 index 0000000000..57cbc6a9b7 --- /dev/null +++ b/ui/app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml @@ -0,0 +1,56 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import "../../../../../imports" +import "../../../../../shared" +import "../../../../../shared/status" + +ModalPopup { + id: popup + + title: qsTr("Homepage") + + onClosed: { + destroy() + } + + Column { + spacing: Style.current.bigPadding + width: parent.width + + ButtonGroup { + id: homepageGroup + } + + StatusRadioButton { + text: qsTr("Default") + ButtonGroup.group: homepageGroup + checked: appSettings.browserHomepage === "" + onCheckedChanged: { + if (checked) { + appSettings.browserHomepage = "" + customUrl.visible = false + } + } + } + + StatusRadioButton { + text: qsTr("Custom...") + ButtonGroup.group: homepageGroup + checked: appSettings.browserHomepage !== "" || customUrl.visible + onClicked: { + customUrl.visible = true + } + } + + Input { + id: customUrl + visible: appSettings.browserHomepage !== "" + placeholderText: qsTr("Paste URL") + pasteFromClipboard: true + textField.onTextChanged: { + appSettings.browserHomepage = customUrl.text + } + } + } +} + diff --git a/ui/main.qml b/ui/main.qml index 3fe68c9631..d5fb403fc0 100644 --- a/ui/main.qml +++ b/ui/main.qml @@ -117,6 +117,7 @@ ApplicationWindow { property bool showBrowserSelector: true property bool openLinksInStatus: true property bool showFavoritesBar: false + property string browserHomepage: "" property bool autoLoadImages: true property bool javaScriptEnabled: true property bool errorPageEnabled: true @@ -158,6 +159,7 @@ ApplicationWindow { property bool showBrowserSelector: defaultAppSettings.showBrowserSelector property bool openLinksInStatus: defaultAppSettings.openLinksInStatus property bool showFavoritesBar: defaultAppSettings.showFavoritesBar + property string browserHomepage: defaultAppSettings.browserHomepage 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 7b22ae1e73..ccf346da8d 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -185,6 +185,7 @@ DISTFILES += \ app/AppLayouts/Profile/Sections/AppearanceContainer.qml \ app/AppLayouts/Profile/Sections/BackupSeedModal.qml \ app/AppLayouts/Profile/Sections/BrowserContainer.qml \ + app/AppLayouts/Profile/Sections/BrowserModals/HomepageModal.qml \ app/AppLayouts/Profile/Sections/ChangeProfilePicModal.qml \ app/AppLayouts/Profile/Sections/MyProfileContainer.qml \ app/AppLayouts/Profile/Sections/OpenLinksWithModal.qml \ diff --git a/ui/shared/status/StatusSettingsLineButton.qml b/ui/shared/status/StatusSettingsLineButton.qml index 4ce8d922cf..66c7c98a13 100644 --- a/ui/shared/status/StatusSettingsLineButton.qml +++ b/ui/shared/status/StatusSettingsLineButton.qml @@ -24,8 +24,12 @@ Item { id: valueText visible: !!root.currentValue text: root.currentValue + elide: Text.ElideRight font.pixelSize: 15 + horizontalAlignment: Text.AlignRight color: Style.current.secondaryText + anchors.left: textItem.right + anchors.leftMargin: Style.current.padding anchors.right: root.isSwitch ? switchItem.left : caret.left anchors.rightMargin: Style.current.padding anchors.verticalCenter: textItem.verticalCenter