From 849465ee40007075cf08497a840c10446a654330 Mon Sep 17 00:00:00 2001
From: typpos <28550406+typpos@users.noreply.github.com>
Date: Fri, 9 Jun 2023 18:47:09 +1000
Subject: [PATCH] Ability to select font for ini editor panels.
---
SandboxiePlus/SandMan/Forms/OptionsWindow.ui | 62 +++++++++++++-----
SandboxiePlus/SandMan/Forms/SettingsWindow.ui | 38 +++++++++--
.../SandMan/Resources/Actions/Font.png | Bin 0 -> 2163 bytes
.../SandMan/Resources/Actions/ResetFont.png | Bin 0 -> 4112 bytes
SandboxiePlus/SandMan/Resources/SandMan.qrc | 2 +
.../SandMan/Windows/OptionsWindow.cpp | 33 +++++++++-
SandboxiePlus/SandMan/Windows/OptionsWindow.h | 5 ++
.../SandMan/Windows/SettingsWindow.cpp | 33 ++++++++++
.../SandMan/Windows/SettingsWindow.h | 4 ++
9 files changed, 156 insertions(+), 21 deletions(-)
create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Font.png
create mode 100644 SandboxiePlus/SandMan/Resources/Actions/ResetFont.png
diff --git a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
index 4e70d414..4b31551c 100644
--- a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
@@ -4643,6 +4643,26 @@ Please note that this values are currently user specific and saved globally for
Edit ini Section
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 10
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
-
@@ -4653,7 +4673,7 @@ Please note that this values are currently user specific and saved globally for
- -
+
-
false
@@ -4663,20 +4683,7 @@ Please note that this values are currently user specific and saved globally for
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
+
-
false
@@ -4686,13 +4693,36 @@ Please note that this values are currently user specific and saved globally for
- -
+
-
QPlainTextEdit::NoWrap
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 20
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
index a041d84c..ca9e9cc3 100644
--- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui
@@ -2135,7 +2135,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
Edit ini Section
- -
+
-
false
@@ -2145,6 +2145,36 @@ Unlike the preview channel, it does not include untested, potentially breaking,
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Minimum
+
+
+
+ 10
+ 20
+
+
+
+
-
@@ -2155,7 +2185,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
- -
+
-
Qt::Horizontal
@@ -2168,7 +2198,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
- -
+
-
false
@@ -2178,7 +2208,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
- -
+
-
QPlainTextEdit::NoWrap
diff --git a/SandboxiePlus/SandMan/Resources/Actions/Font.png b/SandboxiePlus/SandMan/Resources/Actions/Font.png
new file mode 100644
index 0000000000000000000000000000000000000000..c9e100a264343f1a00ceb6529346a7bccf81d314
GIT binary patch
literal 2163
zcmbVO4Qvxt9Ph^LSZ5IeBtQ(_Zm64hy^mhI-i5Mt>!1U=;a1o%!SH(b+Foey&bu4!
zkT`H+#ujlT1_^PGv+nbivH(UcYlCxC2C-eZn2ckG_L~7p1pG{
z7HgLjYBSn`D|kUkIDn{xp(B-05!zx|RGm_RupSy%7)B-8i{CnS0>>oLi?_OhR8Xyh
zF)6T7gDo2yL&C=O0w?0ti?Ky19uXv<0kBjeF6(^Ci>G;cG&ZM697{ut^Dgsc3!>RkT*}K!
z8q)|8C@&yCU+H<1#GEG|U^&u%4^#BQv?a||m2rT)hl}af<^z(Bnyw=&*8*Rh5Keb9
z4+L|SdU3&QPZTqjnU*H0`S-abL9c;M2
z>krq28Pa^$CtXJW$MtMlgcy*c5bgQoL>V(hA^%&ibcype(($UJ-Ps)G&IR<4J6WKN
zs5NwM47^o|4zGfp4SruJcIlTrKfXSKJ-XFdd!%ro(bcm0x^3X(fobPw57w?eV;kt3
z-L|Fl>DHdclA}fOYulIIYI^dS&QEU7KeX?UYpYAExvQsOb?y#2G#h#iUTCUV@9@uu-v};
z^19-Z-m0&gAG-nnzfm)d*j?>7QpdcPZeZ}IN3
n;>(xoM^6u*P}#mt>#z2i$70vkmX#bcKMNY_8~ulC*S+#DcfQ`g
literal 0
HcmV?d00001
diff --git a/SandboxiePlus/SandMan/Resources/Actions/ResetFont.png b/SandboxiePlus/SandMan/Resources/Actions/ResetFont.png
new file mode 100644
index 0000000000000000000000000000000000000000..104ada88dfa0f046c5ee7d962b20160ed1c39ff6
GIT binary patch
literal 4112
zcmcgv30xCr79T(XkyHh&AXdjvX;dbenOsaHHNF>RGBocyjK@d6A
ziq@sngQ`HaRBS!4ibttZDvDOE3NCAHwH~;(v}gsj;!XlY>}qwlyPMxHnQvy^d;j001j4Ru<1(QQOzumH8bVTCknD3^K$fnE+t0x9#f$tXby^03H^N
z;&t=u@+lI6)^Tx?R#Mz_oq>@CfRNC115Tt+W>85bYxGif`@YZFpoWyPX9?x7+z?5r
zHL)2+Dj{R4g2+fAFp?emDj1S3VGQUfGY+Qfw0e^yUCOrGl`w1DV;&o{i~I?(
z__};L7)cu`P{f5H0)|DP7~_(-5+{_(AP|L7ga-?Fhya3N2_KUP1Yqxn&A=H+l_Xvk
z-3!LtN!e<%*&yNZEEWsb!spV)WFCTH7!O8yC<-wWkjbhyr!a%M-&GFC91V5H4(s$u39|4mraDqt*^i5C;Fn(IUr2ts5B;wUP7KIZBkeb6fd4K(F=?O
z6_v)g8PFGv$sA8T;`2Gw8F9O^K@w@Ca5HUG(6qKM&C~nh1yPhM06DWXdXl!7#@o<(
z6(|{Qrlf2p<$MShLMW<0V2OY)fd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lx=P%^aA(ud
z48IlAQe!idHmthd6`ER+H}gW+(88v)EQq|79$%Y_5RgOT(F=%@2!{jL2a!w$Da&6`R@8#i{3apv+R5E2emH^lXw(g^eJg&r@a4>
zYulhnS)4`lT#l>Hd*5se^ACG<)v+;k`z!tGN2OMK1|ER9#S_BT%zJ^iKiwa^I=thn
z&4VhY-Odat{dt&2x%=vTYhy(!@Lk1}y!(l@sa39ivFQ+y)KW4lF28Nz?8A{`IW8;F
zITJ&gD}DSFdxlVx)As0x3SC?iJZ~9~9+_2hYG&PUjV-z7ie@050~)v=WpgG>Y|Xyf
zS$0$|ga)u&X808v^L$ELEX%mx?-&chrvp26ubG@ye6=C5;U6=HZ$gi&t>@N%vOLY#
z=}=>~8F|Zp>#sF=9(RT=yXFfAED2o5I=PPu3%{g`KQSJv>CIh~_h*LC`oBX3_c
z6i09udtmV?hunsRv|H#dq{QTJKaB;?{0U3uPp~~QU2EE-T6PRI5TV|
z6}@>q?EFJ~HEZmJt~1%5^<8PB{PiWdo()o`fUx+Q(uqM|BnrXY)b?Qw7)QMN=l1#J
z(oNWTH?Oi!#6uQTy6wBSHu~cuYa#aM-d$l}2@z!`+`@Hv*%Qw#d2<
zOgI)a&gEp~^lh4-b`1~R9Qu=WbLa{0CJH=QdZS#Qg&KHGpTvgm&X#p2z8mgxbu%Yy
z^vgpMy6)c#JH4}f8-F2v=1TG+pH1GU#vGc&(rMSe=lqLX&79_<+OLm%QChyuBrwi)
z%Gk8~MPPsHi1LO5UOK1s-()U2;Wg~1#ckuPzMa!bI9YWe7p+TY1NTNN>hYAO2mHL^
z$Gq#)Qn8y@0x$5u*JfTh?&>H=WKT7hotrOzn
literal 0
HcmV?d00001
diff --git a/SandboxiePlus/SandMan/Resources/SandMan.qrc b/SandboxiePlus/SandMan/Resources/SandMan.qrc
index ef0fde97..80d7f8e6 100644
--- a/SandboxiePlus/SandMan/Resources/SandMan.qrc
+++ b/SandboxiePlus/SandMan/Resources/SandMan.qrc
@@ -175,6 +175,8 @@
Actions/AntiVir.png
Actions/SourceCode.png
Actions/Qube.png
+ Actions/Font.png
+ Actions/ResetFont.png
Boxes/sandbox-b-empty.png
diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp
index ea14acfd..4fd0c343 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp
+++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.cpp
@@ -8,7 +8,7 @@
#include "../MiscHelpers/Common/SettingsWidgets.h"
#include "Helpers/WinAdmin.h"
#include "../Wizards/TemplateWizard.h"
-
+#include
class NoEditDelegate : public QStyledItemDelegate {
public:
@@ -532,6 +532,13 @@ COptionsWindow::COptionsWindow(const QSharedPointer& pBox, const QStri
connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab()));
// edit
+ ui.btnSelectIniEditFont->setIcon(CSandMan::GetIcon("Font"));
+ ui.btnResetIniEditFont->setIcon(CSandMan::GetIcon("ResetFont"));
+ ui.btnResetIniEditFont->setToolTip(tr("Reset font"));
+ ApplyIniEditFont();
+
+ connect(ui.btnSelectIniEditFont, SIGNAL(clicked(bool)), this, SLOT(OnSelectIniEditFont()));
+ connect(ui.btnResetIniEditFont, SIGNAL(clicked(bool)), this, SLOT(OnResetIniEditFont()));
connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni()));
connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni()));
connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit()));
@@ -625,6 +632,30 @@ COptionsWindow::COptionsWindow(const QSharedPointer& pBox, const QStri
m_pSearch->setPlaceholderText(tr("Search for options"));
}
+void COptionsWindow::ApplyIniEditFont()
+{
+ QFont font; // defaults to application font
+ auto fontName = theConf->GetString("UIConfig/IniFont", "").trimmed();
+ if (!fontName.isEmpty()) bool dummy = font.fromString(fontName); // ignore fromString() fail
+ ui.txtIniSection->setFont(font);
+ ui.btnSelectIniEditFont->setToolTip(tr("Select font (%1)").arg(font.family())); //tr: %1 = name of current font
+}
+
+void COptionsWindow::OnSelectIniEditFont()
+{
+ bool ok;
+ auto newFont = QFontDialog::getFont(&ok, ui.txtIniSection->font(), this);
+ if (!ok) return;
+ theConf->SetValue("UIConfig/IniFont", newFont.toString());
+ ApplyIniEditFont();
+}
+
+void COptionsWindow::OnResetIniEditFont()
+{
+ theConf->DelValue("UIConfig/IniFont");
+ ApplyIniEditFont();
+}
+
void COptionsWindow::OnSetTree()
{
if (!ui.tabs) return;
diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.h b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
index e2cb0e4f..09c1059c 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsWindow.h
+++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
@@ -228,6 +228,9 @@ private slots:
void OnSetTree();
+ void OnSelectIniEditFont();
+ void OnResetIniEditFont();
+
protected:
void closeEvent(QCloseEvent *e);
@@ -481,6 +484,8 @@ protected:
void LoadIniSection();
void SaveIniSection();
+ void ApplyIniEditFont();
+
QString GetCategoryName(const QString& Category);
bool m_HoldChange;
diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
index c0816b82..ba3b3c34 100644
--- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
+++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp
@@ -13,6 +13,7 @@
#include
#include "../Wizards/TemplateWizard.h"
#include "../AddonManager.h"
+#include
#include
@@ -493,6 +494,14 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab()));
// Ini Edit
+
+ ui.btnSelectIniEditFont->setIcon(CSandMan::GetIcon("Font"));
+ ui.btnResetIniEditFont->setIcon(CSandMan::GetIcon("ResetFont"));
+ ui.btnResetIniEditFont->setToolTip(tr("Reset font"));
+ ApplyIniEditFont();
+
+ connect(ui.btnSelectIniEditFont, SIGNAL(clicked(bool)), this, SLOT(OnSelectIniEditFont()));
+ connect(ui.btnResetIniEditFont, SIGNAL(clicked(bool)), this, SLOT(OnResetIniEditFont()));
connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni()));
connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni()));
connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit()));
@@ -538,6 +547,30 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
m_pSearch->setPlaceholderText(tr("Search for settings"));
}
+void CSettingsWindow::ApplyIniEditFont()
+{
+ QFont font; // defaults to application font
+ auto fontName = theConf->GetString("UIConfig/IniFont", "").trimmed();
+ if (!fontName.isEmpty()) bool dummy = font.fromString(fontName); // ignore fromString() fail
+ ui.txtIniSection->setFont(font);
+ ui.btnSelectIniEditFont->setToolTip(tr("Select font (%1)").arg(font.family())); //tr: %1 = name of current font
+}
+
+void CSettingsWindow::OnSelectIniEditFont()
+{
+ bool ok;
+ auto newFont = QFontDialog::getFont(&ok, ui.txtIniSection->font(), this);
+ if (!ok) return;
+ theConf->SetValue("UIConfig/IniFont", newFont.toString());
+ ApplyIniEditFont();
+}
+
+void CSettingsWindow::OnResetIniEditFont()
+{
+ theConf->DelValue("UIConfig/IniFont");
+ ApplyIniEditFont();
+}
+
void CSettingsWindow::OnSetTree()
{
if (!ui.tabs) return;
diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.h b/SandboxiePlus/SandMan/Windows/SettingsWindow.h
index 2639c8fe..daa504c8 100644
--- a/SandboxiePlus/SandMan/Windows/SettingsWindow.h
+++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.h
@@ -151,6 +151,9 @@ private slots:
void OnSetTree();
+ void OnSelectIniEditFont();
+ void OnResetIniEditFont();
+
protected:
void closeEvent(QCloseEvent *e);
@@ -171,6 +174,7 @@ protected:
void LoadIniSection();
void SaveIniSection();
+ void ApplyIniEditFont();
bool m_bRebuildUI;
bool m_HoldChange;