chore(cpn): application settings fixes, housekeeping and refactoring (#7362)

Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Neil Horne
2026-06-16 18:12:22 +10:00
committed by GitHub
co-authored by Peter Feerick Claude Sonnet 4.6
parent 892410b797
commit b693afd5c7
4 changed files with 388 additions and 114 deletions
+321 -75
View File
@@ -80,7 +80,7 @@ void CompStoreObj::removeGroupIfEmpty(const QString &group) const
m_settings.endGroup(); m_settings.endGroup();
} }
//static void dumpMetadata(QObject *obj) { // static void dumpMetadata(QObject *obj) {
// for (int i = obj->metaObject()->propertyOffset() /* 0 */, e = obj->metaObject()->propertyCount(); i < e; ++i) // for (int i = obj->metaObject()->propertyOffset() /* 0 */, e = obj->metaObject()->propertyCount(); i < e; ++i)
// qDebug() << obj->metaObject()->property(i).name() << "=" << obj->metaObject()->property(i).read(obj); // qDebug() << obj->metaObject()->property(i).name() << "=" << obj->metaObject()->property(i).read(obj);
// for (int i = obj->metaObject()->methodOffset() /* 0 */, e = obj->metaObject()->methodCount(); i < e; ++i) { // for (int i = obj->metaObject()->methodOffset() /* 0 */, e = obj->metaObject()->methodCount(); i < e; ++i) {
@@ -88,7 +88,7 @@ void CompStoreObj::removeGroupIfEmpty(const QString &group) const
// qDebug().noquote() << (a == 0 ? " private" : a == 1 ? "protected" : " public") << (t == 1 ? "signal:" : t == 2 ? "slot: " : ": ") // qDebug().noquote() << (a == 0 ? " private" : a == 1 ? "protected" : " public") << (t == 1 ? "signal:" : t == 2 ? "slot: " : ": ")
// << obj->metaObject()->method(i).typeName() << obj->metaObject()->method(i).methodSignature(); // << obj->metaObject()->method(i).typeName() << obj->metaObject()->method(i).methodSignature();
// } // }
//} // }
// static methods // static methods
@@ -205,7 +205,8 @@ const QString CompStoreObj::propertyKeyName(CompStoreObj * obj, const QString &
QPair<QString, QString> CompStoreObj::splitGroupedPath(const QString & path) QPair<QString, QString> CompStoreObj::splitGroupedPath(const QString & path)
{ {
const QStringList list = path.split('/'); const QStringList list = path.split('/');
const QString grp = list.size() > 1 ? list.first() : QStringLiteral("General"); // "General" is the default (no-name) group, used by AppData top-level settings. // grp is propertyGroup() thus why size minus 2
const QString grp = list.size() > 1 ? list.mid(0, list.size() - 2).join("/") : QStringLiteral("General"); // "General" is the default (no-name) group, used by AppData top-level settings.
return QPair<QString, QString>(grp, list.last()); return QPair<QString, QString>(grp, list.last());
} }
@@ -230,7 +231,7 @@ const QHash<QString, QHash<QString, QString> > & CompStoreObj::keyToNameMap()
it.next(); it.next();
QHash<QString, QString> grpMap; QHash<QString, QString> grpMap;
CompStoreObj * obj = it.value(); CompStoreObj * obj = it.value();
//dumpMetadata(obj); // dumpMetadata(obj);
for (int i = obj->metaObject()->propertyOffset(), e = obj->metaObject()->propertyCount(); i < e; ++i) { for (int i = obj->metaObject()->propertyOffset(), e = obj->metaObject()->propertyCount(); i < e; ++i) {
const QString name = QString(obj->metaObject()->property(i).name()); const QString name = QString(obj->metaObject()->property(i).name());
const QString key = propertyKeyName(obj, name); const QString key = propertyKeyName(obj, name);
@@ -238,7 +239,7 @@ const QHash<QString, QHash<QString, QString> > & CompStoreObj::keyToNameMap()
grpMap.insert(key, name); grpMap.insert(key, name);
} }
map.insert(it.key(), grpMap); map.insert(it.key(), grpMap);
//qDebug() << it.key() << grpMap; // qDebug() << it.key() << grpMap;
} }
} }
return map; return map;
@@ -249,7 +250,6 @@ const QHash<QString, QHash<QString, QString> > & CompStoreObj::keyToNameMap()
JStickData::JStickData() : CompStoreObj(), index(-1) JStickData::JStickData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
bool JStickData::existsOnDisk() bool JStickData::existsOnDisk()
@@ -259,7 +259,6 @@ bool JStickData::existsOnDisk()
JButtonData::JButtonData() : CompStoreObj(), index(-1) JButtonData::JButtonData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
bool JButtonData::existsOnDisk() bool JButtonData::existsOnDisk()
@@ -269,7 +268,6 @@ bool JButtonData::existsOnDisk()
NamedJStickData::NamedJStickData() : CompStoreObj(), index(-1) NamedJStickData::NamedJStickData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
bool NamedJStickData::existsOnDisk() bool NamedJStickData::existsOnDisk()
@@ -279,7 +277,6 @@ bool NamedJStickData::existsOnDisk()
NamedJButtonData::NamedJButtonData() : CompStoreObj(), index(-1) NamedJButtonData::NamedJButtonData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
bool NamedJButtonData::existsOnDisk() bool NamedJButtonData::existsOnDisk()
@@ -289,7 +286,6 @@ bool NamedJButtonData::existsOnDisk()
NamedJSData::NamedJSData() : CompStoreObj(), index(-1) NamedJSData::NamedJSData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
bool NamedJSData::existsOnDisk() bool NamedJSData::existsOnDisk()
@@ -297,12 +293,30 @@ bool NamedJSData::existsOnDisk()
return (m_settings.value(settingsPath() % jsName(), -1).toInt() > -1); return (m_settings.value(settingsPath() % jsName(), -1).toInt() > -1);
} }
// ** ComponentReleaseData class********************
ComponentReleaseData::ComponentReleaseData() : CompStoreObj(), index(-1)
{
}
// The default copy operator can not be used since the index variable would be destroyed
ComponentReleaseData & ComponentReleaseData::operator= (const ComponentReleaseData & rhs)
{
for (int i = metaObject()->propertyOffset(), e = metaObject()->propertyCount(); i < e; ++i) {
const QMetaProperty & prop = metaObject()->property(i);
if (!prop.isValid() || !prop.isWritable()) {
qWarning() << "Could not copy property" << QString(prop.name()) << "isValid:" << prop.isValid() << "isWritable:" << prop.isWritable();
continue;
}
prop.write(this, prop.read(&rhs));
}
return *this;
}
// ** Profile class******************** // ** Profile class********************
Profile::Profile() : CompStoreObj(), index(-1) Profile::Profile() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
Profile::Profile(const Profile & rhs) : CompStoreObj(), index(-1) Profile::Profile(const Profile & rhs) : CompStoreObj(), index(-1)
@@ -321,6 +335,11 @@ Profile & Profile::operator= (const Profile & rhs)
} }
prop.write(this, prop.read(&rhs)); prop.write(this, prop.read(&rhs));
} }
for (int i = 0; i < MAX_COMPONENTS; i++) {
compRelease[i] = rhs.compRelease[i];
}
return *this; return *this;
} }
@@ -329,11 +348,26 @@ bool Profile::existsOnDisk()
return m_settings.contains(settingsPath() % "Name"); return m_settings.contains(settingsPath() % "Name");
} }
ComponentReleaseData & Profile::getCompRelease(int index)
{
if (index > -1 && index < MAX_COMPONENTS)
return compRelease[index];
return compRelease[0];
}
const ComponentReleaseData & Profile::getCompRelease(int index) const
{
if (index > -1 && index < MAX_COMPONENTS)
return compRelease[index];
return compRelease[0];
}
// ** ComponentAssetData class******************** // ** ComponentAssetData class********************
ComponentAssetData::ComponentAssetData() : CompStoreObj(), index(-1) ComponentAssetData::ComponentAssetData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this);
} }
// The default copy operator can not be used since the index variable would be destroyed // The default copy operator can not be used since the index variable would be destroyed
@@ -359,7 +393,7 @@ bool ComponentAssetData::existsOnDisk()
ComponentData::ComponentData() : CompStoreObj(), index(-1) ComponentData::ComponentData() : CompStoreObj(), index(-1)
{ {
CompStoreObj::addObjectMapping(propertyGroup(), this); qRegisterMetaType<ComponentData::ReleaseChannel>("ComponentData::ReleaseChannel");
} }
// The default copy operator can not be used since the index variable would be destroyed // The default copy operator can not be used since the index variable would be destroyed
@@ -381,15 +415,6 @@ bool ComponentData::existsOnDisk()
return (m_settings.contains(settingsPath() % "name")); return (m_settings.contains(settingsPath() % "name"));
} }
void ComponentData::releaseClear()
{
releaseReset();
releaseIdReset();
prereleaseReset();
dateReset();
versionReset();
}
ComponentAssetData & ComponentData::getAsset(int index) ComponentAssetData & ComponentData::getAsset(int index)
{ {
if (index > -1 && index < MAX_COMPONENT_ASSETS) if (index > -1 && index < MAX_COMPONENT_ASSETS)
@@ -417,6 +442,10 @@ AppData::AppData() :
CompStoreObj(), CompStoreObj(),
m_sessionId(0) m_sessionId(0)
{ {
qRegisterMetaType<AppData::NewModelAction>("AppData::NewModelAction");
qRegisterMetaType<AppData::UpdateCheckFreq>("AppData::UpdateCheckFreq");
qRegisterMetaType<AppData::SimuGenericKeysPos>("AppData::SimuGenericKeysPos");
CompStoreObj::addObjectMapping(propertyGroup(), this); CompStoreObj::addObjectMapping(propertyGroup(), this);
firstUse = !hasCurrentSettings(); firstUse = !hasCurrentSettings();
@@ -426,25 +455,35 @@ AppData::AppData() :
qWarning() << "Could not create settings backup path" << CPN_SETTINGS_BACKUP_DIR; qWarning() << "Could not create settings backup path" << CPN_SETTINGS_BACKUP_DIR;
// Configure the profiles // Configure the profiles
for (int i = 0; i < MAX_PROFILES; i++) for (int i = 0; i < MAX_PROFILES; i++) {
profile[i].setIndex(i); profile[i].setIndex(i);
for (int j = 0; j < MAX_COMPONENTS; j++) {
profile[i].compRelease[j].setIndexes(i, j);
}
}
// Configure the joysticks // Configure the joysticks
for (int i = 0; i < MAX_JS_AXES; i++) for (int i = 0; i < MAX_JS_AXES; i++)
joystick[i].setIndex(i); joystick[i].setIndex(i);
for (int i = 0; i < MAX_JS_BUTTONS; i++) for (int i = 0; i < MAX_JS_BUTTONS; i++)
jsButton[i].setIndex(i); jsButton[i].setIndex(i);
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
namedJS[i].setIndex(i); namedJS[i].setIndex(i);
for (int a = 0; a < MAX_JS_AXES; a += 1)
namedJS[i].joystick[a].setIndex(a, i); for (int j = 0; j < MAX_JS_AXES; j++)
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) namedJS[i].joystick[j].setIndexes(j, i);
namedJS[i].jsButton[b].setIndex(b, i);
for (int j = 0; j < MAX_JS_BUTTONS; j++)
namedJS[i].jsButton[j].setIndexes(j, i);
} }
// Configure the updates // Configure the updates
for (int i = 0; i < MAX_COMPONENTS; i++) { for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].setIndex(i); component[i].setIndex(i);
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) { for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].setIndexes(i, j); component[i].asset[j].setIndexes(i, j);
} }
@@ -454,29 +493,32 @@ AppData::AppData() :
void AppData::saveNamedJS(int i) void AppData::saveNamedJS(int i)
{ {
namedJS[i].jsName(currentProfile().jsName()); namedJS[i].jsName(currentProfile().jsName());
for (int a = 0; a < MAX_JS_AXES; a += 1) {
namedJS[i].joystick[a].stick_axe(joystick[a].stick_axe()); for (int j = 0; j < MAX_JS_AXES; j++) {
namedJS[i].joystick[a].stick_max(joystick[a].stick_max()); namedJS[i].joystick[j].stick_axe(joystick[j].stick_axe());
namedJS[i].joystick[a].stick_med(joystick[a].stick_med()); namedJS[i].joystick[j].stick_max(joystick[j].stick_max());
namedJS[i].joystick[a].stick_min(joystick[a].stick_min()); namedJS[i].joystick[j].stick_med(joystick[j].stick_med());
namedJS[i].joystick[a].stick_min(joystick[a].stick_min()); namedJS[i].joystick[j].stick_min(joystick[j].stick_min());
namedJS[i].joystick[j].stick_inv(joystick[j].stick_inv());
} }
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) {
namedJS[i].jsButton[b].button_idx(jsButton[b].button_idx()); for (int j = 0; j < MAX_JS_BUTTONS; j++) {
namedJS[i].jsButton[j].button_idx(jsButton[j].button_idx());
} }
namedJS[i].jsLastUsed(time(NULL)); namedJS[i].jsLastUsed(time(NULL));
} }
void AppData::saveNamedJS() void AppData::saveNamedJS()
{ {
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i += 1) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
if (namedJS[i].jsName() == currentProfile().jsName()) { if (namedJS[i].jsName() == currentProfile().jsName()) {
saveNamedJS(i); saveNamedJS(i);
return; return;
} }
} }
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i += 1) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
if (namedJS[i].jsName() == "") { if (namedJS[i].jsName() == "") {
saveNamedJS(i); saveNamedJS(i);
return; return;
@@ -485,7 +527,7 @@ void AppData::saveNamedJS()
unsigned int oldestTime = namedJS[0].jsLastUsed(); unsigned int oldestTime = namedJS[0].jsLastUsed();
int oldestN = 0; int oldestN = 0;
for (int i = 1; i < MAX_NAMED_JOYSTICKS; i += 1) { for (int i = 1; i < MAX_NAMED_JOYSTICKS; i++) {
if (namedJS[i].jsLastUsed() < oldestTime) { if (namedJS[i].jsLastUsed() < oldestTime) {
oldestTime = namedJS[i].jsLastUsed(); oldestTime = namedJS[i].jsLastUsed();
oldestN = i; oldestN = i;
@@ -496,22 +538,24 @@ void AppData::saveNamedJS()
void AppData::loadNamedJS(int i) void AppData::loadNamedJS(int i)
{ {
for (int a = 0; a < MAX_JS_AXES; a += 1) { for (int j = 0; j < MAX_JS_AXES; j++) {
joystick[a].stick_axe(namedJS[i].joystick[a].stick_axe()); joystick[j].stick_axe(namedJS[i].joystick[j].stick_axe());
joystick[a].stick_max(namedJS[i].joystick[a].stick_max()); joystick[j].stick_max(namedJS[i].joystick[j].stick_max());
joystick[a].stick_med(namedJS[i].joystick[a].stick_med()); joystick[j].stick_med(namedJS[i].joystick[j].stick_med());
joystick[a].stick_min(namedJS[i].joystick[a].stick_min()); joystick[j].stick_min(namedJS[i].joystick[j].stick_min());
joystick[a].stick_min(namedJS[i].joystick[a].stick_min()); joystick[j].stick_inv(namedJS[i].joystick[j].stick_inv());
} }
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) {
jsButton[b].button_idx(namedJS[i].jsButton[b].button_idx()); for (int j = 0; j < MAX_JS_BUTTONS; j++) {
jsButton[j].button_idx(namedJS[i].jsButton[j].button_idx());
} }
namedJS[i].jsLastUsed(time(NULL)); namedJS[i].jsLastUsed(time(NULL));
} }
void AppData::loadNamedJS() void AppData::loadNamedJS()
{ {
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i += 1) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
if (namedJS[i].jsName() == currentProfile().jsName()) { if (namedJS[i].jsName() == currentProfile().jsName()) {
loadNamedJS(i); loadNamedJS(i);
return; return;
@@ -527,7 +571,8 @@ static QString fmtHex(quint32 num)
void AppData::init() void AppData::init()
{ {
qInfo().noquote() << "Settings init with" << m_settings.organizationName() << m_settings.applicationName() qInfo().noquote() << "Settings init with" << m_settings.organizationName() << m_settings.applicationName()
<< "Saved version:" << fmtHex(m_settings.value(SETTINGS_VERSION_KEY).toUInt()) << "Current version:" << fmtHex(CPN_SETTINGS_VERSION); << "Saved version:" << settingsVersionToDisplay(m_settings.value(SETTINGS_VERSION_KEY).toUInt())
<< "Current version:" << settingsVersionToDisplay(CPN_SETTINGS_VERSION);
// This connection doesn't work in the constructor because AppData is created before QApplication. Globals suck like that. Compensate by using Qt::UniqueConnection because init() may be called multiple times within app lifetime. // This connection doesn't work in the constructor because AppData is created before QApplication. Globals suck like that. Compensate by using Qt::UniqueConnection because init() may be called multiple times within app lifetime.
connect(this, &AppData::idChanged, this, static_cast<void (AppData::*)(int)>(&AppData::sessionId), Qt::UniqueConnection); connect(this, &AppData::idChanged, this, static_cast<void (AppData::*)(int)>(&AppData::sessionId), Qt::UniqueConnection);
@@ -543,23 +588,35 @@ void AppData::initAll()
// Initialize all variables. Use default values if no saved settings. // Initialize all variables. Use default values if no saved settings.
CompStoreObj::initAllProperties(this); CompStoreObj::initAllProperties(this);
// Initialize the profiles // Initialize the profiles
for (int i = 0; i < MAX_PROFILES; i++) for (int i = 0; i < MAX_PROFILES; i++) {
profile[i].init(); profile[i].init();
for (int j = 0; j < MAX_COMPONENTS; j++) {
profile[i].compRelease[j].init();
}
}
// Initialize the joysticks // Initialize the joysticks
for (int i = 0; i < MAX_JS_AXES; i++) for (int i = 0; i < MAX_JS_AXES; i++)
joystick[i].init(); joystick[i].init();
for (int i = 0; i < MAX_JS_BUTTONS; i++) for (int i = 0; i < MAX_JS_BUTTONS; i++)
jsButton[i].init(); jsButton[i].init();
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
namedJS[i].init(); namedJS[i].init();
for (int a = 0; a < MAX_JS_AXES; a += 1)
namedJS[i].joystick[a].init(); for (int j = 0; j < MAX_JS_AXES; j++)
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) namedJS[i].joystick[j].init();
namedJS[i].jsButton[b].init();
for (int j = 0; j < MAX_JS_BUTTONS; j++)
namedJS[i].jsButton[j].init();
} }
// Initialize the updates // Initialize the updates
for (int i = 0; i < MAX_COMPONENTS; i++) { for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].init(); component[i].init();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) { for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].init(); component[i].asset[j].init();
} }
@@ -570,46 +627,73 @@ void AppData::resetAllSettings()
{ {
resetAll(); resetAll();
fwRev.resetAll(); fwRev.resetAll();
for (int i = 0; i < MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++) {
profile[i].resetAll(); profile[i].resetAll();
for (int j = 0; j < MAX_COMPONENTS; j++) {
profile[i].compRelease[j].resetAll();
}
}
for (int i = 0; i < MAX_JS_AXES; i++) for (int i = 0; i < MAX_JS_AXES; i++)
joystick[i].resetAll(); joystick[i].resetAll();
for (int i = 0; i < MAX_JS_BUTTONS; i++) for (int i = 0; i < MAX_JS_BUTTONS; i++)
jsButton[i].resetAll(); jsButton[i].resetAll();
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
namedJS[i].resetAll(); namedJS[i].resetAll();
for (int a = 0; a < MAX_JS_AXES; a += 1)
namedJS[i].joystick[a].resetAll(); for (int j = 0; j < MAX_JS_AXES; j++)
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) namedJS[i].joystick[j].resetAll();
namedJS[i].jsButton[b].resetAll();
for (int j = 0; j < MAX_JS_BUTTONS; j++)
namedJS[i].jsButton[j].resetAll();
} }
for (int i = 0; i < MAX_COMPONENTS; i++) { for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].resetAll(); component[i].resetAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) { for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].resetAll(); component[i].asset[j].resetAll();
} }
} }
firstUse = true; firstUse = true;
} }
void AppData::storeAllSettings() void AppData::storeAllSettings()
{ {
storeAll(); storeAll();
for (int i = 0; i < MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++) {
profile[i].storeAll(); profile[i].storeAll();
for (int j = 0; j < MAX_COMPONENTS; j++) {
profile[i].compRelease[j].storeAll();
}
}
for (int i = 0; i < MAX_JS_AXES; i++) for (int i = 0; i < MAX_JS_AXES; i++)
joystick[i].storeAll(); joystick[i].storeAll();
for (int i = 0; i < MAX_JS_BUTTONS; i++) for (int i = 0; i < MAX_JS_BUTTONS; i++)
jsButton[i].storeAll(); jsButton[i].storeAll();
for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) { for (int i = 0; i < MAX_NAMED_JOYSTICKS; i++) {
namedJS[i].storeAll(); namedJS[i].storeAll();
for (int a = 0; a < MAX_JS_AXES; a += 1)
namedJS[i].joystick[a].storeAll(); for (int j = 0; j < MAX_JS_AXES; j++)
for (int b = 0; b < MAX_JS_BUTTONS; b += 1) namedJS[i].joystick[j].storeAll();
namedJS[i].jsButton[b].storeAll();
for (int j = 0; j < MAX_JS_BUTTONS; j++)
namedJS[i].jsButton[j].storeAll();
} }
for (int i = 0; i < MAX_COMPONENTS; i++) { for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].storeAll(); component[i].storeAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) for (int j = 0; j < MAX_COMPONENT_ASSETS; j++)
component[i].asset[j].storeAll(); component[i].asset[j].storeAll();
} }
@@ -647,10 +731,12 @@ const Profile & AppData::getProfile(int index) const
QMap<int, QString> AppData::getActiveProfiles() const QMap<int, QString> AppData::getActiveProfiles() const
{ {
QMap<int, QString> active; QMap<int, QString> active;
for (int i=0; i<MAX_PROFILES; i++) { for (int i=0; i<MAX_PROFILES; i++) {
if (g.profile[i].existsOnDisk()) if (g.profile[i].existsOnDisk())
active.insert(i, g.profile[i].name()); active.insert(i, g.profile[i].name());
} }
return active; return active;
} }
@@ -658,9 +744,11 @@ void AppData::moveCurrentProfileToTop()
{ {
if (g.sortProfiles() && m_sessionId > 0) { if (g.sortProfiles() && m_sessionId > 0) {
Profile tmpProfile(g.profile[m_sessionId]); Profile tmpProfile(g.profile[m_sessionId]);
for (int i = m_sessionId; i > 0; i -= 1) {
for (int i = m_sessionId; i > 0; i--) {
g.profile[i] = g.profile[i - 1]; g.profile[i] = g.profile[i - 1];
} }
g.profile[0] = tmpProfile; g.profile[0] = tmpProfile;
id(0); id(0);
} }
@@ -669,10 +757,14 @@ void AppData::moveCurrentProfileToTop()
void AppData::convertSettings(QSettings & settings) void AppData::convertSettings(QSettings & settings)
{ {
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt(); quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
if (savedVer == CPN_SETTINGS_VERSION) if (savedVer == CPN_SETTINGS_VERSION)
return; return;
if (savedVer > CPN_SETTINGS_VERSION) { if (savedVer > CPN_SETTINGS_VERSION) {
qWarning().noquote() << "Saved settings version is newer than current, skipping conversions. Saved:" << fmtHex(savedVer) << "Current:" << fmtHex(CPN_SETTINGS_VERSION); qWarning().noquote() << "Saved settings version is newer than current, skipping conversions. Saved:"
<< settingsVersionToDisplay(savedVer) << "Current:"
<< settingsVersionToDisplay(CPN_SETTINGS_VERSION);
return; return;
} }
@@ -683,8 +775,9 @@ void AppData::convertSettings(QSettings & settings)
const bool removeUnused = (savedMajMin < currMajMin); const bool removeUnused = (savedMajMin < currMajMin);
qInfo().noquote().nospace() << "Converting settings " << settings.applicationName() qInfo().noquote().nospace() << "Converting settings " << settings.applicationName()
<< " from v" << fmtHex(savedVer) << " (" << fmtHex(savedMajMin) << ") to v" << " from " << settingsVersionToDisplay(savedVer)
<< fmtHex(CPN_SETTINGS_VERSION) << " (" << fmtHex(currMajMin) << "). Removing unused: " << removeUnused; << " to " << settingsVersionToDisplay(CPN_SETTINGS_VERSION)
<< ". Removing unused: " << removeUnused;
// firmwares renamed from opentx-* to edgetx-* at 2.6 // firmwares renamed from opentx-* to edgetx-* at 2.6
if (savedMajMin <= 0x207) { // Note: change merged post 2.6 rc 1 and version bumped to 2.7 the Nightly users also require upgrade if (savedMajMin <= 0x207) { // Note: change merged post 2.6 rc 1 and version bumped to 2.7 the Nightly users also require upgrade
@@ -721,11 +814,133 @@ void AppData::convertSettings(QSettings & settings)
} }
if (savedMajMin < 0x300) { if (savedMajMin < 0x300) {
// 3.0 CloudBuild copy filter changed to cater for uf2 // CloudBuild copy filter changed to cater for uf2
qInfo().noquote() << "Deleting CloudBuild settings to force refresh"; qInfo().noquote() << "Deleting CloudBuild settings to force refresh";
static const QString path = QStringLiteral("Components/component6"); QString path = QStringLiteral("Components/component6");
if (settings.contains(path)) if (settings.contains(path))
settings.remove(path); settings.remove(path);
// Joystick settings paths changed to fix export issue
qInfo().noquote() << "Reorganising joystick settings";
/*
Old structure TODO THIS IS NOT CORRECT SO FIX IT
-------------
JsCalibration
|_<n>
|_<data>
JsButton
|_<n>
|_<data>
NamedJSData
|_<n>
|_<data>
|_JsCalibration
|_<n>
|_<data>
|_JsButton
|_<n>
|_<data>
New structure
-------------
JsCalibration
|_stick<n>
|_<data>
JsButtons
|_button<n>
|_<data>
NamedJsData
|_name<n>
|_<data>
|_stick<n>
|_<data>
|_button<n>
|_<data>
*/
QString oldpath = "JsCalibration/%1/%2";
QString newpath = "JsCalibration/stick%1/%2";
QStringList keys = { "stick_axe", "stick_min", "stick_med", "stick_max", "stick_inv" };
for (int i = 0; i < MAX_JS_AXES; i++) {
for (int k = 0; k < keys.size(); k++) {
const QString opath = oldpath.arg(i).arg(keys.at(k));
const QString npath = newpath.arg(i).arg(keys.at(k));
if (settings.contains(opath)) {
settings.setValue(npath, settings.value(opath));
settings.remove(opath);
qInfo().noquote() << "Moved " << opath << " to " << npath;
}
}
}
oldpath = "JsButton/%1/%2";
newpath = "JsButtons/button%1/%2";
keys = { "button_idx" };
for (int i = 0; i < MAX_JS_BUTTONS; i++) {
for (int k = 0; k < keys.size(); k++) {
const QString opath = oldpath.arg(i).arg(keys.at(k));
const QString npath = newpath.arg(i).arg(keys.at(k));
if (settings.contains(opath)) {
settings.setValue(npath, settings.value(opath));
settings.remove(opath);
qInfo().noquote() << "Moved " << opath << " to " << npath;
}
}
}
for (int j = 0; j < MAX_NAMED_JOYSTICKS; j++) {
oldpath = "NamedJSData/%1/%2";
newpath = "NamedJSData/name%1/%2";
keys = { "jsName", "jsLastUsed" };
for (int k = 0; k < keys.size(); k++) {
const QString opath = oldpath.arg(j).arg(keys.at(k));
const QString npath = newpath.arg(j).arg(keys.at(k));
if (settings.contains(opath)) {
settings.setValue(npath, settings.value(opath));
settings.remove(opath);
qInfo().noquote() << "Moved " << opath << " to " << npath;
}
}
oldpath = "NamedJSData/%1/JsCalibration/%2/%3";
newpath = "NamedJSData/name%1/stick%2/%3";
keys = { "stick_axe", "stick_min", "stick_med", "stick_max", "stick_inv" };
for (int i = 0; i < MAX_JS_AXES; i++) {
for (int k = 0; k < keys.size(); k++) {
const QString opath = oldpath.arg(j).arg(i).arg(keys.at(k));
const QString npath = newpath.arg(j).arg(i).arg(keys.at(k));
if (settings.contains(opath)) {
settings.setValue(npath, settings.value(opath));
settings.remove(opath);
qInfo().noquote() << "Moved " << opath << " to " << npath;
}
}
}
oldpath = "NamedJSData/%1/JsButton/%2/%3";
newpath = "NamedJSData/name%1/button%2/%3";
keys = { "button_idx" };
for (int i = 0; i < MAX_JS_BUTTONS; i++) {
for (int k = 0; k < keys.size(); k++) {
const QString opath = oldpath.arg(j).arg(i).arg(keys.at(k));
const QString npath = newpath.arg(j).arg(i).arg(keys.at(k));
if (settings.contains(opath)) {
settings.setValue(npath, settings.value(opath));
settings.remove(opath);
qInfo().noquote() << "Moved " << opath << " to " << npath;
}
}
}
}
} }
if (removeUnused) if (removeUnused)
@@ -738,25 +953,33 @@ void AppData::convertSettings(QSettings & settings)
void AppData::clearUnusedSettings(QSettings & settings) void AppData::clearUnusedSettings(QSettings & settings)
{ {
// Go through and clean up anything that doesn't exist or is set to default value. // Go through and clean up anything that doesn't exist or is set to default value.
qInfo().noquote() << "Tidy settings by removing redundant and default settings";
foreach (const QString & key, settings.allKeys()) { foreach (const QString & key, settings.allKeys()) {
if (key == ".") // special Windows registry key, don't delete it if (key == ".") // special Windows registry key, don't delete it
continue; continue;
const QVariant newVal = settings.value(key); const QVariant newVal = settings.value(key);
// Remove key if property does not exist or is the default value. // Remove key if property does not exist or is the default value.
if (!newVal.isValid() || !CompStoreObj::propertyPathIsValidNonDefault(key, newVal)) if (!newVal.isValid() || !CompStoreObj::propertyPathIsValidNonDefault(key, newVal)) {
settings.remove(key); settings.remove(key);
qInfo().noquote() << "Removed key " << key;
}
} }
} }
bool AppData::findPreviousVersionSettings(QString * version) const bool AppData::findPreviousVersionSettings(QString * version) const
{ {
int vmaj = VERSION_MAJOR; // make sure we do not try to import from ourselves otherwise settings WILL get corrupted
int vmin = VERSION_MINOR - 1; // make sure we do not try to import from ourselves otherwise settings WILL get corrupted const int vmax = 30; //abitary maximum minor version
int vmaj = VERSION_MINOR > 1 ? VERSION_MAJOR : VERSION_MAJOR - 1;
int vmin = VERSION_MINOR > 1 ? VERSION_MINOR - 1 : vmax;
// qDebug() << "Search start version:" << vmaj << vmin;
for (;(vmaj << 8 | vmin) >= (2 << 8 | 4);) { // 2.4 earliest EdgeTX version for (;(vmaj << 8 | vmin) >= (2 << 8 | 4);) { // 2.4 earliest EdgeTX version
const QString ver = QString("%1.%2").arg(vmaj).arg(vmin); const QString ver = QString("%1.%2").arg(vmaj).arg(vmin);
const QString prod = QString("Companion %1").arg(ver); const QString prod = QString("Companion %1").arg(ver);
qDebug() << "Searching for previous version" << ver; // qDebug() << "Searching for previous version" << ver;
QSettings settings(COMPANY, prod); QSettings settings(COMPANY, prod);
if (settings.contains(SETTINGS_VERSION_KEY)) { if (settings.contains(SETTINGS_VERSION_KEY)) {
*version = ver; *version = ver;
@@ -768,7 +991,7 @@ bool AppData::findPreviousVersionSettings(QString * version) const
--vmin; --vmin;
if (vmin < 0) { if (vmin < 0) {
vmin = 30; // abitary maximum minor version for earlier major versions vmin = vmax;
--vmaj; --vmaj;
} }
} }
@@ -829,14 +1052,17 @@ bool AppData::exportSettings(QSettings * toSettings, bool clearDestination)
return false; return false;
m_settings.sync(); m_settings.sync();
if (clearDestination) if (clearDestination)
toSettings->clear(); toSettings->clear();
foreach (const QString & key, m_settings.allKeys()) { foreach (const QString & key, m_settings.allKeys()) {
const QVariant newVal = m_settings.value(key); const QVariant newVal = m_settings.value(key);
qDebug() << key << newVal;
// Skip export if property does not exist or is the default value. // Skip export if property does not exist or is the default value.
if (newVal.isValid() && CompStoreObj::propertyPathIsValidNonDefault(key, newVal)) if (newVal.isValid() && CompStoreObj::propertyPathIsValidNonDefault(key, newVal))
toSettings->setValue(key, newVal); toSettings->setValue(key, newVal);
//else qDebug() << "SKIPPING:" << key << newVal; else qDebug() << "SKIPPING:" << key << newVal;
} }
// Write the version and timestamp to export file -- they will NOT be imported, but may be useful for converting future imports. // Write the version and timestamp to export file -- they will NOT be imported, but may be useful for converting future imports.
toSettings->setValue(SETTINGS_VERSION_KEY, m_settings.value(SETTINGS_VERSION_KEY)); toSettings->setValue(SETTINGS_VERSION_KEY, m_settings.value(SETTINGS_VERSION_KEY));
@@ -853,7 +1079,9 @@ bool AppData::exportSettingsToFile(const QString & expFile, QString & resultMsg)
resultMsg = tr("Application Settings have been saved to\n %1").arg(expFile); resultMsg = tr("Application Settings have been saved to\n %1").arg(expFile);
return true; return true;
} }
resultMsg = tr("Could not save Application Settings to file \"%1\"").arg(expFile) % " "; resultMsg = tr("Could not save Application Settings to file \"%1\"").arg(expFile) % " ";
if (toSettings.status() == QSettings::AccessError) if (toSettings.status() == QSettings::AccessError)
resultMsg.append(tr("because the file could not be saved (check access permissions).")); resultMsg.append(tr("because the file could not be saved (check access permissions)."));
else else
@@ -865,6 +1093,7 @@ ComponentData & AppData::getComponent(int index)
{ {
if (index > -1 && index < MAX_COMPONENTS) if (index > -1 && index < MAX_COMPONENTS)
return component[index]; return component[index];
return component[0]; return component[0];
} }
@@ -872,6 +1101,7 @@ const ComponentData & AppData::getComponent(int index) const
{ {
if (index > -1 && index < MAX_COMPONENTS) if (index > -1 && index < MAX_COMPONENTS)
return component[index]; return component[index];
return component[0]; return component[0];
} }
@@ -888,7 +1118,23 @@ void AppData::resetUpdatesSettings()
for (int i = 0; i < MAX_COMPONENTS; i++) { for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].resetAll(); component[i].resetAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) for (int j = 0; j < MAX_COMPONENT_ASSETS; j++)
component[i].asset[j].resetAll(); component[i].asset[j].resetAll();
} }
for (int i = 0; i < MAX_PROFILES; i++) {
for (int j = 0; j < MAX_COMPONENTS; j++) {
profile[i].compRelease[j].resetAll();
}
}
}
const QString AppData::settingsVersionToDisplay(const unsigned int ver)
{
return QString("v%1.%2.%3.%4")
.arg(ver >> 24)
.arg((ver >> 16) & ((1U << 8) - 1))
.arg((ver >> 8) & ((1U << 8) - 1))
.arg(ver & ((1U << 8) - 1));
} }
+54 -25
View File
@@ -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. //! 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() //! \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 2 // Note: bumped for fix during 2.8 RCs #define CPN_SETTINGS_REVISION 3 // Note: bumped for changes during 3.0 dev
//! CPN_SETTINGS_VERSION is used for settings data version tracking. //! CPN_SETTINGS_VERSION is used for settings data version tracking.
#define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION) #define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION)
@@ -345,9 +345,9 @@ class JStickData: public CompStoreObj
protected: protected:
explicit JStickData(); explicit JStickData();
void setIndex(int idx) { index = idx; } void setIndex(int idx) { index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("JsCalibration"); } inline QString propertyGroup() const override { return QStringLiteral("JsCalibration"); }
inline QString settingsPath() const override { return QString("%1/%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/stick%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
friend class NamedJSData; friend class NamedJSData;
@@ -375,9 +375,9 @@ class JButtonData: public CompStoreObj
protected: protected:
explicit JButtonData(); explicit JButtonData();
void setIndex(int idx) { index = idx; } void setIndex(int idx) { index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("JsButton"); } inline QString propertyGroup() const override { return QStringLiteral("JsButtons"); }
inline QString settingsPath() const override { return QString("%1/%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/button%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
friend class NamedJSData; friend class NamedJSData;
@@ -396,9 +396,9 @@ class NamedJStickData: public CompStoreObj
protected: protected:
explicit NamedJStickData(); explicit NamedJStickData();
void setIndex(int idx, int nmIdx) { index = idx; namedIdx = nmIdx; } void setIndexes(int idx, int nmIdx) { index = idx; namedIdx = nmIdx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("NamedJSData/%1").arg(namedIdx); } inline QString propertyGroup() const override { return QStringLiteral("NamedJSData/name%1").arg(namedIdx); }
inline QString settingsPath() const override { return QString("%1/JsCalibration/%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/stick%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
friend class NamedJSData; friend class NamedJSData;
@@ -422,9 +422,9 @@ class NamedJButtonData: public CompStoreObj
protected: protected:
explicit NamedJButtonData(); explicit NamedJButtonData();
void setIndex(int idx, int nmIdx) { index = idx; namedIdx = nmIdx; } void setIndexes(int idx, int nmIdx) { index = idx; namedIdx = nmIdx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("NamedJSData/%1").arg(namedIdx); } inline QString propertyGroup() const override { return QStringLiteral("NamedJSData/name%1").arg(namedIdx); }
inline QString settingsPath() const override { return QString("%1/JsButton/%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/button%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
friend class NamedJSData; friend class NamedJSData;
@@ -443,9 +443,9 @@ class NamedJSData: public CompStoreObj
protected: protected:
explicit NamedJSData(); explicit NamedJSData();
void setIndex(int idx) { index = idx; } void setIndex(int idx) { index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("NamedJSData"); } inline QString propertyGroup() const override { return QStringLiteral("NamedJSData"); }
inline QString settingsPath() const override { return QString("%1/%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/name%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
public: public:
@@ -459,6 +459,36 @@ class NamedJSData: public CompStoreObj
int index; int index;
}; };
//! \brief ComponentReleaseData class stores release properties related to each updateable component.
class ComponentReleaseData: public CompStoreObj
{
Q_OBJECT
public:
ComponentReleaseData & operator=(const ComponentReleaseData & rhs);
protected:
explicit ComponentReleaseData();
void setIndexes(int profileIdx, int idx)
{
profileIndex = profileIdx;
index = idx;
CompStoreObj::addObjectMapping(propertyGroup(), this);
}
inline QString propertyGroup() const override { return QString("Profiles/profile%1").arg(profileIndex); }
inline QString settingsPath() const override { return QString("%1/component%2/").arg(propertyGroup()).arg(index); }
friend class Profile;
friend class AppData;
private:
PROPERTYSTRD( date, "")
PROPERTY (bool, prerelease, false)
PROPERTYSTRD( release, "unknown")
PROPERTY (int, releaseId, 0)
PROPERTYSTRD( version, "0")
int profileIndex;
int index;
};
//! \brief Profile class stores properties related to each Radio Profile. //! \brief Profile class stores properties related to each Radio Profile.
//! \todo TODO: Remove or refactor stored radio settings system (#4583) //! \todo TODO: Remove or refactor stored radio settings system (#4583)
@@ -468,6 +498,10 @@ class Profile: public CompStoreObj
public: public:
Profile & operator=(const Profile & rhs); Profile & operator=(const Profile & rhs);
QString getVariantFromType() const { return fwType().section("-", 1, 1); } QString getVariantFromType() const { return fwType().section("-", 1, 1); }
ComponentReleaseData & getCompRelease(int index);
const ComponentReleaseData & getCompRelease(int index) const;
ComponentReleaseData compRelease[MAX_COMPONENTS];
public slots: public slots:
bool existsOnDisk(); bool existsOnDisk();
@@ -475,7 +509,8 @@ class Profile: public CompStoreObj
protected: protected:
explicit Profile(); explicit Profile();
explicit Profile(const Profile & rhs); explicit Profile(const Profile & rhs);
void setIndex(int idx) { index = idx; }
void setIndex(int idx) { index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("Profiles"); } inline QString propertyGroup() const override { return QStringLiteral("Profiles"); }
inline QString settingsPath() const override { return QString("%1/profile%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/profile%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
@@ -529,9 +564,7 @@ class ComponentAssetData: public CompStoreObj
protected: protected:
explicit ComponentAssetData(); explicit ComponentAssetData();
void setCompIndex(int idx) { compIndex = idx; } void setIndexes(int compIdx, int idx) { compIndex = compIdx; index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
void setIndex(int idx) { index = idx; }
void setIndexes(int compIdx, int idx) { compIndex = compIdx; index = idx; }
inline QString propertyGroup() const override { return QString("Components/component%1").arg(compIndex); } inline QString propertyGroup() const override { return QString("Components/component%1").arg(compIndex); }
inline QString settingsPath() const override { return QString("%1/asset%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/asset%2/").arg(propertyGroup()).arg(index); }
friend class ComponentData; friend class ComponentData;
@@ -566,7 +599,6 @@ class ComponentData: public CompStoreObj
}; };
Q_ENUM(ReleaseChannel) Q_ENUM(ReleaseChannel)
void releaseClear();
static QStringList releaseChannelsList() { return { tr("Releases"), tr("Pre-release"), tr("Nightly") } ; } static QStringList releaseChannelsList() { return { tr("Releases"), tr("Pre-release"), tr("Nightly") } ; }
inline ReleaseChannel boundedReleaseChannel() const { inline ReleaseChannel boundedReleaseChannel() const {
@@ -583,7 +615,7 @@ class ComponentData: public CompStoreObj
protected: protected:
explicit ComponentData(); explicit ComponentData();
void setIndex(int idx) { index = idx; } void setIndex(int idx) { index = idx; CompStoreObj::addObjectMapping(propertyGroup(), this);}
inline QString propertyGroup() const override { return QStringLiteral("Components"); } inline QString propertyGroup() const override { return QStringLiteral("Components"); }
inline QString settingsPath() const override { return QString("%1/component%2/").arg(propertyGroup()).arg(index); } inline QString settingsPath() const override { return QString("%1/component%2/").arg(propertyGroup()).arg(index); }
friend class AppData; friend class AppData;
@@ -591,11 +623,6 @@ class ComponentData: public CompStoreObj
private: private:
PROPERTY (bool, checkForUpdate, false) PROPERTY (bool, checkForUpdate, false)
PROPERTY (ReleaseChannel, releaseChannel, RELEASE_CHANNEL_STABLE) PROPERTY (ReleaseChannel, releaseChannel, RELEASE_CHANNEL_STABLE)
PROPERTYSTRD( release, "unknown")
PROPERTY (int, releaseId, 0)
PROPERTY (bool, prerelease, false)
PROPERTYSTRD( version, "0")
PROPERTYSTRD( date, "")
int index; int index;
@@ -695,6 +722,8 @@ class AppData: public CompStoreObj
bool exportSettings(QSettings * toSettings, bool clearDestination = true); bool exportSettings(QSettings * toSettings, bool clearDestination = true);
bool exportSettingsToFile(const QString & expFile, QString & resultMsg); bool exportSettingsToFile(const QString & expFile, QString & resultMsg);
const QString settingsVersionToDisplay(const unsigned int ver);
Profile profile[MAX_PROFILES]; Profile profile[MAX_PROFILES];
JStickData joystick[MAX_JS_AXES]; JStickData joystick[MAX_JS_AXES];
JButtonData jsButton[MAX_JS_BUTTONS]; JButtonData jsButton[MAX_JS_BUTTONS];
+9 -11
View File
@@ -650,7 +650,7 @@ const bool UpdateInterface::isReleaseLatest()
// nightlies often have the same version so also check id // nightlies often have the same version so also check id
if (isVersionLatest(versionCurrent(), m_repo->releases()->version()) && if (isVersionLatest(versionCurrent(), m_repo->releases()->version()) &&
g.component[m_id].releaseId() == m_repo->releases()->id()) g.currentProfile().getCompRelease(m_id).releaseId() == m_repo->releases()->id())
return true; return true;
return false; return false;
@@ -719,10 +719,8 @@ void UpdateInterface::onStatusCancelled()
m_status->reportProgress(tr("Update cancelled by user"), QtWarningMsg); m_status->reportProgress(tr("Update cancelled by user"), QtWarningMsg);
emit stopping(); emit stopping();
if (m_eventLoop.isRunning()) { if (m_eventLoop.isRunning())
m_eventLoop.processEvents();
m_eventLoop.quit(); m_eventLoop.quit();
}
} }
UpdateParameters* const UpdateInterface::params() const UpdateParameters* const UpdateInterface::params() const
@@ -788,13 +786,13 @@ void UpdateInterface::radioProfileChanged()
void UpdateInterface::releaseClear() void UpdateInterface::releaseClear()
{ {
g.component[m_id].releaseClear(); g.currentProfile().getCompRelease(m_id).resetAll();
releaseCurrent(); releaseCurrent();
} }
const QString UpdateInterface::releaseCurrent() const QString UpdateInterface::releaseCurrent()
{ {
m_params->releaseCurrent = g.component[m_id].release(); m_params->releaseCurrent = g.currentProfile().getCompRelease(m_id).release();
return m_params->releaseCurrent; return m_params->releaseCurrent;
} }
@@ -809,10 +807,10 @@ const QStringList UpdateInterface::releaseList()
int UpdateInterface::releaseSettingsSave() int UpdateInterface::releaseSettingsSave()
{ {
m_status->reportProgress(tr("Save release settings"), QtDebugMsg); m_status->reportProgress(tr("Save release settings"), QtDebugMsg);
g.component[m_id].release(m_repo->releases()->name()); g.currentProfile().getCompRelease(m_id).release(m_repo->releases()->name());
g.component[m_id].version(m_repo->releases()->version()); g.currentProfile().getCompRelease(m_id).version(m_repo->releases()->version());
g.component[m_id].releaseId(m_repo->releases()->id()); g.currentProfile().getCompRelease(m_id).releaseId(m_repo->releases()->id());
g.component[m_id].date(m_repo->releases()->date()); g.currentProfile().getCompRelease(m_id).date(m_repo->releases()->date());
return true; return true;
} }
@@ -1277,7 +1275,7 @@ bool UpdateInterface::validateFolder(QString & fldr)
const QString UpdateInterface::versionCurrent() const QString UpdateInterface::versionCurrent()
{ {
return g.component[m_id].version(); return g.currentProfile().getCompRelease(m_id).version();
} }
// static // static
+4 -3
View File
@@ -315,7 +315,7 @@ void UpdateNetwork::onGetFinished(QNetworkReply * reply, DownloadDataType type)
} }
if (m_reply) { if (m_reply) {
delete m_reply; m_reply->deleteLater();
m_reply = nullptr; m_reply = nullptr;
} }
} }
@@ -330,7 +330,7 @@ void UpdateNetwork::onPostFinished()
} }
if (m_reply) { if (m_reply) {
delete m_reply; m_reply->deleteLater();
m_reply = nullptr; m_reply = nullptr;
} }
@@ -413,7 +413,8 @@ void UpdateNetwork::submitRequest(const QString & action, const QString & url, Q
void UpdateNetwork::cancelDownload() void UpdateNetwork::cancelDownload()
{ {
m_status->reportProgress(tr("Download cancelled"), QtWarningMsg); m_status->reportProgress(tr("Download cancelled"), QtWarningMsg);
m_reply->abort(); if (m_reply)
m_reply->abort();
} }
void UpdateNetwork::updateProgress() void UpdateNetwork::updateProgress()