diff --git a/app/main.cpp b/app/main.cpp index 5d036606..67e90f0c 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -101,9 +101,11 @@ auto main(int argc, char *argv[]) -> int QGuiApplication::setWindowIcon(QIcon(u":/resources/icons/icon.png"_s)); setPalette(); -#if defined(Q_OS_WIN) - QGuiApplication::setFont(QFont("Segoe UI")); -#endif // if defined(Q_OS_WIN) + QFontDatabase::addApplicationFont(u":/resources/fonts/Inter-Regular.ttf"_s); + QFontDatabase::addApplicationFont(u":/resources/fonts/OpenDyslexic3-Regular.ttf"_s); + QGuiApplication::setFont(QFont(SettingsManager::instance()->get("font", u"Inter"_s))); + QObject::connect(Quick::SettingsManager::instance(), &Quick::SettingsManager::fontChanged, &app, + [](const QString &font) { QGuiApplication::setFont(QFont(font)); }); const Logger logger; diff --git a/app/ui/CMakeLists.txt b/app/ui/CMakeLists.txt index 7191b6f8..73974994 100644 --- a/app/ui/CMakeLists.txt +++ b/app/ui/CMakeLists.txt @@ -10,6 +10,8 @@ qt_add_resources(gm-companion-ui "ui-resources" PREFIX "/" FILES resources/splash.jpg + resources/fonts/Inter-Regular.ttf + resources/fonts/OpenDyslexic3-Regular.ttf resources/icons/icon.png resources/icons/dice/d4.png resources/icons/dice/d6.png diff --git a/app/ui/Main.qml b/app/ui/Main.qml index e2b9d02a..c4929f07 100644 --- a/app/ui/Main.qml +++ b/app/ui/Main.qml @@ -65,6 +65,14 @@ ApplicationWindow { } } + Connections { + target: SettingsManager + + function onFontChanged() { + loader.reload(); + } + } + UpdateDialog { id: update_dialog } @@ -198,5 +206,10 @@ ApplicationWindow { active: true onLoaded: splash.close() + + function reload() { + active = false; + active = true; + } } } diff --git a/app/ui/resources/fonts/Inter-Regular.ttf b/app/ui/resources/fonts/Inter-Regular.ttf new file mode 100644 index 00000000..c544be47 Binary files /dev/null and b/app/ui/resources/fonts/Inter-Regular.ttf differ diff --git a/app/ui/resources/fonts/OpenDyslexic3-Regular.ttf b/app/ui/resources/fonts/OpenDyslexic3-Regular.ttf new file mode 100644 index 00000000..0ff4c0b5 Binary files /dev/null and b/app/ui/resources/fonts/OpenDyslexic3-Regular.ttf differ diff --git a/app/ui/tools/settings/GeneralPage.qml b/app/ui/tools/settings/GeneralPage.qml index 0315c2c9..17d10412 100644 --- a/app/ui/tools/settings/GeneralPage.qml +++ b/app/ui/tools/settings/GeneralPage.qml @@ -35,6 +35,7 @@ SplitView { spacing: 10 Label { + id: language_label text: qsTr("Select Language") width: Math.max(implicitWidth, language_box.width) anchors.verticalCenter: parent.verticalCenter @@ -60,6 +61,35 @@ SplitView { } } + Row { + spacing: 10 + + Label { + text: qsTr("Select Font") + width: language_label.width + anchors.verticalCenter: parent.verticalCenter + } + + ComboBox { + id: font_box + + property bool loaded: false + + model: SettingsManager.availableFonts + + onCurrentTextChanged: { + if (loaded) { + SettingsManager.font = currentText; + } + } + + Component.onCompleted: { + currentIndex = SettingsManager.availableFonts.indexOf(SettingsManager.font); + loaded = true; + } + } + } + // Show Tool Names CheckBox { text: qsTr("Show tool names in menu") diff --git a/app/ui/tools/settings/InfoPage.qml b/app/ui/tools/settings/InfoPage.qml index 0d4cad85..3826e65b 100644 --- a/app/ui/tools/settings/InfoPage.qml +++ b/app/ui/tools/settings/InfoPage.qml @@ -72,8 +72,7 @@ Item { Label { id: credits_label - text: qsTr( - "Credits - Open Source projects and other resources used by this application") + text: qsTr("Credits - Open Source projects and other resources used by this application") font.pointSize: 12 anchors.top: parent.top anchors.left: parent.left @@ -119,13 +118,6 @@ Item { links: [["Skoll", "https://game-icons.net"], ["Delapouite", "https://delapouite.com"], ["Lorc", "https://lorcblog.blogspot.com"], ["Cathelineau", "https://game-icons.net"]] } - CreditsItem { - title: "QML IconFonts" - description: qsTr("Use icon fonts in QML") - license: [["Font Awesome: SIL OFL 1.1", "https://scripts.sil.org/OFL"], ["Library: GPLv3", "https://www.gnu.org/licenses/gpl-3.0.en.html"]] - links: [[qsTr("qml-icon-fonts"), "https://github.com/PhilInTheGaps/qml-icon-fonts"], ["FontAwesome", "https://fontawesome.com"]] - } - CreditsItem { title: "http-status-codes-cpp" description: qsTr("HTTP Status Codes and Reason Phrases for C, C++ and Qt") @@ -133,6 +125,13 @@ Item { links: [["j-ulrich/http-status-codes-cpp", "https://github.com/j-ulrich/http-status-codes-cpp"]] } + CreditsItem { + title: "Inter" + description: qsTr("The Inter font family") + license: [["SIL OFL 1.1", "https://github.com/rsms/inter/blob/master/LICENSE.txt"]] + links: [["Website", "https://rsms.me/inter/"], ["GitHub", "https://github.com/rsms/inter"]] + } + CreditsItem { title: "Librespot" description: qsTr("Open Source Spotify client library") @@ -154,6 +153,20 @@ Item { links: [["GitHub", "https://github.com/pipacs/o2"], ["pipacs", "https://github.com/pipacs"]] } + CreditsItem { + title: "OpenDyslexic" + description: qsTr("A typeface for Dyslexia") + license: [["SIL OFL 1.1", "https://github.com/antijingoist/opendyslexic/blob/master/OFL.txt"]] + links: [["Website", "https://opendyslexic.org/"], ["GitHub", "https://github.com/antijingoist/opendyslexic"]] + } + + CreditsItem { + title: "QML IconFonts" + description: qsTr("Use icon fonts in QML") + license: [["Font Awesome: SIL OFL 1.1", "https://scripts.sil.org/OFL"], ["Library: GPLv3", "https://www.gnu.org/licenses/gpl-3.0.en.html"]] + links: [[qsTr("qml-icon-fonts"), "https://github.com/PhilInTheGaps/qml-icon-fonts"], ["FontAwesome", "https://fontawesome.com"]] + } + CreditsItem { title: "Qt Project" description: qsTr("A C++ toolkit for cross-platform application development.") diff --git a/src/common/settings/quick/settingsmanager.h b/src/common/settings/quick/settingsmanager.h index fbd839c6..bbc64198 100644 --- a/src/common/settings/quick/settingsmanager.h +++ b/src/common/settings/quick/settingsmanager.h @@ -33,6 +33,9 @@ class SettingsManager : public QObject SETTINGS_PROPERTY(QString, cloudMode, QStringLiteral("local")) READ_PROPERTY2(QString, languageBcp47, Common::Settings::SettingsManager::instance()->getLanguageBcp47()) + SETTINGS_PROPERTY(QString, font, QStringLiteral("Inter")) + READONLY_PROPERTY2(QStringList, availableFonts, QStringList({"Inter", "OpenDyslexic3"})) + #ifdef NO_UPDATE_CHECK SETTINGS_PROPERTY_VAL2(bool, checkForUpdates, false, "Updates") #else