Files
remote-ui/UI/ui_checkbox.cpp
T
sani7 2a76e13305 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.
2026-02-14 14:32:16 +01:00

47 lines
874 B
C++

#include "ui_checkbox.hpp"
UI_checkbox::UI_checkbox(QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_checked()
{
}
UI_checkbox::UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parent)
: UI_item(UI_CHECKBOX_TYPE, text, fg_color, bg_color, parent), m_checked(false)
{
}
void UI_checkbox::click()
{
m_checked = !m_checked;
emit ui_changed();
emit changed(m_checked);
}
void UI_checkbox::set_state(bool state)
{
m_checked = state;
emit ui_changed();
emit changed(m_checked);
}
bool UI_checkbox::state() const
{
return m_checked;
}
void UI_checkbox::from_json(const json &j)
{
UI_item::from_json(j);
if (j.contains("checked"))
{
m_checked = j["checked"];
}
}
json UI_checkbox::to_json(size_t id) const
{
json j = UI_item::to_json(id);
j["checked"] = m_checked;
return j;
}