Writing 2 plugins refering to the same bunch of code

• May 17, 2021 - 23:42


I'd like to write 2 plugins sharing 80% of their code (one as a standard dialog, one as right-panel explorer).
I couldn't find how to write a library of qml code, reusable in plugins. Is this possible ?



In reply to by Jojo-Schmitz

Thanks. What is the syntax for this ?
I used this documentation https://doc.qt.io/qt-5/qtqml-javascript-imports.html

import QtQuick 2.9
import QtQuick.Controls 2.2 //1.4 
import MuseScore 3.0
//import "file:///D:/data/MuseScore3/Plugins/testlib.js" as TestLib
import "testlib.js" as TestLib
MuseScore {
      menuPath: "Plugins.pluginName"
      description: "Description goes here"
      version: "1.0"
      pluginType : "dialog"
      width: 800
      height: 500

With a really basic teslib.js file:

function GiveHelloText() { return "hello"; }

And it returns the following error:

   ligne 4 : Script file:///D:/data/MuseScore3/Plugins/testlib.js unavailable
   ligne 1 : Expected token `;'
   ligne 1 : Expected token `,'

Is this the right syntax ?
BTW, I used to have a link to the versions of the different QML components that were supported in MuseScore. Couldn't find a back. Can someone point me back to that page ?

In reply to by parkingb

Strangely it was working this morning. So no issue in the filename or path (although a typo error in my question above).
So I went further in my investigation. And actually, the issue is that it seems that MuseScore load the .js file into memory only once. I guess the first time it is needed. And so whatever are the modifications made to the .js file, MS doesn't take those into account (at least from the plugin editor).
One have to close MS and reopen MS to have it loafing the .js file again.
Any way to force MS to re-read the .js file from disk ?

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