diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index b79f3bc7de..cc5bd521ff 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -13,6 +13,7 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 +import Qt.labs.settings 1.0 import "../styles-uit" import "../controls-uit" as HifiControls @@ -54,8 +55,15 @@ Rectangle { letterboxMessage.visible = true letterboxMessage.popupRadius = 0 } + Settings { + id: settings + category: "pal" + property bool filtered: false + property int nearDistance: 30 + } function refreshWithFilter() { - pal.sendToScript({method: 'refresh', params: {filter: filter.checked && {distance: 30}}}) + // We should just be able to set settings.filtered to filter.checked, but see #3249, so send to .js for saving. + pal.sendToScript({method: 'refresh', params: {filter: filter.checked && {distance: settings.nearDistance}}}); } // This is the container for the PAL @@ -101,6 +109,7 @@ Rectangle { Row { HifiControls.CheckBox { id: filter + checked: settings.filtered text: "in view" boxSize: reload.height onCheckedChanged: refreshWithFilter() diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 0a135aeddb..8ae4412fae 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -238,7 +238,11 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'refresh': removeOverlays(); - populateUserList(message.params.selected, message.params.filter); + // If filter is specified from .qml instead of through settings, update the settings. + if (message.params.filter !== undefined) { + Settings.setValue('pal/filtered', !!message.params.filter); + } + populateUserList(message.params.selected); UserActivityLogger.palAction("refresh", ""); break; case 'updateGain': @@ -280,13 +284,10 @@ function addAvatarNode(id) { color: color(selected, false, 0.0), ignoreRayIntersection: false}, selected, !conserveResources); } -var filter = false; // Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter. var avatarsOfInterest = {}; -function populateUserList(selectData, filterRequest) { - if (filterRequest !== undefined) { - filter = filterRequest; - } +function populateUserList(selectData) { + var filter = Settings.getValue('pal/filtered') && {distance: Settings.getValue('pal/nearDistance')}; var data = [], avatars = AvatarList.getAvatarIdentifiers(); avatarsOfInterest = {}; var myPosition = filter && Camera.position,