mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Allow customising the font family. Closes #2443
This commit is contained in:
@@ -491,6 +491,12 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
"Defaults to ``1.0`` which means 100%."); \
|
||||
CONFIG_SETTING_VAL(public, float, float, Font_GlobalScale, 1.0f) \
|
||||
\
|
||||
DOCUMENT( \
|
||||
"The 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_Family, "") \
|
||||
\
|
||||
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" \
|
||||
|
||||
@@ -2400,6 +2400,7 @@ QFont *Formatter::m_Font = NULL;
|
||||
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;
|
||||
float Formatter::m_FixedFontBaseSize = 10.0f;
|
||||
QColor Formatter::m_DarkChecker, Formatter::m_LightChecker;
|
||||
|
||||
@@ -2419,14 +2420,23 @@ void Formatter::setParams(const PersistantConfig &config)
|
||||
m_FontBaseSize = QApplication::font().pointSizeF();
|
||||
m_FixedFont = new QFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
m_FixedFontBaseSize = m_FixedFont->pointSizeF();
|
||||
m_DefaultFontFamily = QApplication::font().family();
|
||||
}
|
||||
|
||||
// this is only used for display to the user
|
||||
if(m_DefaultFontFamily.isEmpty())
|
||||
m_DefaultFontFamily = lit("System font");
|
||||
|
||||
*m_Font =
|
||||
config.Font_PreferMonospaced ? QFontDatabase::systemFont(QFontDatabase::FixedFont) : QFont();
|
||||
if(!config.Font_Family.isEmpty())
|
||||
m_Font->setFamily(config.Font_Family);
|
||||
|
||||
m_Font->setPointSizeF(m_FontBaseSize * config.Font_GlobalScale);
|
||||
QFont f = QApplication::font();
|
||||
f.setPointSizeF(m_FontBaseSize * config.Font_GlobalScale);
|
||||
if(!config.Font_Family.isEmpty())
|
||||
f.setFamily(config.Font_Family);
|
||||
QApplication::setFont(f);
|
||||
|
||||
m_FixedFont->setPointSizeF(m_FixedFontBaseSize * config.Font_GlobalScale);
|
||||
|
||||
@@ -261,11 +261,13 @@ struct Formatter
|
||||
static const QFont &FixedFont() { return *m_FixedFont; }
|
||||
static const QColor DarkCheckerColor() { return m_DarkChecker; }
|
||||
static const QColor LightCheckerColor() { return m_LightChecker; }
|
||||
static QString DefaultFontFamily() { return m_DefaultFontFamily; }
|
||||
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 QColor m_DarkChecker, m_LightChecker;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "SettingsDialog.h"
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <QFontDatabase>
|
||||
#include <QKeyEvent>
|
||||
#include <QTextEdit>
|
||||
#include <QToolButton>
|
||||
@@ -46,6 +47,9 @@ 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();
|
||||
@@ -59,12 +63,29 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent)
|
||||
for(int i = 0; i < StyleData::numAvailable; i++)
|
||||
ui->UIStyle->addItem(StyleData::availStyles[i].styleName);
|
||||
|
||||
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++)
|
||||
{
|
||||
if(ui->Font_Family->itemText(i) == m_Ctx.Config().Font_Family)
|
||||
{
|
||||
curFontOption = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_Ctx.Config().Font_Family.isEmpty() || curFontOption < 0)
|
||||
curFontOption = 0;
|
||||
|
||||
ui->Font_Family->setCurrentIndex(curFontOption);
|
||||
|
||||
for(int i = 0; i < ui->Font_GlobalScale->count(); i++)
|
||||
{
|
||||
if(ui->Font_GlobalScale->currentText() == ui->Font_GlobalScale->itemText(i))
|
||||
@@ -311,6 +332,21 @@ void SettingsDialog::on_okButton_accepted()
|
||||
accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_Font_Family_currentIndexChanged(int index)
|
||||
{
|
||||
if(m_Init)
|
||||
return;
|
||||
|
||||
if(index == 0)
|
||||
m_Ctx.Config().Font_Family.clear();
|
||||
else
|
||||
m_Ctx.Config().Font_Family = ui->Font_Family->currentText();
|
||||
|
||||
m_Ctx.Config().SetupFormatting();
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_Font_GlobalScale_currentIndexChanged(int index)
|
||||
{
|
||||
Font_GlobalScale_returnPressed();
|
||||
|
||||
@@ -56,6 +56,7 @@ private slots:
|
||||
void on_okButton_accepted();
|
||||
|
||||
// general
|
||||
void on_Font_Family_currentIndexChanged(int index);
|
||||
void on_Font_GlobalScale_currentIndexChanged(int index);
|
||||
void Font_GlobalScale_returnPressed();
|
||||
void on_UIStyle_currentIndexChanged(int index);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>564</width>
|
||||
<height>530</height>
|
||||
<height>554</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -115,6 +115,26 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_20">
|
||||
<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="text">
|
||||
<string>Default font family (restart required)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="Font_Family">
|
||||
<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_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>
|
||||
@@ -124,7 +144,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" 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>
|
||||
@@ -134,7 +154,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" 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>
|
||||
@@ -144,7 +164,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" 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>
|
||||
@@ -154,14 +174,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
<string>At least this many decimal places will be displayed on floats.
|
||||
@@ -172,7 +192,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="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="Formatter_MinFigures">
|
||||
<property name="toolTip">
|
||||
<string>Decimals will display at least this many digits.
|
||||
@@ -183,7 +203,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="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string>No more decimal places than this will be displayed on floats.
|
||||
@@ -194,7 +214,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="Formatter_MaxFigures">
|
||||
<property name="toolTip">
|
||||
<string>No more decimal places than this will be displayed on floats.
|
||||
@@ -205,7 +225,7 @@ e.g. a value of 5 means 0.123456789 will display as 0.12345 and 123.123456789 wi
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="toolTip">
|
||||
<string>Any numbers smaller than this exponent will be displayed in scientific notation.
|
||||
@@ -216,7 +236,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="Formatter_NegExp">
|
||||
<property name="toolTip">
|
||||
<string>Any numbers smaller than this exponent will be displayed in scientific notation.
|
||||
@@ -227,7 +247,7 @@ E.g. a value of 3 means 0.005 / 10 = 5E-4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string>Any numbers larger than this exponent will be displayed in scientific notation.
|
||||
@@ -238,7 +258,7 @@ e.g. 1000 * 10 = 1e4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QSpinBox" name="Formatter_PosExp">
|
||||
<property name="toolTip">
|
||||
<string>Any numbers larger than this exponent will be displayed in scientific notation.
|
||||
@@ -252,7 +272,7 @@ e.g. 1000 * 10 = 1e4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" 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.
|
||||
@@ -264,7 +284,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="10" 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.
|
||||
@@ -273,7 +293,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="10" 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.
|
||||
@@ -285,7 +305,7 @@ Defaults to %TEMP%.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -297,7 +317,7 @@ Defaults to blank, which follows system default behaviour.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QLineEdit" name="saveDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -306,7 +326,7 @@ Defaults to blank, which follows system default behaviour.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<item row="12" column="1">
|
||||
<widget class="QPushButton" name="browseSaveCaptureDirectory">
|
||||
<property name="toolTip">
|
||||
<string>Changes the default directory for the save dialog when saving capture files.
|
||||
@@ -318,7 +338,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="QLabel" name="globalHookLabel">
|
||||
<property name="toolTip">
|
||||
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
|
||||
@@ -333,7 +353,7 @@ Since this is a global system hook it must be used carefully and only when neces
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<item row="13" column="1">
|
||||
<widget class="QCheckBox" name="AllowGlobalHook">
|
||||
<property name="toolTip">
|
||||
<string>Enables functionality on the capture application window that will insert RenderDoc automatically
|
||||
@@ -348,7 +368,7 @@ Since this is a global system hook it must be used carefully and only when neces
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="injectProcLabel">
|
||||
<property name="toolTip">
|
||||
<string>Enables the ability to inject into processes on windows.
|
||||
@@ -362,7 +382,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<item row="14" column="1">
|
||||
<widget class="QCheckBox" name="AllowProcessInject">
|
||||
<property name="toolTip">
|
||||
<string>Enables the ability to inject into processes on windows.
|
||||
@@ -376,7 +396,7 @@ program should be launched through RenderDoc via the Launch Process panel.</stri
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<item row="15" 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>
|
||||
@@ -386,7 +406,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="CheckUpdate_AllowChecks">
|
||||
<property name="toolTip">
|
||||
<string>Allows RenderDoc to phone home to https://renderdoc.org to anonymously check for new versions.</string>
|
||||
@@ -396,7 +416,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_10">
|
||||
<property name="toolTip">
|
||||
<string>If a capture is marked as being created on a significantly different system (different OS or platform)
|
||||
@@ -409,7 +429,7 @@ This option overrides that and will always replay locally if the local context i
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<item row="16" 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)
|
||||
@@ -422,7 +442,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">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
||||
Reference in New Issue
Block a user