This commit is contained in:
DavidXanatos 2023-02-12 15:56:23 +01:00
parent 0b19969ef3
commit f64652e506
4 changed files with 15 additions and 8 deletions

View File

@ -94,6 +94,12 @@ QTreeWidgetItem* COptionsWindow::GetAccessEntry(EAccessType Type, const QString&
return NULL;
}
bool COptionsWindow::IsAccessEntrySet(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path)
{
QTreeWidgetItem* pItem = GetAccessEntry(Type, Program, Mode, Path);
return pItem && pItem->checkState(0) == Qt::Checked;
}
void COptionsWindow::SetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path)
{
if (GetAccessEntry(Type, Program, Mode, Path) != NULL)

View File

@ -415,7 +415,7 @@ void COptionsWindow::OnAdvancedChanged()
void COptionsWindow::CheckOpenCOM()
{
bool bComIpcOpen = GetAccessEntry(eIPC, "", eOpen, "\\RPC Control\\epmapper") != NULL || GetAccessEntry(eIPC, "", eOpen, "*") != NULL;
bool bComIpcOpen = IsAccessEntrySet(eIPC, "", eOpen, "\\RPC Control\\epmapper") || IsAccessEntrySet(eIPC, "", eOpen, "*");
if(bComIpcOpen)
ui.chkOpenCOM->setChecked(!m_BoxTemplates.contains("BoxedCOM"));
else
@ -424,7 +424,7 @@ void COptionsWindow::CheckOpenCOM()
void COptionsWindow::OnOpenCOM()
{
bool bComIpcOpen = GetAccessEntry(eIPC, "", eOpen, "\\RPC Control\\epmapper") != NULL || GetAccessEntry(eIPC, "", eOpen, "*") != NULL;
bool bComIpcOpen = IsAccessEntrySet(eIPC, "", eOpen, "\\RPC Control\\epmapper") || IsAccessEntrySet(eIPC, "", eOpen, "*");
SetTemplate("OpenCOM", !bComIpcOpen && ui.chkOpenCOM->isChecked());
SetTemplate("BoxedCOM", bComIpcOpen && !ui.chkOpenCOM->isChecked());
}

View File

@ -1017,11 +1017,11 @@ void COptionsWindow::UpdateCurrentTab()
{
if (m_pCurrentTab == ui.tabRestrictions || m_pCurrentTab == ui.tabOptions || m_pCurrentTab == ui.tabGeneral)
{
ui.chkVmRead->setChecked(GetAccessEntry(eIPC, "", eReadOnly, "$:*") != NULL);
ui.chkVmRead->setChecked(IsAccessEntrySet(eIPC, "", eReadOnly, "$:*"));
}
else if (m_pCurrentTab ==ui.tabPrivileges || m_pCurrentTab == ui.tabSecurity)
{
if (GetAccessEntry(eWnd, "", eOpen, "*") != NULL)
if (IsAccessEntrySet(eWnd, "", eOpen, "*"))
{
ui.chkAddToJob->setEnabled(false);
ui.chkAddToJob->setChecked(false);
@ -1034,9 +1034,9 @@ void COptionsWindow::UpdateCurrentTab()
}
else if (m_pCurrentTab == ui.tabStart || m_pCurrentTab == ui.tabForce)
{
if (GetAccessEntry(eIPC, "!<StartRunAccess>", eClosed, "*") != NULL)
if (IsAccessEntrySet(eIPC, "!<StartRunAccess>", eClosed, "*"))
ui.radStartSelected->setChecked(true);
else if (GetAccessEntry(eIPC, "<StartRunAccess>", eClosed, "*") != NULL)
else if (IsAccessEntrySet(eIPC, "<StartRunAccess>", eClosed, "*"))
ui.radStartExcept->setChecked(true);
else
ui.radStartAll->setChecked(true);
@ -1057,7 +1057,7 @@ void COptionsWindow::UpdateCurrentTab()
}
else if (m_pCurrentTab == ui.tabWnd)
{
if (GetAccessEntry(eWnd, "", eOpen, "*") != NULL)
if (IsAccessEntrySet(eWnd, "", eOpen, "*"))
{
ui.chkNoWindowRename->setEnabled(false);
ui.chkNoWindowRename->setChecked(true);
@ -1065,7 +1065,7 @@ void COptionsWindow::UpdateCurrentTab()
else
{
ui.chkNoWindowRename->setEnabled(true);
ui.chkNoWindowRename->setChecked(GetAccessEntry(eWnd, "", eOpen, "#") != NULL);
ui.chkNoWindowRename->setChecked(IsAccessEntrySet(eWnd, "", eOpen, "#"));
}
}
}

View File

@ -334,6 +334,7 @@ protected:
void CopyGroupToList(const QString& Group, QTreeWidget* pTree, bool disabled = false);
QTreeWidgetItem* GetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
bool IsAccessEntrySet(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void SetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void DelAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);