mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Removes JSON constructor from UI elements
This fixes the error: clang:optin.cplusplus.VirtualCall When virtual methods are called during construction and destruction the polymorphism is restricted to the class that’s being constructed or destructed because the more derived contexts are either not yet initialized or already destructed.
This commit is contained in:
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -12,12 +12,6 @@ UI_combobox::UI_combobox(Color fg_color, Color bg_color, std::vector<std::string
|
||||
setup_item(false, true, true);
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(const json &j, QObject *parent) : UI_item(UI_COMBOBOX_TYPE, parent)
|
||||
{
|
||||
setup_item(false, true, true);
|
||||
from_json(j);
|
||||
}
|
||||
|
||||
void UI_combobox::set_selected(size_t selected)
|
||||
{
|
||||
if (selected == m_selected)
|
||||
|
||||
@@ -10,7 +10,6 @@ class UI_combobox : public UI_item
|
||||
UI_combobox(QObject *parent = nullptr);
|
||||
UI_combobox(Color fg_color, Color bg_color, std::vector<std::string> 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);
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
+1
-2
@@ -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)
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user