Unverified Commit 07422b0d authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8636 from DonLakeFlyer/MobileDirLocation

Mobile QGCFileDialog: Show dir location
parents 6a0f7679 ae6d413c
......@@ -26,11 +26,20 @@ Item {
property real _margins: ScreenTools.defaultFontPixelHeight / 2
property bool _mobileDlg: QGroundControl.corePlugin.options.useMobileFileDialog
property var _rgExtensions
property string _mobileShortPath
Component.onCompleted: setupFileExtensions()
Component.onCompleted: {
setupFileExtensions()
_updateMobileShortPath()
}
onFileExtensionChanged: setupFileExtensions()
onFileExtension2Changed: setupFileExtensions()
onFolderChanged: _updateMobileShortPath()
onFileExtensionChanged: setupFileExtensions()
onFileExtension2Changed: setupFileExtensions()
function _updateMobileShortPath() {
_mobileShortPath = controller.fullFolderPathToShortMobilePath(folder);
}
function setupFileExtensions() {
if (fileExtension2 == "") {
......@@ -105,6 +114,8 @@ Item {
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel { text: qsTr("Path: %1").arg(_mobileShortPath) }
Repeater {
id: fileRepeater
model: controller.getFiles(folder, _rgExtensions)
......
......@@ -9,6 +9,9 @@
#include "QGCFileDialogController.h"
#include "QGCApplication.h"
#include "SettingsManager.h"
#include "AppSettings.h"
#include <QStandardPaths>
#include <QDebug>
......@@ -72,3 +75,19 @@ void QGCFileDialogController::deleteFile(const QString& filename)
{
QFile::remove(filename);
}
QString QGCFileDialogController::fullFolderPathToShortMobilePath(const QString& fullFolderPath)
{
#ifdef __mobile__
QString defaultSavePath = qgcApp()->toolbox()->settingsManager()->appSettings()->savePath()->rawValueString();
if (fullFolderPath.startsWith(defaultSavePath)) {
int lastDirSepIndex = fullFolderPath.lastIndexOf(QStringLiteral("/"));
return qgcApp()->applicationName() + QStringLiteral("/") + fullFolderPath.right(fullFolderPath.length() - lastDirSepIndex);
} else {
return fullFolderPath;
}
#else
qWarning() << "QGCFileDialogController::fullFolderPathToShortMobilePath should only be used in mobile builds";
return fullFolderPath;
#endif
}
......@@ -39,6 +39,11 @@ public:
Q_INVOKABLE void deleteFile(const QString& filename);
Q_INVOKABLE QString urlToLocalFile(QUrl url) { return url.toLocalFile(); }
/// Important: Should only be used in mobile builds where default save location cannot be changed.
/// Returns the standard QGC location portion of a fully qualified folder path.
/// Example: "/Users/Don/Document/QGroundControl/Missions" returns "QGroundControl/Missions"
Q_INVOKABLE QString fullFolderPathToShortMobilePath(const QString& fullFolderPath);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment