Make Ctrl-O and 'Running Scripts->load file' follow the same code path

This commit is contained in:
Brad Davis 2016-01-28 15:52:11 -08:00
parent 1324525ecc
commit db7e4eee8f

View file

@ -72,23 +72,6 @@ Window {
scripts.stopAllScripts(); scripts.stopAllScripts();
} }
Component {
id: fileDialogBuilder
FileDialog { }
}
function loadFromFile() {
var fileDialog = fileDialogBuilder.createObject(desktop, { filterModel: fileFilters });
fileDialog.canceled.connect(function(){
console.debug("Cancelled file open")
})
fileDialog.selectedFile.connect(function(file){
console.debug("Selected " + file)
scripts.loadOneScript(file);
})
}
Rectangle { Rectangle {
color: "white" color: "white"
anchors.fill: parent anchors.fill: parent
@ -201,31 +184,38 @@ Window {
anchors.bottomMargin: 8 anchors.bottomMargin: 8
anchors.right: parent.right anchors.right: parent.right
// For some reason trigginer an API that enters
// an internal event loop directly from the button clicked
// trigger below causes the appliction to behave oddly.
// Most likely because the button onClicked handling is never
// completed until the function returns.
// FIXME find a better way of handling the input dialogs that
// doesn't trigger this.
Timer {
id: asyncAction
interval: 50
repeat: false
running: false
onTriggered: ApplicationInterface.loadScriptURLDialog();
}
Button { Button {
text: "from URL"; text: "from URL";
onClicked: { onClicked: fromUrlTimer.running = true;
focus = false;
asyncAction.running = true; // For some reason trigginer an API that enters
// an internal event loop directly from the button clicked
// trigger below causes the appliction to behave oddly.
// Most likely because the button onClicked handling is never
// completed until the function returns.
// FIXME find a better way of handling the input dialogs that
// doesn't trigger this.
Timer {
id: fromUrlTimer
interval: 5
repeat: false
running: false
onTriggered: ApplicationInterface.loadScriptURLDialog();
} }
} }
Button { Button {
text: "from Disk" text: "from Disk"
onClicked: loadFromFile(); onClicked: fromDiskTimer.running = true;
Timer {
id: fromDiskTimer
interval: 5
repeat: false
running: false
onTriggered: ApplicationInterface.loadDialog();
}
} }
} }