| 1 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 2 |
// Copyright 2019 Juan Palacios <[email protected]> |
| 3 |
|
| 4 |
import QtQuick 2.15 |
| 5 |
import Qt.labs.platform 1.1 |
| 6 |
|
| 7 |
// Native file dialog |
| 8 |
// Requires: |
| 9 |
// · link against Qt5::Widgets |
| 10 |
// · use QApplication instead QGuiApplication |
| 11 |
|
| 12 |
FileDialog { |
| 13 |
property bool saveDlg: false |
| 14 |
|
| 15 |
fileMode: saveDlg ? FileDialog.SaveFile : FileDialog.OpenFile |
| 16 |
folder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0] |
| 17 |
options: FileDialog.ReadOnly |
| 18 |
|
| 19 |
/// Returns the selected file name. |
| 20 |
function fileName() { |
| 21 |
var path = file.toString() |
| 22 |
return path.slice(path.lastIndexOf("/") + 1) |
| 23 |
} |
| 24 |
} |