mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Move to id is size_t
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
|
||||
Test_Sim::Test_Sim(QObject* parrent) :
|
||||
Simulator_base("Test_Sim", std::chrono::milliseconds(1000), parrent),
|
||||
m_button("button", "Off", Color(Color::White), Color(Color::Red)),
|
||||
m_combobox("combobox", "Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0),
|
||||
m_label("label", "Label", Color(Color::White), Color(Color::Black)),
|
||||
m_checkbox("checkbox", "Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}),
|
||||
m_slider("slider", "Slider", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_dial("dial", "Dial", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_thermo("thermo", "Thermo", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_led("led", "Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
|
||||
m_button("Off", Color(Color::White), Color(Color::Red)),
|
||||
m_combobox("Combobox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}, 0),
|
||||
m_label("Label", Color(Color::White), Color(Color::Black)),
|
||||
m_checkbox("Checkbox", Color(Color::White), Color(Color::Black), {"Option 1", "Option 2", "Option 3"}),
|
||||
m_slider("Slider", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_dial("Dial", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_thermo("Thermo", Color(Color::White), Color(Color::Black), 0, 100, 0),
|
||||
m_led("Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
|
||||
{
|
||||
this->m_thermo.set_start_color(Color(Color::Red));
|
||||
this->m_thermo.set_end_color(Color(Color::Red));
|
||||
@@ -28,8 +28,8 @@ m_led("led", "Led", Color(Color::White), Color(Color::Black), Color(Color::Red))
|
||||
this->add_UI_item(&this->m_thermo);
|
||||
this->add_UI_item(&this->m_led);
|
||||
|
||||
QObject::connect(&m_button, &UI_button::on_click, [this](std::string id) { button_clicked(id); });
|
||||
QObject::connect(&m_slider, &UI_slider::on_change, [this](std::string id, double value) { slider_changed(id, value); });
|
||||
QObject::connect(&m_button, &UI_button::on_click, [this] { button_clicked(&m_button); });
|
||||
QObject::connect(&m_slider, &UI_slider::on_change, [this](double value) { slider_changed(&m_slider, value); });
|
||||
}
|
||||
|
||||
void Test_Sim::timer()
|
||||
@@ -49,9 +49,9 @@ void Test_Sim::run_at_startup()
|
||||
spdlog::info("Test_Sim started");
|
||||
}
|
||||
|
||||
void Test_Sim::button_clicked(std::string id)
|
||||
void Test_Sim::button_clicked(UI_button* id)
|
||||
{
|
||||
if (id == "button")
|
||||
if (id == &this->m_button)
|
||||
{
|
||||
bool state = this->m_button.bg_color() == Color(Color::Red) ? true : false;
|
||||
this->m_button.set_bg_color(state ? Color(Color::Green) : Color(Color::Red));
|
||||
@@ -62,11 +62,11 @@ void Test_Sim::button_clicked(std::string id)
|
||||
}
|
||||
}
|
||||
|
||||
void Test_Sim::slider_changed(std::string id, double value)
|
||||
void Test_Sim::slider_changed(UI_slider* id, double value)
|
||||
{
|
||||
spdlog::info("Slider {} changed to {}", id, value);
|
||||
if (id == "slider")
|
||||
if (id == &this->m_slider)
|
||||
{
|
||||
spdlog::info("Test slider changed to {}", value);
|
||||
this->m_label.set_text(std::to_string(value));
|
||||
this->m_dial.set_value(value);
|
||||
this->m_thermo.set_value(value);
|
||||
|
||||
@@ -8,9 +8,10 @@ class Test_Sim : public Simulator_base {
|
||||
void timer() override;
|
||||
void run_at_startup() override;
|
||||
private:
|
||||
void button_clicked(std::string id);
|
||||
void slider_changed(std::string id, double value);
|
||||
private:
|
||||
void button_clicked(UI_button* id);
|
||||
void slider_changed(UI_slider* id, double value);
|
||||
|
||||
private:
|
||||
UI_button m_button;
|
||||
UI_combobox m_combobox;
|
||||
UI_label m_label;
|
||||
|
||||
Reference in New Issue
Block a user