mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 09:34:38 +02:00
Replace drive drop-down plus text field with a paths drop-down
This commit is contained in:
parent
11aeaba114
commit
b2bbf72be2
1 changed files with 51 additions and 46 deletions
|
@ -68,16 +68,12 @@ ModalWindow {
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
console.log("Helper " + helper + " drives " + drives)
|
console.log("Helper " + helper + " drives " + drives)
|
||||||
drivesSelector.onCurrentTextChanged.connect(function(){
|
|
||||||
root.dir = helper.pathToUrl(drivesSelector.currentText);
|
|
||||||
})
|
|
||||||
|
|
||||||
// HACK: The following two lines force the model to initialize properly such that:
|
// HACK: The following lines force the model to initialize properly such that the go-up button
|
||||||
// - Selecting a different drive at the initial screen updates the path displayed.
|
// works properly from the initial screen.
|
||||||
// - The go-up button works properly from the initial screen.
|
var initialFolder = folderListModel.folder;
|
||||||
var initialFolder = currentDirectory.lastValidFolder;
|
fileTableModel.folder = helper.pathToUrl(drives[0]);
|
||||||
root.dir = helper.pathToUrl(drivesSelector.currentText);
|
fileTableModel.folder = initialFolder;
|
||||||
root.dir = helper.pathToUrl(initialFolder);
|
|
||||||
|
|
||||||
iconText = root.title !== "" ? hifi.glyphs.scriptUpload : "";
|
iconText = root.title !== "" ? hifi.glyphs.scriptUpload : "";
|
||||||
}
|
}
|
||||||
|
@ -97,15 +93,6 @@ ModalWindow {
|
||||||
}
|
}
|
||||||
spacing: hifi.dimensions.contentSpacing.x
|
spacing: hifi.dimensions.contentSpacing.x
|
||||||
|
|
||||||
// FIXME implement back button
|
|
||||||
//VrControls.ButtonAwesome {
|
|
||||||
// id: backButton
|
|
||||||
// text: "\uf0a8"
|
|
||||||
// size: currentDirectory.height
|
|
||||||
// enabled: d.backStack.length != 0
|
|
||||||
// MouseArea { anchors.fill: parent; onClicked: d.navigateBack() }
|
|
||||||
//}
|
|
||||||
|
|
||||||
GlyphButton {
|
GlyphButton {
|
||||||
id: upButton
|
id: upButton
|
||||||
glyph: hifi.glyphs.levelUp
|
glyph: hifi.glyphs.levelUp
|
||||||
|
@ -124,20 +111,10 @@ ModalWindow {
|
||||||
enabled: d.homeDestination ? true : false
|
enabled: d.homeDestination ? true : false
|
||||||
onClicked: d.navigateHome();
|
onClicked: d.navigateHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: drivesSelector
|
|
||||||
width: 62
|
|
||||||
model: drives
|
|
||||||
visible: drives.length > 1
|
|
||||||
currentIndex: 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
ComboBox {
|
||||||
id: currentDirectory
|
id: pathSelector
|
||||||
property var lastValidFolder: helper.urlToPath(fileTableModel.folder)
|
|
||||||
height: homeButton.height
|
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
topMargin: hifi.dimensions.contentMargin.y
|
topMargin: hifi.dimensions.contentMargin.y
|
||||||
|
@ -146,23 +123,54 @@ ModalWindow {
|
||||||
right: parent.right
|
right: parent.right
|
||||||
}
|
}
|
||||||
|
|
||||||
function capitalizeDrive(path) {
|
property var lastValidFolder: helper.urlToPath(fileTableModel.folder)
|
||||||
// Consistently capitalize drive letter for Windows.
|
|
||||||
if (/[a-zA-Z]:/.test(path)) {
|
function calculatePathChoices(folder) {
|
||||||
return path.charAt(0).toUpperCase() + path.slice(1);
|
var folders = folder.split("/"),
|
||||||
|
choices = [],
|
||||||
|
i, length;
|
||||||
|
|
||||||
|
if (folders[folders.length - 1] === "") {
|
||||||
|
folders.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (folders[0] !== "") {
|
||||||
|
choices.push(folders[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 1, length = folders.length; i < length; i++) {
|
||||||
|
choices.push(choices[i - 1] + "/" + folders[i]);
|
||||||
|
}
|
||||||
|
choices.reverse();
|
||||||
|
|
||||||
|
if (drives && drives.length > 1) {
|
||||||
|
choices.push("This PC");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (choices.length > 0) {
|
||||||
|
pathSelector.model = choices;
|
||||||
}
|
}
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLastValidFolderChanged: text = capitalizeDrive(lastValidFolder);
|
onLastValidFolderChanged: {
|
||||||
|
var folder = d.capitalizeDrive(lastValidFolder);
|
||||||
|
calculatePathChoices(folder);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME add support auto-completion
|
onCurrentTextChanged: {
|
||||||
onAccepted: {
|
var folder = currentText;
|
||||||
if (!helper.validFolder(text)) {
|
|
||||||
text = lastValidFolder;
|
if (/^[a-zA-z]:$/.test(folder)) {
|
||||||
return
|
folder = "file:///" + folder + "/";
|
||||||
|
} else if (folder === "This PC") {
|
||||||
|
folder = "file:///";
|
||||||
|
} else {
|
||||||
|
folder = helper.pathToUrl(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.urlToPath(folder).toLowerCase() !== helper.urlToPath(fileTableModel.folder).toLowerCase()) {
|
||||||
|
fileTableModel.folder = folder;
|
||||||
}
|
}
|
||||||
fileTableModel.folder = helper.pathToUrl(text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,12 +227,10 @@ ModalWindow {
|
||||||
showDirsFirst: true
|
showDirsFirst: true
|
||||||
showDotAndDotDot: false
|
showDotAndDotDot: false
|
||||||
showFiles: !root.selectDirectory
|
showFiles: !root.selectDirectory
|
||||||
// For some reason, declaring these bindings directly in the targets doesn't
|
|
||||||
// work for setting the initial state
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
currentDirectory.lastValidFolder = helper.urlToPath(folder);
|
|
||||||
showFiles = !root.selectDirectory
|
showFiles = !root.selectDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
onFolderChanged: {
|
onFolderChanged: {
|
||||||
fileTableModel.update(); // Update once the data from the folder change is available.
|
fileTableModel.update(); // Update once the data from the folder change is available.
|
||||||
}
|
}
|
||||||
|
@ -310,7 +316,6 @@ ModalWindow {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentDirectory.lastValidFolder = helper.urlToPath(folder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFolder(row) {
|
function isFolder(row) {
|
||||||
|
|
Loading…
Reference in a new issue