mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Merge branch 'rel-14.10' of ssh://git.openpilot.org/OpenPilot into rel-14.10
This commit is contained in:
commit
0c7264cd19
@ -170,14 +170,20 @@ void AirframeInitialTuningPage::loadValidFiles()
|
||||
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QByteArray jsonData = file.readAll();
|
||||
QJsonDocument templateDoc = QJsonDocument::fromJson(jsonData);
|
||||
QJsonObject json = templateDoc.object();
|
||||
if (json["type"].toInt() == getWizard()->getVehicleType() &&
|
||||
json["subtype"].toInt() == getWizard()->getVehicleSubType()) {
|
||||
QString uuid = json["uuid"].toString();
|
||||
if (!m_templates.contains(uuid)) {
|
||||
m_templates[json["uuid"].toString()] = new QJsonObject(json);
|
||||
QJsonParseError error;
|
||||
QJsonDocument templateDoc = QJsonDocument::fromJson(jsonData, &error);
|
||||
if (error.error == QJsonParseError::NoError) {
|
||||
QJsonObject json = templateDoc.object();
|
||||
if (json["type"].toInt() == getWizard()->getVehicleType() &&
|
||||
json["subtype"].toInt() == getWizard()->getVehicleSubType()) {
|
||||
QString uuid = json["uuid"].toString();
|
||||
if (!m_templates.contains(uuid)) {
|
||||
m_templates[json["uuid"].toString()] = new QJsonObject(json);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Error parsing json file: "
|
||||
<< fileName << ". Error was:" << error.errorString();
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
|
@ -377,7 +377,7 @@ void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked)
|
||||
ui->motorNeutralSlider->setEnabled(checked);
|
||||
quint16 channel = getCurrentChannel();
|
||||
quint16 safeValue = m_actuatorSettings[channel].channelNeutral;
|
||||
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, safeValue, ui->motorNeutralSlider);
|
||||
onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, 0, ui->motorNeutralSlider);
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider)
|
||||
|
@ -162,17 +162,6 @@ QString VehicleTemplateExportDialog::setupVehicleType()
|
||||
}
|
||||
}
|
||||
|
||||
QString VehicleTemplateExportDialog::fixFilenameString(QString input, int truncate)
|
||||
{
|
||||
return input.replace(' ', "").replace('|', "").replace('/', "")
|
||||
.replace('\\', "").replace(':', "").replace('"', "")
|
||||
.replace('\'', "").replace('?', "").replace('*', "")
|
||||
.replace('>', "").replace('<', "")
|
||||
.replace('}', "").replace('{', "")
|
||||
.left(truncate);
|
||||
}
|
||||
|
||||
|
||||
void VehicleTemplateExportDialog::accept()
|
||||
{
|
||||
QJsonObject exportObject;
|
||||
@ -211,24 +200,23 @@ void VehicleTemplateExportDialog::accept()
|
||||
|
||||
QJsonDocument saveDoc(exportObject);
|
||||
|
||||
QString fileName = QString("%1/%2/%3-%4-%5.optmpl")
|
||||
.arg(EXPORT_BASE_NAME)
|
||||
.arg(getTypeDirectory())
|
||||
.arg(fixFilenameString(ui->Name->text(), 20))
|
||||
.arg(fixFilenameString(ui->Type->text(), 30))
|
||||
.arg(fixFilenameString(uuid.toString().right(12)));
|
||||
QFile saveFile(fileName);
|
||||
QDir dir;
|
||||
dir.mkpath(QFileInfo(saveFile).absoluteDir().absolutePath());
|
||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||
saveFile.write(saveDoc.toJson());
|
||||
saveFile.close();
|
||||
QMessageBox::information(this, "Export", tr("Settings were exported to \n%1").arg(QFileInfo(saveFile).absoluteFilePath()), QMessageBox::Ok);
|
||||
} else {
|
||||
QMessageBox::information(this, "Export", tr("Settings could not be exported to \n%1.\nPlease try again.")
|
||||
.arg(QFileInfo(saveFile).absoluteFilePath()), QMessageBox::Ok);
|
||||
const char *fileType = ".optmpl";
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Export settings"), "fileName""", QString("%1 (*%2)").arg(tr("OPTemplates", fileType)));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!fileName.endsWith(fileType)) {
|
||||
fileName.append(fileType);
|
||||
}
|
||||
QFile saveFile(fileName);
|
||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||
saveFile.write(saveDoc.toJson());
|
||||
saveFile.close();
|
||||
} else {
|
||||
QMessageBox::information(this, "Export", tr("Settings could not be exported to \n%1(%2).\nPlease try again.")
|
||||
.arg(QFileInfo(saveFile).absoluteFilePath(), saveFile.error()), QMessageBox::Ok);
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void VehicleTemplateExportDialog::importImage()
|
||||
|
@ -68,7 +68,6 @@ private:
|
||||
|
||||
QString getTypeDirectory();
|
||||
QString setupVehicleType();
|
||||
QString fixFilenameString(QString input, int truncate = 100);
|
||||
};
|
||||
|
||||
#endif // VEHICLETEMPLATEEXPORTDIALOG_H
|
||||
|
Loading…
Reference in New Issue
Block a user