From 710a5c09141a23bfdf9b5d45c4e735f355f231c2 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 15 Aug 2019 11:29:22 -0400 Subject: [PATCH] Keep filter bars from different sidePanes in sync --- src/python/config_files.py | 1 + src/qml/Python.qml | 1 + src/qml/SidePane/PaneToolBar.qml | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/python/config_files.py b/src/python/config_files.py index 3060bfb7..5d8f185f 100644 --- a/src/python/config_files.py +++ b/src/python/config_files.py @@ -132,6 +132,7 @@ class UIState(JSONConfigFile): "collapseAccounts": {}, "page": "Pages/Default.qml", "pageProperties": {}, + "sidePaneFilter": "", "sidePaneManualWidth": None, } diff --git a/src/qml/Python.qml b/src/qml/Python.qml index 70cf74ac..d97b52e7 100644 --- a/src/qml/Python.qml +++ b/src/qml/Python.qml @@ -34,6 +34,7 @@ Python { function saveConfig(backend_attribute, data, callback=null) { if (! py.ready) { return } // config not loaded yet + print(backend_attribute, JSON.stringify( data, null, 4)) callCoro(backend_attribute + ".write", [data], callback) } diff --git a/src/qml/SidePane/PaneToolBar.qml b/src/qml/SidePane/PaneToolBar.qml index 67cf6fce..b81f53b0 100644 --- a/src/qml/SidePane/PaneToolBar.qml +++ b/src/qml/SidePane/PaneToolBar.qml @@ -1,3 +1,4 @@ +import QtQuick 2.12 import QtQuick.Layouts 1.12 import "../Base" @@ -25,5 +26,20 @@ HRowLayout { Layout.fillWidth: true Layout.preferredHeight: parent.height + + onTextChanged: { + if (window.uiState.sidePaneFilter == text) return + + print("save") + window.uiState.sidePaneFilter = text + window.uiStateChanged() + } + + Connections { + target: window + // Keep multiple instances of PaneToolBar in sync + onUiStateChanged: filterField.text = uiState.sidePaneFilter + } + } }