From cbf514a738e0116d39b7d83e703af9dc7a5d9420 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 23 Nov 2016 10:11:28 -0800 Subject: [PATCH] PreferenceDialogs now preserve the sort order of their showCategories. Specifically, this was to fix the issue with the Neuron plugin preferences being the top section in the General Preferences dialog, now it is the last. --- .../qml/dialogs/PreferencesDialog.qml | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/dialogs/PreferencesDialog.qml b/interface/resources/qml/dialogs/PreferencesDialog.qml index ac9aad0e4a..e16f3aa12d 100644 --- a/interface/resources/qml/dialogs/PreferencesDialog.qml +++ b/interface/resources/qml/dialogs/PreferencesDialog.qml @@ -55,22 +55,20 @@ ScrollingWindow { Component.onCompleted: { var categories = Preferences.categories; - var categoryMap; var i; - if (showCategories && showCategories.length) { - categoryMap = {}; - for (i = 0; i < showCategories.length; ++i) { - categoryMap[showCategories[i]] = true; - } + + // build a map of valid categories. + var categoryMap = {}; + for (i = 0; i < categories.length; i++) { + categoryMap[categories[i]] = true; } - for (i = 0; i < categories.length; ++i) { - var category = categories[i]; - if (categoryMap && !categoryMap[category]) { - continue; + // create a section for each valid category in showCategories + // NOTE: the sort order of items in the showCategories array is the same order in the dialog. + for (i = 0; i < showCategories.length; i++) { + if (categoryMap[showCategories[i]]) { + sections.push(sectionBuilder.createObject(prefControls, {name: showCategories[i]})); } - - sections.push(sectionBuilder.createObject(prefControls, { name: category })); } if (sections.length) {