mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:43:03 +02:00
Merge pull request #83 from Atlante45/feat/atp
Add message boxes for rename and delete
This commit is contained in:
commit
9587620eb1
2 changed files with 110 additions and 51 deletions
|
@ -34,7 +34,7 @@ Window {
|
||||||
|
|
||||||
property var scripts: ScriptDiscoveryService;
|
property var scripts: ScriptDiscoveryService;
|
||||||
property var scriptsModel: scripts.scriptsModelFilter
|
property var scriptsModel: scripts.scriptsModelFilter
|
||||||
property var currentDirectory: ""
|
property var currentDirectory;
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
category: "Overlay.AssetServer"
|
category: "Overlay.AssetServer"
|
||||||
|
@ -43,29 +43,96 @@ Window {
|
||||||
property alias directory: root.currentDirectory
|
property alias directory: root.currentDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function reload() {
|
function reload() {
|
||||||
print("reload");
|
print("reload");
|
||||||
}
|
}
|
||||||
|
function addToWorld() {
|
||||||
function goBack() {
|
print("addToWorld");
|
||||||
print("goBack");
|
|
||||||
}
|
}
|
||||||
|
function renameFile() {
|
||||||
|
var path = scriptsModel.data(treeView.currentIndex, 0x100);
|
||||||
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function uploadFile(fileUrl, addToScene) {
|
var object = desktop.inputDialog({
|
||||||
print("uploadFile: " + fileUrl + " " + addToScene);
|
label: "Enter new path:",
|
||||||
|
prefilledText: path,
|
||||||
|
placeholderText: "Enter path here"
|
||||||
|
});
|
||||||
|
object.selected.connect(function(destinationPath) {
|
||||||
|
console.log("Renaming " + path + " to " + destinationPath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFile() {
|
function deleteFile() {
|
||||||
print("deleteFile");
|
var path = scriptsModel.data(treeView.currentIndex, 0x100);
|
||||||
|
if (!path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var object = desktop.messageBox({
|
||||||
|
icon: OriginalDialogs.StandardIcon.Question,
|
||||||
|
buttons: OriginalDialogs.StandardButton.Yes | OriginalDialogs.StandardButton.No,
|
||||||
|
defaultButton: OriginalDialogs.StandardButton.No,
|
||||||
|
text: "Deleting",
|
||||||
|
informativeText: "You are about to delete the following file:\n" +
|
||||||
|
path +
|
||||||
|
"\nDo you want to continue?"
|
||||||
|
});
|
||||||
|
object.selected.connect(function(button) {
|
||||||
|
if (button === OriginalDialogs.StandardButton.Yes) {
|
||||||
|
console.log("Deleting " + path);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseClicked() {
|
||||||
|
var browser = desktop.fileDialog({
|
||||||
|
selectDirectory: false,
|
||||||
|
dir: currentDirectory
|
||||||
|
});
|
||||||
|
browser.selectedFile.connect(function(url){
|
||||||
|
fileUrlTextField.text = fileDialogHelper.urlToPath(url);
|
||||||
|
currentDirectory = browser.dir;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function uploadClicked() {
|
||||||
|
var fileUrl = fileUrlTextField.text
|
||||||
|
var addToWorld = addToWorldCheckBox.checked
|
||||||
|
|
||||||
|
var path = scriptsModel.data(treeView.currentIndex, 0x100);
|
||||||
|
var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "";
|
||||||
|
var filename = fileUrl.slice(fileUrl.lastIndexOf('/') + 1);
|
||||||
|
|
||||||
|
var object = desktop.inputDialog({
|
||||||
|
label: "Enter asset path:",
|
||||||
|
prefilledText: directory + filename,
|
||||||
|
placeholderText: "Enter path here"
|
||||||
|
});
|
||||||
|
object.selected.connect(function(destinationPath) {
|
||||||
|
console.log("Uploading " + fileUrl + " to " + destinationPath + " (addToWorld: " + addToWorld + ")");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: pane.contentWidth
|
width: pane.contentWidth
|
||||||
|
|
||||||
HifiControls.ContentSection {
|
HifiControls.ContentSection {
|
||||||
|
id: assetDirectory
|
||||||
name: "Asset Directory"
|
name: "Asset Directory"
|
||||||
spacing: hifi.dimensions.contentSpacing.y
|
spacing: hifi.dimensions.contentSpacing.y
|
||||||
isFirst: true
|
isFirst: true
|
||||||
|
@ -76,16 +143,6 @@ Window {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
spacing: hifi.dimensions.contentSpacing.x
|
spacing: hifi.dimensions.contentSpacing.x
|
||||||
|
|
||||||
HifiControls.GlyphButton {
|
|
||||||
glyph: hifi.glyphs.back
|
|
||||||
color: hifi.buttons.white
|
|
||||||
colorScheme: root.colorScheme
|
|
||||||
height: 26
|
|
||||||
width: 26
|
|
||||||
|
|
||||||
onClicked: root.goBack()
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControls.GlyphButton {
|
HifiControls.GlyphButton {
|
||||||
glyph: hifi.glyphs.reload
|
glyph: hifi.glyphs.reload
|
||||||
color: hifi.buttons.white
|
color: hifi.buttons.white
|
||||||
|
@ -95,23 +152,35 @@ Window {
|
||||||
|
|
||||||
onClicked: root.reload()
|
onClicked: root.reload()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
HifiControls.Button {
|
||||||
// Take the deleteButotn out of the column flow.
|
text: "ADD TO WORLD"
|
||||||
id: deleteButtonContainer
|
color: hifi.buttons.white
|
||||||
anchors.top: buttonRow.top
|
colorScheme: root.colorScheme
|
||||||
anchors.right: parent.right
|
height: 26
|
||||||
|
width: 120
|
||||||
|
|
||||||
|
onClicked: root.addToWorld()
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControls.Button {
|
||||||
|
text: "RENAME"
|
||||||
|
color: hifi.buttons.white
|
||||||
|
colorScheme: root.colorScheme
|
||||||
|
height: 26
|
||||||
|
width: 80
|
||||||
|
|
||||||
|
onClicked: root.renameFile()
|
||||||
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
id: deleteButton
|
id: deleteButton
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
text: "DELETE SELECTION"
|
text: "DELETE"
|
||||||
color: hifi.buttons.red
|
color: hifi.buttons.red
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
height: 26
|
height: 26
|
||||||
width: 130
|
width: 80
|
||||||
|
|
||||||
onClicked: root.deleteFile()
|
onClicked: root.deleteFile()
|
||||||
}
|
}
|
||||||
|
@ -119,7 +188,7 @@ Window {
|
||||||
|
|
||||||
HifiControls.Tree {
|
HifiControls.Tree {
|
||||||
id: treeView
|
id: treeView
|
||||||
height: 250
|
height: 400
|
||||||
treeModel: scriptsModel
|
treeModel: scriptsModel
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
@ -128,16 +197,12 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.ContentSection {
|
HifiControls.ContentSection {
|
||||||
|
id: uploadSection
|
||||||
name: ""
|
name: ""
|
||||||
spacing: hifi.dimensions.contentSpacing.y
|
spacing: hifi.dimensions.contentSpacing.y
|
||||||
|
|
||||||
Component {
|
|
||||||
id: fileBrowserBuilder;
|
|
||||||
FileDialog { selectDirectory: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControls.TextField {
|
HifiControls.TextField {
|
||||||
id: fileUrl
|
id: fileUrlTextField
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: chooseButton.width + hifi.dimensions.contentSpacing.x
|
anchors.rightMargin: chooseButton.width + hifi.dimensions.contentSpacing.x
|
||||||
|
@ -150,7 +215,7 @@ Window {
|
||||||
Item {
|
Item {
|
||||||
// Take the chooseButton out of the column flow.
|
// Take the chooseButton out of the column flow.
|
||||||
id: chooseButtonContainer
|
id: chooseButtonContainer
|
||||||
anchors.top: fileUrl.top
|
anchors.top: fileUrlTextField.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -164,33 +229,24 @@ Window {
|
||||||
|
|
||||||
width: 100
|
width: 100
|
||||||
|
|
||||||
onClicked: {
|
onClicked: root.chooseClicked()
|
||||||
var browser = fileBrowserBuilder.createObject(desktop, {
|
|
||||||
selectDirectory: true,
|
|
||||||
folder: fileDialogHelper.pathToUrl(currentDirectory)
|
|
||||||
});
|
|
||||||
browser.selectedFile.connect(function(url){
|
|
||||||
console.log(url);
|
|
||||||
fileUrl.text = fileDialogHelper.urlToPath(url);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.CheckBox {
|
HifiControls.CheckBox {
|
||||||
id: addToScene
|
id: addToWorldCheckBox
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: uploadButton.width + hifi.dimensions.contentSpacing.x
|
anchors.rightMargin: uploadButton.width + hifi.dimensions.contentSpacing.x
|
||||||
|
|
||||||
text: "Add to scene on upload"
|
text: "Add to world on upload"
|
||||||
checked: false
|
checked: false
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
// Take the uploadButton out of the column flow.
|
// Take the uploadButton out of the column flow.
|
||||||
id: uploadButtonContainer
|
id: uploadButtonContainer
|
||||||
anchors.top: addToScene.top
|
anchors.top: addToWorldCheckBox.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
@ -203,10 +259,12 @@ Window {
|
||||||
height: 30
|
height: 30
|
||||||
width: 155
|
width: 155
|
||||||
|
|
||||||
enabled: fileUrl.text != ""
|
enabled: fileUrlTextField.text != ""
|
||||||
onClicked: root.uploadFile(fileUrl.text, addToScene.checked)
|
onClicked: root.uploadClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControls.VerticalSpacer {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ ModalWindow {
|
||||||
|
|
||||||
// For text boxes
|
// For text boxes
|
||||||
property alias placeholderText: textResult.placeholderText
|
property alias placeholderText: textResult.placeholderText
|
||||||
|
property alias prefilledText: textResult.text
|
||||||
|
|
||||||
// For combo boxes
|
// For combo boxes
|
||||||
property bool editable: true;
|
property bool editable: true;
|
||||||
|
|
Loading…
Reference in a new issue