From c694415b4bc3903f25603143182ebc9cc8c36ecd Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Wed, 1 Nov 2023 18:23:16 +0100 Subject: [PATCH] qml: add addresslist filter persistence --- electrum/gui/qml/components/Addresses.qml | 15 ++++++++++++--- electrum/gui/qml/qeconfig.py | 22 ++++++++++++++++++++++ electrum/simple_config.py | 2 ++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qml/components/Addresses.qml b/electrum/gui/qml/components/Addresses.qml index 7cd66247c..4d36b9947 100644 --- a/electrum/gui/qml/components/Addresses.qml +++ b/electrum/gui/qml/components/Addresses.qml @@ -34,8 +34,16 @@ Pane { id: showUsed text: qsTr('Show Used') enabled: listview.filterModel.showAddressesCoins != 2 - onCheckedChanged: listview.filterModel.showUsed = checked - Component.onCompleted: checked = listview.filterModel.showUsed + onCheckedChanged: { + listview.filterModel.showUsed = checked + if (activeFocus) { + Config.addresslistShowUsed = checked + } + } + Component.onCompleted: { + checked = Config.addresslistShowUsed + listview.filterModel.showUsed = checked + } } RowLayout { @@ -56,7 +64,7 @@ Pane { showCoinsAddressesModel.append({'text': qsTr('Addresses'), 'value': 1}) showCoinsAddressesModel.append({'text': qsTr('Coins'), 'value': 2}) showCoinsAddressesModel.append({'text': qsTr('Both'), 'value': 3}) - showCoinsAddresses.currentIndex = 0 + listview.filterModel.showAddressesCoins = Config.addresslistShowType for (let i=0; i < showCoinsAddressesModel.count; i++) { if (showCoinsAddressesModel.get(i).value == listview.filterModel.showAddressesCoins) { showCoinsAddresses.currentIndex = i @@ -68,6 +76,7 @@ Pane { onCurrentValueChanged: { if (activeFocus && currentValue) { listview.filterModel.showAddressesCoins = currentValue + Config.addresslistShowType = currentValue } } } diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 2eaccac16..c34796e27 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -212,6 +212,28 @@ class QEConfig(AuthMixin, QObject): self.config.GUI_QML_USER_KNOWS_PRESS_AND_HOLD = userKnowsPressAndHold self.userKnowsPressAndHoldChanged.emit() + addresslistShowTypeChanged = pyqtSignal() + @pyqtProperty(int, notify=addresslistShowTypeChanged) + def addresslistShowType(self): + return self.config.GUI_QML_ADDRESS_LIST_SHOW_TYPE + + @addresslistShowType.setter + def addresslistShowType(self, addresslistShowType): + if addresslistShowType != self.config.GUI_QML_ADDRESS_LIST_SHOW_TYPE: + self.config.GUI_QML_ADDRESS_LIST_SHOW_TYPE = addresslistShowType + self.addresslistShowTypeChanged.emit() + + addresslistShowUsedChanged = pyqtSignal() + @pyqtProperty(bool, notify=addresslistShowUsedChanged) + def addresslistShowUsed(self): + return self.config.GUI_QML_ADDRESS_LIST_SHOW_USED + + @addresslistShowUsed.setter + def addresslistShowUsed(self, addresslistShowUsed): + if addresslistShowUsed != self.config.GUI_QML_ADDRESS_LIST_SHOW_USED: + self.config.GUI_QML_ADDRESS_LIST_SHOW_USED = addresslistShowUsed + self.addresslistShowUsedChanged.emit() + @pyqtSlot('qint64', result=str) @pyqtSlot(QEAmount, result=str) def formatSatsForEditing(self, satoshis): diff --git a/electrum/simple_config.py b/electrum/simple_config.py index 4104fcac4..7a6bf1f38 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -1094,6 +1094,8 @@ This will result in longer routes; it might increase your fees and decrease the GUI_QML_PREFERRED_REQUEST_TYPE = ConfigVar('preferred_request_type', default='bolt11', type_=str) GUI_QML_USER_KNOWS_PRESS_AND_HOLD = ConfigVar('user_knows_press_and_hold', default=False, type_=bool) + GUI_QML_ADDRESS_LIST_SHOW_TYPE = ConfigVar('address_list_show_type', default=1, type_=int) + GUI_QML_ADDRESS_LIST_SHOW_USED = ConfigVar('address_list_show_used', default=False, type_=bool) BTC_AMOUNTS_DECIMAL_POINT = ConfigVar('decimal_point', default=DECIMAL_POINT_DEFAULT, type_=int) BTC_AMOUNTS_FORCE_NZEROS_AFTER_DECIMAL_POINT = ConfigVar(