mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 00:59:56 +02:00
Added more docs with examples.
Revered property type change.
This commit is contained in:
parent
5afa38dc80
commit
9b252ada2e
2 changed files with 77 additions and 5 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
```
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue