Merge pull request #3762 from offhub/add007-4

Update NewBoxWizard.cpp
This commit is contained in:
DavidXanatos 2024-03-27 20:10:20 +01:00 committed by GitHub
commit 819ba064c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 8 deletions

View File

@ -176,6 +176,7 @@ SB_STATUS CNewBoxWizard::TryToCreateBox()
if(field("imagesProtection").toBool()) if(field("imagesProtection").toBool())
pBox->SetBool("ProtectHostImages", true); pBox->SetBool("ProtectHostImages", true);
// SharedTemplate
QString templateName = "SharedTemplate"; QString templateName = "SharedTemplate";
QString templateFullName = QString("Template_Local_%1").arg(templateName); QString templateFullName = QString("Template_Local_%1").arg(templateName);
QString templateSettings = theAPI->SbieIniGetEx(templateFullName, ""); QString templateSettings = theAPI->SbieIniGetEx(templateFullName, "");
@ -192,14 +193,31 @@ SB_STATUS CNewBoxWizard::TryToCreateBox()
} }
else if (field("sharedTemplate").toInt() == 2) { // append to config else if (field("sharedTemplate").toInt() == 2) { // append to config
QStringList templateSettingsLines = templateSettings.split("\r\n", Qt::SkipEmptyParts); QStringList templateSettingsLines = templateSettings.split("\r\n", Qt::SkipEmptyParts);
for (const QString& tLine : templateSettingsLines) { for (const QString& tLine : templateSettingsLines) {
if (!tLine.startsWith("Enabled=") && !tLine.startsWith("ConfigLevel=") && !tLine.startsWith("Tmpl.") && !tLine.startsWith("#")) { // skip lines if (tLine.startsWith("Enabled=") ||
tLine.startsWith("ConfigLevel=") ||
tLine.startsWith("Tmpl.") ||
tLine.startsWith("#")) {
continue; // Skip lines that start with these prefixes
}
QStringList tParts = tLine.split('='); QStringList tParts = tLine.split('=');
if (tParts.size() == 2) { if (tParts.size() != 2) {
continue; // Skip lines that don't have exactly one '=' character
}
QString tKey = tParts[0].trimmed(); QString tKey = tParts[0].trimmed();
QString tValue = tParts[1].trimmed(); QString tValue = tParts[1].trimmed();
pBox->AppendText(tKey, tValue);
if (tLine.endsWith("=y") ||
tLine.endsWith("=Y") ||
tLine.endsWith("=n") ||
tLine.endsWith("=N")) {
pBox->SetText(tKey, tValue);
} }
else {
pBox->AppendText(tKey, tValue);
} }
} }
} }