diff --git a/companion/src/constants.h b/companion/src/constants.h index d62af9404..ea7fd5b93 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -61,6 +61,8 @@ #define CPN_STR_TTL_INFO QCoreApplication::translate("Companion", "Information") // shared Title Case words, eg. for a window title or section heading #define CPN_STR_TTL_WARNING QCoreApplication::translate("Companion", "Warning") #define CPN_STR_TTL_ERROR QCoreApplication::translate("Companion", "Error") +#define CPN_STR_TTL_ACCEPT QCoreApplication::translate("Companion", "Accept") +#define CPN_STR_TTL_DECLINE QCoreApplication::translate("Companion", "Decline") #define CPN_STR_FILES QCoreApplication::translate("Companion", "files") #define CPN_STR_RAD_MOD_SETTINGS QCoreApplication::translate("Companion", "Radio and Models settings") diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 674045df1..ae9e1883b 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -31,6 +31,7 @@ #include "helpers.h" #include +#include void YamlValidateNames(GeneralSettings& gs, Board::Type board) { @@ -363,11 +364,20 @@ bool convert::decode(const Node& node, GeneralSettings& rhs) qDebug() << "Settings version:" << radioSettingsVersion.toString(); if (radioSettingsVersion > SemanticVersion(VERSION)) { - QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: Radio settings file version %1 is not supported by this version of Companion!\n\nModel and radio settings may be corrupted if you continue.\n\nI acknowledge and accept the consequences."); - if (QMessageBox::warning(NULL, CPN_STR_APP_NAME, prmpt.arg(radioSettingsVersion.toString()), (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) != QMessageBox::Yes) { - // TODO: this triggers an error in the calling code so we need a graceful way to handle + QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: File version %1 is not supported by this version of Companion!\n\nModel and radio settings may be corrupted if you continue."); + prmpt = prmpt.arg(radioSettingsVersion.toString()); + QMessageBox msgBox; + msgBox.setWindowTitle(QCoreApplication::translate("YamlGeneralSettings", "Read Radio Settings")); + msgBox.setText(prmpt); + msgBox.setIcon(QMessageBox::Warning); + QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT); + QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE); + msgBox.addButton(pbAccept, QMessageBox::AcceptRole); + msgBox.addButton(pbDecline, QMessageBox::RejectRole); + msgBox.setDefaultButton(pbDecline); + msgBox.exec(); + if (msgBox.clickedButton() == pbDecline) return false; - } } rhs.version = CPN_CURRENT_SETTINGS_VERSION; // depreciated in EdgeTX however data conversions use diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 4987d126d..3f4f7b5a4 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -39,6 +39,7 @@ #include #include +#include void YamlValidateLabelsNames(ModelData& model, Board::Type board) { @@ -1174,11 +1175,20 @@ bool convert::decode(const Node& node, ModelData& rhs) // TODO display model filename in preference to model name as easier for user if (modelSettingsVersion > SemanticVersion(VERSION)) { - QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: Model '%1' has settings version %2 that is not supported by this version of Companion!\n\nModel and radio settings may be corrupted if you continue.\n\nI acknowledge and accept the consequences."); - if (QMessageBox::warning(NULL, CPN_STR_APP_NAME, prmpt.arg(rhs.name).arg(modelSettingsVersion.toString()), (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) != QMessageBox::Yes) { - // TODO: this triggers an error in the calling code so we need a graceful way to handle + QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: '%1' has settings version %2 that is not supported by this version of Companion!\n\nModel settings may be corrupted if you continue."); + prmpt = prmpt.arg(rhs.name).arg(modelSettingsVersion.toString()); + QMessageBox msgBox; + msgBox.setWindowTitle(QCoreApplication::translate("YamlModelSettings", "Read Model Settings")); + msgBox.setText(prmpt); + msgBox.setIcon(QMessageBox::Warning); + QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT); + QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE); + msgBox.addButton(pbAccept, QMessageBox::AcceptRole); + msgBox.addButton(pbDecline, QMessageBox::RejectRole); + msgBox.setDefaultButton(pbDecline); + msgBox.exec(); + if (msgBox.clickedButton() == pbDecline) return false; - } } if (node["timers"]) {