This commit is contained in:
DavidXanatos 2024-07-27 19:35:11 +02:00
parent 7dd4f6498d
commit f8693ad241
7 changed files with 60 additions and 16 deletions

View File

@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- fixed issue with Windows 7 caused by the new CustomLCID option [#4117](https://github.com/sandboxie-plus/Sandboxie/issues/4117)
### Added
- added alias for a sandbox [#4112](https://github.com/sandboxie-plus/Sandboxie/issues/4112)
## [1.14.5 / 5.69.5] - 2024-07-23

View File

@ -71,13 +71,21 @@ _FX BOOLEAN Gui_InitTitle(HMODULE module)
SbieDll_GetSettingsForName(NULL, Dll_ImageName, L"BoxNameTitle", buf, sizeof(buf), NULL);
if (*buf == L'y' || *buf == L'Y') { // indicator + box name
const WCHAR* BoxName = Dll_BoxName;
NTSTATUS status;
WCHAR BoxAlias[MAX_PATH];
status = SbieApi_QueryConfAsIs(NULL, L"BoxAlias", 0, BoxAlias, ARRAYSIZE(BoxAlias));
if (NT_SUCCESS(status) && *BoxAlias)
BoxName = BoxAlias;
UNICODE_STRING uni;
Gui_BoxNameTitleLen = wcslen(Dll_BoxName) + 3;
Gui_BoxNameTitleLen = wcslen(BoxName) + 3;
Gui_BoxNameTitleW =
Dll_Alloc((Gui_BoxNameTitleLen + 3) * sizeof(WCHAR));
Gui_BoxNameTitleW[0] = Gui_TitleSuffixW[1]; // L'['
wcscpy(&Gui_BoxNameTitleW[1], Dll_BoxName);
wcscpy(&Gui_BoxNameTitleW[1], BoxName);
wcscat(Gui_BoxNameTitleW, &Gui_TitleSuffixW[3]); // L"]"
wcscat(Gui_BoxNameTitleW, L" ");

View File

@ -1312,7 +1312,7 @@ QString CSbieAPI::SbieIniGet2(const QString& Section, const QString& Setting, qu
SB_STATUS CSbieAPI::ValidateName(const QString& BoxName)
{
if (BoxName.length() > (BOXNAME_COUNT - 2))
if (BoxName.length() > (BOXNAME_COUNT - 2) || BoxName.isEmpty())
return SB_ERR(SB_NameLenLimit);
/* invalid file name characters on windows

View File

@ -327,8 +327,10 @@ QList<QVariant> CSbieModel::Sync(const QMap<QString, CSandBoxPtr>& BoxList, cons
QVariant Value;
switch(section)
{
case eName: Value = pBox->GetName(); break;
case eName: Value = pBoxEx->GetDisplayName(); break;
//case eName: Value = pBox->GetName(); break;
case eStatus: Value = pBox.objectCast<CSandBoxPlus>()->GetStatusStr(); break;
case eTitle: Value = pBox->GetDesktop(); break;
case eInfo: Value = pBox.objectCast<CSandBoxPlus>()->IsEmptyCached() ? -2 : (bWatchSize ? pBox.objectCast<CSandBoxPlus>()->GetSize() : 0); break;
case ePath: Value = pBox->GetFileRoot(); break;
}
@ -343,7 +345,7 @@ QList<QVariant> CSbieModel::Sync(const QMap<QString, CSandBoxPtr>& BoxList, cons
switch (section)
{
case eName: ColValue.Formatted = Value.toString().replace("_", " "); break;
//case eName: ColValue.Formatted = Value.toString().replace("_", " "); break;
case eInfo: ColValue.Formatted = Value.toULongLong() == -2 ? tr("Empty") : (Value.toULongLong() > 0 ? FormatSize(Value.toULongLong()) : ""); break;
}
}

View File

@ -410,6 +410,15 @@ void CSandBoxPlus::UpdateDetails()
QStringList BorderCfg = GetText("BorderColor").split(",");
m_BoxColor = QColor("#" + BorderCfg[0].mid(5, 2) + BorderCfg[0].mid(3, 2) + BorderCfg[0].mid(1, 2)).rgb();
m_BoxAlias = GetText("BoxAlias");
}
QString CSandBoxPlus::GetDisplayName() const
{
if (!m_BoxAlias.isEmpty())
return m_BoxAlias;
return GetName().replace("_", " ");
}
bool CSandBoxPlus::IsBoxexPath(const QString& Path)

View File

@ -72,6 +72,8 @@ public:
CSandBoxPlus(const QString& BoxName, class CSbieAPI* pAPI);
virtual ~CSandBoxPlus();
virtual QString GetDisplayName() const;
SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = "", int Level = 5, bool Solid = false);
SB_PROGRESS ImportBox(const QString& FileName, const QString& Password = "");
@ -256,6 +258,7 @@ protected:
bool m_BoxDel;
bool m_NoForce;
QRgb m_BoxColor;
QString m_BoxAlias;
};
///////////////////////////////////////////////////////////////////////////////

View File

@ -1411,21 +1411,39 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
}
else if (Action == m_pMenuRename)
{
QString OldValue = SandBoxes.first()->GetName().replace("_", " ");
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter a new name for the Sandbox."), QLineEdit::Normal, OldValue);
if (Value.isEmpty() || Value == OldValue)
auto pBox = SandBoxes.first();
QString OldValue = pBox->GetName().replace("_", " ");
QString Alias = pBox->GetText("BoxAlias");
bool bAlias = false;
if (bAlias = !Alias.isEmpty())
OldValue = Alias;
bool bOk = false;
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", bAlias ? tr("Please enter a new alias for the Sandbox.") : tr("Please enter a new name for the Sandbox."), QLineEdit::Normal, OldValue, &bOk);
if (!bOk || Value == OldValue)
return;
if (!TestNameAndWarn(Value))
if (!Value.isEmpty() && !TestNameAndWarn(Value))
return;
SB_STATUS Status = SandBoxes.first()->RenameBox(Value.replace(" ", "_"));
if (!Status.IsError())
bool bError = false;
if (bAlias || (bError = CSbieAPI::ValidateName(QString(Value).replace(" ", "_")).IsError()))
{
RenameItem(OldValue.replace(" ", "_"), Value.replace(" ", "_"));
if (theAPI->GetGlobalSettings()->GetText("DefaultBox", "DefaultBox").compare(OldValue.replace(" ", "_"), Qt::CaseInsensitive) == 0)
theAPI->GetGlobalSettings()->SetText("DefaultBox", Value.replace(" ", "_"));
if (!bAlias && QMessageBox::question(this, "Sandboxie-Plus", tr("The entered name is not valid, do you want to set it as an alias instead?"), QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
return;
if (Value.isEmpty()) pBox->DelValue("BoxAlias");
else pBox->SetText("BoxAlias", Value);
pBox->UpdateDetails();
}
else
{
SB_STATUS Status = pBox->RenameBox(Value.replace(" ", "_"));
if (!Status.IsError())
{
RenameItem(OldValue.replace(" ", "_"), Value.replace(" ", "_"));
if (theAPI->GetGlobalSettings()->GetText("DefaultBox", "DefaultBox").compare(OldValue.replace(" ", "_"), Qt::CaseInsensitive) == 0)
theAPI->GetGlobalSettings()->SetText("DefaultBox", Value.replace(" ", "_"));
}
Results.append(Status);
}
Results.append(Status);
SaveBoxGrouping();
}
@ -1720,7 +1738,7 @@ void CSbieView::ShowOptions(const CSandBoxPtr& pBox)
{
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
if (pBoxEx->m_pOptionsWnd == NULL) {
pBoxEx->m_pOptionsWnd = new COptionsWindow(pBox, pBox->GetName());
pBoxEx->m_pOptionsWnd = new COptionsWindow(pBox, pBoxEx->GetDisplayName());
connect(theGUI, SIGNAL(Closed()), pBoxEx->m_pOptionsWnd, SLOT(close()));
connect(pBoxEx->m_pOptionsWnd, &COptionsWindow::Closed, [pBoxEx]() {
pBoxEx->m_pOptionsWnd = NULL;