diff --git a/CHANGELOG.md b/CHANGELOG.md index 939ce763..895b2fc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - fixed issue with working directory for run menu entries - fixed inpoper global symlink in sandboxed namespace [#3112](https://github.com/sandboxie-plus/Sandboxie/issues/3112) - fixed 'Addon already installed!' error when clicking 'Show Stack Trace' [#3114](https://github.com/sandboxie-plus/Sandboxie/issues/3114) - +- fixed existing BoxNameTitle=process.exe,- removed when toggling other options [#3106](https://github.com/sandboxie-plus/Sandboxie/issues/3106) diff --git a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp index e946e559..e2b7d164 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp @@ -207,7 +207,7 @@ void COptionsWindow::CreateGeneral() void COptionsWindow::LoadGeneral() { - QString BoxNameTitle = m_pBox->GetText("BoxNameTitle", "n", false, true, false); + QString BoxNameTitle = ReadTextSafe("BoxNameTitle", "n"); ui.cmbBoxIndicator->setCurrentIndex(ui.cmbBoxIndicator->findData(BoxNameTitle.toLower())); QStringList BorderCfg = m_pBox->GetText("BorderColor").split(","); @@ -316,7 +316,11 @@ void COptionsWindow::LoadGeneral() void COptionsWindow::SaveGeneral() { - WriteText("BoxNameTitle", ui.cmbBoxIndicator->currentData().toString()); + QString BoxNameTitle = ui.cmbBoxIndicator->currentData().toString(); + if (BoxNameTitle == "n") + WriteTextSafe("BoxNameTitle", ""); + else + WriteTextSafe("BoxNameTitle", BoxNameTitle); QStringList BorderCfg; BorderCfg.append(QString("#%1%2%3").arg(m_BorderColor.blue(), 2, 16, QChar('0')).arg(m_BorderColor.green(), 2, 16, QChar('0')).arg(m_BorderColor.red(), 2, 16, QChar('0'))); @@ -399,7 +403,12 @@ void COptionsWindow::SaveGeneral() WriteGlobalCheck(ui.chkUseVolumeSerialNumbers, "UseVolumeSerialNumbers", false); } - WriteText("CopyLimitKb", ui.chkCopyLimit->isChecked() ? ui.txtCopyLimit->text() : "-1"); + int iLimit = ui.chkCopyLimit->isChecked() ? ui.txtCopyLimit->text().toInt() : -1; + if(iLimit != 80 * 1024) + WriteText("CopyLimitKb", QString::number(iLimit)); + else + m_pBox->DelValue("CopyLimitKb"); + WriteAdvancedCheck(ui.chkCopyPrompt, "PromptForFileMigration", "", "n"); WriteAdvancedCheck(ui.chkNoCopyWarn, "CopyLimitSilent", "", "y"); WriteAdvancedCheck(ui.chkDenyWrite, "CopyBlockDenyWrite", "y", ""); diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp index 4551859e..312e8630 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp @@ -879,6 +879,34 @@ void COptionsWindow::WriteTextList(const QString& Setting, const QStringList& Li throw Status; } +void COptionsWindow::WriteTextSafe(const QString& Name, const QString& Value) +{ + QStringList List = m_pBox->GetTextList(Name, false); + + // clear all non per process (name=program.exe,value) entries + for (int i = 0; i < List.count(); i++) { + if (!List[i].contains(",")) + List.removeAt(i--); + } + + // Prepand the global entry + if (!Value.isEmpty()) List.append(Value); + + WriteTextList(Name, List); +} + +QString COptionsWindow::ReadTextSafe(const QString& Name, const QString& Default) +{ + QStringList List = m_pBox->GetTextList(Name, false); + + for (int i = 0; i < List.count(); i++) { + if (!List[i].contains(",")) + return List[i]; + } + + return Default; +} + void COptionsWindow::SaveConfig() { bool UpdatePaths = false; diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.h b/SandboxiePlus/SandMan/Windows/OptionsWindow.h index dedb4f40..ac6a037b 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsWindow.h +++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.h @@ -547,6 +547,8 @@ private: void WriteAdvancedCheck(QCheckBox* pCheck, const QString& Name, const QString& OnValue, const QString& OffValue); void WriteText(const QString& Name, const QString& Value); void WriteTextList(const QString& Setting, const QStringList& List); + void WriteTextSafe(const QString& Name, const QString& Value); + QString ReadTextSafe(const QString& Name, const QString& Default); Ui::OptionsWindow ui; QCheckBox* m_pUseIcon;