Skip to content

Commit cf4ba05

Browse files
committed
Expose UI/Fonts/* settings
1 parent de0fbae commit cf4ba05

File tree

3 files changed

+133
-9
lines changed

3 files changed

+133
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ Some settings exposed in UI (Settings and View menus):
162162
If a tag is not mentioned and does not fit any namespace, it will be put at
163163
the end in lexicographic order. Tags within the same namespace are also
164164
ordered lexicographically.
165+
- `UI/Fonts/family` - override the font family for the whole application.
166+
If not specified, the default font for your environment is used.
167+
- `UI/Fonts/pointSize` - override the font size (in points) for the whole
168+
application. If not specified, the default size for your environment is used.
169+
- `UI/Fonts/timeline_family` - font family (for example `Monospace`) to
170+
display messages in the timeline. If not specified, the application-wide font
171+
family is used.
172+
- `UI/Fonts/timeline_pointSize` - font size (in points) to display messages
173+
in the timeline. If not specified, the application-wide point size is used.
165174

166175
Settings not exposed in UI:
167176

@@ -194,15 +203,6 @@ Settings not exposed in UI:
194203
the beginning and end of the quote. By default it's `(.+)(?:\n|$)`.
195204
- `UI/Fonts/render_type` - select how to render fonts in Quaternion timeline;
196205
possible values are "NativeRendering" (default) and "QtRendering".
197-
- `UI/Fonts/family` - override the font family for the whole application.
198-
If not specified, the default font for your environment is used.
199-
- `UI/Fonts/pointSize` - override the font size (in points) for the whole
200-
application. If not specified, the default size for your environment is used.
201-
- `UI/Fonts/timeline_family` - font family (for example `Monospace`) to
202-
display messages in the timeline. If not specified, the application-wide font
203-
family is used.
204-
- `UI/Fonts/timeline_pointSize` - font size (in points) to display messages
205-
in the timeline. If not specified, the application-wide point size is used.
206206

207207
Since version 0.0.9.4, AppImage binaries for Linux and .dmg files for macOS
208208
are compiled with Qt Keychain support. It means that Quaternion will try

client/settingsdialog.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <QTabWidget>
2525
#include <QVBoxLayout>
2626
#include <QDialog>
27+
#include <QFontComboBox>
2728

2829
using Quotient::SettingsGroup;
2930

@@ -59,6 +60,42 @@ GeneralPage::GeneralPage(SettingsDialog *parent):
5960
{
6061
Ui_GeneralPage::setupUi(this);
6162

63+
// uiFont
64+
const auto curUIFontFamily = SettingsGroup("UI").value("Fonts/family", "").toString();
65+
uiFontFamily->insertItem(0, tr("system default"));
66+
if (curUIFontFamily == "") {
67+
uiFontFamily->setCurrentIndex(0);
68+
uiFontPointSize->setDisabled(true);
69+
} else {
70+
uiFontFamily->setCurrentIndex(uiFontFamily->findText(curUIFontFamily));
71+
}
72+
73+
connect(uiFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &font) {
74+
QString value;
75+
if (font.family() == tr("system default")) {
76+
uiFontPointSize->setDisabled(true);
77+
SettingsGroup("UI").setValue("Fonts/pointSize", "");
78+
value = "";
79+
} else {
80+
uiFontPointSize->setDisabled(false);
81+
if (uiFontPointSize->currentIndex() == -1) {
82+
uiFontPointSize->setCurrentIndex(3);
83+
SettingsGroup("UI").setValue("Fonts/pointSize", "9");
84+
}
85+
value = font.family();
86+
}
87+
SettingsGroup("UI").setValue("Fonts/family", value);
88+
});
89+
90+
for (int i = 6; i <= 18; i++)
91+
uiFontPointSize->addItem(QString::number(i));
92+
const auto curUIFontPointSize = SettingsGroup("UI").value("Fonts/pointSize", "");
93+
uiFontPointSize->setCurrentIndex(curUIFontPointSize.toInt() - 6);
94+
95+
connect(uiFontPointSize, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this, [this](const QString &text) {
96+
SettingsGroup("UI").setValue("Fonts/pointSize", text);
97+
});
98+
6299
// closeToTray
63100
closeToTray->setChecked(SettingsGroup("UI").value("close_to_tray", false).toBool());
64101
connect(closeToTray, &QAbstractButton::toggled, this, [=](bool checked) {
@@ -78,6 +115,44 @@ GeneralPage::GeneralPage(SettingsDialog *parent):
78115
emit timelineChanged();
79116
});
80117

118+
// timelineFont
119+
const auto curTimelineFontFamily = SettingsGroup("UI").value("Fonts/timeline_family", "").toString();
120+
timelineFontFamily->insertItem(0, tr("system default"));
121+
if (curTimelineFontFamily == "") {
122+
timelineFontFamily->setCurrentIndex(0);
123+
timelineFontPointSize->setDisabled(true);
124+
} else {
125+
timelineFontFamily->setCurrentIndex(timelineFontFamily->findText(curTimelineFontFamily));
126+
}
127+
128+
connect(timelineFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &font) {
129+
QString value;
130+
if (font.family() == tr("system default")) {
131+
timelineFontPointSize->setDisabled(true);
132+
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", "");
133+
value = "";
134+
} else {
135+
timelineFontPointSize->setDisabled(false);
136+
if (timelineFontPointSize->currentIndex() == -1) {
137+
timelineFontPointSize->setCurrentIndex(3);
138+
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", "9");
139+
}
140+
value = font.family();
141+
}
142+
SettingsGroup("UI").setValue("Fonts/timeline_family", value);
143+
emit timelineChanged();
144+
});
145+
146+
for (int i = 6; i <= 18; i++)
147+
timelineFontPointSize->addItem(QString::number(i));
148+
const auto curTimelineFontPointSize = SettingsGroup("UI").value("Fonts/timeline_pointSize", "");
149+
timelineFontPointSize->setCurrentIndex(curTimelineFontPointSize.toInt() - 6);
150+
151+
connect(timelineFontPointSize, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this, [this](const QString &text) {
152+
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", text);
153+
emit timelineChanged();
154+
});
155+
81156
// useShuttleScrollbar
82157
useShuttleScrollbar->setChecked(SettingsGroup("UI").value("use_shuttle_dial", true).toBool());
83158
connect(useShuttleScrollbar, &QAbstractButton::toggled, this, [=](bool checked) {

client/settingsgeneralpage.ui

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,34 @@
4242
</property>
4343
</widget>
4444
</item>
45+
<item>
46+
<layout class="QFormLayout" name="formLayout_2">
47+
<property name="fieldGrowthPolicy">
48+
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
49+
</property>
50+
<item row="0" column="0">
51+
<widget class="QLabel" name="label_5">
52+
<property name="text">
53+
<string>UI font</string>
54+
</property>
55+
</widget>
56+
</item>
57+
<item row="0" column="1">
58+
<layout class="QHBoxLayout" name="horizontalLayout_2">
59+
<item>
60+
<widget class="QFontComboBox" name="uiFontFamily"/>
61+
</item>
62+
<item>
63+
<widget class="QComboBox" name="uiFontPointSize">
64+
<property name="editable">
65+
<bool>false</bool>
66+
</property>
67+
</widget>
68+
</item>
69+
</layout>
70+
</item>
71+
</layout>
72+
</item>
4573
<item>
4674
<widget class="QCheckBox" name="closeToTray">
4775
<property name="toolTip">
@@ -96,6 +124,27 @@
96124
<item row="0" column="1">
97125
<widget class="QComboBox" name="timeline_layout"/>
98126
</item>
127+
<item row="1" column="0">
128+
<widget class="QLabel" name="label_6">
129+
<property name="text">
130+
<string>Font</string>
131+
</property>
132+
</widget>
133+
</item>
134+
<item row="1" column="1">
135+
<layout class="QHBoxLayout" name="horizontalLayout_3">
136+
<item>
137+
<widget class="QFontComboBox" name="timelineFontFamily"/>
138+
</item>
139+
<item>
140+
<widget class="QComboBox" name="timelineFontPointSize">
141+
<property name="editable">
142+
<bool>false</bool>
143+
</property>
144+
</widget>
145+
</item>
146+
</layout>
147+
</item>
99148
</layout>
100149
</item>
101150
<item>

0 commit comments

Comments
 (0)