Rename settings and change the way post install deletes are configured and operate

This commit is contained in:
elecpower
2022-09-06 09:29:41 +10:00
committed by Peter Feerick
parent 97048a1544
commit 07f9d38237
13 changed files with 168 additions and 132 deletions
+2 -2
View File
@@ -62,9 +62,9 @@ UpdateCompanion::UpdateCompanion(QWidget * parent) :
bool UpdateCompanion::asyncInstall()
{
reportProgress(tr("Run application installer: %1").arg(g.runInstaller() ? tr("true") : tr("false")), QtDebugMsg);
reportProgress(tr("Run application installer: %1").arg(g.runAppInstaller() ? tr("true") : tr("false")), QtDebugMsg);
if (!g.runInstaller())
if (!g.runAppInstaller())
return true;
progressMessage(tr("Async install"));
+35 -24
View File
@@ -47,8 +47,8 @@ UpdateParameters::UpdateParameters(QWidget * parent) :
QWidget(parent)
{
data.flags = 0;
data.decompressUseDwnld = true;
data.updateUseSD = true;
data.decompressDirUseDwnld = true;
data.updateDirUseSD = true;
}
UpdateParameters& UpdateParameters::operator=(const UpdateParameters& source)
@@ -63,9 +63,9 @@ UpdateParameters& UpdateParameters::operator=(const UpdateParameters& source)
data.currentRelease = source.data.currentRelease;
data.updateRelease = source.data.updateRelease;
data.downloadDir = source.data.downloadDir;
data.decompressUseDwnld = source.data.decompressUseDwnld;
data.decompressDirUseDwnld = source.data.decompressDirUseDwnld;
data.decompressDir = source.data.decompressDir;
data.updateUseSD = source.data.updateUseSD;
data.updateDirUseSD = source.data.updateDirUseSD;
data.updateDir = source.data.updateDir;
while (!data.assets.isEmpty()) {
@@ -144,7 +144,6 @@ UpdateInterface::UpdateInterface(QWidget * parent) :
file(nullptr)
{
progress = nullptr;
logLevel = g.updateLogLevel();
settingsIdx = -1;
QNetworkProxyFactory::setUseSystemConfiguration(true);
@@ -257,12 +256,8 @@ QString UpdateInterface::updateFlagsToString(UpdateFlags val)
return "Preparation";
case UPDFLG_Download:
return "Download";
case UPDFLG_DelDownload:
return "Delete Download";
case UPDFLG_Decompress:
return "Decompress";
case UPDFLG_DelDecompress:
return "Delete Decompress";
case UPDFLG_CopyDest:
return "Copy to Destination";
case UPDFLG_CopyFiles:
@@ -273,6 +268,8 @@ QString UpdateInterface::updateFlagsToString(UpdateFlags val)
return "Housekeeping";
case UPDFLG_AsyncInstall:
return "Async Install";
case UPDFLG_DelDownloads:
return "Delete Downloads";
default:
return CPN_STR_UNKNOWN_ITEM;
}
@@ -345,9 +342,9 @@ void UpdateInterface::initParamFolders(UpdateParameters * params)
params->data.downloadDir = g.downloadDir().trimmed();
params->data.decompressUseDwnld = g.decompressUseDwnld();
params->data.decompressDirUseDwnld = g.decompressDirUseDwnld();
if (params->data.decompressUseDwnld)
if (params->data.decompressDirUseDwnld)
params->data.decompressDir = params->data.downloadDir;
else {
if (g.decompressDir().trimmed().isEmpty())
@@ -356,9 +353,9 @@ void UpdateInterface::initParamFolders(UpdateParameters * params)
params->data.decompressDir = g.decompressDir().trimmed();
}
params->data.updateUseSD = g.updateUseSD();
params->data.updateDirUseSD = g.updateDirUseSD();
if (params->data.updateUseSD && (!g.currentProfile().sdPath().trimmed().isEmpty()))
if (params->data.updateDirUseSD && (!g.currentProfile().sdPath().trimmed().isEmpty()))
params->data.updateDir = g.currentProfile().sdPath().trimmed();
else {
if (g.updateDir().trimmed().isEmpty())
@@ -371,9 +368,16 @@ void UpdateInterface::initParamFolders(UpdateParameters * params)
void UpdateInterface::resetRunEnvironment()
{
progress = nullptr;
logLevel = g.updLogLevel();
qDebug() << tr("Log level: %1").arg(logLevel);
*runParams = *dfltParams;
runParams->data.flags &= ~UPDFLG_Update;
if (g.updDelDownloads())
runParams->data.flags |= UpdateInterface::UPDFLG_DelDownloads;
else
runParams->data.flags &= ~UpdateInterface::UPDFLG_DelDownloads;
}
int UpdateInterface::getSettingsIdx()
@@ -542,17 +546,21 @@ bool UpdateInterface::setRunFolders()
{
QString fldr(releases->name());
fldr = fldr.replace("\"", "");
fldr = fldr.replace("'", "");
fldr = fldr.replace("\'", "");
fldr = fldr.replace(" ", "_");
fldr = fldr.replace("(", "_");
fldr = fldr.replace(")", "_");
fldr = fldr.replace("[", "_");
fldr = fldr.replace("]", "_");
downloadDir = runParams->data.downloadDir % "/" % name % "/" % fldr;
downloadDir = QString("%1/%2/%3").arg(runParams->data.downloadDir).arg(name).arg(fldr);
if (!checkCreateDirectory(downloadDir, UPDFLG_Download))
return false;
reportProgress(tr("Download directory: %1").arg(downloadDir), QtDebugMsg);
decompressDir = runParams->data.decompressDir % "/" % name % "/" % fldr;
decompressDir = QString("%1/%2/%3").arg(runParams->data.decompressDir).arg(name).arg(fldr);
if (!checkCreateDirectory(decompressDir, UPDFLG_Decompress))
return false;
@@ -849,7 +857,7 @@ void UpdateInterface::downloadBinaryToFile(const QString & url, const QString &
{
downloadSuccess = false;
QFileInfo f(downloadDir % "/" % QString("A%1/%2").arg(assets->id()).arg(filename));
QFileInfo f(QString("%1/A%2/%3").arg(downloadDir).arg(assets->id()).arg(filename));
progressMessage(tr("Downloading: %1").arg(filename));
reportProgress(tr("Download: %1").arg(filename), QtInfoMsg);
@@ -907,14 +915,14 @@ bool UpdateInterface::decompressAsset(int row)
if (filename.isEmpty())
return false;
QFileInfo f(downloadDir % "/" % QString("A%1/%2").arg(assets->id()).arg(assets->filename()));
QFileInfo f(QString("%1/A%2/%3").arg(downloadDir).arg(assets->id()).arg(assets->filename()));
if (!f.exists())
return false;
reportProgress(tr("Decompress: %1").arg(filename), QtInfoMsg);
decompressArchive(f.absoluteFilePath(), decompressDir % "/" % QString("A%1").arg(assets->id()));
decompressArchive(f.absoluteFilePath(), QString("%1/A%2").arg(decompressDir).arg(assets->id()));
return true;
}
@@ -971,7 +979,7 @@ bool UpdateInterface::copyStructure()
progress->setMaximum(100);
}
QDir srcPath(decompressDir % QString("/A%1/%2").arg(assets->id()).arg(QFileInfo(assets->filename()).completeBaseName()));
QDir srcPath(QString("%1/A%2/%3").arg(decompressDir).arg(assets->id()).arg(QFileInfo(assets->filename()).completeBaseName()));
if (!srcPath.exists()) {
reportProgress(tr("Decompressed file structure not found at %1").arg(QDir::toNativeSeparators(srcPath.path())), QtCriticalMsg);
@@ -1087,9 +1095,9 @@ bool UpdateInterface::copyFiles()
QString srcPath;
if (assets->flags() & UPDFLG_Decompress)
srcPath = decompressDir % QString("/A%1/%2").arg(assets->id()).arg(QFileInfo(assets->filename()).completeBaseName());
srcPath = QString("%1/A%2/%3").arg(decompressDir).arg(assets->id()).arg(QFileInfo(assets->filename()).completeBaseName());
else if (assets->flags() & UPDFLG_Download)
srcPath = downloadDir % QString("/A%1").arg(assets->id());
srcPath = QString("%1/A%2").arg(downloadDir).arg(assets->id());
else {
reportProgress(tr("Unable to determine source directory for asset %1").arg(assets->filename()), QtCriticalMsg);
return false;
@@ -1292,7 +1300,8 @@ bool UpdateInterface::housekeeping()
if (progress)
progress->setValue(++cnt);
if (runParams->data.assets.at(0).flags & UPDFLG_DelDownload) {
if (runParams->data.flags & UPDFLG_DelDownloads) {
reportProgress(tr("Delete download directory: %1").arg(downloadDir), QtDebugMsg);
QDir d(downloadDir);
if (!d.removeRecursively())
reportProgress(tr("Failed to delete downloads folder %1").arg(downloadDir), QtCriticalMsg);
@@ -1301,7 +1310,8 @@ bool UpdateInterface::housekeeping()
if (progress)
progress->setValue(++cnt);
if (!g.decompressUseDwnld() && (runParams->data.assets.at(0).flags & UPDFLG_DelDecompress)) {
if (!g.decompressDirUseDwnld() && (runParams->data.flags & UPDFLG_DelDownloads)) {
reportProgress(tr("Delete decompress directory: %1").arg(decompressDir), QtDebugMsg);
QDir d(decompressDir);
if (!d.removeRecursively())
reportProgress(tr("Failed to delete decompress folder %1").arg(decompressDir), QtCriticalMsg);
@@ -1320,6 +1330,7 @@ bool UpdateInterface::asyncInstall()
bool UpdateInterface::saveReleaseSettings()
{
reportProgress(tr("Save release settings"), QtDebugMsg);
g.component[settingsIdx].release(releases->name());
g.component[settingsIdx].version(releases->version());
g.component[settingsIdx].id(releases->id());
+9 -10
View File
@@ -63,9 +63,9 @@ class UpdateParameters : public QWidget
QString currentRelease;
QString updateRelease;
QString downloadDir;
bool decompressUseDwnld;
bool decompressDirUseDwnld;
QString decompressDir;
bool updateUseSD;
bool updateDirUseSD;
QString updateDir;
QVector<AssetParams> assets;
};
@@ -101,14 +101,13 @@ class UpdateInterface : public QWidget
UPDFLG_Locked = 1 << 2,
UPDFLG_Preparation = 1 << 3,
UPDFLG_Download = 1 << 4,
UPDFLG_DelDownload = 1 << 5,
UPDFLG_Decompress = 1 << 6,
UPDFLG_DelDecompress = 1 << 7,
UPDFLG_CopyDest = 1 << 8,
UPDFLG_CopyFiles = 1 << 9,
UPDFLG_CopyStructure = 1 << 10,
UPDFLG_Housekeeping = 1 << 11,
UPDFLG_AsyncInstall = 1 << 12,
UPDFLG_Decompress = 1 << 5,
UPDFLG_CopyDest = 1 << 6,
UPDFLG_CopyFiles = 1 << 7,
UPDFLG_CopyStructure = 1 << 8,
UPDFLG_Housekeeping = 1 << 9,
UPDFLG_AsyncInstall = 1 << 10,
UPDFLG_DelDownloads = 1 << 11,
UPDFLG_Common = UPDFLG_Preparation | UPDFLG_Download | UPDFLG_Decompress | UPDFLG_CopyDest | UPDFLG_Housekeeping,
};
Q_ENUM(UpdateFlags)
@@ -40,7 +40,7 @@ UpdateMultiProtocol::UpdateMultiProtocol(QWidget * parent) :
UpdateParameters::AssetParams &ap = dfltParams->addAsset();
ap.filterType = UpdateParameters::UFT_Expression;
ap.filter = "^mm-stm-serial-.*\\.bin$";
ap.flags = (dfltParams->data.flags | UPDFLG_CopyFiles) &~ (UPDFLG_Decompress | UPDFLG_DelDecompress);
ap.flags = (dfltParams->data.flags | UPDFLG_CopyFiles) &~ UPDFLG_Decompress;
ap.destSubDir = "FIRMWARE";
}
}
@@ -212,8 +212,6 @@ UpdateOptionsDialog::UpdateOptionsDialog(QWidget * parent, UpdateFactories * fac
chkDecompresses.at(i)->isChecked() ? ap.flags |= UpdateInterface::UPDFLG_Decompress :ap.flags &= ~UpdateInterface::UPDFLG_Decompress;
chkInstalls.at(i)->isChecked() ? ap.flags |= UpdateInterface::UPDFLG_AsyncInstall : ap.flags &= ~UpdateInterface::UPDFLG_AsyncInstall;
chkCopies.at(i)->isChecked() ? ap.flags |= UpdateInterface::UPDFLG_CopyDest : ap.flags &= ~UpdateInterface::UPDFLG_CopyDest;
ui->chkDelDownload->isChecked() ? ap.flags |= UpdateInterface::UPDFLG_DelDownload : ap.flags &= ~UpdateInterface::UPDFLG_DelDownload;
ui->chkDelDecompress->isChecked() ? ap.flags |= UpdateInterface::UPDFLG_DelDecompress : ap.flags &= ~UpdateInterface::UPDFLG_DelDecompress;
}
emit changed(idx);
@@ -251,9 +249,6 @@ void UpdateOptionsDialog::update()
leCopyFilters.at(i)->setText(ap.copyFilter);
leSubFolders.at(i)->setText(ap.destSubDir);
ui->chkDelDownload->setChecked(ap.flags & UpdateInterface::UPDFLG_DelDownload);
ui->chkDelDecompress->setChecked(ap.flags & UpdateInterface::UPDFLG_DelDecompress);
i++;
}
}
+2 -50
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>677</width>
<height>393</height>
<width>531</width>
<height>282</height>
</rect>
</property>
<property name="windowTitle">
@@ -70,54 +70,6 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpGeneral">
<property name="title">
<string>General</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="chkDelDownload">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete downloads</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDelDecompress">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete decompressions</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>286</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
+1 -1
View File
@@ -106,6 +106,6 @@ void Updates::checkRunSDSync()
if (!g.currentProfile().runSDSync())
return;
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Run SD Sync now?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Run SD card sync now?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
emit runSDSync();
}
+14 -8
View File
@@ -47,7 +47,7 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
ui->leDownloadDir->setText(g.downloadDir());
connect(ui->chkDecompressUseDwnld, &QCheckBox::stateChanged, [=](const int checked) {
connect(ui->chkDecompressDirUseDwnld, &QCheckBox::stateChanged, [=](const int checked) {
if (!checked) {
ui->leDecompressDir->setText(g.decompressDir());
ui->leDecompressDir->setEnabled(true);
@@ -60,10 +60,10 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
}
});
ui->chkDecompressUseDwnld->setChecked(!g.decompressUseDwnld());
ui->chkDecompressUseDwnld->setChecked(g.decompressUseDwnld());
ui->chkDecompressDirUseDwnld->setChecked(!g.decompressDirUseDwnld());
ui->chkDecompressDirUseDwnld->setChecked(g.decompressDirUseDwnld());
connect(ui->chkUpdateUseSD, &QCheckBox::stateChanged, [=](const int checked) {
connect(ui->chkUpdateDirUseSD, &QCheckBox::stateChanged, [=](const int checked) {
if (!checked) {
ui->leUpdateDir->setText(g.updateDir());
ui->leUpdateDir->setEnabled(true);
@@ -76,8 +76,8 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
}
});
ui->chkUpdateUseSD->setChecked(!g.updateUseSD());
ui->chkUpdateUseSD->setChecked(g.updateUseSD());
ui->chkUpdateDirUseSD->setChecked(!g.updateDirUseSD());
ui->chkUpdateDirUseSD->setChecked(g.updateDirUseSD());
connect(ui->btnDownloadSelect, &QPushButton::clicked, [=]() {
QString dirPath = QFileDialog::getExistingDirectory(this,tr("Select your download folder"), g.downloadDir());
@@ -174,6 +174,8 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
ui->grpComponents->setLayout(grid);
ui->chkDelDownloads->setChecked(g.updDelDownloads());
connect(ui->buttonBox, &QDialogButtonBox::accepted, [=]() {
QMapIterator<QString, int> it(factories->sortedComponentsList());
@@ -187,10 +189,14 @@ UpdatesDialog::UpdatesDialog(QWidget * parent, UpdateFactories * factories) :
UpdateParameters *runParams = factories->getRunParams(name);
runParams->data.flags |= UpdateInterface::UPDFLG_Update;
runParams->data.downloadDir = ui->leDownloadDir->text();
runParams->data.decompressUseDwnld = ui->chkDecompressUseDwnld->isChecked();
runParams->data.decompressDirUseDwnld = ui->chkDecompressDirUseDwnld->isChecked();
runParams->data.decompressDir = ui->leDecompressDir->text();
runParams->data.updateUseSD = ui->chkUpdateUseSD->isChecked();
runParams->data.updateDirUseSD = ui->chkUpdateDirUseSD->isChecked();
runParams->data.updateDir = ui->leUpdateDir->text();
if (ui->chkDelDownloads->isChecked())
runParams->data.flags |= UpdateInterface::UPDFLG_DelDownloads;
else
runParams->data.flags &= ~UpdateInterface::UPDFLG_DelDownloads;
}
}
}
+33 -4
View File
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>289</height>
<width>593</width>
<height>345</height>
</rect>
</property>
<property name="windowTitle">
@@ -47,7 +47,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkDecompressUseDwnld">
<widget class="QCheckBox" name="chkDecompressDirUseDwnld">
<property name="text">
<string>Create sub-folders in Download folder</string>
</property>
@@ -71,7 +71,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkUpdateUseSD">
<widget class="QCheckBox" name="chkUpdateDirUseSD">
<property name="text">
<string>Use Radio Profile SD structure</string>
</property>
@@ -130,6 +130,35 @@
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="grpOther">
<property name="title">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="chkDelDownloads">
<property name="text">
<string>Delete downloads after update</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">