QML Help

• Jul 15, 2012 - 19:25

I'd be very grateful if someone could skim over the JavaScript bit of my MIDISightReader plugin and give me some clues as to how to upgrade it to the new QML framework.

Specifically:
- Get the plugin directory.
- Get the directory for temp files.
- Save a score as a MIDI file.
- Pop up a dialog who's text is read from a file, or is generated in the JavaScript.
- Set the stdout of a process to write to a file.
- Trigger a piece of JavaScript code from the stderr of a process run by the plugin.

I had a look at the built-in manual, but many of these methods seem to be missing.

Thanks.


Comments

The new plugin framework is still under development.

Go to Plugins -> Plugin creator and press the help button (with the rubber ring), you will find some help

Interesting reading :

Answers to your questions.

  • Get the plugin directory. I think it's not available yet
  • Get the directory for temp files.: Yesterday I added a FileIO interface. It's not yet documented. Check https://gist.github.com/3116128 for a crude example of defining a file in tempdir, and write to it.
  • Save a score as a MIDI file. writeScore(Score*, const QString& name, const QString& ext) should do it.
  • Pop up a dialog who's text is read from a file, or is generated in the JavaScript. UI is still under discussion. You can take a look to the QML tutorial I linked above. Reading a file see FileIO and the point 2 above.
  • Set the stdout of a process to write to a file: You can read the std outputs with readAllStandardOutput without passing via a file. You need to create the process with newProcess. Check the run example packaged in the current nightlies.
  • Trigger a piece of JavaScript code from the stderr of a process run by the plugin: not sure I guess that one. Can you explain again?

In reply to by [DELETED] 5

Thanks. I will peruse the tutorials.
Sounds like some of the features I need are not there yet.

Dialog box - I did find some QML to display warning message boxes, but it did not work.

Trigger JavaScript from stderr - this was a bit of a bodge! I think in the old plugin framework, the plugin was run in the GUI thread, as the GUI "hung" while the plugin was running. I need to display a results dialog when the Java bit of the plugin has completed. The only way I found to do this was for the Java to write the results to a file (.msg). When that completed, the Java wrote to stderr and this triggered the JavaScript to read the message file and display it. Naff, but it worked. You can see the JavaScript bit of the plugin that sets up this trigger:
midiSightReader.readyReadStandardError.connect(logMessage);
The logMessage() function then reads the file and shows a dialog with the message.

In reply to by [DELETED] 5

I looked at your new FileIO interface example.
FileIO {
id: myFile
source: tempPath() + "/my_file.xml"
onError: console.log(msg)
}

Using the above, how do I get the string which represents myFile? I need to pass the string to my plugin code.

Thanks.

Do you still have an unanswered question? Please log in first to post your question.