diff --git a/UI/ui_button.cpp b/UI/ui_button.cpp index 1ae78c4..278b587 100644 --- a/UI/ui_button.cpp +++ b/UI/ui_button.cpp @@ -5,9 +5,8 @@ UI_button::UI_button(std::string text, Color fg_color, Color bg_color, QObject * { } -UI_button::UI_button(const json &j, QObject *parent) : UI_item(UI_BUTTON_TYPE, parent) +UI_button::UI_button(QObject *parent) : UI_item(UI_BUTTON_TYPE, parent) { - from_json(j); } void UI_button::from_json(const json &j) diff --git a/UI/ui_button.hpp b/UI/ui_button.hpp index c7a23a3..caee94e 100644 --- a/UI/ui_button.hpp +++ b/UI/ui_button.hpp @@ -8,7 +8,7 @@ class UI_button : public UI_item Q_OBJECT public: UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_button(const json &j, QObject *parent = nullptr); + UI_button(QObject *parent = nullptr); void from_json(const json &j) override; json to_json(size_t id) const override; diff --git a/UI/ui_can.cpp b/UI/ui_can.cpp index 37c0c2f..c902358 100644 --- a/UI/ui_can.cpp +++ b/UI/ui_can.cpp @@ -17,10 +17,9 @@ UI_can::UI_can(Color fg_color, Color bg_color, QObject *parent) : UI_item(UI_CAN setup_item(false, true, true); } -UI_can::UI_can(const json &j, QObject *parent) : UI_item(UI_CAN_TYPE, parent) +UI_can::UI_can(QObject *parent) : UI_item(UI_CAN_TYPE, parent) { setup_item(false, true, true); - from_json(j); } void UI_can::add_send_message(QCanBusFrame msg) diff --git a/UI/ui_can.hpp b/UI/ui_can.hpp index c9a661c..92de899 100644 --- a/UI/ui_can.hpp +++ b/UI/ui_can.hpp @@ -20,7 +20,7 @@ class UI_can : public UI_item Q_OBJECT public: UI_can(Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_can(const json &j, QObject *parent = nullptr); + UI_can(QObject *parent = nullptr); void add_send_message(QCanBusFrame msg); void add_received_message(QCanBusFrame msg); diff --git a/UI/ui_checkbox.cpp b/UI/ui_checkbox.cpp index 20e2cd4..0b05d27 100644 --- a/UI/ui_checkbox.cpp +++ b/UI/ui_checkbox.cpp @@ -9,11 +9,6 @@ UI_checkbox::UI_checkbox(std::string text, Color fg_color, Color bg_color, QObje { } -UI_checkbox::UI_checkbox(const json &j, QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_checked() -{ - from_json(j); -} - void UI_checkbox::click() { m_checked = !m_checked; diff --git a/UI/ui_checkbox.hpp b/UI/ui_checkbox.hpp index 6610338..6ddb0ee 100644 --- a/UI/ui_checkbox.hpp +++ b/UI/ui_checkbox.hpp @@ -9,7 +9,6 @@ class UI_checkbox : public UI_item public: UI_checkbox(QObject *parent = nullptr); UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_checkbox(const json &j, QObject *parent = nullptr); void click() override; void set_state(bool state); diff --git a/UI/ui_combobox.cpp b/UI/ui_combobox.cpp index c6f6418..29be3fa 100644 --- a/UI/ui_combobox.cpp +++ b/UI/ui_combobox.cpp @@ -12,12 +12,6 @@ UI_combobox::UI_combobox(Color fg_color, Color bg_color, std::vector options, size_t selected = 0, QObject *parent = nullptr); - UI_combobox(const json &j, QObject *parent = nullptr); void set_selected(size_t selected) override; void set_selected(std::string selected); diff --git a/UI/ui_dial.cpp b/UI/ui_dial.cpp index d2af6c4..6a9f732 100644 --- a/UI/ui_dial.cpp +++ b/UI/ui_dial.cpp @@ -22,9 +22,8 @@ UI_dial::UI_dial(std::string text, double min, double max, double value, QObject { } -UI_dial::UI_dial(const json &j, QObject *parent) : UI_item(UI_DIAL_TYPE, parent) +UI_dial::UI_dial(QObject *parent) : UI_item(UI_DIAL_TYPE, parent) { - from_json(j); } void UI_dial::set_value(double value) diff --git a/UI/ui_dial.hpp b/UI/ui_dial.hpp index fb77a7c..73e078d 100644 --- a/UI/ui_dial.hpp +++ b/UI/ui_dial.hpp @@ -13,7 +13,7 @@ class UI_dial : public UI_item UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parent = nullptr); UI_dial(std::string text, double min, double max, double value, QObject *parent = nullptr); - UI_dial(const json &j, QObject *parent = nullptr); + UI_dial(QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/UI/ui_label.cpp b/UI/ui_label.cpp index a02fff8..2453020 100644 --- a/UI/ui_label.cpp +++ b/UI/ui_label.cpp @@ -5,9 +5,8 @@ UI_label::UI_label(std::string text, Color fg_color, Color bg_color, QObject *pa { } -UI_label::UI_label(const json &j, QObject *parent) : UI_item(UI_LABEL_TYPE, parent) +UI_label::UI_label(QObject *parent) : UI_item(UI_LABEL_TYPE, parent) { - from_json(j); } void UI_label::from_json(const json &j) diff --git a/UI/ui_label.hpp b/UI/ui_label.hpp index 25182c6..49daedc 100644 --- a/UI/ui_label.hpp +++ b/UI/ui_label.hpp @@ -9,7 +9,7 @@ class UI_label : public UI_item Q_OBJECT public: UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_label(const json &j, QObject *parent = nullptr); + UI_label(QObject *parent = nullptr); void from_json(const json &j) override; json to_json(size_t id) const override; diff --git a/UI/ui_led.cpp b/UI/ui_led.cpp index faeff42..4f4b3b0 100644 --- a/UI/ui_led.cpp +++ b/UI/ui_led.cpp @@ -9,11 +9,6 @@ UI_led::UI_led(std::string text, Color fg_color, Color bg_color, QObject *parent { } -UI_led::UI_led(const json &j, QObject *parent) : UI_item(UI_LED_TYPE, parent) -{ - from_json(j); -} - bool UI_led::set_led(bool state, Color on, Color off) { set_bg_color(state ? on : off); diff --git a/UI/ui_led.hpp b/UI/ui_led.hpp index f6ced7d..0d18fcf 100644 --- a/UI/ui_led.hpp +++ b/UI/ui_led.hpp @@ -10,7 +10,6 @@ class UI_led : public UI_item public: UI_led(QObject *parent = nullptr); UI_led(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_led(const json &j, QObject *parent = nullptr); bool set_led(bool state, Color on, Color off); diff --git a/UI/ui_plot.cpp b/UI/ui_plot.cpp index cd8c0c8..4576e40 100644 --- a/UI/ui_plot.cpp +++ b/UI/ui_plot.cpp @@ -10,11 +10,6 @@ UI_plot::UI_plot(std::string text, std::string x_label, std::string y_label, QOb set_text(text); } -UI_plot::UI_plot(const json &j, QObject *parent) : UI_item{UI_PLOT_TYPE, parent} -{ - from_json(j); -} - void UI_plot::set_x_label(std::string name) { m_x_label = name; diff --git a/UI/ui_plot.hpp b/UI/ui_plot.hpp index e3e9394..668f82d 100644 --- a/UI/ui_plot.hpp +++ b/UI/ui_plot.hpp @@ -8,7 +8,6 @@ class UI_plot : public UI_item public: explicit UI_plot(QObject *parent = nullptr); UI_plot(std::string text, std::string x_label, std::string y_label, QObject *parent = nullptr); - UI_plot(const json &j, QObject *parent = nullptr); void set_x_label(std::string name); std::string x_label() const; diff --git a/UI/ui_slider.cpp b/UI/ui_slider.cpp index f874eda..e173119 100644 --- a/UI/ui_slider.cpp +++ b/UI/ui_slider.cpp @@ -22,9 +22,8 @@ UI_slider::UI_slider(std::string text, double min, double max, double value, QOb { } -UI_slider::UI_slider(const json &j, QObject *parent) : UI_item(UI_SLIDER_TYPE, parent) +UI_slider::UI_slider(QObject *parent) : UI_item(UI_SLIDER_TYPE, parent) { - from_json(j); } void UI_slider::set_value(double value) diff --git a/UI/ui_slider.hpp b/UI/ui_slider.hpp index 88bc4cb..ed33aaf 100644 --- a/UI/ui_slider.hpp +++ b/UI/ui_slider.hpp @@ -13,7 +13,7 @@ class UI_slider : public UI_item UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parent = nullptr); UI_slider(std::string text, double min, double max, double value, QObject *parent = nullptr); - UI_slider(const json &j, QObject *parent = nullptr); + UI_slider(QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/UI/ui_textbox.cpp b/UI/ui_textbox.cpp index 9ccd2a3..3a3350c 100644 --- a/UI/ui_textbox.cpp +++ b/UI/ui_textbox.cpp @@ -5,9 +5,8 @@ UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject { } -UI_textbox::UI_textbox(const json &j, QObject *parent) : UI_item(UI_TEXTBOX_TYPE, parent) +UI_textbox::UI_textbox(QObject *parent) : UI_item(UI_TEXTBOX_TYPE, parent) { - from_json(j); } void UI_textbox::set_text(std::string text) diff --git a/UI/ui_textbox.hpp b/UI/ui_textbox.hpp index fcc5929..5314473 100644 --- a/UI/ui_textbox.hpp +++ b/UI/ui_textbox.hpp @@ -9,7 +9,7 @@ class UI_textbox : public UI_item Q_OBJECT public: UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent = nullptr); - UI_textbox(const json &j, QObject *parent = nullptr); + UI_textbox(QObject *parent = nullptr); void set_text(std::string text) override; diff --git a/UI/ui_thermo.cpp b/UI/ui_thermo.cpp index ca2eb03..72a81ea 100644 --- a/UI/ui_thermo.cpp +++ b/UI/ui_thermo.cpp @@ -22,9 +22,8 @@ UI_thermo::UI_thermo(std::string text, double min, double max, double value, QOb { } -UI_thermo::UI_thermo(const json &j, QObject *parent) : UI_item(UI_THERMO_TYPE, parent) +UI_thermo::UI_thermo(QObject *parent) : UI_item(UI_THERMO_TYPE, parent) { - from_json(j); } void UI_thermo::set_value(double value) diff --git a/UI/ui_thermo.hpp b/UI/ui_thermo.hpp index 1ada877..7576133 100644 --- a/UI/ui_thermo.hpp +++ b/UI/ui_thermo.hpp @@ -14,7 +14,7 @@ class UI_thermo : public UI_item UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value, QObject *parent = nullptr); UI_thermo(std::string text, double min, double max, double value, QObject *parent = nullptr); - UI_thermo(const json &j, QObject *parent = nullptr); + UI_thermo(QObject *parent = nullptr); void set_value(double value) override; double value() const; diff --git a/tests/UI_button.cpp b/tests/UI_button.cpp index 26fcf73..7f3a69e 100644 --- a/tests/UI_button.cpp +++ b/tests/UI_button.cpp @@ -5,7 +5,8 @@ TEST(UI_button, to_from_json) { UI_button button("button_text", Color(255, 255, 255), Color(0, 0, 0), nullptr); json j = button.to_json(0); - UI_button button2(j); + UI_button button2; + button2.from_json(j); EXPECT_EQ(button.text(), button2.text()); EXPECT_EQ(button.fg_color(), button2.fg_color()); EXPECT_EQ(button.bg_color(), button2.bg_color()); diff --git a/tests/UI_checkbox.cpp b/tests/UI_checkbox.cpp index 5eade45..1106460 100644 --- a/tests/UI_checkbox.cpp +++ b/tests/UI_checkbox.cpp @@ -4,7 +4,8 @@ TEST(UI_checkbox, to_from_json) { UI_checkbox checkbox("checkbox_text", Color(255, 255, 255), Color(0, 0, 0)); json j = checkbox.to_json(0); - UI_checkbox checkbox2(j); + UI_checkbox checkbox2; + checkbox2.from_json(j); EXPECT_EQ(checkbox.text(), checkbox2.text()); EXPECT_EQ(checkbox.fg_color(), checkbox2.fg_color()); EXPECT_EQ(checkbox.bg_color(), checkbox2.bg_color()); diff --git a/tests/UI_combobox.cpp b/tests/UI_combobox.cpp index 60d6bd7..be4d848 100644 --- a/tests/UI_combobox.cpp +++ b/tests/UI_combobox.cpp @@ -2,11 +2,12 @@ TEST(UI_combobox, to_from_json) { - UI_combobox checkbox(Color(255, 255, 255), Color(0, 0, 0), {"option1", "option2"}); - json j = checkbox.to_json(0); - UI_combobox checkbox2(j); - EXPECT_EQ(checkbox.text(), checkbox2.text()); - EXPECT_EQ(checkbox.fg_color(), checkbox2.fg_color()); - EXPECT_EQ(checkbox.bg_color(), checkbox2.bg_color()); - EXPECT_EQ(checkbox.selected(), checkbox2.selected()); + UI_combobox combobox(Color(255, 255, 255), Color(0, 0, 0), {"option1", "option2"}); + json j = combobox.to_json(0); + UI_combobox combobox2; + combobox2.from_json(j); + EXPECT_EQ(combobox.text(), combobox2.text()); + EXPECT_EQ(combobox.fg_color(), combobox2.fg_color()); + EXPECT_EQ(combobox.bg_color(), combobox2.bg_color()); + EXPECT_EQ(combobox.selected(), combobox2.selected()); } diff --git a/tests/UI_dial.cpp b/tests/UI_dial.cpp index 760a647..8e15283 100644 --- a/tests/UI_dial.cpp +++ b/tests/UI_dial.cpp @@ -4,7 +4,8 @@ TEST(UI_dial, to_from_json) { UI_dial dial("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50); json j = dial.to_json(0); - UI_dial dial2(j); + UI_dial dial2; + dial2.from_json(j); EXPECT_EQ(dial.text(), dial2.text()); EXPECT_EQ(dial.fg_color(), dial2.fg_color()); EXPECT_EQ(dial.bg_color(), dial2.bg_color()); diff --git a/tests/UI_label.cpp b/tests/UI_label.cpp index 4cec2fd..2a1c3f6 100644 --- a/tests/UI_label.cpp +++ b/tests/UI_label.cpp @@ -10,7 +10,8 @@ TEST(UI_label, to_from_json) EXPECT_EQ(j["fg_color"], "#000000FF"); EXPECT_EQ(j["bg_color"], "#FFFFFFFF"); - UI_label label2(j); + UI_label label2; + label2.from_json(j); EXPECT_EQ(label2.text(), "label_text"); EXPECT_EQ(label2.fg_color(), Color(0, 0, 0)); EXPECT_EQ(label2.bg_color(), Color(255, 255, 255)); diff --git a/tests/UI_led.cpp b/tests/UI_led.cpp index 5e2a261..46e845b 100644 --- a/tests/UI_led.cpp +++ b/tests/UI_led.cpp @@ -4,7 +4,8 @@ TEST(UI_led, to_from_json) { UI_led led("led_text", Color(0, 0, 0), Color(255, 255, 255)); json j = led.to_json(0); - UI_led led2(j); + UI_led led2; + led2.from_json(j); EXPECT_EQ(led.text(), led2.text()); EXPECT_EQ(led.fg_color(), led2.fg_color()); EXPECT_EQ(led.bg_color(), led2.bg_color()); diff --git a/tests/UI_slider.cpp b/tests/UI_slider.cpp index 9ee2410..9fb34ea 100644 --- a/tests/UI_slider.cpp +++ b/tests/UI_slider.cpp @@ -4,7 +4,8 @@ TEST(UI_slider, to_from_json) { UI_slider slider("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50, nullptr); json j = slider.to_json(0); - UI_slider slider2(j); + UI_slider slider2; + slider2.from_json(j); EXPECT_EQ(slider.text(), slider2.text()); EXPECT_EQ(slider.fg_color(), slider2.fg_color()); EXPECT_EQ(slider.bg_color(), slider2.bg_color()); diff --git a/tests/UI_textbox.cpp b/tests/UI_textbox.cpp index 96b54d3..d748039 100644 --- a/tests/UI_textbox.cpp +++ b/tests/UI_textbox.cpp @@ -4,7 +4,8 @@ TEST(UI_textbox, to_from_json) { UI_textbox textbox("hint", Color(0, 0, 0), Color(255, 255, 255)); json j = textbox.to_json(0); - UI_textbox textbox2(j); + UI_textbox textbox2; + textbox2.from_json(j); EXPECT_EQ(textbox.text(), textbox2.text()); EXPECT_EQ(textbox.fg_color(), textbox2.fg_color()); EXPECT_EQ(textbox.bg_color(), textbox2.bg_color()); diff --git a/tests/UI_thermo.cpp b/tests/UI_thermo.cpp index b026e90..b23703f 100644 --- a/tests/UI_thermo.cpp +++ b/tests/UI_thermo.cpp @@ -4,7 +4,8 @@ TEST(UI_thermo, to_from_json) { UI_thermo thermo("thermo_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50); json j = thermo.to_json(0); - UI_thermo thermo2(j); + UI_thermo thermo2; + thermo2.from_json(j); EXPECT_EQ(thermo.text(), thermo2.text()); EXPECT_EQ(thermo.fg_color(), thermo2.fg_color()); EXPECT_EQ(thermo.bg_color(), thermo2.bg_color());