From 3b99bcb29a8b6ecf730b1f6026d793edcca494d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Wed, 24 Jan 2024 12:02:03 +0000 Subject: [PATCH] fix: apply Custom order to main wallet view also fix navigating into section/subsection Fixes #13275 --- .../Profile/views/SettingsContentBase.qml | 4 +- .../AppLayouts/Profile/views/WalletView.qml | 50 +++++++++++++++---- .../Profile/views/wallet/ManageTokensView.qml | 6 --- ui/app/AppLayouts/Wallet/WalletLayout.qml | 2 +- .../Wallet/views/CollectiblesView.qml | 12 ++++- ui/app/mainui/AppMain.qml | 14 ++---- ui/imports/shared/views/AssetsView.qml | 12 ++++- ui/imports/utils/Constants.qml | 3 +- 8 files changed, 71 insertions(+), 32 deletions(-) diff --git a/ui/app/AppLayouts/Profile/views/SettingsContentBase.qml b/ui/app/AppLayouts/Profile/views/SettingsContentBase.qml index e33af57d71..ec2c1d10b0 100644 --- a/ui/app/AppLayouts/Profile/views/SettingsContentBase.qml +++ b/ui/app/AppLayouts/Profile/views/SettingsContentBase.qml @@ -20,7 +20,7 @@ FocusScope { property alias titleRowComponentLoader: loader property list headerComponents property alias bottomHeaderComponents: secondHeaderRow.contentItem - default property Item content + default property alias content: contentWrapper.children property alias titleLayout: titleLayout property bool dirty: false @@ -49,8 +49,6 @@ FocusScope { } Component.onCompleted: { - content.parent = contentWrapper - if (headerComponents.length) { for (let i in headerComponents) { headerComponents[i].parent = titleRow diff --git a/ui/app/AppLayouts/Profile/views/WalletView.qml b/ui/app/AppLayouts/Profile/views/WalletView.qml index 435334825a..323b39d5a6 100644 --- a/ui/app/AppLayouts/Profile/views/WalletView.qml +++ b/ui/app/AppLayouts/Profile/views/WalletView.qml @@ -2,6 +2,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.13 import QtGraphicalEffects 1.13 +import Qt.labs.settings 1.1 import QtQml 2.15 import StatusQ.Controls 0.1 @@ -22,6 +23,8 @@ import "../panels" import AppLayouts.Profile.views.wallet 1.0 import AppLayouts.Wallet.stores 1.0 +import AppLayouts.Wallet.controls 1.0 +import AppLayouts.Wallet 1.0 SettingsContentBase { id: root @@ -65,9 +68,22 @@ SettingsContentBase { } onSaveChangesClicked: { manageTokensView.saveChanges() + + let sectionLink = "%1/%2/".arg(Constants.appSection.wallet).arg(WalletLayout.LeftPanelSelection.AllAddresses) + + if (Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets) { + sectionLink += WalletLayout.RightPanelSelection.Assets + priv.assetSettings.setValue("currentSortValue", SortOrderComboBox.TokenOrderCustom) + priv.assetSettings.sync() + } else if (Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles) { + sectionLink += WalletLayout.RightPanelSelection.Collectibles + priv.collectiblesSettings.setValue("currentSortValue", SortOrderComboBox.TokenOrderCustom) + priv.collectiblesSettings.sync() + } + Global.displayToastMessage( qsTr("Your new custom token order has been applied to your %1", "Go to Wallet") - .arg(`` + qsTr("Wallet", "Go to Wallet") + ""), + .arg(`` + qsTr("Wallet", "Go to Wallet") + ""), "", "checkmark-circle", false, @@ -79,6 +95,24 @@ SettingsContentBase { manageTokensView.resetChanges() } + readonly property var priv: QtObject { + id: priv + readonly property bool isManageTokensSubsection: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets || + Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles || + Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageHidden || + Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAdvanced + + readonly property var assetSettings: Settings { + category: "AssetsViewSortSettings" + //property int currentSortValue + } + + readonly property var collectiblesSettings: Settings { + category: "CollectiblesViewSortSettings" + //property int currentSortValue + } + } + StackLayout { id: stackContainer @@ -94,9 +128,7 @@ SettingsContentBase { Binding on currentIndex { value: root.manageTokensViewIndex - when: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets || - Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles || - Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageTokenLists + when: priv.isManageTokensSubsection restoreMode: Binding.RestoreNone } @@ -294,13 +326,13 @@ SettingsContentBase { return 0 case Constants.walletSettingsSubsection.manageCollectibles: return 1 - case Constants.walletSettingsSubsection.manageTokenLists: - return 2 + case Constants.walletSettingsSubsection.manageHidden: + return 3 + case Constants.walletSettingsSubsection.manageAdvanced: + return 4 } } - when: Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageAssets || - Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageCollectibles || - Global.settingsSubSubsection === Constants.walletSettingsSubsection.manageTokenLists + when: priv.isManageTokensSubsection restoreMode: Binding.RestoreNone } } diff --git a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml index b9596de165..5ede7947c5 100644 --- a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml +++ b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml @@ -49,12 +49,6 @@ ColumnLayout { loader.item.saveSettings() } - function resetChanges() { - if (tabBar.currentIndex > d.hiddenTabIndex) - return - loader.item.revert() - } - QtObject { id: d diff --git a/ui/app/AppLayouts/Wallet/WalletLayout.qml b/ui/app/AppLayouts/Wallet/WalletLayout.qml index ebeb061544..1fd27efd1f 100644 --- a/ui/app/AppLayouts/Wallet/WalletLayout.qml +++ b/ui/app/AppLayouts/Wallet/WalletLayout.qml @@ -57,8 +57,8 @@ Item { } enum RightPanelSelection { - Collectibles, Assets, + Collectibles, Activity } diff --git a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml index 213fc2031b..1adde03c52 100644 --- a/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml +++ b/ui/app/AppLayouts/Wallet/views/CollectiblesView.qml @@ -157,12 +157,22 @@ ColumnLayout { } Settings { + id: settings category: "CollectiblesViewSortSettings" - property alias currentSortField: cmbTokenOrder.currentIndex + property int currentSortValue: SortOrderComboBox.TokenOrderDateAdded property alias currentSortOrder: cmbTokenOrder.currentSortOrder property alias selectedFilterGroupIds: cmbFilter.selectedFilterGroupIds } + Component.onCompleted: { + settings.sync() + cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue) + } + + Component.onDestruction: { + settings.currentSortValue = cmbTokenOrder.currentValue + } + ColumnLayout { Layout.fillWidth: true Layout.fillHeight: false diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 1346540d46..4e2f4205ff 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -342,18 +342,12 @@ Item { return appMain.rootStore.mainModuleInst.setActiveSectionBySectionType(sectionType) + if (sectionType === Constants.appSection.profile) { Global.settingsSubsection = subsection; - Global.settingsSubSubsection = settingsSubsection; - return - } - - if (sectionType === Constants.appSection.wallet) { - appView.children[Constants.appViewStackIndex.wallet].item.openDesiredView( - WalletLayout.LeftPanelSelection.AllAddresses, - WalletLayout.RightPanelSelection.Activity, - data - ) + Global.settingsSubSubsection = subSubsection; + } else if (sectionType === Constants.appSection.wallet) { + appView.children[Constants.appViewStackIndex.wallet].item.openDesiredView(subsection, subSubsection, data) } } diff --git a/ui/imports/shared/views/AssetsView.qml b/ui/imports/shared/views/AssetsView.qml index d8ee69f62e..f02ef1d42f 100644 --- a/ui/imports/shared/views/AssetsView.qml +++ b/ui/imports/shared/views/AssetsView.qml @@ -156,11 +156,21 @@ ColumnLayout { } Settings { + id: settings category: "AssetsViewSortSettings" - property alias currentSortField: cmbTokenOrder.currentIndex + property int currentSortValue: SortOrderComboBox.TokenOrderCurrencyBalance property alias currentSortOrder: cmbTokenOrder.currentSortOrder } + Component.onCompleted: { + settings.sync() + cmbTokenOrder.currentIndex = cmbTokenOrder.indexOfValue(settings.currentSortValue) + } + + Component.onDestruction: { + settings.currentSortValue = cmbTokenOrder.currentValue + } + ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: root.filterVisible ? implicitHeight : 0 diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 918c6e532a..7b1b3b9021 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -357,7 +357,8 @@ QtObject { readonly property int manageAccounts: 1 readonly property int manageAssets: 2 readonly property int manageCollectibles: 3 - readonly property int manageTokenLists: 4 + readonly property int manageHidden: 4 + readonly property int manageAdvanced: 5 } readonly property QtObject currentUserStatus: QtObject{