summaryrefslogtreecommitdiff
path: root/DevTools
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-10 20:58:54 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-10 20:58:54 +0200
commit8d67aa1e590d87efd5bef727a47d9f79ad57659d (patch)
tree1a8e8853d90fa05a2793648cb75c2e3614afd63b /DevTools
parent2d3293dfbd085da013e65f3c001cc5be07a01eaa (diff)
downloadserenity-8d67aa1e590d87efd5bef727a47d9f79ad57659d.zip
FormCompiler: Generate a basic UI skeleton holder struct.
The basic idea is that you would use it like this: MyWidget::MyWidget(GWidget* parent) : GWidget(parent) { m_ui = new UI_MyWidget; set_main_widget(m_ui->main_widget); ... }
Diffstat (limited to 'DevTools')
-rw-r--r--DevTools/FormCompiler/main.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/DevTools/FormCompiler/main.cpp b/DevTools/FormCompiler/main.cpp
index e3ab18ffa2..c4c7ede2af 100644
--- a/DevTools/FormCompiler/main.cpp
+++ b/DevTools/FormCompiler/main.cpp
@@ -34,15 +34,50 @@ int main(int argc, char** argv)
return 1;
}
- dbg() << "auto* main_widget = new GWidget(nullptr);";
+ dbg() << "struct UI_" << name << " {";
+ dbg() << " GWidget* main_widget;";
widgets.as_array().for_each([&](auto& value) {
ASSERT(value.is_object());
const JsonObject& widget_object = value.as_object();
auto name = widget_object.get("name").to_string();
auto class_name = widget_object.get("class").to_string();
- dbg() << "auto* " << name << " = new " << class_name << "(main_widget);";
+ dbg() << " " << class_name << "* " << name << ";";
});
+ dbg() << " UI_" << name << "();";
+
+ dbg() << "};";
+
+ dbg() << "UI_" << name << "::UI_" << name << "()";
+ dbg() << "{";
+
+ dbg() << " main_widget = new GWidget(nullptr);";
+
+ widgets.as_array().for_each([&](auto& value) {
+ ASSERT(value.is_object());
+ const JsonObject& widget_object = value.as_object();
+ auto name = widget_object.get("name").to_string();
+ auto class_name = widget_object.get("class").to_string();
+ dbg() << " " << name << " = new " << class_name << "(main_widget);";
+
+ widget_object.for_each_member([&](auto& property_name, auto& property_value) {
+ if (property_name == "class")
+ return;
+
+ String value;
+
+ if (property_value.is_null())
+ value = "{}";
+ else
+ value = property_value.serialized();
+
+ dbg() << " " << name << "->set_" << property_name << "(" << value << ");";
+ });
+
+ dbg() << "";
+ });
+ dbg() << "}";
+
return 0;
}