This commit is contained in:
DavidXanatos 2024-11-29 10:03:07 +01:00
parent d9d22e22b1
commit b9062c6af2
9 changed files with 46 additions and 26 deletions

View File

@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.15.4 / 5.70.4] - 2024-12-??
###
- Fixed issues with ini section editor in dark mode
- Fix deleting sandbox content [#4407](https://github.com/sandboxie-plus/Sandboxie/pull/4407)
## [1.15.3 / 5.70.3] - 2024-11-28
### Added

View File

@ -26,7 +26,7 @@
#define VERSION_MJR 5
#define VERSION_MIN 70
#define VERSION_REV 3
#define VERSION_REV 4
#define VERSION_UPD 0
#if VERSION_UPD > 0

View File

@ -1,55 +1,65 @@
#include "stdafx.h"
#include "IniHighlighter.h"
CIniHighlighter::CIniHighlighter(QTextDocument *parent)
CIniHighlighter::CIniHighlighter(bool bDarkMode, QTextDocument *parent)
: QSyntaxHighlighter(parent)
{
// Define colors for light and dark mode
QColor blue = bDarkMode ? QColor("#87CEFA") : QColor("#0000FF"); // Lighter blue for dark mode
QColor green = bDarkMode ? QColor("#90EE90") : QColor("#008000"); // Lighter green for dark mode
QColor darkRed = bDarkMode ? QColor("#FF6347") : QColor("#800000"); // Lighter red for dark mode
QColor red = bDarkMode ? QColor("#FF4500") : QColor("#FF0000"); // Brighter red for dark mode
QColor black = bDarkMode ? QColor("#DCDCDC") : QColor("#000000"); // Light gray for dark mode
QColor brown = bDarkMode ? QColor("#F4A460") : QColor("#A52A2A"); // Light brown for dark mode
QColor purple = bDarkMode ? QColor("#DA70D6") : QColor("#800080"); // Brighter purple for dark mode
QColor gray = bDarkMode ? QColor("#A9A9A9") : QColor("#808080"); // Lighter gray for dark mode
HighlightRule rule;
// Section headers: [Section]
sectionFormat.setForeground(QColor("#0000FF")); // Blue
sectionFormat.setForeground(blue);
sectionFormat.setFontWeight(QFont::Bold);
rule.pattern = QRegularExpression("^\\s*\\[.*\\]\\s*$");
rule.format = sectionFormat;
highlightRules.append(rule);
// Comments: ; comment or # comment
commentFormat.setForeground(QColor("#008000")); // Green
commentFormat.setForeground(green);
rule.pattern = QRegularExpression("^\\s*[;#].*");
rule.format = commentFormat;
highlightRules.append(rule);
// Keys: key=
keyFormat.setForeground(QColor("#800000")); // Dark Red
keyFormat.setForeground(darkRed);
rule.pattern = QRegularExpression("^[\\w\\.]+(?=\\s*=)");
rule.format = keyFormat;
highlightRules.append(rule);
// Equals sign: =
equalsFormat.setForeground(QColor("#FF0000")); // Red
equalsFormat.setForeground(red);
rule.pattern = QRegularExpression("=");
rule.format = equalsFormat;
highlightRules.append(rule);
// Values: =value
valueFormat.setForeground(QColor("#000000")); // Black
valueFormat.setForeground(black);
rule.pattern = QRegularExpression("(?<=\\=).*");
rule.format = valueFormat;
highlightRules.append(rule);
// Initialize formats for value prefix and first comma
valuePrefixFormat.setForeground(QColor("#0000FF")); // Blue
firstCommaFormat.setForeground(QColor("#FF0000")); // Red
valuePrefixFormat.setForeground(blue);
firstCommaFormat.setForeground(red);
#ifdef INI_WITH_JSON
// Initialize JSON formats
jsonKeyFormat.setForeground(QColor("#A52A2A")); // Brown
jsonStringFormat.setForeground(QColor("#000000")); // Black
jsonNumberFormat.setForeground(QColor("#0000FF")); // Blue
jsonBoolNullFormat.setForeground(QColor("#800080")); // Purple
jsonBracesFormat.setForeground(QColor("#808080")); // Gray
jsonColonFormat.setForeground(QColor("#FF0000")); // Red
jsonCommaFormat.setForeground(QColor("#FF0000")); // Red
jsonKeyFormat.setForeground(brown);
jsonStringFormat.setForeground(black);
jsonNumberFormat.setForeground(blue);
jsonBoolNullFormat.setForeground(purple);
jsonBracesFormat.setForeground(gray);
jsonColonFormat.setForeground(red);
jsonCommaFormat.setForeground(red);
// 1. JSON Colon: Match colons not preceded by backslash
HighlightRule jsonRule;

View File

@ -9,7 +9,7 @@ class CIniHighlighter : public QSyntaxHighlighter
Q_OBJECT
public:
explicit CIniHighlighter(QTextDocument *parent = nullptr);
explicit CIniHighlighter(bool bDarkMode, QTextDocument *parent = nullptr);
~CIniHighlighter();
protected:

View File

@ -1308,9 +1308,9 @@ void CSandMan::OnRestartAsAdmin()
theAPI->Disconnect();
WCHAR buf[255] = { 0 };
GetModuleFileNameW(NULL, buf, 255);
SHELLEXECUTEINFO se;
memset(&se, 0, sizeof(SHELLEXECUTEINFO));
se.cbSize = sizeof(SHELLEXECUTEINFO);
SHELLEXECUTEINFOW se;
memset(&se, 0, sizeof(se));
se.cbSize = sizeof(se);
se.lpVerb = L"runas";
se.lpFile = buf;
se.nShow = SW_HIDE;

View File

@ -100,14 +100,14 @@ void COptionsWindow::SaveINetAccess()
int Mode = ui.cmbBlockINet->currentData().toInt();
if (Mode == 1) {
if (!FindEntryInSettingList("AllowNetworkAccess", "!<InternetAccess>,n"))
m_pBox->InsertText("AllowNetworkAccess", "!<InternetAccess>,n");
m_pBox->AppendText("AllowNetworkAccess", "!<InternetAccess>,n");
}
else
m_pBox->DelValue("AllowNetworkAccess", "!<InternetAccess>,n");
if (Mode == 0) {
if (m_WFPisBlocking && !FindEntryInSettingList("AllowNetworkAccess", "y"))
m_pBox->InsertText("AllowNetworkAccess", "y");
m_pBox->AppendText("AllowNetworkAccess", "y");
}
else
m_pBox->DelValue("AllowNetworkAccess", "y");
@ -115,7 +115,7 @@ void COptionsWindow::SaveINetAccess()
QTreeWidgetItem* pBlockedNet = FindGroupByName("<BlockNetAccess>");
if (pBlockedNet && pBlockedNet->childCount() > 0) {
if (theGUI->IsWFPEnabled() && !FindEntryInSettingList("AllowNetworkAccess", "<BlockNetAccess>,n"))
m_pBox->InsertText("AllowNetworkAccess", "<BlockNetAccess>,n");
m_pBox->AppendText("AllowNetworkAccess", "<BlockNetAccess>,n");
}
else
m_pBox->DelValue("AllowNetworkAccess", "<BlockNetAccess>,n");

View File

@ -415,7 +415,7 @@ COptionsWindow::COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QStri
pTree->setAlternatingRowColors(true);
}
m_pCodeEdit = new CCodeEdit(new CIniHighlighter);
m_pCodeEdit = new CCodeEdit(new CIniHighlighter(theGUI->m_DarkTheme));
ui.txtIniSection->parentWidget()->layout()->replaceWidget(ui.txtIniSection, m_pCodeEdit);
delete ui.txtIniSection;
ui.txtIniSection = NULL;

View File

@ -601,7 +601,7 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
ui.btnResetIniFont->setIcon(CSandMan::GetIcon("ResetFont"));
ui.btnResetIniFont->setToolTip(tr("Reset font"));
m_pCodeEdit = new CCodeEdit(new CIniHighlighter);
m_pCodeEdit = new CCodeEdit(new CIniHighlighter(theGUI->m_DarkTheme));
ui.txtIniSection->parentWidget()->layout()->replaceWidget(ui.txtIniSection, m_pCodeEdit);
delete ui.txtIniSection;
ui.txtIniSection = NULL;

View File

@ -2,7 +2,7 @@
#define VERSION_MJR 1
#define VERSION_MIN 15
#define VERSION_REV 3
#define VERSION_REV 4
#define VERSION_UPD 0
#ifndef STR