From 9a307a67d135ef4c32b55e5c1d4c98103d0469d9 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Thu, 22 Jun 2017 15:02:52 -0700 Subject: [PATCH] Hack workaround to 5.9 android FileDialog Qt bug https://bugreports.qt.io/browse/QTBUG-61424 --- HackAndroidFileDialog.qrc | 5 +++++ HackFileDialog.qrc | 5 +++++ qgroundcontrol.pro | 13 +++++++++++-- src/QmlControls/HackAndroidFileDialog.qml | 18 ++++++++++++++++++ src/QmlControls/HackFileDialog.qml | 9 +++++++++ src/QmlControls/QGCFileDialog.qml | 5 ++++- src/QmlControls/QGroundControl.Controls.qmldir | 1 + 7 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 HackAndroidFileDialog.qrc create mode 100644 HackFileDialog.qrc create mode 100644 src/QmlControls/HackAndroidFileDialog.qml create mode 100644 src/QmlControls/HackFileDialog.qml diff --git a/HackAndroidFileDialog.qrc b/HackAndroidFileDialog.qrc new file mode 100644 index 000000000..509c47125 --- /dev/null +++ b/HackAndroidFileDialog.qrc @@ -0,0 +1,5 @@ + + + src/QmlControls/HackAndroidFileDialog.qml + + diff --git a/HackFileDialog.qrc b/HackFileDialog.qrc new file mode 100644 index 000000000..a7436f270 --- /dev/null +++ b/HackFileDialog.qrc @@ -0,0 +1,5 @@ + + + src/QmlControls/HackFileDialog.qml + + diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 549455492..f20c2f2b1 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -13,8 +13,8 @@ exists($${OUT_PWD}/qgroundcontrol.pro) { message(Qt version $$[QT_VERSION]) -!equals(QT_MAJOR_VERSION, 5) | !greaterThan(QT_MINOR_VERSION, 4) { - error("Unsupported Qt version, 5.5+ is required") +!equals(QT_MAJOR_VERSION, 5) | !greaterThan(QT_MINOR_VERSION, 6) { + error("Unsupported Qt version, 5.7+ is required") } include(QGCCommon.pri) @@ -288,6 +288,15 @@ CustomBuild { $$PWD/qgcresources.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/QmlControls/HackAndroidFileDialog.qml b/src/QmlControls/HackAndroidFileDialog.qml new file mode 100644 index 000000000..f6c3ec909 --- /dev/null +++ b/src/QmlControls/HackAndroidFileDialog.qml @@ -0,0 +1,18 @@ +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. + +Item { + property var folder + property var nameFilters + property var title + property var selectExisting + property var selectMultiple + property var selectFolder + + signal accepted + signal rejected +} diff --git a/src/QmlControls/HackFileDialog.qml b/src/QmlControls/HackFileDialog.qml new file mode 100644 index 000000000..24e0c5dd6 --- /dev/null +++ b/src/QmlControls/HackFileDialog.qml @@ -0,0 +1,9 @@ +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/QGCFileDialog.qml b/src/QmlControls/QGCFileDialog.qml index c10dbcf13..3ab7fce53 100644 --- a/src/QmlControls/QGCFileDialog.qml +++ b/src/QmlControls/QGCFileDialog.qml @@ -66,7 +66,10 @@ Item { QGCFileDialogController { id: controller } QGCPalette { id: qgcPal; colorGroupEnabled: true } - FileDialog { + // 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. + HackFileDialog { id: fullFileDialog folder: "file://" + _root.folder nameFilters: _root.nameFilters ? _root.nameFilters : [] diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index 8f3050ffb..64be6551d 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -13,6 +13,7 @@ FlightModeDropdown 1.0 FlightModeDropdown.qml FlightModeMenu 1.0 FlightModeMenu.qml GeoFenceEditor 1.0 GeoFenceEditor.qml GeoFenceMapVisuals 1.0 GeoFenceMapVisuals.qml +HackFileDialog 1.0 HackFileDialog.qml IndicatorButton 1.0 IndicatorButton.qml JoystickThumbPad 1.0 JoystickThumbPad.qml MainToolBar 1.0 MainToolBar.qml -- 2.22.0