From dc6d5f2a1b704a02c5b71451132b02ab4f73d003 Mon Sep 17 00:00:00 2001 From: Roland Pallai Date: Sat, 31 Aug 2019 18:18:02 +0200 Subject: [PATCH] Expose UI/Fonts/* settings --- README.md | 18 ++++----- client/settingsdialog.cpp | 75 +++++++++++++++++++++++++++++++++++ client/settingsgeneralpage.ui | 46 +++++++++++++++++++++ 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index acc915cf5..469e882e8 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/client/settingsdialog.cpp b/client/settingsdialog.cpp index 693c70bcf..465177e01 100644 --- a/client/settingsdialog.cpp +++ b/client/settingsdialog.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using Quotient::SettingsGroup; @@ -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::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) { @@ -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::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) { diff --git a/client/settingsgeneralpage.ui b/client/settingsgeneralpage.ui index 5291039a8..c1a732568 100644 --- a/client/settingsgeneralpage.ui +++ b/client/settingsgeneralpage.ui @@ -42,6 +42,31 @@ + + + + + + UI font + + + + + + + + + + + + false + + + + + + + @@ -96,6 +121,27 @@ + + + + Font + + + + + + + + + + + + false + + + + +