import QtQuick 2.11 import QtQuick.Controls 2.4 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.11 import QGroundControl 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controllers 1.0 /// This control is meant to be a direct replacement for the standard Qml FileDialog control. /// It differs for mobile builds which uses a completely custom file picker. Item { id: _root visible: false property string folder // Due to Qt bug with file url parsing this must be an absolute path property var nameFilters: [] // Important: Only name filters with simple wildcarding like *.foo are supported. property string title property bool selectExisting property bool selectFolder signal acceptedForLoad(string file) signal acceptedForSave(string file) signal rejected function openForLoad() { _openForLoad = true if (_mobileDlg && folder.length !== 0) { mainWindow.showComponentDialog(mobileFileOpenDialog, title, mainWindow.showDialogDefaultWidth, StandardButton.Cancel) } else { fullFileDialog.open() } } function openForSave() { _openForLoad = false if (_mobileDlg && folder.length !== 0) { mainWindow.showComponentDialog(mobileFileSaveDialog, title, mainWindow.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } else { fullFileDialog.open() } } function close() { fullFileDialog.close() } property bool _openForLoad: true property real _margins: ScreenTools.defaultFontPixelHeight / 2 property bool _mobileDlg: QGroundControl.corePlugin.options.useMobileFileDialog property var _rgExtensions property string _mobileShortPath Component.onCompleted: { _setupFileExtensions() _updateMobileShortPath() } onFolderChanged: _updateMobileShortPath() onNameFiltersChanged: _setupFileExtensions() function _updateMobileShortPath() { if (ScreenTools.isMobile) { _mobileShortPath = controller.fullFolderPathToShortMobilePath(folder); } } function _setupFileExtensions() { _rgExtensions = [ ] for (var i=0; i<_root.nameFilters.length; i++) { var filter = _root.nameFilters[i] var regExp = /^.*\((.*)\)$/ var result = regExp.exec(filter) if (result.length === 2) { filter = result[1] } var rgFilters = filter.split(" ") for (var j=0; j