Commit da1296ef authored by DonLakeFlyer's avatar DonLakeFlyer
Browse files

New file save settings and desktop/mobile file dialog capability

parent 5e3af5c1
......@@ -41,8 +41,6 @@ public:
Q_INVOKABLE QStringList searchParametersForComponent(int componentId, const QString& searchText, bool searchInName=true, bool searchInDescriptions=true);
Q_INVOKABLE void clearRCToParam(void);
Q_INVOKABLE void saveToFilePicker(void);
Q_INVOKABLE void loadFromFilePicker(void);
Q_INVOKABLE void saveToFile(const QString& filename);
Q_INVOKABLE void loadFromFile(const QString& filename);
Q_INVOKABLE void refresh(void);
......
......@@ -8,68 +8,49 @@
****************************************************************************/
#include "QGCMobileFileDialogController.h"
#include "QFileDialogController.h"
#include <QStandardPaths>
#include <QDebug>
#include <QDir>
QGC_LOGGING_CATEGORY(QGCMobileFileDialogControllerLog, "QGCMobileFileDialogControllerLog")
QGC_LOGGING_CATEGORY(QFileDialogControllerLog, "QFileDialogControllerLog")
QStringList QGCMobileFileDialogController::getFiles(const QString& fileExtension)
QStringList QFileDialogController::getFiles(const QString& directoryPath, const QString& fileExtension)
{
qCDebug(QFileDialogControllerLog) << "getFiles" << directoryPath << fileExtension;
QStringList files;
QDir fileDir(_getSaveLocation());
QDir fileDir(directoryPath);
QFileInfoList fileInfoList = fileDir.entryInfoList(QStringList(QString("*.%1").arg(fileExtension)), QDir::Files, QDir::Name);
foreach (const QFileInfo& fileInfo, fileInfoList) {
qCDebug(QFileDialogControllerLog) << "getFiles found" << fileInfo.baseName();
files << fileInfo.baseName() + QStringLiteral(".") + fileExtension;
}
return files;
}
QString QGCMobileFileDialogController::fullPath(const QString& filename, const QString& fileExtension)
QString QFileDialogController::filenameWithExtension(const QString& filename, const QString& fileExtension)
{
qDebug() << "QGCMobileFileDialogController::fullPath" << filename << fileExtension;
QString saveLocation(_getSaveLocation());
if (saveLocation.isEmpty()) {
return filename;
}
QString filenameWithExtension(filename);
QString fixedFilename(filename);
QString correctExtension = QString(".%1").arg(fileExtension);
if (!filename.endsWith(correctExtension)) {
fixedFilename += correctExtension;
if (!filenameWithExtension.endsWith(correctExtension)) {
filenameWithExtension += correctExtension;
}
QString fullPath = saveLocation + QDir::separator() + fixedFilename;
qCDebug(QGCMobileFileDialogControllerLog) << "Full path" << fullPath;
return fullPath;
return filenameWithExtension;
}
bool QGCMobileFileDialogController::fileExists(const QString& filename, const QString& fileExtension)
bool QFileDialogController::fileExists(const QString& filename)
{
QFile file(fullPath(filename, fileExtension));
qDebug() << "QGCMobileFileDialogController::fileExists" << file.fileName();
return file.exists();
return QFile(filename).exists();
}
QString QGCMobileFileDialogController::_getSaveLocation(void)
QString QFileDialogController::fullyQualifiedFilename(const QString& directoryPath, const QString& filename, const QString& fileExtension)
{
QStringList docDirs = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
if (docDirs.count() <= 0) {
qCWarning(QGCMobileFileDialogControllerLog) << "No save location";
return QString();
}
QString saveDirectory = docDirs[0];
if (!QDir(saveDirectory).exists()) {
QDir().mkdir(saveDirectory);
}
qCDebug(QGCMobileFileDialogControllerLog) << "Save directory" << saveDirectory;
return saveDirectory;
return directoryPath + QStringLiteral("/") + filenameWithExtension(filename, fileExtension);
}
......@@ -8,36 +8,34 @@
****************************************************************************/
#ifndef QGCMobileFileDialogController_H
#define QGCMobileFileDialogController_H
#ifndef QFileDialogController_H
#define QFileDialogController_H
#include <QObject>
#include <QUrl>
#include "QGCLoggingCategory.h"
Q_DECLARE_LOGGING_CATEGORY(QGCMobileFileDialogControllerLog)
Q_DECLARE_LOGGING_CATEGORY(QFileDialogControllerLog)
class QGCMobileFileDialogController : public QObject
class QFileDialogController : public QObject
{
Q_OBJECT
public:
/// Return all file in Documents location which match the specified extension
Q_INVOKABLE QStringList getFiles(const QString& fileExtension);
/// Return the full path for specified file in the Documents location
/// @param filename File name, not fully qualified, may not have extension
/// @param fileExtension Expected file extension, added if needed
Q_INVOKABLE QString fullPath(const QString& filename, const QString& fileExtension);
/// Check for file existence
/// @param filename File name, not fully qualified, may not have extension
/// @param fileExtension Expected file extension, added if needed
/// @return true: File exists at Documents location
Q_INVOKABLE bool fileExists(const QString& filename, const QString& fileExtension);
/// Return all file in the specified path which match the specified extension
Q_INVOKABLE QStringList getFiles(const QString& directoryPath, const QString& fileExtension);
/// Returns the specified file name with the extension added it needed
Q_INVOKABLE QString filenameWithExtension(const QString& filename, const QString& fileExtension);
/// Returns the fully qualified file name from the specified parts
Q_INVOKABLE QString fullyQualifiedFilename(const QString& directoryPath, const QString& filename, const QString& fileExtension);
/// Check for file existence of specified fully qualified file name
Q_INVOKABLE bool fileExists(const QString& filename);
private:
QString _getSaveLocation(void);
Q_INVOKABLE QString urlToLocalFile(QUrl url) { return url.toLocalFile(); }
};
#endif
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
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 var qgcView
property string folder
property var nameFilters
property string fileExtension
property string title
property bool selectExisting
property bool selectFolder
property bool _openForLoad
property real _margins: ScreenTools.defaultFontPixelHeight / 2
function openForLoad() {
_openForLoad = true
if (ScreenTools.isMobile && folder.length !== 0) {
qgcView.showDialog(mobileFileOpenDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel)
} else {
fullFileDialog.open()
}
}
function openForSave() {
_openForLoad = false
if (ScreenTools.isMobile && folder.length !== 0) {
qgcView.showDialog(mobileFileSaveDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok)
} else {
fullFileDialog.open()
}
}
function close() {
fullFileDialog.close()
}
signal acceptedForLoad(string file)
signal acceptedForSave(string file)
signal rejected
QFileDialogController { id: controller }
QGCPalette { id: qgcPal; colorGroupEnabled: true }
FileDialog {
id: fullFileDialog
folder: "file://" + _root.folder
nameFilters: _root.nameFilters
title: _root.title
selectExisting: _root.selectExisting
selectMultiple: false
selectFolder: _root.selectFolder
onAccepted: {
if (_openForLoad) {
_root.acceptedForLoad(controller.urlToLocalFile(fileUrl))
} else {
_root.acceptedForSave(controller.urlToLocalFile(fileUrl))
}
}
onRejected: _root.rejected()
}
Component {
id: mobileFileOpenDialog
QGCViewDialog {
Item {
anchors.margins: _margins
anchors.fill: parent
QGCListView {
id: listView
anchors.fill: parent
spacing: _margins / 2
orientation: ListView.Vertical
model: controller.getFiles(folder, fileExtension)
delegate: QGCButton {
text: modelData
onClicked: {
hideDialog()
_root.acceptedForLoad(controller.fullyQualifiedFilename(folder, modelData, fileExtension))
}
}
}
QGCLabel {
text: qsTr("No files")
visible: listView.model.length == 0
}
}
}
}
Component {
id: mobileFileSaveDialog
QGCViewDialog {
function accept() {
if (filenameTextField.text == "") {
return
}
if (!replaceMessage.visible) {
if (controller.fileExists(controller.fullyQualifiedFilename(folder, filenameTextField.text, fileExtension))) {
replaceMessage.visible = true
return
}
}
_root.acceptedForSave(controller.fullyQualifiedFilename(folder, filenameTextField.text, fileExtension))
hideDialog()
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
text: qsTr("File name:")
}
QGCTextField {
id: filenameTextField
onTextChanged: replaceMessage.visible = false
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("File names must end with .%1 file extension. If missing it will be added.").arg(fileExtension)
}
QGCLabel {
id: replaceMessage
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("The file %1 exists. Click Save again to replace it.").arg(filenameTextField.text)
visible: false
color: qgcPal.warningText
}
}
}
}
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.Palette 1.0
/// Simple file open dialog for mobile
QGCViewDialog {
property string fileExtension ///< File extension for file listing
signal filenameReturned(string filename)
readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
QGCMobileFileDialogController { id: controller }
QGCPalette { id: qgcPal; colorGroupEnabled: true }
Item {
anchors.margins: _margins
anchors.fill: parent
QGCListView {
anchors.fill: parent
spacing: _margins / 2
orientation: ListView.Vertical
model: controller.getFiles(fileExtension)
delegate: QGCButton {
text: modelData
onClicked: {
hideDialog()
filenameReturned(controller.fullPath(modelData, fileExtension))
}
}
}
QGCLabel {
text: qsTr("No files")
visible: controller.getFiles(fileExtension).length == 0
}
}
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.Palette 1.0
/// Simple file picker for mobile
QGCViewDialog {
property string fileExtension ///< File extension for file listing
signal filenameReturned(string filename)
readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
function accept() {
if (filenameTextField.text == "") {
return
}
if (!replaceMessage.visible) {
if (controller.fileExists(filenameTextField.text, fileExtension)) {
console.log("File exists")
replaceMessage.visible = true
return
}
}
filenameReturned(controller.fullPath(filenameTextField.text, fileExtension))
hideDialog()
}
QGCMobileFileDialogController { id: controller }
QGCPalette { id: qgcPal; colorGroupEnabled: true }
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
QGCLabel {
text: qsTr("File name:")
}
QGCTextField {
id: filenameTextField
onTextChanged: replaceMessage.visible = false
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("File names must end with .%1 file extension. If missing it will be added.").arg(fileExtension)
}
QGCLabel {
id: replaceMessage
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
text: qsTr("The file %1 exists. Click Save again to replace it.").arg(filenameTextField.text)
visible: false
color: qgcPal.warningText
}
}
}
......@@ -33,13 +33,12 @@ QGCButton 1.0 QGCButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml
QGCComboBox 1.0 QGCComboBox.qml
QGCFileDialog 1.0 QGCFileDialog.qml
QGCFlickable 1.0 QGCFlickable.qml
QGCGroupBox 1.0 QGCGroupBox.qml
QGCLabel 1.0 QGCLabel.qml
QGCListView 1.0 QGCListView.qml
QGCMapLabel 1.0 QGCMapLabel.qml
QGCMobileFileOpenDialog 1.0 QGCMobileFileOpenDialog.qml
QGCMobileFileSaveDialog 1.0 QGCMobileFileSaveDialog.qml
QGCMouseArea 1.0 QGCMouseArea.qml
QGCMovableItem 1.0 QGCMovableItem.qml
QGCPipable 1.0 QGCPipable.qml
......
......@@ -21,6 +21,7 @@
#include "FactMetaData.h"
#include "SimulatedPosition.h"
#include "QGCLoggingCategory.h"
#include "AppSettings.h"
#ifdef QT_DEBUG
#include "MockLink.h"
......@@ -118,8 +119,6 @@ public:
Q_INVOKABLE bool linesIntersect(QPointF xLine1, QPointF yLine1, QPointF xLine2, QPointF yLine2);
Q_INVOKABLE QString urlToLocalFile(QUrl url) { return url.toLocalFile(); }
// Property accesors
QString appName () { return qgcApp()->applicationName(); }
......@@ -151,9 +150,9 @@ public:
void setFlightMapPosition (QGeoCoordinate& coordinate);
void setFlightMapZoom (double zoom);
QString parameterFileExtension(void) const { return QGCApplication::parameterFileExtension; }
QString missionFileExtension(void) const { return QGCApplication::missionFileExtension; }
QString telemetryFileExtension(void) const { return QGCApplication::telemetryFileExtension; }
QString parameterFileExtension(void) const { return AppSettings::parameterFileExtension; }
QString missionFileExtension(void) const { return AppSettings::missionFileExtension; }
QString telemetryFileExtension(void) const { return AppSettings::telemetryFileExtension; }
QString qgcVersion(void) const { return qgcApp()->applicationVersion(); }
......
......@@ -12,7 +12,7 @@
/// @author Gus Grubba <mavlink@grubba.com>
#if !defined(__mobile__)
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
#include "MainWindow.h"
#endif
......@@ -407,7 +407,7 @@ QGCMapEngineManager::importSets(QString path) {
//-- TODO: This has to be something fixed
dir = QDir(QDir::homePath()).filePath(QString("export_%1.db").arg(QDateTime::currentDateTime().toTime_t()));
#else
dir = QGCFileDialog::getOpenFileName(
dir = QGCQFileDialog::getOpenFileName(
MainWindow::instance(),
"Export Tile Set",
QDir::homePath(),
......@@ -437,7 +437,7 @@ QGCMapEngineManager::exportSets(QString path) {
#if defined(__mobile__)
dir = QDir(QDir::homePath()).filePath(QString("export_%1.db").arg(QDateTime::currentDateTime().toTime_t()));
#else
dir = QGCFileDialog::getSaveFileName(
dir = QGCQFileDialog::getSaveFileName(
MainWindow::instance(),
"Export Tile Set",
QDir::homePath(),
......
......@@ -55,13 +55,6 @@
"units": "meters",
"decimalPlaces": 2
},
{
"name": "MissionAutoLoadDir",
"shortDescription": "Mission auto load directory",
"longDescription": "The directory from which missions will be automatically loaded onto a vehicle when it connects. The mission file must be named AutoLoad#.mission where the # is replaced with the vehicle id.",
"type": "string",
"defaultValue": ""
},
{
"name": "PromptFLightDataSave",
"shortDescription": "Save telemetry Log after each flight",
......@@ -90,6 +83,13 @@
"type": "bool",
"defaultValue": false
},
{
"name": "AutoLoadMissions",
"shortDescription": "AutoLoad mission on vehicle connect",
"longDescription": "Automatically load a mission file named AutoLoad#.mission when a vehicle with id # connects.",
"type": "bool",
"defaultValue": false
},
{
"name": "BaseDeviceFontPointSize",
"shortDescription": "Application font size",
......@@ -116,9 +116,9 @@
"defaultValue": false
},
{
"name": "TelemetrySavePath",
"shortDescription": "Telemetry log save directory",
"longDescription": "The directory to which telemetry logs are automatically saved to.",
"name": "SavePath",
"shortDescription": "Application save directory",
"longDescription": "Directory to which all data files are saved/loaded from",
"type": "string",
"defaultValue": ""
}
......
......@@ -13,6 +13,7 @@
#include <QQmlEngine>
#include <QtQml>
#include <QStandardPaths>
const char* AppSettings::appSettingsGroupName = "App";
const char* AppSettings::offlineEditingFirmwareTypeSettingsName = "OfflineEditingFirmwareType";
......@@ -21,7 +22,6 @@ const char* AppSettings::offlineEditingCruiseSpeedSettingsName = "Offline
const char* AppSettings::offlineEditingHoverSpeedSettingsName = "OfflineEditingHoverSpeed";
const char* AppSettings::batteryPercentRemainingAnnounceSettingsName = "batteryPercentRemainingAnnounce";
const char* AppSettings::defaultMissionItemAltitudeSettingsName = "DefaultMissionItemAltitude";
const char* AppSettings::missionAutoLoadDirSettingsName = "MissionAutoLoadDir";
const char* AppSettings::telemetrySaveName = "PromptFLightDataSave";
const char* AppSettings::telemetrySaveNotArmedName = "PromptFLightDataSaveNotArmed";
const char* AppSettings::audioMutedName = "AudioMuted";
......@@ -29,7 +29,18 @@ const char* AppSettings::virtualJoystickName = "Virtual
const char* AppSettings::appFontPointSizeName = "BaseDeviceFontPointSize";
const char* AppSettings::indoorPaletteName = "StyleIsDark";
const char* AppSettings::showLargeCompassName = "ShowLargeCompass";
const char* AppSettings::telemetrySavePathName = "TelemetrySavePath";
const char* AppSettings::savePathName = "SavePath";
const char* AppSettings::autoLoadMissionsName = "AutoLoadMissions";
const char* AppSettings::parameterFileExtension = "params";
const char* AppSettings::missionFileExtension = "mission";
const char* AppSettings::fenceFileExtension = "fence";
const char* AppSettings::rallyPointFileExtension = "rally";
const char* AppSettings::telemetryFileExtension = "tlog";
const char* AppSettings::parameterDirectory = "Parameters";
const char* AppSettings::telemetryDirectory = "Telemetry";
const char* AppSettings::missionDirectory = "Missions";
AppSettings::AppSettings(QObject* parent)
: SettingsGroup(appSettingsGroupName, QString() /* root settings group */, parent)
......@@ -39,7 +50,6 @@ AppSettings::AppSettings(QObject* parent)
, _offlineEditingHoverSpeedFact(NULL)
, _batteryPercentRemainingAnnounceFact(NULL)
, _defaultMissionItemAltitudeFact(NULL)
, _missionAutoLoadDirFact(NULL)
, _telemetrySaveFact(NULL)
, _telemetrySaveNotArmedFact(NULL)
, _audioMutedFact(NULL)
......@@ -47,11 +57,44 @@ AppSettings::AppSettings(QObject* parent)
, _appFontPointSizeFact(NULL)
, _indoorPaletteFact(NULL)
, _showLargeCompassFact(NULL)
, _telemetrySavePathFact(NULL)
, _savePathFact(NULL)
, _autoLoadMissionsFact(NULL)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
qmlRegisterUncreatableType<AppSettings>("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only");
QGCPalette::setGlobalTheme(indoorPalette()->rawValue().toBool() ? QGCPalette::Dark : QGCPalette::Light);
// Instantiate savePath so we can check for override and setup default path if needed
Fact* savePathFact = savePath();
QString appName = qgcApp()->applicationName();
if (savePathFact->rawValue().toString().isEmpty() && _nameToMetaDataMap[savePathName]->rawDefaultValue().toString().isEmpty()) {
#ifdef __mobile__
QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
savePathFact->setVisible(false);
#else
QDir rootDir = QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
#endif
savePathFact->setRawValue(rootDir.filePath(appName));
}
connect(savePathFact, &Fact::rawValueChanged, this, &AppSettings::savePathsChanged);
connect(savePathFact, &Fact::rawValueChanged, this, &AppSettings::_checkSavePathDirectories);
_checkSavePathDirectories();
}
void AppSettings::_checkSavePathDirectories(void)
{
QDir savePathDir(savePath()->rawValue().toString());
if (!savePathDir.exists()) {
QDir().mkpath(savePathDir.absolutePath());
}
if (savePathDir.exists()) {
savePathDir.mkdir(parameterDirectory);
savePathDir.mkdir(telemetryDirectory);
savePathDir.mkdir(missionDirectory);
}
}
Fact* AppSettings::offlineEditingFirmwareType(void)
......@@ -106,15 +149,6 @@ Fact* AppSettings::defaultMissionItemAltitude(void)
return _defaultMissionItemAltitudeFact;
}
Fact* AppSettings::missionAutoLoadDir(void)
{
if (!_missionAutoLoadDirFact) {
_missionAutoLoadDirFact = _createSettingsFact(missionAutoLoadDirSettingsName);
}
return _missionAutoLoadDirFact;
}
Fact* AppSettings::telemetrySave(void)
{
if (!_telemetrySaveFact) {
......@@ -185,12 +219,60 @@ Fact* AppSettings::showLargeCompass(void)
return _showLargeCompassFact;
}
Fact* AppSettings::telemetrySavePath(void)
Fact* AppSettings::savePath(void)
{
if (!_savePathFact) {
_savePathFact = _createSettingsFact(savePathName);
}
return _savePathFact;
}
QString AppSettings::missionSavePath(void)
{
QString fullPath;
QString path = savePath()->rawValue().toString();
if (!path.isEmpty() && QDir(path).exists()) {
QDir dir(path);
return dir.filePath(missionDirectory);
}
return fullPath;
}
QString AppSettings::parameterSavePath(void)
{
QString fullPath;
QString path = savePath()->rawValue().toString();
if (!path.isEmpty() && QDir(path).exists()) {
QDir dir(path);
return dir.filePath(parameterDirectory);
}
return fullPath;
}
QString AppSettings::telemetrySavePath(void)
{
QString fullPath;
QString path = savePath()->rawValue().toString();
if (!path.isEmpty() && QDir(path).exists()) {
QDir dir(path);
return dir.filePath(telemetryDirectory);
}
return fullPath;
}
Fact* AppSettings::autoLoadMissions(void)
{
if (!_telemetrySavePathFact) {
_telemetrySavePathFact = _createSettingsFact(telemetrySavePathName);
if (!_autoLoadMissionsFact) {
_autoLoadMissionsFact = _createSettingsFact(autoLoadMissionsName);
}
return _telemetrySavePathFact;
return _autoLoadMissionsFact;
}
......@@ -25,7 +25,6 @@ public:
Q_PROPERTY(Fact* offlineEditingHoverSpeed READ offlineEditingHoverSpeed CONSTANT)
Q_PROPERTY(Fact* batteryPercentRemainingAnnounce READ batteryPercentRemainingAnnounce CONSTANT)
Q_PROPERTY(Fact* defaultMissionItemAltitude READ defaultMissionItemAltitude CONSTANT)
Q_PROPERTY(Fact* missionAutoLoadDir READ missionAutoLoadDir CONSTANT)
Q_PROPERTY(Fact* telemetrySave READ telemetrySave CONSTANT)
Q_PROPERTY(Fact* telemetrySaveNotArmed READ telemetrySaveNotArmed CONSTANT)
Q_PROPERTY(Fact* audioMuted READ audioMuted CONSTANT)
......@@ -33,7 +32,16 @@ public:
Q_PROPERTY(Fact* appFontPointSize READ appFontPointSize CONSTANT)
Q_PROPERTY(Fact* indoorPalette READ indoorPalette CONSTANT)
Q_PROPERTY(Fact* showLargeCompass READ showLargeCompass CONSTANT)
Q_PROPERTY(Fact* telemetrySavePath READ telemetrySavePath CONSTANT)
Q_PROPERTY(Fact* savePath READ savePath CONSTANT)
Q_PROPERTY(Fact* autoLoadMissions READ autoLoadMissions CONSTANT)
Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString telemetrySavePath READ telemetrySavePath NOTIFY savePathsChanged)
Q_PROPERTY(QString missionFileExtension MEMBER missionFileExtension CONSTANT)
Q_PROPERTY(QString parameterFileExtension MEMBER parameterFileExtension CONSTANT)
Q_PROPERTY(QString telemetryFileExtension MEMBER telemetryFileExtension CONSTANT)
Fact* offlineEditingFirmwareType (void);
Fact* offlineEditingVehicleType (void);
......@@ -41,7 +49,6 @@ public:
Fact* offlineEditingHoverSpeed (void);
Fact* batteryPercentRemainingAnnounce (void);
Fact* defaultMissionItemAltitude (void);
Fact* missionAutoLoadDir (void);
Fact* telemetrySave (void);
Fact* telemetrySaveNotArmed (void);
Fact* audioMuted (void);
......@@ -49,7 +56,12 @@ public:
Fact* appFontPointSize (void);
Fact* indoorPalette (void);
Fact* showLargeCompass (void);
Fact* telemetrySavePath (void);
Fact* savePath (void);
Fact* autoLoadMissions (void);
QString missionSavePath (void);
QString parameterSavePath (void);
QString telemetrySavePath (void);
static const char* appSettingsGroupName;
......@@ -59,7 +71,6 @@ public:
static const char* offlineEditingHoverSpeedSettingsName;
static const char* batteryPercentRemainingAnnounceSettingsName;
static const char* defaultMissionItemAltitudeSettingsName;
static const char* missionAutoLoadDirSettingsName;
static const char* telemetrySaveName;
static const char* telemetrySaveNotArmedName;
static const char* audioMutedName;
......@@ -67,10 +78,27 @@ public:
static const char* appFontPointSizeName;
static const char* indoorPaletteName;
static const char* showLargeCompassName;
static const char* telemetrySavePathName;
static const char* savePathName;
static const char* autoLoadMissionsName;
// Application wide file extensions
static const char* parameterFileExtension;
static const char* missionFileExtension;
static const char* fenceFileExtension;
static const char* rallyPointFileExtension;
static const char* telemetryFileExtension;
// Child directories of savePath for specific file types
static const char* parameterDirectory;
static const char* telemetryDirectory;
static const char* missionDirectory;
signals:
void savePathsChanged(void);
private slots:
void _indoorPaletteChanged(void);
void _checkSavePathDirectories(void);
private:
SettingsFact* _offlineEditingFirmwareTypeFact;
......@@ -79,7 +107,6 @@ private:
SettingsFact* _offlineEditingHoverSpeedFact;
SettingsFact* _batteryPercentRemainingAnnounceFact;
SettingsFact* _defaultMissionItemAltitudeFact;
SettingsFact* _missionAutoLoadDirFact;
SettingsFact* _telemetrySaveFact;
SettingsFact* _telemetrySaveNotArmedFact;
SettingsFact* _audioMutedFact;
......@@ -87,7 +114,8 @@ private:
SettingsFact* _appFontPointSizeFact;
SettingsFact* _indoorPaletteFact;
SettingsFact* _showLargeCompassFact;
SettingsFact* _telemetrySavePathFact;
SettingsFact* _savePathFact;
SettingsFact* _autoLoadMissionsFact;
};
#endif
......@@ -1665,17 +1665,19 @@ void Vehicle::_startMissionRequest(void)
if (!_missionManagerInitialRequestSent && _parameterManager->parametersReady() && _vehicleCapabilitiesKnown) {
qCDebug(VehicleLog) << "_startMissionRequest";
_missionManagerInitialRequestSent = true;
QString missionAutoLoadDirPath = _settingsManager->appSettings()->missionAutoLoadDir()->rawValue().toString();
if (missionAutoLoadDirPath.isEmpty()) {
_missionManager->requestMissionItems();
} else {
QmlObjectListModel* visualItems = NULL;
QDir missionAutoLoadDir(missionAutoLoadDirPath);
QString autoloadFilename = missionAutoLoadDir.absoluteFilePath(tr("AutoLoad%1.mission").arg(_id));
if (MissionController::loadItemsFromFile(this, autoloadFilename, &visualItems)) {
MissionController::sendItemsToVehicle(this, visualItems);
if (_settingsManager->appSettings()->autoLoadMissions()->rawValue().toBool()) {
QString missionAutoLoadDirPath = _settingsManager->appSettings()->missionSavePath();
if (!missionAutoLoadDirPath.isEmpty()) {
QmlObjectListModel* visualItems = NULL;
QDir missionAutoLoadDir(missionAutoLoadDirPath);
QString autoloadFilename = missionAutoLoadDir.absoluteFilePath(tr("AutoLoad%1.%2").arg(_id).arg(AppSettings::missionFileExtension));
if (MissionController::loadItemsFromFile(this, autoloadFilename, &visualItems)) {
MissionController::sendItemsToVehicle(this, visualItems);
return;
}
}
}
_missionManager->requestMissionItems();
} else {
if (!_parameterManager->parametersReady()) {
qCDebug(VehicleLog) << "Delaying _startMissionRequest due to parameters not ready";
......
......@@ -14,7 +14,7 @@
#include "FirmwareUpgradeController.h"
#include "Bootloader.h"
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
#include "QGCApplication.h"
#include "QGCFileDownload.h"
#include "QGCOptions.h"
......@@ -442,7 +442,7 @@ void FirmwareUpgradeController::_getFirmwareFile(FirmwareIdentifier firmwareId)
}
if (firmwareId.firmwareType == CustomFirmware) {
_firmwareFilename = QGCFileDialog::getOpenFileName(NULL, // Parent to main window
_firmwareFilename = QGCQFileDialog::getOpenFileName(NULL, // Parent to main window
"Select Firmware File", // Dialog Caption
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), // Initial directory
"Firmware Files (*.px4 *.bin *.ihx)"); // File filter
......
......@@ -11,7 +11,7 @@
#include "CustomCommandWidgetController.h"
#include "MultiVehicleManager.h"
#include "QGCMAVLink.h"
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
#include "UAS.h"
#include "QGCApplication.h"
......@@ -53,7 +53,7 @@ void CustomCommandWidgetController::_activeVehicleChanged(Vehicle* activeVehicle
void CustomCommandWidgetController::selectQmlFile(void)
{
QSettings settings;
QString qmlFile = QGCFileDialog::getOpenFileName(NULL, "Select custom Qml file", QString(), "Qml files (*.qml)");
QString qmlFile = QGCQFileDialog::getOpenFileName(NULL, "Select custom Qml file", QString(), "Qml files (*.qml)");
if (qmlFile.isEmpty()) {
_customQmlFile.clear();
settings.remove(_settingsKey);
......
......@@ -30,7 +30,7 @@
#include "QGCFlightGearLink.h"
#include "QGC.h"
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
#include "QGCMessageBox.h"
#include "QGCApplication.h"
#include "Vehicle.h"
......@@ -744,7 +744,7 @@ bool QGCFlightGearLink::connectSimulation()
}
// Let the user pick the right directory
QString dirPath = QGCFileDialog::getExistingDirectory(MainWindow::instance(), tr("Please select directory of FlightGear application : ") + fgAppName);
QString dirPath = QGCQFileDialog::getExistingDirectory(MainWindow::instance(), tr("Please select directory of FlightGear application : ") + fgAppName);
if (dirPath.isEmpty()) {
return false;
}
......
......@@ -9,12 +9,12 @@
/// @file
/// @brief Unit test for QGCFileDialog catching mechanism.
/// @brief Unit test for QGCQFileDialog catching mechanism.
///
/// @author Don Gagne <don@thegagnes.com>
#include "FileDialogTest.h"
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
FileDialogTest::FileDialogTest(void)
{
......@@ -28,19 +28,19 @@ void FileDialogTest::_fileDialogExpected_test(void)
for (int i=0; i<response.count(); i++) {
setExpectedFileDialog(getExistingDirectory, QStringList(response[i]));
QCOMPARE(QGCFileDialog::getExistingDirectory(), response[i]);
QCOMPARE(QGCQFileDialog::getExistingDirectory(), response[i]);
checkExpectedFileDialog();
}
for (int i=0; i<response.count(); i++) {
setExpectedFileDialog(getOpenFileName, QStringList(response[i]));
QCOMPARE(QGCFileDialog::getOpenFileName(), response[i]);
QCOMPARE(QGCQFileDialog::getOpenFileName(), response[i]);
checkExpectedFileDialog();
}
for (int i=0; i<response.count(); i++) {
setExpectedFileDialog(getSaveFileName, QStringList(response[i]));
QCOMPARE(QGCFileDialog::getSaveFileName(), response[i]);
QCOMPARE(QGCQFileDialog::getSaveFileName(), response[i]);
checkExpectedFileDialog();
}
......@@ -54,7 +54,7 @@ void FileDialogTest::_fileDialogExpected_test(void)
for (int i=0; i<responseList.count(); i++) {
setExpectedFileDialog(getOpenFileNames, responseList[i]);
QStringList retResponse = QGCFileDialog::getOpenFileNames();
QStringList retResponse = QGCQFileDialog::getOpenFileNames();
checkExpectedFileDialog();
QCOMPARE(retResponse.count(), responseList[i].count());
for (int j=0; j<retResponse.count(); j++) {
......@@ -66,14 +66,14 @@ void FileDialogTest::_fileDialogExpected_test(void)
void FileDialogTest::_fileDialogUnexpected_test(void)
{
// This should cause an expected failure in the cleanup method
QGCFileDialog::getOpenFileName();
QGCQFileDialog::getOpenFileName();
_expectMissedFileDialog = true;
}
void FileDialogTest::_previousFileDialog_test(void)
{
// This is the previous unexpected file dialog
QGCFileDialog::getOpenFileName();
QGCQFileDialog::getOpenFileName();
// Setup for an expected message box.
QEXPECT_FAIL("", "Expecting failure due to previous file dialog", Continue);
......@@ -90,7 +90,7 @@ void FileDialogTest::_fileDialogExpectedIncorrect_test(void)
{
// Expecting save but get open dialog
setExpectedFileDialog(getSaveFileName, QStringList());
QGCFileDialog::getOpenFileName();
QGCQFileDialog::getOpenFileName();
checkExpectedFileDialog(expectFailWrongFileDialog);
// This is going to fail in cleanup as well since we have a missed file dialog
......
......@@ -9,7 +9,7 @@
/// @file
/// @brief Unit test for QGCFileDialog catching mechanism.
/// @brief Unit test for QGCQFileDialog catching mechanism.
///
/// @author Don Gagne <don@thegagnes.com>
......
......@@ -28,7 +28,7 @@
#define UT_REGISTER_TEST(className) static UnitTestWrapper<className> className(#className);
class QGCMessageBox;
class QGCFileDialog;
class QGCQFileDialog;
class LinkManager;
class MockLink;
class MainWindow;
......@@ -58,7 +58,7 @@ public:
getSaveFileName
};
/// @brief Sets up for an expected QGCFileDialog
/// @brief Sets up for an expected QGCQFileDialog
/// @param type Type of expected file dialog
/// @param response Files to return from call. Multiple files only supported by getOpenFileNames
void setExpectedFileDialog(enum FileDialogType type, QStringList response);
......@@ -67,7 +67,7 @@ public:
expectFailNoFailure = 1 << 0, ///< not expecting any failures
expectFailNoDialog = 1 << 1, ///< expecting a failure due to no dialog displayed
expectFailBadResponseButton = 1 << 2, ///< expecting a failure due to bad button response (QGCMessageBox only)
expectFailWrongFileDialog = 1 << 3 ///< expecting one dialog type, got the wrong type (QGCFileDialog ony)
expectFailWrongFileDialog = 1 << 3 ///< expecting one dialog type, got the wrong type (QGCQFileDialog ony)
};
/// @brief Check whether a message box was displayed and correctly responded to
......@@ -134,7 +134,7 @@ private:
// This allows the private call to _messageBox
friend class QGCMessageBox;
// When the app is running in unit test mode the QGCFileDialog methods are re-routed here.
// When the app is running in unit test mode the QGCQFileDialog methods are re-routed here.
static QString _getExistingDirectory(
QWidget* parent,
......@@ -167,7 +167,7 @@ private:
static QString _fileDialogResponseSingle(enum FileDialogType type);
// This allows the private calls to the file dialog methods
friend class QGCFileDialog;
friend class QGCQFileDialog;
void _unitTestCalled(void);
static QList<QObject*>& _testList(void);
......@@ -178,7 +178,7 @@ private:
static QMessageBox::StandardButton _messageBoxResponseButton; ///< Response to next message box
static int _missedMessageBoxCount; ///< Count of message box not checked with call to messageBoxWasDisplayed
// Catch QGCFileDialog calls
// Catch QGCQFileDialog calls
static bool _fileDialogRespondedTo; ///< File dialog was responded to
static bool _fileDialogResponseSet; ///< true: _fileDialogResponse was set by a call to UnitTest::setExpectedFileDialog
static QStringList _fileDialogResponse; ///< Response to next file dialog
......
......@@ -10,7 +10,7 @@
#include "ui_QGCMAVLinkLogPlayer.h"
#include "QGCApplication.h"
#include "LinkManager.h"
#include "QGCFileDialog.h"
#include "QGCQFileDialog.h"
#include "QGCMessageBox.h"
QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(QWidget *parent) :
......@@ -69,7 +69,7 @@ void QGCMAVLinkLogPlayer::_selectLogFileForPlayback(void)
return;
}
QString logFilename = QGCFileDialog::getOpenFileName(
QString logFilename = QGCQFileDialog::getOpenFileName(
this,
tr("Load MAVLink Log File"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
......
Supports Markdown
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