summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-06 10:37:03 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-06 10:37:03 +0800
commit03399dffb1d96dec521d24d2c31a90b665194b97 (patch)
treed28a3eef0c22d69a5dbe39b314897a23b6ed2d0a
parent820227a86c3b938792384279a487f1ab0dd070d6 (diff)
If there's conf, init using it
-rw-r--r--bootstrap.cxx12
-rw-r--r--bootstrap.pro1
2 files changed, 11 insertions, 2 deletions
diff --git a/bootstrap.cxx b/bootstrap.cxx
index 6f01ab1..433ccfd 100644
--- a/bootstrap.cxx
+++ b/bootstrap.cxx
@@ -1,15 +1,23 @@
+#include <toml.h>
#include "bootstrap.hxx"
Bootstrap::Bootstrap(QObject *parent):
QObject(parent),
+ bs_mode(LightMode),
bs_theme(None),
bs_lightBodyBg("#fff"),
bs_darkBodyBg("#212529")
{
QFile conf{QStringLiteral(":/qtquickcontrols2.conf")};
- conf.open(QFile::ReadOnly | QFile::Text);
- qDebug() << conf.readAll();
+ if (!conf.open(QIODevice::ReadOnly | QIODevice::Text)) return;
+ auto toml = toml_parse(conf.readAll().data(), nullptr, 0);
conf.close();
+ auto bootstrap = toml_table_in(toml, "Bootstrap");
+ if (bootstrap) {
+ auto mode = toml_int_in(bootstrap, "Mode");
+ if (mode.ok) bs_mode = static_cast<Mode>(mode.u.i);
+ }
+ toml_free(toml);
}
Bootstrap *Bootstrap::qmlAttachedProperties(QObject *object)
diff --git a/bootstrap.pro b/bootstrap.pro
index d5cf36e..e9fa9f7 100644
--- a/bootstrap.pro
+++ b/bootstrap.pro
@@ -17,6 +17,7 @@ style.path = $$[QT_INSTALL_QML]/QtQuick/Controls.2/$$QML_IMPORT_NAME
HEADERS += $${TARGET}.hxx
SOURCES += $${TARGET}.cxx
+LIBS += -ltoml
TARGET = qqc2$$TARGET
target.path = $$[QT_INSTALL_QML]/$$QML_IMPORT_NAME