feat(cpn): save model images with models and settings (#7234)
This commit is contained in:
@@ -78,7 +78,7 @@ static void writeYamlToByteArray(const YAML::Node& node, QByteArray& data, bool
|
||||
data_ostream << node;
|
||||
data = QByteArray::fromStdString(data_ostream.str());
|
||||
|
||||
qDebug() << "Saving YAML:";
|
||||
//qDebug() << "Saving YAML:";
|
||||
|
||||
if(addChecksum) {
|
||||
uint16_t checksum = 0xFFFF;
|
||||
@@ -88,7 +88,7 @@ static void writeYamlToByteArray(const YAML::Node& node, QByteArray& data, bool
|
||||
data.prepend(checksum_ostream.str().c_str());
|
||||
}
|
||||
|
||||
qDebug() << data.toStdString().c_str();
|
||||
//qDebug() << data.toStdString().c_str();
|
||||
}
|
||||
|
||||
bool loadLabelsListFromYaml(RadioData::ModelLabels& labels,
|
||||
|
||||
@@ -2334,3 +2334,42 @@ void ModelData::initTopBar()
|
||||
zone.widgetName = "Internal GPS";
|
||||
}
|
||||
}
|
||||
|
||||
QString ModelData::getImageFilename() const
|
||||
{
|
||||
if (!isBitmapEmpty()) {
|
||||
QString extn;
|
||||
|
||||
if (!getCurrentFirmware()->getCapability(ModelImageKeepExtn))
|
||||
extn = "." % getDefaultImageFileExtn();
|
||||
|
||||
return QString(bitmap).append(extn);
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString ModelData::getImageFileExtn() const
|
||||
{
|
||||
if (getCurrentFirmware()->getCapability(ModelImageKeepExtn)) {
|
||||
QStringList strl = QString(bitmap).split(".");
|
||||
return strl.count() > 1 ? strl.at(strl.count() - 1) : "";
|
||||
} else {
|
||||
return getDefaultImageFileExtn();
|
||||
}
|
||||
}
|
||||
|
||||
QString ModelData::getDefaultImageFileExtn()
|
||||
{
|
||||
QString ret;
|
||||
|
||||
if (!getCurrentFirmware()->getCapability(ModelImageKeepExtn))
|
||||
ret = getCurrentFirmware()->getCapabilityStr(ModelImageFilters).replace("*.", "");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ModelData::isBitmapEmpty() const
|
||||
{
|
||||
return bitmap[0] == '\0';
|
||||
}
|
||||
|
||||
@@ -293,6 +293,10 @@ class ModelData {
|
||||
const Board::SwitchType getSwitchType(int sw, const GeneralSettings & gs) const;
|
||||
|
||||
QString getChecklistFilename() const;
|
||||
QString getImageFilename() const;
|
||||
QString getImageFileExtn() const;
|
||||
static QString getDefaultImageFileExtn();
|
||||
bool isBitmapEmpty() const;
|
||||
|
||||
enum ReferenceUpdateAction {
|
||||
REF_UPD_ACT_CLEAR,
|
||||
|
||||
@@ -107,7 +107,8 @@ int OpenTxFirmware::getCapability(::Capability capability)
|
||||
case HasMixerNames:
|
||||
return (IS_TARANIS_X9(board) ? 8 : 6);
|
||||
case HasModelImage:
|
||||
return (board == BOARD_TARANIS_X9D || IS_TARANIS_PLUS(board) || board == BOARD_TARANIS_X9DP_2019 || IS_FAMILY_HORUS_OR_T16(board));
|
||||
return (board == BOARD_TARANIS_X9D || IS_TARANIS_PLUS(board) || board == BOARD_TARANIS_X9DP_2019 ||
|
||||
IS_FAMILY_HORUS_OR_T16(board) || Boards::getCapability(board, Board::HasColorLcd));
|
||||
case HasModelLabels:
|
||||
return IS_FAMILY_HORUS_OR_T16(board);
|
||||
case HasModelsList:
|
||||
|
||||
Reference in New Issue
Block a user