feat(cpn): reorganise and refactor Edit Settings (Profile/Application/Simulator/Update) dialog (#7623)
This commit is contained in:
@@ -621,7 +621,6 @@ void AppData::initAll()
|
||||
void AppData::resetAllSettings()
|
||||
{
|
||||
resetAll();
|
||||
fwRev.resetAll();
|
||||
|
||||
for (int i = 0; i < MAX_PROFILES; i++) {
|
||||
profile[i].resetAll();
|
||||
@@ -766,6 +765,7 @@ void AppData::convertSettings(QSettings & settings)
|
||||
// We only want to remove old/deprecated settngs if the {major}{minor} part of the settings version number has changed.
|
||||
// This preserves backwards compatiblity within minor version releases (where only revision number changes).
|
||||
const unsigned savedMajMin = (savedVer >> 16);
|
||||
const unsigned savedRevision = (savedVer & 0x0F);
|
||||
const unsigned currMajMin = (CPN_SETTINGS_VERSION >> 16);
|
||||
const bool removeUnused = (savedMajMin < currMajMin);
|
||||
|
||||
@@ -938,6 +938,40 @@ void AppData::convertSettings(QSettings & settings)
|
||||
}
|
||||
}
|
||||
|
||||
if (savedMajMin <= 0x300 && savedRevision < CPN_SETTINGS_REVISION) {
|
||||
// split out profile fwType options and language into separate fields
|
||||
qInfo().noquote() << "Converting profiles firmware type";
|
||||
static const QString profilePath = QStringLiteral("Profiles/profile%1");
|
||||
static const QString profileFwTypePath = QStringLiteral("Profiles/profile%1/fwType");
|
||||
for (int i = 0; i < MAX_PROFILES; i++) {
|
||||
if (settings.contains(profileFwTypePath.arg(i))) {
|
||||
const QVariant oldValue = settings.value(profileFwTypePath.arg(i));
|
||||
if (oldValue.isValid()) {
|
||||
const QStringList oldparts = settings.value(profileFwTypePath.arg(i)).toString().split("-");
|
||||
QString newfwType;
|
||||
QString newfwOpts;
|
||||
QString newfwLang;
|
||||
if (oldparts.count() > 1) {
|
||||
newfwType = oldparts.mid(0, 2).join("-");
|
||||
settings.setValue(profileFwTypePath.arg(i), newfwType);
|
||||
}
|
||||
if (oldparts.count() > 2) {
|
||||
newfwLang = oldparts.last();
|
||||
settings.setValue(profilePath.arg(i) % "/fwLanguage", newfwLang);
|
||||
}
|
||||
if (oldparts.count() > 3) {
|
||||
newfwOpts = oldparts.mid(2, oldparts.count() - 3).join("-");
|
||||
settings.setValue(profilePath.arg(i) % "/fwOptions", newfwOpts);
|
||||
}
|
||||
qInfo().noquote() << "Converted entry" << profileFwTypePath.arg(i)
|
||||
<< "from (" << oldValue << ")"
|
||||
<< "to (type:" << newfwType << "opts:" << newfwOpts << "lang:" << newfwLang << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (removeUnused)
|
||||
clearUnusedSettings(settings);
|
||||
|
||||
@@ -1108,8 +1142,9 @@ void AppData::resetUpdatesSettings()
|
||||
decompressDirUseDwnldReset();
|
||||
updateDirReset();
|
||||
updateDirUseSDReset();
|
||||
updDelDownloadsReset();
|
||||
updLogLevelReset();
|
||||
updDelDownloadsReset();
|
||||
updDelDecompressReset();
|
||||
|
||||
for (int i = 0; i < MAX_COMPONENTS; i++) {
|
||||
component[i].resetAll();
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
//! CPN_SETTINGS_REVISION is used to track settings changes independently of EdgeTX version. It should be reset to zero whenever settings are migrated to new COMPANY or PRODUCT.
|
||||
//! \note !! Increment this value if properties are removed or refactored. It will trigger a conversion/cleanup of any stored settings. \sa AppData::convertSettings()
|
||||
#define CPN_SETTINGS_REVISION 3 // Note: bumped for changes during 3.0 dev
|
||||
#define CPN_SETTINGS_REVISION 4 // Note: bumped for multiple changes during 3.0 dev
|
||||
|
||||
//! CPN_SETTINGS_VERSION is used for settings data version tracking.
|
||||
#define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION)
|
||||
@@ -310,23 +310,6 @@ class CompStoreObj: public QObject
|
||||
class AppData;
|
||||
|
||||
|
||||
//! \brief FwRevision class stores data about downloaded firmware binaries. It uses dynamic key names and does not have any properties.
|
||||
class FwRevision: public CompStoreObj
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
inline int get(const QString & fwType) const { return m_settings.value(settingsPath() % fwType, 0).toInt(); }
|
||||
inline void set(const QString & fwType, const int fwRevision) const { store(QString("%1").arg(fwRevision), fwType); }
|
||||
inline void remove(const QString & tag) const { clear(tag); }
|
||||
inline void resetAll() override { clear(propertyGroup(), ""); }
|
||||
|
||||
protected:
|
||||
explicit FwRevision() : CompStoreObj() { CompStoreObj::addDynamicPropertyGroup(propertyGroup()); }
|
||||
QString propertyGroup() const override { return QStringLiteral("FwRevisions"); }
|
||||
friend class AppData;
|
||||
};
|
||||
|
||||
|
||||
//! \brief JStickData class stores properties related to each joystick axis (calibration/assignment/direction).
|
||||
class JStickData: public CompStoreObj
|
||||
{
|
||||
@@ -519,28 +502,31 @@ class Profile: public CompStoreObj
|
||||
PROPERTYSTR2(name, "Name")
|
||||
PROPERTYSTR2(splashFile, "SplashFileName")
|
||||
PROPERTYSTR(fwName)
|
||||
PROPERTYSTR(fwType)
|
||||
PROPERTYSTR(fwType) // converted 3.0 split out options and language to own fields
|
||||
PROPERTYSTR(fwOptions) // added 3.0
|
||||
PROPERTYSTR(fwLanguage) // added 3.0
|
||||
PROPERTYSTR(sdPath)
|
||||
PROPERTYSTR(pBackupDir)
|
||||
PROPERTYSTR(modelsDir) // added 3.0
|
||||
|
||||
PROPERTY (int, defaultInternalModule, 0)
|
||||
PROPERTY (int, externalModuleSize, 1) // added 2.9 - Board::EXTMODSIZE_STD used for existing profiles
|
||||
PROPERTY4(int, channelOrder, "default_channel_order", 0)
|
||||
PROPERTY4(int, defaultMode, "default_mode", 1)
|
||||
PROPERTY (int, volumeGain, 10)
|
||||
PROPERTY (int, externalModuleSize, 1) // added 2.9 - Board::EXTMODSIZE_STD used for existing profiles
|
||||
PROPERTY4(int, channelOrder, "default_channel_order", 0)
|
||||
PROPERTY4(int, defaultMode, "default_mode", 1)
|
||||
PROPERTY (int, volumeGain, 10) // divided by 10
|
||||
|
||||
PROPERTY (bool, burnFirmware, false)
|
||||
PROPERTY (bool, penableBackup, false)
|
||||
PROPERTY (bool, runSDSync, false)
|
||||
|
||||
// Simulator variables
|
||||
PROPERTY(SimulatorOptions, simulatorOptions, SimulatorOptions())
|
||||
PROPERTY(bool, telemSimEnabled, false)
|
||||
PROPERTY(bool, telemSimPauseOnHide, true)
|
||||
PROPERTY(bool, telemSimResetRssiOnStop, false)
|
||||
PROPERTY(QColor, radioSimCaseColor, QColor(Qt::black))
|
||||
PROPERTY(bool, simBtnClickedUseOSTheme, true)
|
||||
PROPERTY(QColor, simBtnClickedColor, QColor(Qt::red))
|
||||
PROPERTY(SimulatorOptions, simulatorOptions, SimulatorOptions())
|
||||
PROPERTY(bool, telemSimEnabled, false)
|
||||
PROPERTY(bool, telemSimPauseOnHide, true)
|
||||
PROPERTY(bool, telemSimResetRssiOnStop, false)
|
||||
PROPERTY(QColor, radioSimCaseColor, QColor(Qt::black))
|
||||
PROPERTY(bool, simBtnClickedUseOSTheme, true)
|
||||
PROPERTY(QColor, simBtnClickedColor, QColor(Qt::red))
|
||||
|
||||
// General settings
|
||||
PROPERTYQBA(generalSettings)
|
||||
@@ -672,6 +658,8 @@ class AppData: public CompStoreObj
|
||||
// refer enum QtMsgType
|
||||
static QStringList updateLogLevelsList() { return { tr("Debug"), tr("Warning"), tr("Critical"), tr("Fatal"), tr("Information") } ; }
|
||||
static QStringList simuGenericKeysPosList() { return { tr("Default"), tr("Left"), tr("Right") } ; }
|
||||
static QStringList simuBackLightColorList() { return { tr("Blue"), tr("Green"), tr("Red"), tr("Orange"), tr("Yellow") } ; }
|
||||
static QStringList splashLibsList() { return { tr("Only show user splash images"), tr("Show user and companion splash images") } ; }
|
||||
|
||||
explicit AppData();
|
||||
void init() override;
|
||||
@@ -728,7 +716,6 @@ class AppData: public CompStoreObj
|
||||
JStickData joystick[MAX_JS_AXES];
|
||||
JButtonData jsButton[MAX_JS_BUTTONS];
|
||||
NamedJSData namedJS[MAX_NAMED_JOYSTICKS];
|
||||
FwRevision fwRev;
|
||||
ComponentData component[MAX_COMPONENTS];
|
||||
|
||||
void clearJSData() {
|
||||
@@ -760,6 +747,7 @@ class AppData: public CompStoreObj
|
||||
PROPERTYQBA2(mainWinGeo, "mainWindowGeometry")
|
||||
PROPERTYQBA2(mainWinState, "mainWindowState")
|
||||
PROPERTYQBA2(modelEditGeo, "modelEditGeometry")
|
||||
PROPERTYQBA2(prefsEditGeo, "prefsEditGeometry") // added 3.0
|
||||
PROPERTYQBA (mdiWinGeo)
|
||||
PROPERTYQBA (mdiWinState)
|
||||
PROPERTYQBA (compareWinGeo)
|
||||
@@ -775,6 +763,7 @@ class AppData: public CompStoreObj
|
||||
PROPERTYSTRD(downloadDir, CPN_DOCUMENTS_LOCATION % "/downloads")
|
||||
PROPERTYSTRD(decompressDir, CPN_DOCUMENTS_LOCATION % "/decompress")
|
||||
PROPERTYSTRD(updateDir, CPN_DOCUMENTS_LOCATION % "/updates")
|
||||
PROPERTYSTRD(modelsDir, CPN_DOCUMENTS_LOCATION % "/models") // added 3.0
|
||||
PROPERTY (bool, decompressDirUseDwnld, true)
|
||||
PROPERTY (bool, updateDirUseSD, true)
|
||||
PROPERTY (bool, runAppInstaller, false)
|
||||
@@ -782,6 +771,7 @@ class AppData: public CompStoreObj
|
||||
PROPERTY (bool, updDelDownloads, false)
|
||||
PROPERTY (bool, updDelDecompress, false)
|
||||
PROPERTYSTR (lastUpdateDir)
|
||||
PROPERTY (bool, logVerbose, false)
|
||||
|
||||
PROPERTYSTR (locale)
|
||||
PROPERTYSTR (gePath)
|
||||
|
||||
Reference in New Issue
Block a user