-
-
Save teamikl/0443922aa0a29de2641a to your computer and use it in GitHub Desktop.
MuseScore Plugin - MusicXML miscellaneous import
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.1 | |
import QtQuick.Controls 1.2 | |
import QtQuick.Dialogs 1.0 | |
import QtQuick.XmlListModel 2.0 | |
import MuseScore 1.0 | |
MuseScore { | |
menuPath: "Plugins.MusicXML.Import (misc)" | |
version: "1.0" | |
description: qsTr("This plugin import MusicXML file and set misc attributes as meta info.") | |
// デバッグ確認用 | |
// pluginType: "dialog" | |
// width: 500; height: 600; | |
onRun: { | |
fileDialog.open() | |
} | |
function importMusicXML(filename) { | |
var score = this.readScore(filename); | |
} | |
XmlListModel { | |
id: xmlModel | |
query: "/score-partwise/identification/miscellaneous/miscellaneous-field" | |
XmlRole { name: "key"; query: "@name/string()" } | |
XmlRole { name: "value"; query: "string()" } | |
onRowsInserted: { | |
for (var i = first; i <= last; ++i) { | |
var item = this.get(i); | |
curScore.setMetaTag(item.key, item.value); | |
console.log("setMetaTag "+item.key+": "+item.value); | |
} | |
} | |
} | |
FileDialog { | |
id: fileDialog | |
title: qsTr("Please choose a file") | |
nameFilters: ["MusicXML Files (*.xml *mxml)", "All files (*)"] | |
selectExisting: true | |
onAccepted: { | |
var filename = fileDialog.fileUrl; | |
importMusicXML(filename.toString().replace(/^file:\/{3}/, "")); | |
xmlModel.source = filename; | |
} | |
} | |
TableView { | |
model: xmlModel | |
TableViewColumn { | |
role: "key" | |
title: "Key" | |
width: 200 | |
} | |
TableViewColumn { | |
role: "value" | |
title: "Value" | |
width: 300 | |
} | |
anchors.fill: parent | |
width: parent.width | |
height: parent.height | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment