mirror of
https://github.com/lubosz/overte.git
synced 2025-06-03 07:10:24 +02:00
Fixing save dialog issues saving new files
This commit is contained in:
parent
60d97c45af
commit
64597f9d9f
2 changed files with 58 additions and 42 deletions
|
@ -229,8 +229,22 @@ ModalWindow {
|
|||
id: okAction
|
||||
text: root.saveDialog ? "Save" : (root.selectDirectory ? "Choose" : "Open")
|
||||
enabled: currentSelection.text ? true : false
|
||||
onTriggered: okActionTimer.start();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: okActionTimer
|
||||
interval: 50
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
if (root.saveDialog) {
|
||||
if (!root.saveDialog) {
|
||||
selectedFile(d.currentSelectionUrl);
|
||||
root.destroy()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Handle the ambiguity between different cases
|
||||
// * typed name (with or without extension)
|
||||
// * full path vs relative vs filename only
|
||||
|
@ -269,15 +283,10 @@ ModalWindow {
|
|||
}
|
||||
}
|
||||
|
||||
selectedFile(d.currentSelectionUrl);
|
||||
root.destroy()
|
||||
} else {
|
||||
selectedFile(d.currentSelectionUrl);
|
||||
root.destroy()
|
||||
console.log("Selecting " + selection)
|
||||
selectedFile(selection);
|
||||
root.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Action {
|
||||
|
|
|
@ -86,5 +86,12 @@ bool FileDialogHelper::urlExists(const QUrl& url) {
|
|||
}
|
||||
|
||||
bool FileDialogHelper::urlIsWritable(const QUrl& url) {
|
||||
return QFileInfo(url.toLocalFile()).isWritable();
|
||||
QFileInfo fileInfo(url.toLocalFile());
|
||||
// Is the file writable?
|
||||
if (fileInfo.exists()) {
|
||||
return fileInfo.isWritable();
|
||||
}
|
||||
|
||||
// No file, get the parent directory and check if writable
|
||||
return QFileInfo(fileInfo.absoluteDir().absolutePath()).isWritable();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue