Skip to content

Add a way to initialize script dialog from command line #32

Description

@narnaud

Nowadays, we can run or test a script from the command line using –run or –test.

The one missing piece would be to be able to initialize the dialog from the command line, particularly useful for testing.

Script Dialog use widget name to access data from QML, for example a QLineEdit named fileName will be accessed using data.fileName from QML. We could use a similar mechanism to initialize data. I'm thinking of something like that:

knut --test Script.qml --data `{ fileName:"myfilename"; checkBox: true }`

ie passing either a json fileName or a string that can be interpreted as a json file.

That would mean:

  • adding a new data option in KnutCore
  • loading the json file or interpreting the string (using nlohman/json
  • saving that to initialize the script (most likely needs to be saved in ScriptRunner)
  • create method ScriptDialogItem::initialize(json) to initialize the dialog from a json
  • in ScriptRunner::runQml if it's a ScriptDialog, pass the json to it

Finally, once everything is done, add a test:

  • create a small dialog script with some different widgets (lineedit, checkbox, spinbox, combo...) - see Create a demo script for ScriptDialog #28
  • create a test method that check the data values are not the ones initialized in the designer
  • create a test in tst_knut and pass the data so it works fine

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions