feat(cpn): Allow opening of individual model yml files (#1959)

- parse the yaml file and if successful open as a new document in a Models and Settings window
- warn the user that no radio conversion has been possible as source radio flavour unknown
- populate radio settings with default values based on current radio profile
This commit is contained in:
Neil Horne
2022-06-07 10:50:21 +10:00
committed by GitHub
parent 1e8ef179d6
commit cd59eac89f
3 changed files with 75 additions and 8 deletions
+9
View File
@@ -1340,6 +1340,11 @@ void MdiChild::newFile(bool createDefaults)
bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile)
{
if (getStorageType(filename) == STORAGE_TYPE_YML) {
newFile(false);
resetCurrentFile = false;
}
Storage storage(filename);
if (!storage.load(radioData)) {
QMessageBox::critical(this, CPN_STR_TTL_ERROR, storage.error());
@@ -1355,6 +1360,10 @@ bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile)
setCurrentFile(filename);
}
// set after successful import
if (getStorageType(filename) == STORAGE_TYPE_YML)
setModified();
// For etx files this will never be true as any conversion occurs when parsing file
if (!Boards::isBoardCompatible(storage.getBoard(), getCurrentBoard())) {
if (!convertStorage(storage.getBoard(), getCurrentBoard(), true))