summaryrefslogtreecommitdiff
path: root/Bootstrap.cxx
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-12 17:28:44 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-12 17:28:44 +0800
commit81a72b6eeb0614d2f8139314cf5d3948faa467b0 (patch)
treee4db90f5f12c80fc6089d9db18397c32a5000c2a /Bootstrap.cxx
parentdb23fd439fbc4acf7cb102538decb3e49100d6ff (diff)
Body font & its use in Label
Diffstat (limited to 'Bootstrap.cxx')
-rw-r--r--Bootstrap.cxx40
1 files changed, 39 insertions, 1 deletions
diff --git a/Bootstrap.cxx b/Bootstrap.cxx
index 31681a4..99a8639 100644
--- a/Bootstrap.cxx
+++ b/Bootstrap.cxx
@@ -9,15 +9,32 @@
B[i] = QColor{color.u.s};\
free(color.u.s);\
}
-
+
Bootstrap::Bootstrap(QObject *parent):
QObject{parent},
bsMode{Mode::Light},
bsTheme{Theme::None},
+#ifdef __ANDROID__
+ bsFontSansSerif{"Roboto"},
+#elif defined(__APPLE__)
+ bsFontSansSerif{"Helvetica Neue"},
+#elif defined(__EMSCRIPTEN__)
+ bsFontSansSerif{"Arial"},
+#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) \
+ || defined(_WIN64) || defined(__WIN64)
+ bsFontSansSerif{"Segoe UI"},
+#else
+ bsFontSansSerif{"Liberation Sans"},
+#endif
+ bsBodyFont{bsFontSansSerif},
bodyColors{{"#212529", "#adb5bd"}},
bodyBgs{{"#fff", "#212529"}},
borderColors{{"#dee2e6", "#495057"}}
{
+ bsBodyFont.setStyleHint(QFont::SansSerif);
+ bsBodyFont.setPointSizeF(16.0);
+ bsBodyFont.setWeight(QFont::Normal);
+
QFile conf{QStringLiteral(":/qtquickcontrols2.conf")};
if (!conf.open(QIODevice::ReadOnly | QIODevice::Text)) return;
auto toml = toml_parse(conf.readAll().data(), nullptr, 0);
@@ -32,6 +49,17 @@ Bootstrap::Bootstrap(QObject *parent):
auto mode = toml_int_in(bootstrap, "Mode");
if (mode.ok) bsMode = static_cast<Mode>(mode.u.i);
+ auto fontFamily = toml_string_in(bootstrap, "BodyFontFamily");
+ if (fontFamily.ok) {
+ bsBodyFont.setFamily(fontFamily.u.s);
+ free(fontFamily.u.s);
+ bsBodyFont.setStyleHint(QFont::AnyStyle);
+ }
+ auto fontSize = toml_double_in(bootstrap, "BodyFontSize");
+ if (fontSize.ok) bsBodyFont.setPointSizeF(fontSize.u.d);
+ auto fontWeight = toml_int_in(bootstrap, "BodyFontWeight");
+ if (fontWeight.ok) bsBodyFont.setWeight(fontWeight.u.i);
+
toml_array_t *colors;
OVERRIDE_COLORS("BodyColors", bodyColors);
OVERRIDE_COLORS("BodyBgs", bodyBgs);
@@ -72,6 +100,16 @@ void Bootstrap::setTheme(Theme theme)
emit themeChanged();
}
+QString Bootstrap::fontSansSerif() const
+{
+ return bsFontSansSerif;
+}
+
+QFont Bootstrap::bodyFont() const
+{
+ return bsBodyFont;
+}
+
QColor Bootstrap::bodyColor() const
{
return bodyColors.at(static_cast<int>(bsMode));