Files
remote-ui/UI/ui_textbox.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

44 lines
808 B
C++

#include "ui_textbox.hpp"
UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent)
: UI_item(UI_TEXTBOX_TYPE, "", fg_color, bg_color, parent), m_hint(hint)
{
}
UI_textbox::UI_textbox(QObject *parent) : UI_item(UI_TEXTBOX_TYPE, parent)
{
}
void UI_textbox::set_text(std::string text)
{
if (text == m_text)
return;
m_text = text;
emit ui_changed();
emit changed(m_text);
}
void UI_textbox::set_hint(std::string hint)
{
m_hint = hint;
emit ui_changed();
}
std::string UI_textbox::hint() const
{
return m_hint;
}
void UI_textbox::from_json(const json &j)
{
UI_item::from_json(j);
m_hint = j.at("hint");
}
json UI_textbox::to_json(size_t id) const
{
json j = UI_item::to_json(id);
j["hint"] = m_hint;
return j;
}