1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-14 06:29:18 +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);
const char *fileType = ".optmpl";
const char *fileType = ".vtmpl";
QString fileName = QString("%1-%2-%3%4")
.arg(fixFilenameString(ui->Name->text(), 20))
@ -240,7 +240,7 @@ void VehicleTemplateExportDialog::saveTemplate(QString path)
QString fullPath;
if (path.isEmpty()) {
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 {
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()
{
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());
QDir dir;

View File

@ -115,7 +115,7 @@ void VehicleTemplateSelectorWidget::updateDescription(QJsonObject *templ)
ui->templateDescription->setText(description);
} else {
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 "
"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 "
@ -161,13 +161,14 @@ QString VehicleTemplateSelectorWidget::getTemplatePath()
}
}
void VehicleTemplateSelectorWidget::loadFilesInDir(QString templateBasePath)
void VehicleTemplateSelectorWidget::loadFilesInDir(QString templateBasePath, bool local)
{
QDir templateDir(templateBasePath);
qDebug() << "Loading templates from base path:" << templateBasePath;
QStringList names;
names << "*.optmpl";
names << "*.vtmpl"; // Vehicle template
templateDir.setNameFilters(names);
templateDir.setSorting(QDir::Name);
QStringList files = templateDir.entryList();
@ -203,8 +204,8 @@ void VehicleTemplateSelectorWidget::loadValidFiles()
}
m_templates.clear();
QString path = getTemplatePath();
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertDataPath("%%DATAPATH%%cloudconfig")).arg(path));
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertStoragePath("%%STOREPATH%%cloudconfig")).arg(path));
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertDataPath("%%DATAPATH%%vehicletemplates")).arg(path), false);
loadFilesInDir(QString("%1/%2/").arg(Utils::InsertStoragePath("%%STOREPATH%%vehicletemplates")).arg(path), true);
}
void VehicleTemplateSelectorWidget::setupTemplateList()

View File

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