| 1 |
import QtQuick 2.4 |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
SettingControl { |
| 5 |
id: root |
| 6 |
|
| 7 |
property alias checked: toggle.checked |
| 8 |
property alias value: toggle.checked |
| 9 |
property bool defaultValue: false |
| 10 |
|
| 11 |
// should we set the option, if the current value matches the default? |
| 12 |
// this is used to suppress setting needless options to their default |
| 13 |
// value |
| 14 |
property bool setIfDefault: false |
| 15 |
|
| 16 |
implicitHeight: toggle.height + Style.margin + description.height |
| 17 |
|
| 18 |
ToggleSwitch { |
| 19 |
id: toggle |
| 20 |
label: root.label |
| 21 |
enabled: root.enabled |
| 22 |
} |
| 23 |
|
| 24 |
SettingDescription { |
| 25 |
id: description |
| 26 |
enabled: root.enabled |
| 27 |
text: root.description |
| 28 |
anchors.top: toggle.bottom |
| 29 |
anchors.topMargin: Style.margin |
| 30 |
width: root.width |
| 31 |
} |
| 32 |
|
| 33 |
function apply() |
| 34 |
{ |
| 35 |
if (option == "") |
| 36 |
return; |
| 37 |
|
| 38 |
if (setIfDefault || (value != defaultValue)) { |
| 39 |
_config.setEnableDisableOption(option, checked) |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
function setValue(newValue) |
| 44 |
{ |
| 45 |
toggle.setValue(newValue) |
| 46 |
} |
| 47 |
} |