Fix companion model edit image names (#848)

* Fix companion model edit bitmap image names

* Add radio conversion of file extension
This commit is contained in:
Neil Horne
2021-10-05 20:33:35 +11:00
committed by GitHub
parent 249db20500
commit adf514fe16
11 changed files with 110 additions and 83 deletions
+15
View File
@@ -407,6 +407,21 @@ void ModelData::convert(RadioDataConversionState & cstate)
thrTraceSrc = RawSource(SOURCE_TYPE_STICK, (int)thrTraceSrc + 3).convert(cstate).index - 3;
}
Firmware *fw = getCurrentFirmware();
if (fw->getCapability(HasModelImage) && bitmap[0] != '\0') {
QString filename = bitmap;
QFileInfo file(filename);
if (fw->getCapability(ModelImageKeepExtn) && file.suffix() == "")
filename.append(".bmp"); // bmp is assumed default for radios that do not store file extension
else if (!fw->getCapability(ModelImageKeepExtn) && file.suffix() != "") {
int posn = filename.indexOf("." % file.suffix(), + 1);
filename.remove(posn, filename.size() - posn + 1);
}
memset(bitmap, 0, CPN_MAX_BITMAP_LEN);
strncpy(bitmap, filename.toLatin1().data(), fw->getCapability(ModelImageNameLen));
}
for (int i = 0; i < CPN_MAX_MODULES; i++) {
moduleData[i].convert(cstate.withComponentIndex(i));
}