diff --git a/HackAndroidFileDialog.qrc b/HackAndroidFileDialog.qrc deleted file mode 100644 index 509c47125d627c3aa8c57724f9d36a919677bb75..0000000000000000000000000000000000000000 --- a/HackAndroidFileDialog.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - src/QmlControls/HackAndroidFileDialog.qml - - diff --git a/HackFileDialog.qrc b/HackFileDialog.qrc deleted file mode 100644 index a7436f2702a0771ab125b90438e11cae8c0883d2..0000000000000000000000000000000000000000 --- a/HackFileDialog.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - src/QmlControls/HackFileDialog.qml - - diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index aba1506e15091a794ec3bcca275233035bed348c..8a0b3ddeff2c28f902c28bd485ba32689f3596b2 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -362,15 +362,6 @@ CustomBuild { $$PWD/resources/InstrumentValueIcons/InstrumentValueIcons.qrc \ } -# On Qt 5.9 android versions there is the following bug: https://bugreports.qt.io/browse/QTBUG-61424 -# This prevents FileDialog from being used. So we have a temp hack workaround for it which just no-ops -# the FileDialog fallback mechanism on android 5.9 builds. -equals(QT_MAJOR_VERSION, 5):equals(QT_MINOR_VERSION, 9):AndroidBuild { - RESOURCES += $$PWD/HackAndroidFileDialog.qrc -} else { - RESOURCES += $$PWD/HackFileDialog.qrc -} - # # Main QGroundControl portion of project file # diff --git a/src/MissionManager/QGCMapPolylineVisuals.qml b/src/MissionManager/QGCMapPolylineVisuals.qml index 2a864eebd4b8816120bc3fd1941644851b9f6a5b..46c43b52c6505895df2dc158b20bbbc5464f3760 100644 --- a/src/MissionManager/QGCMapPolylineVisuals.qml +++ b/src/MissionManager/QGCMapPolylineVisuals.qml @@ -128,7 +128,6 @@ Item { title: qsTr("Select KML File") selectExisting: true nameFilters: ShapeFileHelper.fileDialogKMLFilters - fileExtension: QGroundControl.settingsManager.appSettings.kmlFileExtension onAcceptedForLoad: { mapPolyline.loadKMLFile(file) diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index 141abedea08bdb683baa748d4e5ef874b98bdcaf..2fe5fec30da8ee3c5646758afcdc845d68a0e122 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -271,8 +271,6 @@ Item { fileDialog.planFiles = true fileDialog.selectExisting = true fileDialog.nameFilters = _planMasterController.loadNameFilters - fileDialog.fileExtension = _appSettings.planFileExtension - fileDialog.fileExtension2 = _appSettings.missionFileExtension fileDialog.openForLoad() } @@ -284,8 +282,6 @@ Item { fileDialog.planFiles = true fileDialog.selectExisting = false fileDialog.nameFilters = _planMasterController.saveNameFilters - fileDialog.fileExtension = _appSettings.planFileExtension - fileDialog.fileExtension2 = _appSettings.missionFileExtension fileDialog.openForSave() } @@ -301,8 +297,6 @@ Item { fileDialog.planFiles = false fileDialog.selectExisting = false fileDialog.nameFilters = ShapeFileHelper.fileDialogKMLFilters - fileDialog.fileExtension = _appSettings.kmlFileExtension - fileDialog.fileExtension2 = "" fileDialog.openForSave() } } diff --git a/src/QmlControls/AppMessages.qml b/src/QmlControls/AppMessages.qml index b6717b964d9befb70bdee00c8dd90a01cbda2344..95015b4327a9e98d7ad54da5f0336064790bbb57 100644 --- a/src/QmlControls/AppMessages.qml +++ b/src/QmlControls/AppMessages.qml @@ -162,7 +162,6 @@ Item { id: writeDialog folder: QGroundControl.settingsManager.appSettings.logSavePath nameFilters: [qsTr("Log files (*.txt)"), qsTr("All Files (*)")] - fileExtension: qsTr("txt") selectExisting: false title: qsTr("Select log save file") onAcceptedForSave: { diff --git a/src/QmlControls/HackFileDialog.qml b/src/QmlControls/HackFileDialog.qml deleted file mode 100644 index 24e0c5dd6245ac80ef7b30d2829572d7190ae922..0000000000000000000000000000000000000000 --- a/src/QmlControls/HackFileDialog.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.3 -import QtQuick.Dialogs 1.2 - -// On Qt 5.9 android versions there is the following bug: https://bugreports.qt.io/browse/QTBUG-61424 -// This prevents FileDialog from being used. So we have a temp hack workaround for it which just no-ops -// the FileDialog fallback mechanism on android 5.9 builds. - -FileDialog { -} diff --git a/src/QmlControls/KMLOrSHPFileDialog.qml b/src/QmlControls/KMLOrSHPFileDialog.qml index cf57c11e47b56c4a604fbadad703431d6160443b..a7b3e971137712400fb6eec171d5eb4a21177840 100644 --- a/src/QmlControls/KMLOrSHPFileDialog.qml +++ b/src/QmlControls/KMLOrSHPFileDialog.qml @@ -19,6 +19,4 @@ QGCFileDialog { title: qsTr("Select Polygon File") selectExisting: true nameFilters: ShapeFileHelper.fileDialogKMLOrSHPFilters - fileExtension: QGroundControl.settingsManager.appSettings.kmlFileExtension - fileExtension2: QGroundControl.settingsManager.appSettings.shpFileExtension } diff --git a/src/QmlControls/LogReplayStatusBar.qml b/src/QmlControls/LogReplayStatusBar.qml index ab56388675959e538c8cb01f58ec4dbde4c6e36a..e51ba014d63867240522ee3a96d5224ee63e8427 100644 --- a/src/QmlControls/LogReplayStatusBar.qml +++ b/src/QmlControls/LogReplayStatusBar.qml @@ -28,8 +28,7 @@ Rectangle { QGCFileDialog { id: filePicker title: qsTr("Select Telemetery Log") - nameFilters: [qsTr("Telemetry Logs (*.%1)").arg(_logFileExtension), qsTr("All Files (*)")] - fileExtension: _logFileExtension + nameFilters: [ qsTr("Telemetry Logs (*.%1)").arg(_logFileExtension), qsTr("All Files (*)") ] selectExisting: true folder: QGroundControl.settingsManager.appSettings.telemetrySavePath onAcceptedForLoad: { diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index 13ffcac57d17a6f2f0e75cee2ddecaf24a29aa0a..e8e0b811ac0c7d403a07920600ac35fa02aec843 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -287,7 +287,6 @@ Item { QGCFileDialog { id: fileDialog folder: _appSettings.parameterSavePath - fileExtension: _appSettings.parameterFileExtension nameFilters: [ qsTr("Parameter Files (*.%1)").arg(_appSettings.parameterFileExtension) , qsTr("All Files (*.*)") ] onAcceptedForSave: { diff --git a/src/QmlControls/QGCFileDialog.qml b/src/QmlControls/QGCFileDialog.qml index aba634bb40163ad955b6a0d1a8f44da84460f276..baafccfe1f8b56312f142d79cb6c9ab9db122939 100644 --- a/src/QmlControls/QGCFileDialog.qml +++ b/src/QmlControls/QGCFileDialog.qml @@ -15,41 +15,14 @@ Item { visible: false property string folder // Due to Qt bug with file url parsing this must be an absolute path - property var nameFilters - property string fileExtension // Primary file extension to search for - property string fileExtension2: "" // Secondary file extension to search for + property var nameFilters: [] // Important: Only name filters with simple wildcarding like *.foo are supported. property string title property bool selectExisting property bool selectFolder - 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() - } - - onFileExtensionChanged: setupFileExtensions() - onFileExtension2Changed: setupFileExtensions() - onFolderChanged: _updateMobileShortPath() - - function _updateMobileShortPath() { - if (ScreenTools.isMobile) { - _mobileShortPath = controller.fullFolderPathToShortMobilePath(folder); - } - } - - function setupFileExtensions() { - if (fileExtension2 == "") { - _rgExtensions = [ fileExtension ] - } else { - _rgExtensions = [ fileExtension, fileExtension2 ] - } - } + signal acceptedForLoad(string file) + signal acceptedForSave(string file) + signal rejected function openForLoad() { _openForLoad = true @@ -73,17 +46,48 @@ Item { fullFileDialog.close() } - signal acceptedForLoad(string file) - signal acceptedForSave(string file) - signal rejected + 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