chore(cpn): add Accept and Decline buttons to yaml decode unsupported versions dialogs (#4801)
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
void YamlValidateNames(GeneralSettings& gs, Board::Type board)
|
||||
{
|
||||
@@ -363,11 +364,20 @@ bool convert<GeneralSettings>::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
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
void YamlValidateLabelsNames(ModelData& model, Board::Type board)
|
||||
{
|
||||
@@ -1174,11 +1175,20 @@ bool convert<ModelData>::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"]) {
|
||||
|
||||
Reference in New Issue
Block a user