summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-08 08:59:52 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-04-08 08:59:52 +0800
commit57701c90c21109a966cf14c223461dc115930033 (patch)
treef361ac27c3cccf71a9c109978a01c08856821bd4
parent36bec9d95a61d1cdc33d86cf25c22acacdcf0217 (diff)
Macro for appending colours
-rw-r--r--Bootstrap.cxx40
1 files changed, 14 insertions, 26 deletions
diff --git a/Bootstrap.cxx b/Bootstrap.cxx
index 7183cb7..5d6a2ce 100644
--- a/Bootstrap.cxx
+++ b/Bootstrap.cxx
@@ -1,6 +1,16 @@
#include "tomlc99/toml.h"
#include "Bootstrap.hxx"
+#define APPEND_COLORS(A, B) \
+ colors = toml_array_in(bootstrap, A);\
+ if (colors)\
+ for (int i = 0; ; i++) {\
+ auto color = toml_string_at(colors, i);\
+ if (!color.ok) break;\
+ B.append(QColor{color.u.s});\
+ free(color.u.s);\
+ }
+
Bootstrap::Bootstrap(QObject *parent):
QObject{parent},
bsMode{Light},
@@ -23,32 +33,10 @@ Bootstrap::Bootstrap(QObject *parent):
auto mode = toml_int_in(bootstrap, "Mode");
if (mode.ok) bsMode = static_cast<Mode>(mode.u.i);
- auto colors = toml_array_in(bootstrap, "BodyColors");
- if (colors)
- for (int i = 0; ; i++) {
- auto color = toml_string_at(colors, i);
- if (!color.ok) break;
- bodyColors.append(QColor{color.u.s});
- free(color.u.s);
- }
-
- colors = toml_array_in(bootstrap, "BodyBgs");
- if (colors)
- for (int i = 0; ; i++) {
- auto color = toml_string_at(colors, i);
- if (!color.ok) break;
- bodyBgs.append(QColor{color.u.s});
- free(color.u.s);
- }
-
- colors = toml_array_in(bootstrap, "BorderColors");
- if (colors)
- for (int i = 0; ; i++) {
- auto color = toml_string_at(colors, i);
- if (!color.ok) break;
- borderColors.append(QColor{color.u.s});
- free(color.u.s);
- }
+ toml_array_t *colors;
+ APPEND_COLORS("BodyColors", bodyColors);
+ APPEND_COLORS("BodyBgs", bodyBgs);
+ APPEND_COLORS("BorderColors", borderColors);
toml_free(toml);
}