From 9d2a55b0f5fb9ecec0c6424107049be13b252d35 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Thu, 23 May 2024 18:58:14 +0200 Subject: [PATCH] Change for formatting for main.qml for better readability --- src/main.qml | 373 +++++++++++++++++++++++++-------------------------- 1 file changed, 186 insertions(+), 187 deletions(-) diff --git a/src/main.qml b/src/main.qml index 6ce7279..81d00d2 100644 --- a/src/main.qml +++ b/src/main.qml @@ -10,210 +10,209 @@ import QtQuick.Dialogs import QtQuick.Layouts ApplicationWindow { - id: mainWindow - title: "Persefone.jl Desktop" - width: 1024 - height: 768 - visibility: "Maximized" - visible: true - - menuBar: MenuBar { - Menu { - title: "&Simulation" - Action { - text: "&New Simulation" - onTriggered: { vars.launching = true } //TODO select config file - } - Action { - text: "&Configure Simulation" - onTriggered: { Julia.configwindow() } - } - Action { - text: "&Load Saved State" - onTriggered: { loadFileChooser.open() } - } - Action { - text: "&Save Current State" - onTriggered: { saveFileChooser.open() } - } - MenuSeparator { } - Action { - text: "&Quit" - onTriggered: { mainWindow.close() } - } - } - Menu { - title: "&Data" - Action { - text: "Show &Population Graph" - onTriggered: { populationGraph.visible = true } - } - Action { - text: "Save &Simulation Output" - onTriggered: { Julia.saveoutput() } - } - } - Menu { - title: "&Help" - Action { - text: "&Documentation" - onTriggered: { Qt.openUrlExternally("https://persefone-model.eu/documentation") } - } - Action { - text: "&Website" - onTriggered: { Qt.openUrlExternally("https://persefone-model.eu/") } - } - Action { - text: "&About" - onTriggered: { aboutDialog.open() } - } - } - } + id: mainWindow + title: "Persefone.jl Desktop" + width: 1024 + height: 768 + visibility: "Maximized" + visible: true - // visualise the model map and the locations of animals - MakieViewport { - id: mapviewport - anchors.fill: parent - renderFunction: render_map_callback + menuBar: MenuBar { + Menu { + title: "&Simulation" + Action { + text: "&New Simulation" + onTriggered: { vars.launching = true } //TODO select config file + } + Action { + text: "&Configure Simulation" + onTriggered: { Julia.configwindow() } + } + Action { + text: "&Load Saved State" + onTriggered: { loadFileChooser.open() } + } + Action { + text: "&Save Current State" + onTriggered: { saveFileChooser.open() } + } + MenuSeparator { } + Action { + text: "&Quit" + onTriggered: { mainWindow.close() } + } + } + Menu { + title: "&Data" + Action { + text: "Show &Population Graph" + onTriggered: { populationGraph.visible = true } + } + Action { + text: "Save &Simulation Output" + onTriggered: { Julia.saveoutput() } + } + } + Menu { + title: "&Help" + Action { + text: "&Documentation" + onTriggered: { Qt.openUrlExternally("https://persefone-model.eu/documentation") } + } + Action { + text: "&Website" + onTriggered: { Qt.openUrlExternally("https://persefone-model.eu/") } + } + Action { + text: "&About" + onTriggered: { aboutDialog.open() } + } } + } - // the main control bar, with pause/step/run buttons, the progress - // bar and a speed slider - footer: ToolBar { - RowLayout { - //TODO change button texts to icons - // (https://doc.qt.io/qt-6/qtquickcontrols-icons.html) - id: controlBar - anchors.fill: parent - Layout.alignment: Qt.AlignVCenter - Layout.fillWidth: true - // anchors.topMargin: 5 //FIXME - // anchors.bottomMargin: 5 - Button { - id: backButton - text: "<" - ToolTip.text: "Back" - ToolTip.visible: hovered - onClicked: { Julia.previousstep() } - } - Button { - id: stepButton - text: ">" - ToolTip.text: "Step" - ToolTip.visible: hovered - onClicked: { Julia.nextstep() } - } - Button { - id: runButton - text: vars.runbuttontext - ToolTip.text: vars.runbuttontip - ToolTip.visible: hovered - onClicked: { vars.running = !vars.running } - } - ProgressBar { - id: progressBar - value: vars.progress - Layout.fillWidth: true - ToolTip.text: "Simulation progress" - ToolTip.visible: hovered - } - Slider { - id: speedSlider - from: 0.0 - to: 2.0 - value: vars.delay - stepSize: 0.1 - snapMode: Slider.SnapAlways - ToolTip.text: "Time delay between updates" - ToolTip.visible: hovered - onValueChanged: vars.delay = value - } - Text { - id: dateText - text: Julia.datestring() - //width: //TODO - } - } + // visualise the model map and the locations of animals + MakieViewport { + id: mapviewport + anchors.fill: parent + renderFunction: render_map_callback + } + + // the main control bar, with pause/step/run buttons, the progress + // bar and a speed slider + footer: ToolBar { + RowLayout { + //TODO change button texts to icons + // (https://doc.qt.io/qt-6/qtquickcontrols-icons.html) + id: controlBar + anchors.fill: parent + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + // anchors.topMargin: 5 //FIXME + // anchors.bottomMargin: 5 + Button { + id: backButton + text: "<" + ToolTip.text: "Back" + ToolTip.visible: hovered + onClicked: { Julia.previousstep() } + } + Button { + id: stepButton + text: ">" + ToolTip.text: "Step" + ToolTip.visible: hovered + onClicked: { Julia.nextstep() } + } + Button { + id: runButton + text: vars.runbuttontext + ToolTip.text: vars.runbuttontip + ToolTip.visible: hovered + onClicked: { vars.running = !vars.running } + } + ProgressBar { + id: progressBar + value: vars.progress + Layout.fillWidth: true + ToolTip.text: "Simulation progress" + ToolTip.visible: hovered + } + Slider { + id: speedSlider + from: 0.0 + to: 2.0 + value: vars.delay + stepSize: 0.1 + snapMode: Slider.SnapAlways + ToolTip.text: "Time delay between updates" + ToolTip.visible: hovered + onValueChanged: vars.delay = value + } + Text { + id: dateText + text: Julia.datestring() + //width: //TODO + } } + } - // extra windows - MessageDialog { - id: aboutDialog - text: "Persefone.jl Desktop" - informativeText: "A mechanistic model of agricultural landscapes \ + // extra windows + MessageDialog { + id: aboutDialog + text: "Persefone.jl Desktop" + informativeText: "A mechanistic model of agricultural landscapes \ and ecosystems in Europe.\n\n\ © 2023 Daniel Vedder, Lea Kolb, Guy Pe'er\n\ Distributed under the MIT license." - } + } - FileDialog { - id: loadFileChooser - defaultSuffix: "dat" - nameFilters: ["Save files (*.dat)"] - onAccepted: { Julia.loadsimulation(selectedFile.toString()) } - } + FileDialog { + id: loadFileChooser + defaultSuffix: "dat" + nameFilters: ["Save files (*.dat)"] + onAccepted: { Julia.loadsimulation(selectedFile.toString()) } + } - FileDialog { - id: saveFileChooser - defaultSuffix: "dat" - fileMode: FileDialog.SaveFile - nameFilters: ["Save files (*.dat)"] - onAccepted: { Julia.savesimulation(selectedFile.toString()) } - } + FileDialog { + id: saveFileChooser + defaultSuffix: "dat" + fileMode: FileDialog.SaveFile + nameFilters: ["Save files (*.dat)"] + onAccepted: { Julia.savesimulation(selectedFile.toString()) } + } - Window { - id: populationGraph - title: "Population Graph" - width: 512 - height: 512 - visible: false + Window { + id: populationGraph + title: "Population Graph" + width: 512 + height: 512 + visible: false - MakieViewport { - id: plotviewport - anchors.fill: parent - renderFunction: render_plot_callback - } + MakieViewport { + id: plotviewport + anchors.fill: parent + renderFunction: render_plot_callback } + } + + Popup { + id: splashPopup + parent: Overlay.overlay + closePolicy: Popup.NoAutoClose + modal: true + padding: 0 - Popup { - id: splashPopup - parent: Overlay.overlay - closePolicy: Popup.NoAutoClose - modal: true - padding: 0 + width: 600 + height: 250 + x: Math.round((parent.width - width) / 2) + y: Math.round((parent.height - height) / 2) - width: 600 - height: 250 - x: Math.round((parent.width - width) / 2) - y: Math.round((parent.height - height) / 2) - - Image { - anchors.fill: parent - source: "persefonejl_logo_v3_splash.png" - } + Image { + anchors.fill: parent + source: "persefonejl_logo_v3_splash.png" } + } - // set up connections and signals to update the simulation and the display - Connections { - target: timer - function onTimeout() { vars.ticks += 1 } + // set up connections and signals to update the simulation and the display + Connections { + target: timer + function onTimeout() { vars.ticks += 1 } + } + + JuliaSignals { + signal updateMakie() + onUpdateMakie: { + dateText.text = Julia.datestring(); + mapviewport.update(); + plotviewport.update(); } - - JuliaSignals { - signal updateMakie() - onUpdateMakie: { - dateText.text = Julia.datestring(); - mapviewport.update(); - plotviewport.update(); - } - signal showSplash() - onShowSplash: { - splashPopup.open() - } - signal closeSplash() - onCloseSplash: { - splashPopup.close() - } + signal showSplash() + onShowSplash: { + splashPopup.open() } - + signal closeSplash() + onCloseSplash: { + splashPopup.close() + } + } } -- GitLab