From 2c13aa8076391d471ae3d434d0410b9c573c986a Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 4 Oct 2021 12:59:01 +0200 Subject: [ui] workarounds for font in osx --- gui/components/Footer.qml | 10 +++++++++- gui/components/Locations.qml | 3 ++- gui/components/MainView.qml | 8 ++++++-- gui/components/Splash.qml | 2 +- gui/components/VPNState.qml | 2 +- gui/gui.qrc | 1 + gui/main.cpp | 7 +++++++ gui/main.qml | 13 ++++++++++++- gui/qtquickcontrols2.conf | 6 ++++++ gui/resources/fonts/Roboto-Bold.ttf | Bin 0 -> 167336 bytes 10 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 gui/resources/fonts/Roboto-Bold.ttf diff --git a/gui/components/Footer.qml b/gui/components/Footer.qml index 71477b4..11f5114 100644 --- a/gui/components/Footer.qml +++ b/gui/components/Footer.qml @@ -11,7 +11,7 @@ ToolBar { Material.background: Theme.bgColor Material.foreground: "black" Material.elevation: 0 - visible: stackView.depth > 1 && ctx !== undefined ? false : true + visible: isFooterVisible() Item { @@ -186,4 +186,12 @@ ToolBar { return false } } + + function isFooterVisible() { + console.debug(stackView.depth) + if (stackView.depth > 1) { + return false + } + return true + } } diff --git a/gui/components/Locations.qml b/gui/components/Locations.qml index a93700a..097f9fe 100644 --- a/gui/components/Locations.qml +++ b/gui/components/Locations.qml @@ -60,6 +60,7 @@ ThemedPage { id: recommendedLabel //: Location Selection: label for radio button that selects automatically text: qsTr("Recommended") + font.weight: Font.Bold font.bold: true } WrappedRadioButton { @@ -203,7 +204,7 @@ ThemedPage { } }, State { - when: ctx && ctx.status == "on" + when: ctx != undefined && ctx.status == "on" PropertyChanges { target: manualLabel text: manualSelectionLabel diff --git a/gui/components/MainView.qml b/gui/components/MainView.qml index 95bb212..c103565 100644 --- a/gui/components/MainView.qml +++ b/gui/components/MainView.qml @@ -130,7 +130,7 @@ Page { } font.pixelSize: 14 textFormat: Text.RichText - text: getLink(ctx.donateURL) + text: getLink(ctx) onLinkActivated: Qt.openUrlExternally(ctx.donateURL) } @@ -150,7 +150,11 @@ Page { onYes: Qt.openUrlExternally(ctx.donateURL) } - function getLink(url) { + function getLink(ctx) { + if (!ctx) { + return "" + } + let url = ctx.donateURL return "" + url + "" } diff --git a/gui/components/Splash.qml b/gui/components/Splash.qml index 625ab18..cf75108 100644 --- a/gui/components/Splash.qml +++ b/gui/components/Splash.qml @@ -57,7 +57,7 @@ Page { if (root.error != "") { return } - if (ctx && ctx.isReady) { + if (ctx && ctx.isReady || qmlDebug) { splashTimer.stop() loader.source = "MainView.qml" } else { diff --git a/gui/components/VPNState.qml b/gui/components/VPNState.qml index 189fd0b..64a109a 100644 --- a/gui/components/VPNState.qml +++ b/gui/components/VPNState.qml @@ -20,7 +20,7 @@ StateGroup { name: initializing }, State { - when: ctx && ctx.status == "off" && startingUI == true + when: ctx != undefined && ctx.status == "off" && startingUI == true PropertyChanges { target: connectionState text: qsTr("Connecting") diff --git a/gui/gui.qrc b/gui/gui.qrc index 5aeb85b..31082ee 100644 --- a/gui/gui.qrc +++ b/gui/gui.qrc @@ -62,6 +62,7 @@ resources/fonts/Poppins-Light.ttf resources/fonts/Montserrat-SemiBold.ttf resources/fonts/Roboto-Regular.ttf + resources/fonts/Roboto-Bold.ttf qml/VpnState.qml diff --git a/gui/main.cpp b/gui/main.cpp index be1be0a..581aedd 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -55,6 +56,12 @@ int main(int argc, char **argv) { Backend backend; + const int fontId = QFontDatabase::addApplicationFont(":/resources/fonts/Roboto-Regular.ttf"); + if (fontId == -1) + qWarning() << "Failed to add Roboto as app font"; + else + qDebug() << QFontDatabase::applicationFontFamilies(fontId); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setApplicationVersion(backend.getVersion()); QApplication app(argc, argv); diff --git a/gui/main.qml b/gui/main.qml index c063739..7469620 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -68,7 +68,18 @@ ApplicationWindow { source: "qrc:/monserrat-bold.ttf" } - font.family: lightFont.name + FontLoader { + id: robotoFont + source: "qrc:/roboto.ttf" + } + + FontLoader { + id: robotoBoldFont + source: "qrc:/roboto-bold.ttf" + } + + font.family: robotoFont.name + font.weight: Font.Light Loader { id: loader diff --git a/gui/qtquickcontrols2.conf b/gui/qtquickcontrols2.conf index 1e387cc..de2b30f 100644 --- a/gui/qtquickcontrols2.conf +++ b/gui/qtquickcontrols2.conf @@ -1,6 +1,12 @@ +[Default] +Font\Family=Poppins + [Controls] Style=Material [Material] Theme=Light Variant=Dense + +[Material\Font] +Family=Poppins diff --git a/gui/resources/fonts/Roboto-Bold.ttf b/gui/resources/fonts/Roboto-Bold.ttf new file mode 100644 index 0000000..3742457 Binary files /dev/null and b/gui/resources/fonts/Roboto-Bold.ttf differ -- cgit v1.2.3