Add text box

This commit is contained in:
Atlante45 2016-03-08 16:40:54 -08:00
parent 254e04c4b7
commit 028c7ab6ba
2 changed files with 35 additions and 23 deletions

View file

@ -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"
@ -57,15 +57,35 @@ Window {
} }
function uploadFile(fileUrl, addToScene) { function chooseClicked() {
var browser = fileBrowserBuilder.createObject(desktop, {
selectDirectory: false,
folder: fileDialogHelper.pathToUrl(currentDirectory)
});
browser.selectedFile.connect(function(url){
console.log(url);
fileUrlTextField.text = fileDialogHelper.urlToPath(url);
});
}
function uploadClicked() {
var fileUrl = fileUrlTextField.text
var addToScene = addToSceneCheckBox.checked
var object = desktop.inputDialog({ var object = desktop.inputDialog({
label: "Enter asset path", label: "Enter asset path:",
//placeholderText: "atp:/myFolder/myFile.ext" prefilledText: "atp:/myFolder/myFile.ext",
placeholderText: "Enter path here"
}); });
object.selected.connect(function(value) { object.selected.connect(function(destinationPath) {
print(value); console.log("Uploading " + fileUrl + " to " + destinationPath + " (addToScene: " + addToScene + ")");
}); });
print("uploadFile: " + fileUrl + " " + addToScene);
} }
Column { Column {
@ -147,7 +167,7 @@ Window {
} }
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
@ -160,7 +180,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 {
@ -174,21 +194,12 @@ Window {
width: 100 width: 100
onClicked: { onClicked: root.chooseClicked()
var browser = fileBrowserBuilder.createObject(desktop, {
selectDirectory: false,
folder: fileDialogHelper.pathToUrl(currentDirectory)
});
browser.selectedFile.connect(function(url){
console.log(url);
fileUrl.text = fileDialogHelper.urlToPath(url);
});
}
} }
} }
HifiControls.CheckBox { HifiControls.CheckBox {
id: addToScene id: addToSceneCheckBox
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
@ -200,7 +211,7 @@ Window {
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: addToSceneCheckBox.top
anchors.right: parent.right anchors.right: parent.right
HifiControls.Button { HifiControls.Button {
@ -213,8 +224,8 @@ 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()
} }
} }
} }

View file

@ -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;