1.9.1
This commit is contained in:
parent
f340330b1a
commit
bfffaf96a0
|
@ -22,6 +22,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||
- fixed memory corruption issue with Normal[File/Key]Path [#2588](https://github.com/sandboxie-plus/Sandboxie/issues/2588)
|
||||
- fixed DPI scaling in the snapshot manager window [#782](https://github.com/sandboxie-plus/Sandboxie/issues/782)
|
||||
|
||||
### Changed
|
||||
- reworked box grouping config storeage
|
||||
|
||||
|
||||
## [1.9.0 / 5.64.0] - 2023-04-17
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "SbieIni.h"
|
||||
#include "../SbieAPI.h"
|
||||
#include "../SbieDefs.h"
|
||||
|
||||
#include <ntstatus.h>
|
||||
#define WIN32_NO_STATUS
|
||||
|
@ -206,6 +207,38 @@ SB_STATUS CSbieIni::DelValue(const QString& Setting, const QString& Value)
|
|||
return m_pAPI->SbieIniSet(m_Name, Setting, Value, CSbieAPI::eIniDelete, m_RefreshOnChange);
|
||||
}
|
||||
|
||||
void CSbieIni::SetTextMap(const QString& Setting, const QMap<QString, QStringList> Map)
|
||||
{
|
||||
QStringList Mapping;
|
||||
foreach(const QString& Group, Map.keys())
|
||||
{
|
||||
QString CurrentLine;
|
||||
foreach(const QString & Name, Map[Group]) {
|
||||
if (Setting.length() + 1 + Group.length() + 1 + CurrentLine.length() + 1 + Name.length() >= CONF_LINE_LEN) { // limit line length
|
||||
Mapping.append(Group + ":" + CurrentLine);
|
||||
CurrentLine.clear();
|
||||
}
|
||||
if (!CurrentLine.isEmpty()) CurrentLine.append(",");
|
||||
CurrentLine.append(Name);
|
||||
}
|
||||
if(!CurrentLine.isEmpty())
|
||||
Mapping.append(Group + ":" + CurrentLine);
|
||||
}
|
||||
DelValue(Setting);
|
||||
foreach(const QString & Value, Mapping)
|
||||
AppendText(Setting, Value);
|
||||
}
|
||||
|
||||
QMap<QString, QStringList> CSbieIni::GetTextMap(const QString& Setting)
|
||||
{
|
||||
QMap<QString, QStringList> Map;
|
||||
foreach(const QString &CurrentLine, GetTextList(Setting, false)) {
|
||||
int pos = CurrentLine.lastIndexOf(":");
|
||||
Map[pos == -1 ? "" : CurrentLine.left(pos)].append(CurrentLine.mid(pos+1).split(","));
|
||||
}
|
||||
return Map;
|
||||
}
|
||||
|
||||
QList<QPair<QString, QString>> CSbieIni::GetIniSection(qint32* pStatus, bool withTemplates) const
|
||||
{
|
||||
qint32 status = STATUS_SUCCESS;
|
||||
|
|
|
@ -34,6 +34,9 @@ public:
|
|||
virtual SB_STATUS InsertText(const QString& Setting, const QString& Value);
|
||||
virtual SB_STATUS AppendText(const QString& Setting, const QString& Value);
|
||||
|
||||
virtual void SetTextMap(const QString& Setting, const QMap<QString, QStringList> Map);
|
||||
virtual QMap<QString, QStringList> GetTextMap(const QString& Setting);
|
||||
|
||||
virtual SB_STATUS DelValue(const QString& Setting, const QString& Value = QString());
|
||||
|
||||
virtual QList<QPair<QString, QString>> GetIniSection(qint32* pStatus = NULL, bool withTemplates = false) const;
|
||||
|
|
|
@ -25,7 +25,8 @@ CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
|
|||
m_pMainLayout->setContentsMargins(0,0,0,0);
|
||||
this->setLayout(m_pMainLayout);
|
||||
|
||||
//m_UserConfigChanged = false;
|
||||
m_UserConfigChanged = false;
|
||||
m_HoldExpand = false;
|
||||
|
||||
m_pSbieModel = new CSbieModel(this);
|
||||
m_pSbieModel->SetTree(true);
|
||||
|
@ -454,8 +455,11 @@ void CSbieView::Refresh()
|
|||
|
||||
QModelIndex ModelIndex = m_pSbieModel->FindIndex(ID);
|
||||
|
||||
if (m_pSbieModel->GetType(ModelIndex) == CSbieModel::eProcess)
|
||||
if (m_pSbieModel->GetType(ModelIndex) == CSbieModel::eProcess) {
|
||||
m_HoldExpand = true;
|
||||
m_pSbieTree->expand(m_pSortProxy->mapFromSource(ModelIndex));
|
||||
m_HoldExpand = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString Name;
|
||||
|
@ -464,8 +468,11 @@ void CSbieView::Refresh()
|
|||
else if (m_pSbieModel->GetType(ModelIndex) == CSbieModel::eBox)
|
||||
Name = m_pSbieModel->GetSandBox(ModelIndex)->GetName();
|
||||
|
||||
if (!m_Collapsed.contains(Name))
|
||||
if (!m_Collapsed.contains(Name)) {
|
||||
m_HoldExpand = true;
|
||||
m_pSbieTree->expand(m_pSortProxy->mapFromSource(ModelIndex));
|
||||
m_HoldExpand = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -921,7 +928,7 @@ void CSbieView::OnGroupAction(QAction* Action)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
//m_UserConfigChanged = true;
|
||||
m_UserConfigChanged = true;
|
||||
UpdateMoveMenu();
|
||||
|
||||
SaveUserConfig();
|
||||
|
@ -1001,7 +1008,7 @@ QString CSbieView::AddNewGroup()
|
|||
m_Groups[Parent].append(Name);
|
||||
|
||||
|
||||
//m_UserConfigChanged = true;
|
||||
m_UserConfigChanged = true;
|
||||
UpdateMoveMenu();
|
||||
|
||||
SaveUserConfig();
|
||||
|
@ -1435,7 +1442,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
|
|||
|
||||
CSandMan::CheckResults(Results);
|
||||
|
||||
//m_UserConfigChanged = true;
|
||||
m_UserConfigChanged = true;
|
||||
SaveUserConfig();
|
||||
}
|
||||
|
||||
|
@ -1826,6 +1833,9 @@ void CSbieView::ShowOptions(const QString& Name)
|
|||
|
||||
void CSbieView::ChangeExpand(const QModelIndex& index, bool bExpand)
|
||||
{
|
||||
if (m_HoldExpand)
|
||||
return;
|
||||
|
||||
QModelIndex ModelIndex = m_pSortProxy->mapToSource(index);
|
||||
|
||||
if (m_pSbieModel->GetType(ModelIndex) == CSbieModel::eProcess)
|
||||
|
@ -1842,27 +1852,34 @@ void CSbieView::ChangeExpand(const QModelIndex& index, bool bExpand)
|
|||
else
|
||||
m_Collapsed.insert(Name);
|
||||
|
||||
//m_UserConfigChanged = true;
|
||||
m_UserConfigChanged = true;
|
||||
|
||||
SaveUserConfig();
|
||||
}
|
||||
|
||||
void CSbieView::ReloadUserConfig()
|
||||
{
|
||||
m_Groups.clear();
|
||||
if (!theAPI->IsConnected())
|
||||
return;
|
||||
|
||||
QString Grouping = theConf->GetString("UIConfig/BoxDisplayOrder");
|
||||
if(Grouping.isEmpty())
|
||||
Grouping = theAPI->GetUserSettings()->GetText("BoxDisplayOrder");
|
||||
CSbieView__ParseGroup(Grouping, m_Groups);
|
||||
m_Groups = theAPI->GetUserSettings()->GetTextMap("BoxGrouping");
|
||||
if (m_Groups.isEmpty()) { // try legacy entries
|
||||
QString Grouping = theConf->GetString("UIConfig/BoxDisplayOrder");
|
||||
if (Grouping.isEmpty())
|
||||
Grouping = theAPI->GetUserSettings()->GetText("BoxDisplayOrder");
|
||||
CSbieView__ParseGroup(Grouping, m_Groups);
|
||||
}
|
||||
|
||||
UpdateMoveMenu();
|
||||
|
||||
QString Collapsed = theConf->GetString("UIConfig/BoxCollapsedView");
|
||||
if (Collapsed.isEmpty())
|
||||
Collapsed = theAPI->GetUserSettings()->GetText("BoxCollapsedView");
|
||||
|
||||
m_Collapsed = ListToSet(SplitStr(Collapsed, ","));
|
||||
QMap<QString, QStringList> Collapsed = theAPI->GetUserSettings()->GetTextMap("CollapsedBoxes");
|
||||
m_Collapsed = ListToSet(Collapsed[""]);
|
||||
if (m_Collapsed.isEmpty()) { // try legacy entries
|
||||
QString Collapsed = theConf->GetString("UIConfig/BoxCollapsedView");
|
||||
if (Collapsed.isEmpty())
|
||||
Collapsed = theAPI->GetUserSettings()->GetText("BoxCollapsedView");
|
||||
m_Collapsed = ListToSet(SplitStr(Collapsed, ","));
|
||||
}
|
||||
|
||||
ClearUserUIConfig();
|
||||
}
|
||||
|
@ -1895,27 +1912,31 @@ void CSbieView::ClearUserUIConfig(const QMap<QString, CSandBoxPtr> AllBoxes)
|
|||
|
||||
void CSbieView::SaveUserConfig()
|
||||
{
|
||||
//if (!m_UserConfigChanged)
|
||||
// return;
|
||||
//m_UserConfigChanged = false;
|
||||
if (!m_UserConfigChanged)
|
||||
return;
|
||||
m_UserConfigChanged = false;
|
||||
|
||||
if (!m_Groups.isEmpty()) {
|
||||
if (!theAPI->IsConnected())
|
||||
return;
|
||||
|
||||
auto Groups = m_Groups;
|
||||
// clean up non existing entries
|
||||
for (auto I = Groups.begin(); I != Groups.end(); ++I) {
|
||||
foreach(const QString &Name, I.value()) {
|
||||
if (theAPI->GetBoxByName(Name).isNull() && !Groups.contains(Name))
|
||||
I->removeAll(Name);
|
||||
}
|
||||
theAPI->GetUserSettings()->SetRefreshOnChange(false);
|
||||
|
||||
auto Groups = m_Groups;
|
||||
// clean up non existing entries
|
||||
for (auto I = Groups.begin(); I != Groups.end(); ++I) {
|
||||
foreach(const QString &Name, I.value()) {
|
||||
if (theAPI->GetBoxByName(Name).isNull() && !Groups.contains(Name))
|
||||
I->removeAll(Name);
|
||||
}
|
||||
|
||||
QString Grouping = CSbieView__SerializeGroup(Groups);
|
||||
theConf->SetValue("UIConfig/BoxDisplayOrder", Grouping);
|
||||
}
|
||||
theAPI->GetUserSettings()->SetTextMap("BoxGrouping", Groups);
|
||||
|
||||
QString Collapsed = SetToList(m_Collapsed).join(",");
|
||||
theConf->SetValue("UIConfig/BoxCollapsedView", Collapsed);
|
||||
QMap<QString, QStringList> Collapsed;
|
||||
Collapsed.insert("", SetToList(m_Collapsed));
|
||||
theAPI->GetUserSettings()->SetTextMap("CollapsedBoxes", Collapsed);
|
||||
|
||||
theAPI->GetUserSettings()->SetRefreshOnChange(true);
|
||||
theAPI->CommitIniChanges();
|
||||
}
|
||||
|
||||
void CSbieView::OnMoveItem(const QString& Name, const QString& To, int row)
|
||||
|
@ -1933,7 +1954,7 @@ void CSbieView::OnMoveItem(const QString& Name, const QString& To, int row)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
//m_UserConfigChanged = true;
|
||||
m_UserConfigChanged = true;
|
||||
UpdateMoveMenu();
|
||||
|
||||
SaveUserConfig();
|
||||
|
|
|
@ -79,7 +79,8 @@ protected:
|
|||
|
||||
QMap<QString, QStringList> m_Groups;
|
||||
QSet<QString> m_Collapsed;
|
||||
//bool m_UserConfigChanged;
|
||||
bool m_UserConfigChanged;
|
||||
bool m_HoldExpand;
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue