Skip to content

Commit

Permalink
Expose UI/Fonts/* settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rpallai committed Aug 31, 2019
1 parent de0fbae commit dc6d5f2
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ Some settings exposed in UI (Settings and View menus):
If a tag is not mentioned and does not fit any namespace, it will be put at
the end in lexicographic order. Tags within the same namespace are also
ordered lexicographically.
- `UI/Fonts/family` - override the font family for the whole application.
If not specified, the default font for your environment is used.
- `UI/Fonts/pointSize` - override the font size (in points) for the whole
application. If not specified, the default size for your environment is used.
- `UI/Fonts/timeline_family` - font family (for example `Monospace`) to
display messages in the timeline. If not specified, the application-wide font
family is used.
- `UI/Fonts/timeline_pointSize` - font size (in points) to display messages
in the timeline. If not specified, the application-wide point size is used.

Settings not exposed in UI:

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

Since version 0.0.9.4, AppImage binaries for Linux and .dmg files for macOS
are compiled with Qt Keychain support. It means that Quaternion will try
Expand Down
75 changes: 75 additions & 0 deletions client/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QTabWidget>
#include <QVBoxLayout>
#include <QDialog>
#include <QFontComboBox>

using Quotient::SettingsGroup;

Expand Down Expand Up @@ -59,6 +60,42 @@ GeneralPage::GeneralPage(SettingsDialog *parent):
{
Ui_GeneralPage::setupUi(this);

// uiFont
const auto curUIFontFamily = SettingsGroup("UI").value("Fonts/family", "").toString();
uiFontFamily->insertItem(0, tr("system default"));
if (curUIFontFamily == "") {
uiFontFamily->setCurrentIndex(0);
uiFontPointSize->setDisabled(true);
} else {
uiFontFamily->setCurrentIndex(uiFontFamily->findText(curUIFontFamily));
}

connect(uiFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &font) {
QString value;
if (font.family() == tr("system default")) {
uiFontPointSize->setDisabled(true);
SettingsGroup("UI").setValue("Fonts/pointSize", "");
value = "";
} else {
uiFontPointSize->setDisabled(false);
if (uiFontPointSize->currentIndex() == -1) {
uiFontPointSize->setCurrentIndex(3);
SettingsGroup("UI").setValue("Fonts/pointSize", "9");
}
value = font.family();
}
SettingsGroup("UI").setValue("Fonts/family", value);
});

for (int i = 6; i <= 18; i++)
uiFontPointSize->addItem(QString::number(i));
const auto curUIFontPointSize = SettingsGroup("UI").value("Fonts/pointSize", "");
uiFontPointSize->setCurrentIndex(curUIFontPointSize.toInt() - 6);

connect(uiFontPointSize, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this, [this](const QString &text) {
SettingsGroup("UI").setValue("Fonts/pointSize", text);
});

// closeToTray
closeToTray->setChecked(SettingsGroup("UI").value("close_to_tray", false).toBool());
connect(closeToTray, &QAbstractButton::toggled, this, [=](bool checked) {
Expand All @@ -78,6 +115,44 @@ GeneralPage::GeneralPage(SettingsDialog *parent):
emit timelineChanged();
});

// timelineFont
const auto curTimelineFontFamily = SettingsGroup("UI").value("Fonts/timeline_family", "").toString();
timelineFontFamily->insertItem(0, tr("system default"));
if (curTimelineFontFamily == "") {
timelineFontFamily->setCurrentIndex(0);
timelineFontPointSize->setDisabled(true);
} else {
timelineFontFamily->setCurrentIndex(timelineFontFamily->findText(curTimelineFontFamily));
}

connect(timelineFontFamily, &QFontComboBox::currentFontChanged, this, [this](const QFont &font) {
QString value;
if (font.family() == tr("system default")) {
timelineFontPointSize->setDisabled(true);
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", "");
value = "";
} else {
timelineFontPointSize->setDisabled(false);
if (timelineFontPointSize->currentIndex() == -1) {
timelineFontPointSize->setCurrentIndex(3);
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", "9");
}
value = font.family();
}
SettingsGroup("UI").setValue("Fonts/timeline_family", value);
emit timelineChanged();
});

for (int i = 6; i <= 18; i++)
timelineFontPointSize->addItem(QString::number(i));
const auto curTimelineFontPointSize = SettingsGroup("UI").value("Fonts/timeline_pointSize", "");
timelineFontPointSize->setCurrentIndex(curTimelineFontPointSize.toInt() - 6);

connect(timelineFontPointSize, QOverload<const QString &>::of(&QComboBox::currentIndexChanged), this, [this](const QString &text) {
SettingsGroup("UI").setValue("Fonts/timeline_pointSize", text);
emit timelineChanged();
});

// useShuttleScrollbar
useShuttleScrollbar->setChecked(SettingsGroup("UI").value("use_shuttle_dial", true).toBool());
connect(useShuttleScrollbar, &QAbstractButton::toggled, this, [=](bool checked) {
Expand Down
46 changes: 46 additions & 0 deletions client/settingsgeneralpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>UI font</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QFontComboBox" name="uiFontFamily"/>
</item>
<item>
<widget class="QComboBox" name="uiFontPointSize">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="closeToTray">
<property name="toolTip">
Expand Down Expand Up @@ -96,6 +121,27 @@
<item row="0" column="1">
<widget class="QComboBox" name="timeline_layout"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QFontComboBox" name="timelineFontFamily"/>
</item>
<item>
<widget class="QComboBox" name="timelineFontPointSize">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit dc6d5f2

Please sign in to comment.