From 03399dffb1d96dec521d24d2c31a90b665194b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Thu, 6 Apr 2023 10:37:03 +0800 Subject: If there's conf, init using it --- bootstrap.cxx | 12 ++++++++++-- bootstrap.pro | 1 + 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 #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.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 -- cgit v1.2.3