Allow customising the fixed/monospace font as well. Refs #2443

This commit is contained in:
baldurk committed 2022-01-12 11:24:22 +00:00
1 parent 83f4b0bfcc
commit 0620a8f114
7 files changed
+139 -53

No files matched your search

@@ -497,6 +497,12 @@ DECLARE_REFLECTION_STRUCT(BugReport);
"Defaults to an empty string which means to use the system default."); \
CONFIG_SETTING_VAL(public, QString, rdcstr, Font_Family, "") \
\
DOCUMENT( \
"The monospaced font family to use in the UI.\n" \
"\n" \
"Defaults to an empty string which means to use the system default."); \
CONFIG_SETTING_VAL(public, QString, rdcstr, Font_MonoFamily, "") \
\
DOCUMENT( \
"``True`` if a monospaced font should be used in all places where data is displayed, even " \
"if the data is not tabular such as names.\n" \
+19 -4
View File
@@ -2401,6 +2401,7 @@ QFont *Formatter::m_FixedFont = NULL;
float Formatter::m_FontBaseSize = 10.0f; // this should always be overridden below, but just in
// case let's pick a sensible value
QString Formatter::m_DefaultFontFamily;
QString Formatter::m_DefaultMonoFontFamily;
float Formatter::m_FixedFontBaseSize = 10.0f;
QColor Formatter::m_DarkChecker, Formatter::m_LightChecker;
@@ -2421,16 +2422,27 @@ void Formatter::setParams(const PersistantConfig &config)
m_FixedFont = new QFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
m_FixedFontBaseSize = m_FixedFont->pointSizeF();
m_DefaultFontFamily = QApplication::font().family();
m_DefaultMonoFontFamily = QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
}
// this is only used for display to the user
if(m_DefaultFontFamily.isEmpty())
m_DefaultFontFamily = lit("System font");
if(m_DefaultMonoFontFamily.isEmpty())
m_DefaultMonoFontFamily = lit("System font");
*m_Font =
config.Font_PreferMonospaced ? QFontDatabase::systemFont(QFontDatabase::FixedFont) : QFont();
if(!config.Font_Family.isEmpty())
m_Font->setFamily(config.Font_Family);
if(config.Font_PreferMonospaced)
{
*m_Font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
if(!config.Font_MonoFamily.isEmpty())
m_Font->setFamily(config.Font_MonoFamily);
}
else
{
*m_Font = QFont();
if(!config.Font_Family.isEmpty())
m_Font->setFamily(config.Font_Family);
}
m_Font->setPointSizeF(m_FontBaseSize * config.Font_GlobalScale);
QFont f = QApplication::font();
@@ -2439,6 +2451,9 @@ void Formatter::setParams(const PersistantConfig &config)
f.setFamily(config.Font_Family);
QApplication::setFont(f);
if(!config.Font_MonoFamily.isEmpty())
m_FixedFont->setFamily(config.Font_MonoFamily);
m_FixedFont->setPointSizeF(m_FixedFontBaseSize * config.Font_GlobalScale);
Formatter::setPalette(QApplication::palette());
+2 -1
View File
@@ -262,12 +262,13 @@ struct Formatter
static const QColor DarkCheckerColor() { return m_DarkChecker; }
static const QColor LightCheckerColor() { return m_LightChecker; }
static QString DefaultFontFamily() { return m_DefaultFontFamily; }
static QString DefaultMonoFontFamily() { return m_DefaultMonoFontFamily; }
private:
static int m_minFigures, m_maxFigures, m_expNegCutoff, m_expPosCutoff;
static double m_expNegValue, m_expPosValue;
static QFont *m_Font, *m_FixedFont;
static float m_FontBaseSize, m_FixedFontBaseSize;
static QString m_DefaultFontFamily;
static QString m_DefaultFontFamily, m_DefaultMonoFontFamily;
static QColor m_DarkChecker, m_LightChecker;
};
+63 -9
View File
@@ -47,9 +47,6 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
m_ReplayOptions = new ReplayOptionsSelector(m_Ctx, false, this);
QStringList fontFamilies = QFontDatabase().families();
fontFamilies.insert(0, tr("Default (%1)").arg(Formatter::DefaultFontFamily()));
ui->replayOptionsLayout->insertWidget(0, m_ReplayOptions);
QString styleChooseTooltip = ui->UIStyle->toolTip();
@@ -63,14 +60,13 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
for(int i = 0; i < StyleData::numAvailable; i++)
ui->UIStyle->addItem(StyleData::availStyles[i].styleName);
QFontDatabase fontdb;
QStringList fontFamilies = fontdb.families();
fontFamilies.insert(0, tr("Default (%1)").arg(Formatter::DefaultFontFamily()));
ui->Font_Family->addItems(fontFamilies);
ui->Font_GlobalScale->addItems({lit("50%"), lit("75%"), lit("100%"), lit("125%"), lit("150%"),
lit("175%"), lit("200%"), lit("250%"), lit("300%"), lit("400%")});
ui->Font_GlobalScale->setCurrentText(
QString::number(ceil(m_Ctx.Config().Font_GlobalScale * 100)) + lit("%"));
int curFontOption = -1;
for(int i = 0; i < ui->Font_Family->count(); i++)
{
@@ -86,6 +82,49 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
ui->Font_Family->setCurrentIndex(curFontOption);
// remove the default again
fontFamilies.removeAt(0);
// remove any non-fixed width fonts
for(int i = 0; i < fontFamilies.count();)
{
if(!fontdb.isFixedPitch(fontFamilies[i]))
{
fontFamilies.removeAt(i);
// check i again
continue;
}
// move to the next
i++;
}
// re-add the default
fontFamilies.insert(0, tr("Default (%1)").arg(Formatter::DefaultMonoFontFamily()));
ui->Font_MonoFamily->addItems(fontFamilies);
curFontOption = -1;
for(int i = 0; i < ui->Font_MonoFamily->count(); i++)
{
if(ui->Font_MonoFamily->itemText(i) == m_Ctx.Config().Font_MonoFamily)
{
curFontOption = i;
break;
}
}
if(m_Ctx.Config().Font_MonoFamily.isEmpty() || curFontOption < 0)
curFontOption = 0;
ui->Font_MonoFamily->setCurrentIndex(curFontOption);
ui->Font_GlobalScale->addItems({lit("50%"), lit("75%"), lit("100%"), lit("125%"), lit("150%"),
lit("175%"), lit("200%"), lit("250%"), lit("300%"), lit("400%")});
ui->Font_GlobalScale->setCurrentText(
QString::number(ceil(m_Ctx.Config().Font_GlobalScale * 100)) + lit("%"));
for(int i = 0; i < ui->Font_GlobalScale->count(); i++)
{
if(ui->Font_GlobalScale->currentText() == ui->Font_GlobalScale->itemText(i))
@@ -347,6 +386,21 @@ void SettingsDialog::on_Font_Family_currentIndexChanged(int index)
m_Ctx.Config().Save();
}
void SettingsDialog::on_Font_MonoFamily_currentIndexChanged(int index)
{
if(m_Init)
return;
if(index == 0)
m_Ctx.Config().Font_MonoFamily.clear();
else
m_Ctx.Config().Font_MonoFamily = ui->Font_MonoFamily->currentText();
m_Ctx.Config().SetupFormatting();
m_Ctx.Config().Save();
}
void SettingsDialog::on_Font_GlobalScale_currentIndexChanged(int index)
{
Font_GlobalScale_returnPressed();
@@ -57,6 +57,7 @@ private slots:
// general
void on_Font_Family_currentIndexChanged(int index);
void on_Font_MonoFamily_currentIndexChanged(int index);
void on_Font_GlobalScale_currentIndexChanged(int index);
void Font_GlobalScale_returnPressed();
void on_UIStyle_currentIndexChanged(int index);
+48 -34
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>564</width>
<height>554</height>
<height>580</height>
</rect>
</property>
<property name="windowTitle">
@@ -66,7 +66,7 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<property name="documentMode">
<bool>true</bool>
@@ -129,12 +129,26 @@
<property name="toolTip">
<string>The default font family to be used for text. This will be overridden by the default monospace font if the below option for monospace override is chosen.</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_21">
<property name="toolTip">
<string>The default font family to be used for monospaced text, typically code display or tables of buffer data. If the below option for monospace override is chosen this font will be used for those extra places.</string>
</property>
<property name="text">
<string>Monospaced font family (restart required)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="Font_MonoFamily">
<property name="toolTip">
<string>The default font family to be used for monospaced text, typically code display or tables of buffer data. If the below option for monospace override is chosen this font will be used for those extra places.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_27">
<property name="toolTip">
<string>A global scale for all fonts in the program. This will only scale text, icons and other UI elements will be scaled according to DPI settings as normal.</string>
@@ -144,7 +158,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="Font_GlobalScale">
<property name="toolTip">
<string>A global scale for all fonts in the program. This will only scale text, icons and other UI elements will be scaled according to DPI settings as normal.</string>
@@ -154,34 +168,34 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="toolTip">
<string>Wherever possible a monospaced font will be used instead of the default font</string>
<string>Prefer using a monospace font instead of the default font for places where resource names, action and marker names, and similar pieces of information are displayed.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;By default a monospaced font will only be used for places where fixed width is important such as code and numerical data displays.</string>
</property>
<property name="text">
<string>Prefer monospaced fonts in UI (restart required)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QCheckBox" name="Font_PreferMonospaced">
<property name="toolTip">
<string>Wherever possible a monospaced font will be used instead of the default font</string>
<string>Prefer using a monospace font instead of the default font for places where resource names, action and marker names, and similar pieces of information are displayed.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;By default a monospaced font will only be used for places where fixed width is important such as code and numerical data displays.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>At least this many decimal places will be displayed on floats.
@@ -192,7 +206,7 @@ e.g. a value of 2 means 0 will display as 0.00, 0.5 as 0.50. A value of 5 would
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QSpinBox" name="Formatter_MinFigures">
<property name="toolTip">
<string>Decimals will display at least this many digits.
@@ -203,7 +217,7 @@ e.g. a value of 2 means 0 will display as 0.00, 0.5 as 0.50</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>No more decimal places than this will be displayed on floats.
@@ -214,7 +228,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QSpinBox" name="Formatter_MaxFigures">
<property name="toolTip">
<string>No more decimal places than this will be displayed on floats.
@@ -225,7 +239,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345 and 123.123456789 wi
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>Any numbers smaller than this exponent will be displayed in scientific notation.
@@ -236,7 +250,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QSpinBox" name="Formatter_NegExp">
<property name="toolTip">
<string>Any numbers smaller than this exponent will be displayed in scientific notation.
@@ -247,7 +261,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="toolTip">
<string>Any numbers larger than this exponent will be displayed in scientific notation.
@@ -258,7 +272,7 @@ e.g. 1000 * 10 = 1e4</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QSpinBox" name="Formatter_PosExp">
<property name="toolTip">
<string>Any numbers larger than this exponent will be displayed in scientific notation.
@@ -272,7 +286,7 @@ e.g. 1000 * 10 = 1e4</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
@@ -284,7 +298,7 @@ Defaults to %TEMP%.</string>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLineEdit" name="tempDirectory">
<property name="toolTip">
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
@@ -293,7 +307,7 @@ Defaults to %TEMP%.</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QPushButton" name="browseTempCaptureDirectory">
<property name="toolTip">
<string>Changes the directory where capture files are saved after being created, until saved manually or deleted.
@@ -305,7 +319,7 @@ Defaults to %TEMP%.</string>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_6">
<property name="toolTip">
<string>Changes the default directory for the save dialog when saving capture files.
@@ -317,7 +331,7 @@ Defaults to blank, which follows system default behaviour.</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<widget class="QLineEdit" name="saveDirectory">
<property name="toolTip">
<string>Changes the default directory for the save dialog when saving capture files.
@@ -326,7 +340,7 @@ Defaults to blank, which follows system default behaviour.</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QPushButton" name="browseSaveCaptureDirectory">
<property name="toolTip">
<string>Changes the default directory for the save dialog when saving capture files.
@@ -338,7 +352,7 @@ Defaults to blank, which follows system default behaviour.</string>
</property>
</widget>
</item>
<item row="13" column="0">
<item row="14" column="0">
<widget class="QLabel" name="globalHookLabel">
<property name="toolTip">
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
@@ -353,7 +367,7 @@ Since this is a global system hook it must be used carefully and only when neces
</property>
</widget>
</item>
<item row="13" column="1">
<item row="14" column="1">
<widget class="QCheckBox" name="AllowGlobalHook">
<property name="toolTip">
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
@@ -368,7 +382,7 @@ Since this is a global system hook it must be used carefully and only when neces
</property>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QLabel" name="injectProcLabel">
<property name="toolTip">
<string>Enables the ability to inject into processes on windows.
@@ -382,7 +396,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QCheckBox" name="AllowProcessInject">
<property name="toolTip">
<string>Enables the ability to inject into processes on windows.
@@ -396,7 +410,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions.</string>
@@ -406,7 +420,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QCheckBox" name="CheckUpdate_AllowChecks">
<property name="toolTip">
<string>Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions.</string>
@@ -416,7 +430,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
</property>
</widget>
</item>
<item row="16" column="0">
<item row="17" column="0">
<widget class="QLabel" name="label_10">
<property name="toolTip">
<string>If a capture is marked as being created on a significantly different system (different OS or platform)
@@ -429,7 +443,7 @@ This option overrides that and will always replay locally if the local context i
</property>
</widget>
</item>
<item row="16" column="1">
<item row="17" column="1">
<widget class="QCheckBox" name="AlwaysReplayLocally">
<property name="toolTip">
<string>If a capture is marked as being created on a significantly different system (different OS or platform)
@@ -442,7 +456,7 @@ This option overrides that and will always replay locally if the local context i
</property>
</widget>
</item>
<item row="17" column="1">
<item row="18" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
-5
View File
@@ -1068,11 +1068,6 @@ See FAQ on &quot;Gamma display of linear data&quot;</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Consolas</family>
</font>
</property>
<property name="text">
<string>texStatusName</string>
</property>