Skip to content

Commit

Permalink
Fix all examples following the IntermediatePy one
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSazonov committed Aug 30, 2024
1 parent 2fc57bc commit b869b5d
Show file tree
Hide file tree
Showing 100 changed files with 752 additions and 1,018 deletions.
112 changes: 0 additions & 112 deletions examples/BasicMinimalC++/README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pragma Singleton

import QtQuick

import Logic.Mock as MockLogic
import Backends.MockQml as MockLogic


QtObject {

property var application: MockLogic.Application
property var project: MockLogic.Project
property var status: MockLogic.Status
property var report: MockLogic.Report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ QtObject {

property bool created: false

property string name: ''

readonly property var info: {
'name': 'Super duper project',
'description': 'Default project description from Mock proxy',
'location': '/path to the project',
'description': '',
'location': '',
'creationDate': ''
}

Expand Down Expand Up @@ -56,14 +57,18 @@ QtObject {
]

function create() {
console.debug(`Creating project ${info.name}`)
console.debug(`Creating project '${name}'`)
info.creationDate = `${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`
infoChanged() // this signal is not emitted automatically when only part of the object is changed
created = true
}

function save() {
console.debug(`Saving project ${info.name}`)
console.debug(`NOT IMPLEMENTED: Saving project '${name}'`)
}

function editInfo(path, new_value) {
console.debug(`NOT IMPLEMENTED: Changing project info.${path} from '${info.path}' to '${new_value}'`)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ pragma Singleton
import QtQuick

QtObject {
property bool created: true
property bool created: false

readonly property string asHtml: '
<!DOCTYPE html>
<html>
<style>
th, td { padding-right: 18px; }
th, td { padding-right: 18px; }
th { text-align: left; }
</style>
<body>
Expand All @@ -28,7 +28,7 @@ th, td { padding-right: 18px; }
</tr>
<tr></tr>
<tr>
<th>Title</th>
<th>Name</th>
<th>La0.5Ba0.5CoO3</th>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import QtQuick
QtObject {

readonly property string project: 'Undefined'
readonly property string phaseCount: '1'
readonly property string phasesCount: '1'
readonly property string experimentsCount: '1'
readonly property string calculator: 'CrysPy'
readonly property string minimizer: 'Lmfit (leastsq)'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module MockLogic
module MockQml

singleton BackendProxy BackendProxy.qml
singleton Project Project.qml
singleton Report Report.qml
singleton Status Status.qml
3 changes: 3 additions & 0 deletions examples/BasicMinimalC++/src/BasicMinimalC++/Backends/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Logic

singleton MockBackend MockBackend.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ EaComponents.ApplicationWindow {
appBarLeftButtons: [

EaElements.ToolButton {
enabled: Globals.BackendProxy.project.created
enabled: Globals.BackendWrapper.projectCreated
highlighted: true
fontIcon: 'save'
ToolTip.text: qsTr('Save current state of the project')
onClicked: Globals.BackendProxy.project.save()
onClicked: Globals.BackendWrapper.projectSave()
}

]
Expand All @@ -49,13 +49,12 @@ EaComponents.ApplicationWindow {
// Home page
EaElements.AppBarTabButton {
id: homeButton
objectName: 'applicationWindow.appBarCentralTabs.homeButton'
fontIcon: 'home'
text: qsTr('Home')
ToolTip.text: qsTr('Home')
//Component.onCompleted: {
// Globals.References.applicationWindow.appBarCentralTabs.homeButton = homeButton
//}
Component.onCompleted: {
Globals.References.applicationWindow.appBarCentralTabs.homeButton = homeButton
}
},
// Home page

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import QtQuick
QtObject {

readonly property var about: {
'name': 'EasyBasicMinimalC++',
'namePrefix': 'Easy',
'nameSuffix': 'BasicMinimalC++',
'namePrefixForLogo': 'easy',
'nameSuffixForLogo': 'basicminimalc++',
'name': 'BasicMinimalC++',
'namePrefix': 'BasicMinimal',
'nameSuffix': 'C++',
'namePrefixForLogo': 'basicminimal',
'nameSuffixForLogo': 'c++',
'homePageUrl': 'https://github.com/EasyScience/EasyExample',
'issuesUrl': 'https://github.com/EasyScience/EasyExample/issues',
'licenseUrl': 'https://github.com/EasyScience/EasyExample/LICENCE.md',
Expand All @@ -34,3 +34,4 @@ QtObject {
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-FileCopyrightText: 2024 EasyApp contributors
// SPDX-License-Identifier: BSD-3-Clause
// © 2024 Contributors to the EasyApp project <https://github.com/easyscience/EasyApp>

pragma Singleton

import QtQuick

// This module is registered in the main.py file and allows access to the properties
// and backend methods of the singleton object of the ‘PyBackend’ class.
// If ‘PyBackend’ is not defined, then 'MockBackend' from directory 'Backends' is used.
// It is needed to run the GUI frontend via the qml runtime tool without any Python backend.
import Backends as Backends


QtObject {

////////////////
// Backend proxy
////////////////

readonly property var activeBackend: {
if (typeof Backends.PyBackend !== 'undefined') {
console.debug('Currently, the REAL python backend is in use')
return Backends.PyBackend
} else {
console.debug('Currently, the MOCK backend is in use')
return Backends.MockBackend
}
}

/////////////
// Status bar
/////////////

readonly property string statusProject: activeBackend.status.project
readonly property string statusPhasesCount: activeBackend.status.phasesCount
readonly property string statusExperimentsCount: activeBackend.status.experimentsCount
readonly property string statusCalculator: activeBackend.status.calculator
readonly property string statusMinimizer: activeBackend.status.minimizer
readonly property string statusVariables: activeBackend.status.variables

///////////////
// Project page
///////////////

readonly property var projectInfo: activeBackend.project.info
readonly property var projectExamples: activeBackend.project.examples

property bool projectCreated: activeBackend.project.created
onProjectCreatedChanged: activeBackend.project.created = projectCreated
property string projectName: activeBackend.project.name
onProjectNameChanged: activeBackend.project.name = projectName

function projectCreate() { activeBackend.project.create() }
function projectSave() { activeBackend.project.save() }
function projectEditInfo(path, new_value) { activeBackend.project.editInfo(path, new_value) }

///////////////
// Summary page
///////////////

readonly property string reportAsHtml: activeBackend.report.asHtml

property bool reportCreated: activeBackend.report.created
onReportCreatedChanged: activeBackend.report.created = reportCreated
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import QtQuick
// Initialisation of the reference dictionary. It is filled in later, when the required object is
// created and its unique id is assigned and added here instead of 'null'. After that, any object
// whose id is stored here can be accessed from any other qml file.

QtObject {

// Populated in ApplicationWindows.qml
Expand Down
Loading

0 comments on commit b869b5d

Please sign in to comment.