mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
UI
rename some signals add some constructors that have no color
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
add_library(UI)
|
add_library(UI STATIC)
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core SerialBus)
|
find_package(Qt6 REQUIRED COMPONENTS Core SerialBus)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,5 +23,5 @@ json UI_button::to_json(size_t id) const
|
|||||||
|
|
||||||
void UI_button::click()
|
void UI_button::click()
|
||||||
{
|
{
|
||||||
emit on_click();
|
emit clicked();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,5 +17,5 @@ class UI_button : public UI_item
|
|||||||
void click() override;
|
void click() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void on_click();
|
void clicked();
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ void UI_combobox::set_selected(size_t selected)
|
|||||||
return;
|
return;
|
||||||
m_selected = selected;
|
m_selected = selected;
|
||||||
emit value_changed();
|
emit value_changed();
|
||||||
emit on_change(selected_text());
|
emit changed(selected_text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_combobox::set_selected(std::string selected)
|
void UI_combobox::set_selected(std::string selected)
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ class UI_combobox : public UI_x_boxes
|
|||||||
void from_json(const json &j) override;
|
void from_json(const json &j) override;
|
||||||
json to_json(size_t id) const override;
|
json to_json(size_t id) const override;
|
||||||
signals:
|
signals:
|
||||||
void on_change(std::string selected);
|
void changed(std::string selected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t m_selected;
|
size_t m_selected;
|
||||||
|
|||||||
@@ -6,12 +6,22 @@ UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_co
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_dial::UI_dial(std::string text, std::string unit, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_dial(text, unit, Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: UI_dial(text, "", fg_color, bg_color, min, max, value, parent)
|
: UI_dial(text, "", fg_color, bg_color, min, max, value, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_dial::UI_dial(std::string text, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_dial(text, "", Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_dial::UI_dial(const json &j, QObject *parent) : UI_item(UI_DIAL_TYPE, parent)
|
UI_dial::UI_dial(const json &j, QObject *parent) : UI_item(UI_DIAL_TYPE, parent)
|
||||||
{
|
{
|
||||||
from_json(j);
|
from_json(j);
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ class UI_dial : public UI_item
|
|||||||
public:
|
public:
|
||||||
UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
UI_dial(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||||
UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
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(const json &j, QObject *parent = nullptr);
|
||||||
|
|
||||||
void set_value(double value) override;
|
void set_value(double value) override;
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ void UI_item::set_text(std::string text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UI_item::append_text(std::string text)
|
||||||
|
{
|
||||||
|
m_text.append(text);
|
||||||
|
emit value_changed();
|
||||||
|
}
|
||||||
|
|
||||||
std::string UI_item::text() const
|
std::string UI_item::text() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return m_text;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class UI_item : public QObject
|
|||||||
bool is_type(json j);
|
bool is_type(json j);
|
||||||
|
|
||||||
virtual void set_text(std::string text);
|
virtual void set_text(std::string text);
|
||||||
|
void append_text(std::string text);
|
||||||
std::string text() const;
|
std::string text() const;
|
||||||
|
|
||||||
void set_text_size(uint8_t text_size);
|
void set_text_size(uint8_t text_size);
|
||||||
|
|||||||
+2
-1
@@ -14,9 +14,10 @@ UI_led::UI_led(const json &j, QObject *parent) : UI_item(UI_LED_TYPE, parent)
|
|||||||
from_json(j);
|
from_json(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_led::set_led(bool state, Color on, Color off)
|
bool UI_led::set_led(bool state, Color on, Color off)
|
||||||
{
|
{
|
||||||
set_bg_color(state ? on : off);
|
set_bg_color(state ? on : off);
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_led::from_json(const json &j)
|
void UI_led::from_json(const json &j)
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ class UI_led : public UI_item
|
|||||||
UI_led(std::string text, Color fg_color, Color bg_color, 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);
|
UI_led(const json &j, QObject *parent = nullptr);
|
||||||
|
|
||||||
void set_led(bool state, Color on, Color off);
|
bool set_led(bool state, Color on, Color off);
|
||||||
|
|
||||||
void from_json(const json &j) override;
|
void from_json(const json &j) override;
|
||||||
json to_json(size_t id) const override;
|
json to_json(size_t id) const override;
|
||||||
|
|||||||
@@ -7,12 +7,22 @@ UI_slider::UI_slider(std::string text, std::string unit, Color fg_color, Color b
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_slider::UI_slider(std::string text, std::string unit, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_slider(text, unit, Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: UI_slider(text, "", fg_color, bg_color, min, max, value, parent)
|
: UI_slider(text, "", fg_color, bg_color, min, max, value, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_slider::UI_slider(std::string text, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_slider(text, "", Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_slider::UI_slider(const json &j, QObject *parent) : UI_item(UI_SLIDER_TYPE, parent)
|
UI_slider::UI_slider(const json &j, QObject *parent) : UI_item(UI_SLIDER_TYPE, parent)
|
||||||
{
|
{
|
||||||
from_json(j);
|
from_json(j);
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ class UI_slider : public UI_item
|
|||||||
public:
|
public:
|
||||||
UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
UI_slider(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||||
UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
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(const json &j, QObject *parent = nullptr);
|
||||||
|
|
||||||
void set_value(double value) override;
|
void set_value(double value) override;
|
||||||
|
|||||||
@@ -7,12 +7,22 @@ UI_thermo::UI_thermo(std::string text, std::string unit, Color fg_color, Color b
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_thermo::UI_thermo(std::string text, std::string unit, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_thermo(text, unit, Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: UI_thermo(text, "", fg_color, bg_color, min, max, value, parent)
|
: UI_thermo(text, "", fg_color, bg_color, min, max, value, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_thermo::UI_thermo(std::string text, double min, double max, double value, QObject *parent)
|
||||||
|
: UI_thermo(text, "", Color::Default, Color::Default, min, max, value, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI_thermo::UI_thermo(const json &j, QObject *parent) : UI_item(UI_THERMO_TYPE, parent)
|
UI_thermo::UI_thermo(const json &j, QObject *parent) : UI_item(UI_THERMO_TYPE, parent)
|
||||||
{
|
{
|
||||||
from_json(j);
|
from_json(j);
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ class UI_thermo : public UI_item
|
|||||||
public:
|
public:
|
||||||
UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
UI_thermo(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||||
UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||||
QObject *parent = nullptr);
|
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(const json &j, QObject *parent = nullptr);
|
||||||
|
|
||||||
void set_value(double value) override;
|
void set_value(double value) override;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Test_Sim::Test_Sim(CAN_Wrapper *can_wrapper, QObject *parent)
|
|||||||
this->push_ui_item(&this->m_led);
|
this->push_ui_item(&this->m_led);
|
||||||
this->push_ui_item(&this->m_checkbox);
|
this->push_ui_item(&this->m_checkbox);
|
||||||
|
|
||||||
QObject::connect(&m_button, &UI_button::on_click, this, [=, this] { button_clicked(&m_button); });
|
QObject::connect(&m_button, &UI_button::clicked, this, [=, this] { button_clicked(&m_button); });
|
||||||
QObject::connect(&m_slider, &UI_slider::on_change, this,
|
QObject::connect(&m_slider, &UI_slider::on_change, this,
|
||||||
[=, this](double value) { slider_changed(&m_slider, value); });
|
[=, this](double value) { slider_changed(&m_slider, value); });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user