mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 14:46:55 +02:00
Integrate file open dialog into running scripts dialog
This commit is contained in:
parent
746c388f7a
commit
cf8d2c5182
2 changed files with 25 additions and 2 deletions
|
@ -18,6 +18,12 @@ Window {
|
|||
property var scripts: ScriptDiscoveryService;
|
||||
property var scriptsModel: scripts.scriptsModelFilter
|
||||
property var runningScriptsModel: ListModel { }
|
||||
property var fileFilters: ListModel {
|
||||
id: jsFilters
|
||||
ListElement { text: "Javascript Files (*.js)"; filter: "*.js" }
|
||||
ListElement { text: "All Files (*.*)"; filter: "*.*" }
|
||||
}
|
||||
|
||||
|
||||
Settings {
|
||||
category: "Overlay.RunningScripts"
|
||||
|
@ -65,6 +71,23 @@ Window {
|
|||
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 {
|
||||
color: "white"
|
||||
implicitWidth: 384; implicitHeight: 640
|
||||
|
@ -163,7 +186,7 @@ Window {
|
|||
}
|
||||
Button {
|
||||
text: "from Disk"
|
||||
onClicked: ApplicationInterface.loadDialog();
|
||||
onClicked: loadFromFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ void OffscreenUi::createDesktop() {
|
|||
if (_desktop) {
|
||||
qDebug() << "Desktop already created";
|
||||
}
|
||||
getRootContext()->setContextProperty("DebugQML", false);
|
||||
getRootContext()->setContextProperty("DebugQML", QVariant(false));
|
||||
_desktop = dynamic_cast<QQuickItem*>(load("Root.qml"));
|
||||
Q_ASSERT(_desktop);
|
||||
getRootContext()->setContextProperty("Desktop", _desktop);
|
||||
|
|
Loading…
Reference in a new issue