feat(color): Use generic YAML parser to save/load Theme yaml files (#3346)
* Change ThemeFile class to use generic YAML parser instead of hard wired code. Fix handling of empty input lines in YAML parser. Increase size of YAML parser variables to handle theme 'info' property length. * Update comment. * Fix error. * Proper fix for blank lines in YAML file. * Fix YAML blank line handling (attempt 3). * Ensure theme YAML file is backward compatible. * Store selected theme in radio settings instead of selectedtheme.txt file. On start, if radio settings theme is empty, try and load from selectedtheme.txt file. In Companion, save/load the selected theme in the radio settings YAML file; but no UI to select theme. * Update selected theme name in radio.yml if the theme name was edited. * Only save 'selectedTheme' in Companion on color LCD radios.
This commit is contained in:
@@ -148,6 +148,8 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
|
||||
auto fw = getCurrentFirmware();
|
||||
|
||||
bool hasColorLcd = Boards::getCapability(fw->getBoard(), Board::HasColorLcd);
|
||||
|
||||
node["semver"] = VERSION;
|
||||
|
||||
std::string board = fw->getFlavour().toStdString();
|
||||
@@ -281,6 +283,9 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
||||
// OneBit sampling (X9D only?)
|
||||
node["uartSampleMode"] = rhs.uartSampleMode;
|
||||
|
||||
if (hasColorLcd)
|
||||
node["selectedTheme"] = rhs.selectedTheme;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -496,6 +501,8 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
||||
if (needsConversion)
|
||||
rhs.init();
|
||||
|
||||
node["selectedTheme"] >> rhs.selectedTheme;
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace YAML
|
||||
|
||||
@@ -101,6 +101,7 @@ constexpr int BLUETOOTH_NAME_LEN {10};
|
||||
constexpr int TTS_LANGUAGE_LEN {2};
|
||||
constexpr int HARDWARE_NAME_LEN {3};
|
||||
constexpr int REGISTRATION_ID_LEN {8};
|
||||
constexpr int SELECTED_THEME_NAME_LEN {26};
|
||||
|
||||
class GeneralSettings {
|
||||
Q_DECLARE_TR_FUNCTIONS(GeneralSettings)
|
||||
@@ -283,6 +284,8 @@ class GeneralSettings {
|
||||
int pwrOnSpeed;
|
||||
int pwrOffSpeed;
|
||||
|
||||
char selectedTheme[SELECTED_THEME_NAME_LEN + 1];
|
||||
|
||||
bool switchPositionAllowedTaranis(int index) const;
|
||||
bool switchSourceAllowedTaranis(int index) const;
|
||||
bool isPotAvailable(int index) const;
|
||||
|
||||
Reference in New Issue
Block a user