| 1 |
/* GCompris - ClockgameEditor.qml |
| 2 |
* |
| 3 |
* SPDX-FileCopyrightText: 2025 Johnny Jazeix <[email protected]> |
| 4 |
* |
| 5 |
* Authors: |
| 6 |
* Johnny Jazeix <[email protected]> |
| 7 |
* |
| 8 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 9 |
*/ |
| 10 |
import QtQuick |
| 11 |
import QtQuick.Controls.Basic |
| 12 |
|
| 13 |
import "../../singletons" |
| 14 |
import "../../components" |
| 15 |
|
| 16 |
import ".." |
| 17 |
|
| 18 |
DatasetEditorBase { |
| 19 |
id: editor |
| 20 |
required property string textActivityData // Json array stringified as stored in database (dataset_/dataset_content) |
| 21 |
property ListModel mainModel: ({}) // The main ListModel, declared as a property for dynamic creation |
| 22 |
readonly property var prototypeStack: [ mainPrototype ] // A stack of prototypes (Only one here. There is no nested Listmodel) |
| 23 |
|
| 24 |
ListModel { |
| 25 |
id: mainPrototype |
| 26 |
property bool multiple: true |
| 27 |
ListElement { name: "numberOfSubLevels"; label: qsTr("Exercise count"); type: "int"; def: "10" } |
| 28 |
ListElement { name: "displayMinutesHand"; label: qsTr("Find minutes"); type: "boolean"; def: "true" } |
| 29 |
ListElement { name: "displaySecondsHand"; label: qsTr("Find seconds"); type: "boolean"; def: "true" } |
| 30 |
ListElement { name: "hoursVisible"; label: qsTr("Display hours numbers"); type: "boolean"; def: "true" } |
| 31 |
ListElement { name: "hoursMarksVisible"; label: qsTr("Display hours marks"); type: "boolean"; def: "true" } |
| 32 |
ListElement { name: "zonesVisible"; label: qsTr("Grey/white background between each hour"); type: "boolean"; def: "true" } |
| 33 |
ListElement { name: "minutesVisible"; label: qsTr("Display minutes numbers"); type: "boolean"; def: "true" } |
| 34 |
ListElement { name: "noHint"; label: qsTr("Hide the Hint button in the bar (which gives the current time)"); type: "boolean"; def: "true" } |
| 35 |
ListElement { name: "useFixedHours"; label: qsTr("Fixed hour"); type: "boolean"; def: "false" } |
| 36 |
ListElement { name: "fixedHours"; label: qsTr("Value"); type: "int"; def: "0" } |
| 37 |
ListElement { name: "useFixedMinutes"; label: qsTr("Fixed minutes"); type: "boolean"; def: "false" } |
| 38 |
ListElement { name: "fixedMinutes"; label: qsTr("Value"); type: "int"; def: "0" } |
| 39 |
ListElement { name: "useFixedSeconds"; label: qsTr("Fixed seconds"); type: "boolean"; def: "false" } |
| 40 |
ListElement { name: "fixedSeconds"; label: qsTr("Value"); type: "int"; def: "0" } |
| 41 |
} |
| 42 |
EditorBox { |
| 43 |
id: levelEditor |
| 44 |
anchors.fill: parent |
| 45 |
editorPrototype: mainPrototype |
| 46 |
editorModel: editor.mainModel |
| 47 |
|
| 48 |
fieldsComponent: Component { |
| 49 |
Column { |
| 50 |
id: fieldsColumn |
| 51 |
// Properties required by FieldEdit. Must be in the parent |
| 52 |
property ListModel currentPrototype: levelEditor.editorPrototype |
| 53 |
property ListModel currentModel: levelEditor.editorModel |
| 54 |
property int modelIndex: parent.index |
| 55 |
x: Style.margins |
| 56 |
y: Style.margins |
| 57 |
spacing: Style.smallMargins |
| 58 |
|
| 59 |
readonly property bool useFixedHours: currentModel && currentModel.get(fieldsColumn.modelIndex) ? |
| 60 |
currentModel.get(fieldsColumn.modelIndex).useFixedHours : false |
| 61 |
readonly property bool useFixedMinutes: currentModel && currentModel.get(fieldsColumn.modelIndex) ? |
| 62 |
currentModel.get(fieldsColumn.modelIndex).useFixedMinutes : false |
| 63 |
readonly property bool useFixedSeconds: currentModel && currentModel.get(fieldsColumn.modelIndex) ? |
| 64 |
currentModel.get(fieldsColumn.modelIndex).useFixedSeconds : false |
| 65 |
|
| 66 |
FieldEdit { name: "numberOfSubLevels" } |
| 67 |
FieldEdit { name: "displayMinutesHand" } |
| 68 |
FieldEdit { name: "displaySecondsHand" } |
| 69 |
FieldEdit { name: "hoursVisible" } |
| 70 |
FieldEdit { name: "hoursMarksVisible" } |
| 71 |
FieldEdit { name: "zonesVisible" } |
| 72 |
FieldEdit { name: "minutesVisible" } |
| 73 |
FieldEdit { name: "noHint" } |
| 74 |
FieldEdit { name: "useFixedHours" } |
| 75 |
FieldEdit { name: "fixedHours"; visible: fieldsColumn.useFixedHours } |
| 76 |
FieldEdit { name: "useFixedMinutes" } |
| 77 |
FieldEdit { name: "fixedMinutes"; visible: fieldsColumn.useFixedMinutes } |
| 78 |
FieldEdit { name: "useFixedSeconds" } |
| 79 |
FieldEdit { name: "fixedSeconds"; visible: fieldsColumn.useFixedSeconds } |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
Component.onCompleted: mainModel = datasetEditor.jsonToListModel(prototypeStack, JSON.parse(textActivityData)) |
| 85 |
} |