From 9b252ada2e56a8a09bacded1622147911ed840b6 Mon Sep 17 00:00:00 2001 From: armored-dragon Date: Sun, 20 Apr 2025 07:12:34 -0500 Subject: [PATCH] Added more docs with examples. Revered property type change. --- scripts/system/settings/README.md | 80 ++++++++++++++++++- scripts/system/settings/qml/SettingNumber.qml | 2 +- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/scripts/system/settings/README.md b/scripts/system/settings/README.md index ffdf80eb8a..1afdee3b1e 100644 --- a/scripts/system/settings/README.md +++ b/scripts/system/settings/README.md @@ -13,25 +13,43 @@ The important settings related widgets are as follows: | SettingComboBox.qml | A drop down element which provides a list of options | | SettingNumber.qml | An input which only allows numerical data entry | | SettingSlider.qml | An input which only allows numerical data entry, presented as a slider | -| SettingSlider.qml | An input which only allows numerical data entry, presented as a slider | #### Examples +SettingBoolean.qml: +```qml +SettingBoolean { + // Provide the label for the setting (String). + settingText: "Rendering effects"; + + // Set the initial value of the boolean based on the current setting (bool). + settingEnabled: Render.renderMethod == 0; + + // When the value is changed, execute... + onSettingEnabledChanged: { + // Adjust the application setting to the current value of this boolean. + Render.renderMethod = settingEnabled ? 0 : 1; + } +} +``` + + SettingComboBox.qml: ```qml SettingComboBox { - // Provide the label for the setting (String) + // Provide the label for the setting (String). settingText: "Refresh rate"; // Options for the setting (Array of strings) options: ["Economical", "Interactive", "Real-Time", "Custom"]; - // Set the index of the combobox based on the current setting (int) + // Set the index of the combobox based on the current setting (int). optionIndex: Performance.getRefreshRateProfile(); // When the value is changed, execute... onValueChanged: { - // Adjust the application setting to the current value of the combobox + // Adjust the application setting to the current value of the combobox. + // Note: the "index" variable provides the index of the provided options which is selected. Performance.setRefreshRateProfile(index); // If the index is 3 (Custom), show advanced settings, otherwise hide advanced settings. @@ -39,3 +57,57 @@ SettingComboBox { } } ``` + +SettingNumber.qml: +```qml +SettingNumber { + // Provide the label for the setting (String). + settingText: "Focus Active"; + + // Set the minimum value allowed for this input (real). + minValue: 5; + + // Set the maximum value allowed (real). + maxValue: 9999; + + // Extra text to add at the far right of the element. + suffixText: "fps"; + + // Set the initial value of the number based on the current setting (var). + settingValue: Performance.getCustomRefreshRate(0); + + // When the value is changed, execute... + onValueChanged: { + // Adjust the application setting to the current value of this number. + // Note: the "value" variable provides the current value of this element. + Performance.setCustomRefreshRate(0, value); + } +} +``` + +SettingSlider.qml: +```qml +SettingSlider { + // Provide the label for the setting (String). + settingText: "Resolution scale"; + + // Set the step size for the slider (real). + sliderStepSize: 0.1; + + // Set the minimum value allowed by the slider (real). + minValue: 0.1; + + // Set the maximum value allowed by the slider (real). + maxValue: 2; + + // Set the initial value based on the current setting (var). + settingValue: Render.viewportResolutionScale.toFixed(1) + + // When the value is changed, execute... + onSliderValueChanged: { + // Adjust the application setting to the current value of this slider. + // Note: the "value" variable provides the current value of this element. + Render.viewportResolutionScale = value.toFixed(1) + } +} +``` \ No newline at end of file diff --git a/scripts/system/settings/qml/SettingNumber.qml b/scripts/system/settings/qml/SettingNumber.qml index 86f1138241..aa00a3f3c4 100644 --- a/scripts/system/settings/qml/SettingNumber.qml +++ b/scripts/system/settings/qml/SettingNumber.qml @@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3 Item { id: root; property string settingText: ""; - property int settingValue: 0; + property var settingValue: 0; property real minValue: 0; property real maxValue: 9;