Merge pull request #3030 from typpos/FontSelectForIniEdit

Ability to select font for ini editor panels.
This commit is contained in:
DavidXanatos 2023-07-03 20:19:23 +02:00 committed by GitHub
commit 70073e5d32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 198 additions and 77 deletions

View File

@ -48,7 +48,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tabGeneral"> <widget class="QWidget" name="tabGeneral">
<attribute name="title"> <attribute name="title">
@ -85,6 +85,7 @@
<widget class="QLabel" name="lblGeneral"> <widget class="QLabel" name="lblGeneral">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -127,6 +128,7 @@
<widget class="QLabel" name="lblRecovery"> <widget class="QLabel" name="lblRecovery">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -257,6 +259,7 @@
<widget class="QLabel" name="lblMessages"> <widget class="QLabel" name="lblMessages">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -289,6 +292,7 @@
<widget class="QLabel" name="lblNotify"> <widget class="QLabel" name="lblNotify">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -422,6 +426,7 @@
<widget class="QLabel" name="lblStartMenu"> <widget class="QLabel" name="lblStartMenu">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -478,6 +483,7 @@
<widget class="QLabel" name="lblSysTray"> <widget class="QLabel" name="lblSysTray">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -498,6 +504,7 @@
<widget class="QLabel" name="lblRunBoxed"> <widget class="QLabel" name="lblRunBoxed">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -561,6 +568,7 @@
<widget class="QLabel" name="lblStartUp"> <widget class="QLabel" name="lblStartUp">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -834,6 +842,7 @@
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -948,43 +957,17 @@
<layout class="QGridLayout" name="gridLayout_32"> <layout class="QGridLayout" name="gridLayout_32">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_31"> <layout class="QGridLayout" name="gridLayout_31">
<item row="1" column="2"> <item row="3" column="1">
<widget class="QComboBox" name="cmbDPI"/> <widget class="QLabel" name="label_6">
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_23">
<property name="text"> <property name="text">
<string>High DPI Scaling</string> <string>Ini Editor Font</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="4" column="4">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Font Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_19"> <spacer name="horizontalSpacer_19">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -997,7 +980,111 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="1">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Font Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_23">
<property name="text">
<string>High DPI Scaling</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblDisplay">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Graphic Options</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cmbFontScale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2">
<spacer name="horizontalSpacer_18">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="4"> <item row="3" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btnSelectIniFont">
<property name="toolTip">
<string>Select font</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnResetIniFont">
<property name="toolTip">
<string>Reset font</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="6">
<spacer name="horizontalSpacer_20"> <spacer name="horizontalSpacer_20">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1010,28 +1097,14 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="3"> <item row="2" column="4">
<widget class="QLabel" name="label">
<property name="text">
<string>(Restart required)</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cmbFontScale">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
<property name="text"> <property name="text">
<string>%</string> <string>%</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<spacer name="verticalSpacer_10"> <spacer name="verticalSpacer_10">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -1044,31 +1117,22 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="1" column="2">
<widget class="QLabel" name="lblDisplay"> <widget class="QComboBox" name="cmbDPI"/>
<property name="font"> </item>
<font> <item row="1" column="4">
<bold>true</bold> <widget class="QLabel" name="label">
<kerning>true</kerning>
</font>
</property>
<property name="text"> <property name="text">
<string>Graphic Options</string> <string>(Restart required)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2"> <item row="3" column="2">
<spacer name="horizontalSpacer_18"> <widget class="QLabel" name="lblIniEditFont">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>#</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</item> </item>
@ -1086,7 +1150,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabsAddons"> <widget class="QTabWidget" name="tabsAddons">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tabAddonList"> <widget class="QWidget" name="tabAddonList">
<attribute name="title"> <attribute name="title">
@ -1226,6 +1290,7 @@
<widget class="QLabel" name="lblCertExp"> <widget class="QLabel" name="lblCertExp">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -1351,6 +1416,7 @@
<widget class="QLabel" name="lblUpdates"> <widget class="QLabel" name="lblUpdates">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -1582,6 +1648,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
<widget class="QLabel" name="lblBoxRoot"> <widget class="QLabel" name="lblBoxRoot">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -1694,6 +1761,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
<widget class="QLabel" name="lblBoxFeatures"> <widget class="QLabel" name="lblBoxFeatures">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -1785,6 +1853,7 @@ Unlike the preview channel, it does not include untested, potentially breaking,
<widget class="QLabel" name="lblProtection"> <widget class="QLabel" name="lblProtection">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
<kerning>true</kerning> <kerning>true</kerning>
</font> </font>
@ -2145,16 +2214,6 @@ Unlike the preview channel, it does not include untested, potentially breaking,
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QPushButton" name="btnEditIni">
<property name="text">
<string>Edit ini</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">
@ -2168,6 +2227,16 @@ Unlike the preview channel, it does not include untested, potentially breaking,
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0">
<widget class="QPushButton" name="btnEditIni">
<property name="text">
<string>Edit ini</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QPushButton" name="btnCancelEdit"> <widget class="QPushButton" name="btnCancelEdit">
<property name="enabled"> <property name="enabled">

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -175,6 +175,8 @@
<file>Actions/AntiVir.png</file> <file>Actions/AntiVir.png</file>
<file>Actions/SourceCode.png</file> <file>Actions/SourceCode.png</file>
<file>Actions/Qube.png</file> <file>Actions/Qube.png</file>
<file>Actions/Font.png</file>
<file>Actions/ResetFont.png</file>
</qresource> </qresource>
<qresource prefix="/Boxes"> <qresource prefix="/Boxes">
<file alias="Empty3">Boxes/sandbox-b-empty.png</file> <file alias="Empty3">Boxes/sandbox-b-empty.png</file>

View File

@ -532,6 +532,8 @@ COptionsWindow::COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QStri
connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab())); connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab()));
// edit // edit
ApplyIniEditFont();
connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni())); connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni()));
connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni())); connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni()));
connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit())); connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit()));
@ -625,6 +627,14 @@ COptionsWindow::COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QStri
m_pSearch->setPlaceholderText(tr("Search for options")); 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);
}
void COptionsWindow::OnSetTree() void COptionsWindow::OnSetTree()
{ {
if (!ui.tabs) return; if (!ui.tabs) return;

View File

@ -481,6 +481,8 @@ protected:
void LoadIniSection(); void LoadIniSection();
void SaveIniSection(); void SaveIniSection();
void ApplyIniEditFont();
QString GetCategoryName(const QString& Category); QString GetCategoryName(const QString& Category);
bool m_HoldChange; bool m_HoldChange;

View File

@ -13,6 +13,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include "../Wizards/TemplateWizard.h" #include "../Wizards/TemplateWizard.h"
#include "../AddonManager.h" #include "../AddonManager.h"
#include <qfontdialog.h>
#include <windows.h> #include <windows.h>
@ -493,6 +494,15 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab())); connect(ui.tabs, SIGNAL(currentChanged(int)), this, SLOT(OnTab()));
// Ini Edit // Ini Edit
ui.btnSelectIniFont->setIcon(CSandMan::GetIcon("Font"));
ui.btnSelectIniFont->setToolTip(tr("Select font"));
ui.btnResetIniFont->setIcon(CSandMan::GetIcon("ResetFont"));
ui.btnResetIniFont->setToolTip(tr("Reset font"));
ApplyIniEditFont();
connect(ui.btnSelectIniFont, SIGNAL(clicked(bool)), this, SLOT(OnSelectIniEditFont()));
connect(ui.btnResetIniFont, SIGNAL(clicked(bool)), this, SLOT(OnResetIniEditFont()));
connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni())); connect(ui.btnEditIni, SIGNAL(clicked(bool)), this, SLOT(OnEditIni()));
connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni())); connect(ui.btnSaveIni, SIGNAL(clicked(bool)), this, SLOT(OnSaveIni()));
connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit())); connect(ui.btnCancelEdit, SIGNAL(clicked(bool)), this, SLOT(OnCancelEdit()));
@ -538,6 +548,30 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
m_pSearch->setPlaceholderText(tr("Search for settings")); 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.lblIniEditFont->setText(tr("%0, %1 pt").arg(font.family()).arg(font.pointSizeF())); // tr: example: "Calibri, 9.5 pt"
}
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() void CSettingsWindow::OnSetTree()
{ {
if (!ui.tabs) return; if (!ui.tabs) return;

View File

@ -151,6 +151,9 @@ private slots:
void OnSetTree(); void OnSetTree();
void OnSelectIniEditFont();
void OnResetIniEditFont();
protected: protected:
void closeEvent(QCloseEvent *e); void closeEvent(QCloseEvent *e);
@ -171,6 +174,7 @@ protected:
void LoadIniSection(); void LoadIniSection();
void SaveIniSection(); void SaveIniSection();
void ApplyIniEditFont();
bool m_bRebuildUI; bool m_bRebuildUI;
bool m_HoldChange; bool m_HoldChange;