Skip to content

Instantly share code, notes, and snippets.

@lasconic
Created July 15, 2012 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lasconic/3116128 to your computer and use it in GitHub Desktop.
Save lasconic/3116128 to your computer and use it in GitHub Desktop.
import QtQuick 1.0
import MuseScore 1.0
import FileIO 1.0
MuseScore {
menuPath: "Plugins.ABC Import"
width: 640
height: 480
onRun: {}
FileIO {
id: myFile
source: tempPath() + "/my_file.xml"
onError: console.log(msg)
}
Rectangle {
id: mainarea
color: "grey"
anchors.fill: parent
Text {
id: textLabel
width:parent.width
height:10
text: "Enter ABC notation below:"
font.pointSize:12
}
Rectangle {
id:abcContainer
anchors.top: textLabel.bottom
anchors.topMargin: 10
width:parent.width
height:400
color:'white'
Flickable {
id:abcFlickable
anchors.fill: parent
contentWidth:abcText.width; contentHeight:abcText.height
flickableDirection: Flickable.VerticalFlick
clip: true
TextEdit {
id: abcText
wrapMode: TextEdit.Wrap
width:abcContainer.width;
font.family:"Courier"
font.pointSize:12
focus: true
}
}
}
Rectangle {
id: container
height: text.height + 10; width: text.width + 20
border.width: 1
radius: 4
smooth: true
anchors.top: abcContainer.bottom
gradient: Gradient {
GradientStop {
position: 0.0
color: !mouseArea.pressed ? activePalette.light : activePalette.button
}
GradientStop {
position: 1.0
color: !mouseArea.pressed ? activePalette.button : activePalette.dark
}
}
SystemPalette { id: activePalette }
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
var doc = new XMLHttpRequest()
var url = "http://abc2musicxml.appspot.com/abcrenderer?abc=" + encodeURIComponent(abcText.text);
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.DONE) {
var a = doc.responseText;
myFile.write(a);
readScore(myFile.source);
Qt.quit();
}
}
doc.open("GET", url);
doc.send()
}
}
Text {
id: text
anchors.centerIn:parent
font.pointSize: 10
text: "Convert"
color: activePalette.buttonText
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment