feat(cpn): Enhancements to update component runtime options (#2324)

* enh(cpn): Save update component asset options and manage in app settings

* Add option to delete decompress folders independent of delete download folder

* Fix sdsync to point to last update folder

* Update options dlg to allow choosing release channel and saving settings as defaults

* Rename params

* Asset options dialog shared between settings and update run. Add to Save as defaults
This commit is contained in:
Neil Horne
2022-09-26 08:55:16 +10:00
committed by GitHub
parent 30c54b48c9
commit 3563e917c6
31 changed files with 1016 additions and 555 deletions
+94 -25
View File
@@ -19,6 +19,7 @@
*/
#include "appdata.h"
#include "updates/updateoptionsdialog.h"
#include <QDateTime>
#include <QDir>
@@ -289,6 +290,32 @@ void Profile::resetFwVariables()
}
// ** ComponentAssetData class********************
ComponentAssetData::ComponentAssetData() : CompStoreObj(), index(-1)
{
CompStoreObj::addObjectMapping(propertyGroup(), this);
}
// The default copy operator can not be used since the index variable would be destroyed
ComponentAssetData & ComponentAssetData::operator= (const ComponentAssetData & 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;
}
bool ComponentAssetData::existsOnDisk()
{
return (m_settings.contains(settingsPath() % "desc"));
}
// ** ComponentData class********************
ComponentData::ComponentData() : CompStoreObj(), index(-1)
@@ -318,11 +345,32 @@ bool ComponentData::existsOnDisk()
void ComponentData::clearRelease()
{
release(CompStoreObj::propertyDefaultValue(this, "release").toString());
id(CompStoreObj::propertyDefaultValue(this, "id").toInt());
prerelease(CompStoreObj::propertyDefaultValue(this, "prerelease").toBool());
date(CompStoreObj::propertyDefaultValue(this, "date").toString());
version(CompStoreObj::propertyDefaultValue(this, "version").toString());
releaseReset();
idReset();
prereleaseReset();
dateReset();
versionReset();
}
ComponentAssetData & ComponentData::getAsset(int index)
{
if (index > -1 && index < MAX_COMPONENT_ASSETS)
return asset[index];
return asset[0];
}
const ComponentAssetData & ComponentData::getAsset(int index) const
{
if (index > -1 && index < MAX_COMPONENT_ASSETS)
return asset[index];
return asset[0];
}
void ComponentData::initAllAssets()
{
for (int i = 0; i < MAX_COMPONENT_ASSETS; i++) {
asset[i].resetAll();
}
}
// ** AppData class********************
@@ -345,16 +393,20 @@ AppData::AppData() :
qWarning() << "Could not create settings backup path" << CPN_SETTINGS_BACKUP_DIR;
// Configure the profiles
for (int i=0; i<MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++)
profile[i].setIndex(i);
// Configure the joysticks
for (int i=0; i<MAX_JOYSTICKS; i++)
for (int i = 0; i < MAX_JOYSTICKS; i++)
joystick[i].setIndex(i);
// Configure the updates
for (int i=0; i<MAX_COMPONENTS; i++)
for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].setIndex(i);
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].setIndexes(i, j);
}
}
}
static QString fmtHex(quint32 num)
@@ -381,38 +433,49 @@ void AppData::initAll()
// Initialize all variables. Use default values if no saved settings.
CompStoreObj::initAllProperties(this);
// Initialize the profiles
for (int i=0; i<MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++)
profile[i].init();
// Initialize the joysticks
for (int i=0; i<MAX_JOYSTICKS; i++)
for (int i = 0; i < MAX_JOYSTICKS; i++)
joystick[i].init();
// Initialize the updatess
for (int i=0; i<MAX_COMPONENTS; i++)
for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].init();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].init();
}
}
}
void AppData::resetAllSettings()
{
resetAll();
fwRev.resetAll();
for (int i=0; i<MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++)
profile[i].resetAll();
for (int i=0; i<MAX_JOYSTICKS; i++)
for (int i = 0; i < MAX_JOYSTICKS; i++)
joystick[i].resetAll();
for (int i=0; i<MAX_COMPONENTS; i++)
for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].resetAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++) {
component[i].asset[j].resetAll();
}
}
firstUse = true;
}
void AppData::storeAllSettings()
{
storeAll();
for (int i=0; i<MAX_PROFILES; i++)
for (int i = 0; i < MAX_PROFILES; i++)
profile[i].storeAll();
for (int i=0; i<MAX_JOYSTICKS; i++)
for (int i = 0; i < MAX_JOYSTICKS; i++)
joystick[i].storeAll();
for (int i=0; i<MAX_COMPONENTS; i++)
for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].storeAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++)
component[i].asset[j].storeAll();
}
}
bool AppData::hasCurrentSettings() const
@@ -653,12 +716,18 @@ const ComponentData & AppData::getComponent(int index) const
void AppData::resetUpdatesSettings()
{
g.updateCheckFreqReset();
g.downloadDirReset();
g.decompressDirReset();
g.decompressDirUseDwnldReset();
g.updateDirReset();
g.updateDirUseSDReset();
g.updDelDownloadsReset();
g.updLogLevelReset();
updateCheckFreqReset();
downloadDirReset();
decompressDirReset();
decompressDirUseDwnldReset();
updateDirReset();
updateDirUseSDReset();
updDelDownloadsReset();
updLogLevelReset();
for (int i = 0; i < MAX_COMPONENTS; i++) {
component[i].resetAll();
for (int j = 0; j < MAX_COMPONENT_ASSETS; j++)
component[i].asset[j].resetAll();
}
}
+45 -2
View File
@@ -61,6 +61,7 @@
#define MAX_PROFILES 20
#define MAX_JOYSTICKS 8
#define MAX_COMPONENTS 10
#define MAX_COMPONENT_ASSETS 5
// It important that these function names are consistent everywhere.
#define PROP_FSIG_INIT_IMPL _init()
@@ -422,6 +423,41 @@ class Profile: public CompStoreObj
}
};
//! \brief ComponentAssetData class stores properties related to each updateable component.
class ComponentAssetData: public CompStoreObj
{
Q_OBJECT
public:
ComponentAssetData & operator=(const ComponentAssetData & rhs);
public slots:
bool existsOnDisk();
protected:
explicit ComponentAssetData();
void setCompIndex(int idx) { compIndex = idx; }
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 settingsPath() const override { return QString("%1/asset%2/").arg(propertyGroup()).arg(index); }
friend class ComponentData;
friend class AppData;
private:
PROPERTYSTR ( desc)
PROPERTY (int, processes, 0)
PROPERTY (int, flags, 0)
PROPERTY (int, filterType, 0)
PROPERTYSTR ( filter)
PROPERTY (int, maxExpected, 0)
PROPERTYSTR ( destSubDir)
PROPERTY (int, copyFilterType, 0)
PROPERTYSTR ( copyFilter)
int compIndex;
int index;
};
//! \brief ComponentData class stores properties related to each updateable component.
class ComponentData: public CompStoreObj
{
@@ -440,8 +476,13 @@ class ComponentData: public CompStoreObj
static QStringList releaseChannelsList() { return { tr("Releases"), tr("Pre-release"), tr("Nightly") } ; }
inline ReleaseChannel boundedReleaseChannel() const {
return qBound(RELEASE_CHANNEL_STABLE, releaseChannel(), RELEASE_CHANNEL_NIGHTLY);
}
return qBound(RELEASE_CHANNEL_STABLE, releaseChannel(), RELEASE_CHANNEL_NIGHTLY); }
ComponentAssetData asset[MAX_COMPONENT_ASSETS];
ComponentAssetData & getAsset(int index);
const ComponentAssetData & getAsset(int index) const;
void initAllAssets();
public slots:
bool existsOnDisk();
@@ -606,6 +647,8 @@ class AppData: public CompStoreObj
PROPERTY (bool, runAppInstaller, false)
PROPERTY (int, updLogLevel, 4)
PROPERTY (bool, updDelDownloads, false)
PROPERTY (bool, updDelDecompress, false)
PROPERTYSTR (lastUpdateDir)
PROPERTYSTR (locale)
PROPERTYSTR (gePath)