mirror of
https://github.com/lubosz/overte.git
synced 2025-04-13 13:13:19 +02:00
Add drive selection to the file dialog
This commit is contained in:
parent
64597f9d9f
commit
dc0e038535
4 changed files with 29 additions and 7 deletions
|
@ -36,6 +36,7 @@ ModalWindow {
|
|||
// Set from OffscreenUi::getOpenFile()
|
||||
property int options; // <-- FIXME unused
|
||||
|
||||
|
||||
property bool selectDirectory: false;
|
||||
property bool showHidden: false;
|
||||
// FIXME implement
|
||||
|
@ -43,10 +44,18 @@ ModalWindow {
|
|||
property bool saveDialog: false;
|
||||
property var helper: fileDialogHelper
|
||||
property alias model: fileTableView.model
|
||||
property var drives: helper.drives()
|
||||
|
||||
signal selectedFile(var file);
|
||||
signal canceled();
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Helper " + helper + " drives " + drives)
|
||||
drivesSelector.onCurrentTextChanged.connect(function(){
|
||||
root.dir = helper.pathToUrl(drivesSelector.currentText);
|
||||
})
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "white"
|
||||
|
@ -78,6 +87,16 @@ ModalWindow {
|
|||
size: 32
|
||||
onClicked: d.navigateHome();
|
||||
}
|
||||
|
||||
VrControls.ComboBox {
|
||||
id: drivesSelector
|
||||
width: 48
|
||||
height: homeButton.height
|
||||
model: drives
|
||||
visible: drives.length > 1
|
||||
currentIndex: 0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
|
|
|
@ -95,3 +95,11 @@ bool FileDialogHelper::urlIsWritable(const QUrl& url) {
|
|||
// No file, get the parent directory and check if writable
|
||||
return QFileInfo(fileInfo.absoluteDir().absolutePath()).isWritable();
|
||||
}
|
||||
|
||||
QStringList FileDialogHelper::drives() {
|
||||
QStringList result;
|
||||
for (const auto& drive : QDir::drives()) {
|
||||
result << drive.absolutePath();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
|
||||
Q_INVOKABLE QUrl home();
|
||||
Q_INVOKABLE QStringList standardPath(StandardLocation location);
|
||||
Q_INVOKABLE QStringList drives();
|
||||
Q_INVOKABLE QString urlToPath(const QUrl& url);
|
||||
Q_INVOKABLE bool urlIsDir(const QUrl& url);
|
||||
Q_INVOKABLE bool urlIsFile(const QUrl& url);
|
||||
|
|
|
@ -118,13 +118,7 @@ ApplicationWindow {
|
|||
Button {
|
||||
text: "Open File"
|
||||
property var builder: Component {
|
||||
FileDialog {
|
||||
folder: "file:///C:/users/bdavis";
|
||||
filterModel: ListModel {
|
||||
ListElement { text: "Javascript Files (*.js)"; filter: "*.js" }
|
||||
ListElement { text: "All Files (*.*)"; filter: "*.*" }
|
||||
}
|
||||
}
|
||||
FileDialog { }
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
|
|
Loading…
Reference in a new issue