| 1 |
import QtQuick 2.4 |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
SettingControl { |
| 5 |
id: root |
| 6 |
|
| 7 |
|
| 8 |
// alias for save+restore |
| 9 |
property alias value: dateTimeEdit.value |
| 10 |
|
| 11 |
property alias defaultValue: root.now |
| 12 |
|
| 13 |
readonly property date now: new Date() |
| 14 |
|
| 15 |
implicitHeight: childrenRect.height |
| 16 |
|
| 17 |
DateTimeEdit { |
| 18 |
id: dateTimeEdit |
| 19 |
label: root.label |
| 20 |
enabled: root.enabled |
| 21 |
width: root.width |
| 22 |
} |
| 23 |
|
| 24 |
SettingDescription { |
| 25 |
id: description |
| 26 |
enabled: root.enabled |
| 27 |
text: root.description |
| 28 |
anchors.top: dateTimeEdit.bottom |
| 29 |
anchors.topMargin: Style.margin |
| 30 |
width: root.width |
| 31 |
} |
| 32 |
|
| 33 |
function restoreState() |
| 34 |
{ |
| 35 |
var rawValue = _config.getValueForKey("", root.setting, defaultValue); |
| 36 |
var year = rawValue.getFullYear(); |
| 37 |
if (isNaN(year) || (year < 1800)) { |
| 38 |
// assume it's an invalid date, there doesn't seem to be a better |
| 39 |
// way to check date validity from JS :( |
| 40 |
rawValue = defaultValue |
| 41 |
} |
| 42 |
|
| 43 |
dateTimeEdit.setDate(rawValue); |
| 44 |
} |
| 45 |
} |