/// PersefoneDesktop - a GUI to the Persefone model of agriculture and ecosystems /// /// This file defines the layout of the configuration window. /// import QtQuick import QtQuick.Window import QtQuick.Controls import QtQuick.Layouts import QtQuick.Dialogs import org.julialang ApplicationWindow { id: configWindow title: "Configure simulation" width: 700 height: 350 visible: true ColumnLayout { id: generalSettings anchors.top: parent.top anchors.left: parent.left anchors.leftMargin: 20 anchors.topMargin: 20 spacing: 8 Text { text: "General Settings:" horizontalAlignment: Text.AlignCenter font.bold: true } RowLayout { Label { text: "Configuration file:" } Label { text: conf.userconfigfile font.italic: true } Button { text: "Select..." onClicked: conffileChooser.open() } FileDialog { id: conffileChooser defaultSuffix: "toml" fileMode: FileDialog.SaveFile nameFilters: ["Configuration files (*.toml)"] onAccepted: conf.userconfigfile = selectedFile } } RowLayout { Label { text: "Output folder:" } Label { text: conf.outdir font.italic: true } Button { text: "Select..." onClicked: outdirChooser.open() } FolderDialog { id: outdirChooser selectedFolder: conf.outdir onAccepted: conf.outdir = selectedFolder } } //XXX Not all regions have data available! // (currently, only Jena is fully configured) RowLayout { Label { text: "Region:" } ComboBox { currentIndex: 3 model: ["Bodensee", "Eichsfeld", "Hohenlohe", "Jena", "Oberrhein", "Thüringer Becken"] onCurrentIndexChanged: conf.region = currentText } } RowLayout { Label { text: "Crop model:" } ComboBox { currentIndex: 0 model: ["ALMaSS", "AquaCrop"] onCurrentIndexChanged: conf.cropmodel = currentText } } //XXX For which years do I actually have data? RowLayout { Label { text: "Start date:" } SpinBox { Layout.maximumWidth: 100 from: 1 to: 31 value: conf.startdateday editable: true wrap: true onValueModified: conf.startdateday = value } SpinBox { Layout.maximumWidth: 100 from: 1 to: 12 value: conf.startdatemonth editable: true wrap: true onValueModified: conf.startdatemonth = value } SpinBox { Layout.maximumWidth: 100 from: 2000 to: 2050 value: conf.startdateyear editable: true wrap: true textFromValue: function(value) { return Number(value).toString(); } onValueModified: conf.startdateyear = value } } RowLayout { Label { text: "End date:" } SpinBox { Layout.maximumWidth: 100 from: 1 to: 31 value: conf.enddateday editable: true wrap: true onValueModified: conf.enddateday = value } SpinBox { Layout.maximumWidth: 100 from: 1 to: 12 value: conf.enddatemonth editable: true wrap: true onValueModified: conf.enddatemonth = value } SpinBox { Layout.maximumWidth: 100 from: 2000 to: 2050 value: conf.enddateyear editable: true wrap: true textFromValue: function(value) { return Number(value).toString(); } onValueModified: conf.enddateyear = value } } } ColumnLayout { id: advancedSettings anchors.top: parent.top anchors.right: parent.right anchors.left: generalSettings.right anchors.rightMargin: 20 anchors.topMargin: 20 anchors.leftMargin: 20 spacing: 8 Text { text: "Advanced Settings:" horizontalAlignment: Text.AlignCenter font.bold: true } RowLayout { Label { text: "Random seed:" } SpinBox { from: 0 to: 2147483647 value: 2 editable: true onValueModified: conf.seed = value } } RowLayout { Label { text: "Log level:" } ComboBox { currentIndex: 2 model: ["debug", "info", "warn"] onCurrentIndexChanged: conf.loglevel = currentText } } RowLayout { Label { text: "Processors:" } SpinBox { from: 1 to: 8 value: conf.processors editable: true onValueModified: conf.processors = value } } CheckBox { checked: conf.csvoutput text: "Write CSV output" onClicked: conf.csvoutput = checked } //TODO add config options for: // farmmodel // targetspecies // insectmodel } footer: ToolBar { RowLayout { anchors.right: parent.right layoutDirection: Qt.RightToLeft Button { text: "Start new simulation" onClicked: { //Julia.splashscreen() //FIXME crashes Julia.writeconfig() Julia.newsimulation() configWindow.close() } } Button { text: "Save configuration" onClicked: { Julia.writeconfig() configWindow.close() } } Button { text: "Cancel" onClicked: configWindow.close() } } } }