1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

LP-16 Updated code to use new vehicle template path and extension.

This commit is contained in:
m_thread 2015-07-15 10:30:36 +02:00
parent c193b53d3a
commit da6b0715f7
3 changed files with 9 additions and 8 deletions

View File

@ -229,7 +229,7 @@ void VehicleTemplateExportDialog::saveTemplate(QString path)
QJsonDocument saveDoc(exportObject); QJsonDocument saveDoc(exportObject);
const char *fileType = ".optmpl"; const char *fileType = ".vtmpl";
QString fileName = QString("%1-%2-%3%4") QString fileName = QString("%1-%2-%3%4")
.arg(fixFilenameString(ui->Name->text(), 20)) .arg(fixFilenameString(ui->Name->text(), 20))
@ -240,7 +240,7 @@ void VehicleTemplateExportDialog::saveTemplate(QString path)
QString fullPath; QString fullPath;
if (path.isEmpty()) { if (path.isEmpty()) {
fullPath = QString("%1%2%3").arg(QDir::homePath()).arg(QDir::separator()).arg(fileName); fullPath = QString("%1%2%3").arg(QDir::homePath()).arg(QDir::separator()).arg(fileName);
fullPath = QFileDialog::getSaveFileName(this, tr("Export settings"), fullPath, QString("%1 (*%2)").arg(tr("OPTemplates"), fileType)); fullPath = QFileDialog::getSaveFileName(this, tr("Export settings"), fullPath, QString("%1 (*%2)").arg(tr("VehicleTemplates"), fileType));
} else { } else {
fullPath = QString("%1%2%3").arg(path).arg(QDir::separator()).arg(fileName); fullPath = QString("%1%2%3").arg(path).arg(QDir::separator()).arg(fileName);
} }
@ -272,7 +272,7 @@ QString VehicleTemplateExportDialog::fixFilenameString(QString input, int trunca
void VehicleTemplateExportDialog::exportTemplate() void VehicleTemplateExportDialog::exportTemplate()
{ {
QString path = QString("%1%2%3%4").arg(Utils::InsertStoragePath("%%STOREPATH%%cloudconfig")) QString path = QString("%1%2%3%4").arg(Utils::InsertStoragePath("%%STOREPATH%%vehicletemplates"))
.arg(QDir::separator()).arg(getTypeDirectory()).arg(QDir::separator()); .arg(QDir::separator()).arg(getTypeDirectory()).arg(QDir::separator());
QDir dir; QDir dir;

View File

@ -115,7 +115,7 @@ void VehicleTemplateSelectorWidget::updateDescription(QJsonObject *templ)
ui->templateDescription->setText(description); ui->templateDescription->setText(description);
} else { } else {
ui->templateDescription->setText(tr("This option will use the current tuning settings saved on the controller, if your controller " ui->templateDescription->setText(tr("This option will use the current tuning settings saved on the controller, if your controller "
"is currently unconfigured, then the OpenPilot firmware defaults will be used.\n\n" "is currently unconfigured, then the pre-configured firmware defaults will be used.\n\n"
"It is suggested that if this is a first time configuration of your controller, rather than " "It is suggested that if this is a first time configuration of your controller, rather than "
"use this option, instead select a tuning set that matches your own airframe as close as " "use this option, instead select a tuning set that matches your own airframe as close as "
"possible from the list above or if you are not able to fine one, then select the generic item " "possible from the list above or if you are not able to fine one, then select the generic item "
@ -161,13 +161,14 @@ QString VehicleTemplateSelectorWidget::getTemplatePath()
} }
} }
void VehicleTemplateSelectorWidget::loadFilesInDir(QString templateBasePath) void VehicleTemplateSelectorWidget::loadFilesInDir(QString templateBasePath, bool local)
{ {
QDir templateDir(templateBasePath); QDir templateDir(templateBasePath);
qDebug() << "Loading templates from base path:" << templateBasePath; qDebug() << "Loading templates from base path:" << templateBasePath;
QStringList names; QStringList names;
names << "*.optmpl"; names << "*.optmpl";
names << "*.vtmpl"; // Vehicle template
templateDir.setNameFilters(names); templateDir.setNameFilters(names);
templateDir.setSorting(QDir::Name); templateDir.setSorting(QDir::Name);
QStringList files = templateDir.entryList(); QStringList files = templateDir.entryList();
@ -203,8 +204,8 @@ void VehicleTemplateSelectorWidget::loadValidFiles()
} }
m_templates.clear(); m_templates.clear();
QString path = getTemplatePath(); QString path = getTemplatePath();
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertDataPath("%%DATAPATH%%cloudconfig")).arg(path)); loadFilesInDir(QString("%1/%2/").arg(Utils::InsertDataPath("%%DATAPATH%%vehicletemplates")).arg(path), false);
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertStoragePath("%%STOREPATH%%cloudconfig")).arg(path)); loadFilesInDir(QString("%1/%2/").arg(Utils::InsertStoragePath("%%STOREPATH%%vehicletemplates")).arg(path), true);
} }
void VehicleTemplateSelectorWidget::setupTemplateList() void VehicleTemplateSelectorWidget::setupTemplateList()

View File

@ -61,7 +61,7 @@ private:
QGraphicsPixmapItem *m_photoItem; QGraphicsPixmapItem *m_photoItem;
void loadValidFiles(); void loadValidFiles();
void loadFilesInDir(QString templateBasePath); void loadFilesInDir(QString templateBasePath, bool local);
void setupTemplateList(); void setupTemplateList();
QString getTemplateKey(QJsonObject *templ); QString getTemplateKey(QJsonObject *templ);
void updatePhoto(QJsonObject *templ); void updatePhoto(QJsonObject *templ);