mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
UI
Add units to the dial, slider and thermo
This commit is contained in:
+13
-3
@@ -1,12 +1,20 @@
|
||||
#include "UI_dial.hpp"
|
||||
|
||||
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, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent)
|
||||
: UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value)
|
||||
: UI_item(UI_DIAL_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit)
|
||||
{
|
||||
}
|
||||
|
||||
UI_dial::UI_dial(const json &j, QObject *parrent) : UI_item(UI_DIAL_TYPE, parrent)
|
||||
UI_dial::UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max,
|
||||
double value, QObject *parrent)
|
||||
: UI_dial(text, "", fg_color, bg_color, min, max, value, parrent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UI_dial::UI_dial(const json &j, QObject *parrent)
|
||||
: UI_item(UI_DIAL_TYPE, parrent)
|
||||
{
|
||||
from_json(j);
|
||||
}
|
||||
@@ -44,6 +52,7 @@ void UI_dial::from_json(const json &j)
|
||||
this->m_min = j.at("min");
|
||||
this->m_max = j.at("max");
|
||||
this->m_value = j.at("value");
|
||||
this->m_unit = j.at("unit");
|
||||
}
|
||||
|
||||
json UI_dial::to_json(size_t id) const
|
||||
@@ -52,5 +61,6 @@ json UI_dial::to_json(size_t id) const
|
||||
j["min"] = this->m_min;
|
||||
j["max"] = this->m_max;
|
||||
j["value"] = this->m_value;
|
||||
j["unit"] = this->m_unit;
|
||||
return j;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ class UI_dial : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_dial(const json &j, QObject *parrent = nullptr);
|
||||
@@ -24,4 +26,5 @@ class UI_dial : public UI_item
|
||||
double m_min;
|
||||
double m_max;
|
||||
double m_value;
|
||||
std::string m_unit;
|
||||
};
|
||||
|
||||
+11
-2
@@ -1,11 +1,18 @@
|
||||
#include "UI_slider.hpp"
|
||||
|
||||
UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max,
|
||||
UI_slider::UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
|
||||
double value, QObject *parrent)
|
||||
: UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value)
|
||||
: UI_item(UI_SLIDER_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit)
|
||||
{
|
||||
}
|
||||
|
||||
UI_slider::UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent)
|
||||
: UI_slider(text, "", fg_color, bg_color, min, max, value, parrent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
UI_slider::UI_slider(const json &j, QObject *parrent) : UI_item(UI_SLIDER_TYPE, parrent)
|
||||
{
|
||||
from_json(j);
|
||||
@@ -45,6 +52,7 @@ void UI_slider::from_json(const json &j)
|
||||
this->m_min = j.at("min");
|
||||
this->m_max = j.at("max");
|
||||
this->m_value = j.at("value");
|
||||
this->m_unit = j.at("unit");
|
||||
}
|
||||
|
||||
json UI_slider::to_json(size_t id) const
|
||||
@@ -53,5 +61,6 @@ json UI_slider::to_json(size_t id) const
|
||||
j["min"] = this->m_min;
|
||||
j["max"] = this->m_max;
|
||||
j["value"] = this->m_value;
|
||||
j["unit"] = this->m_unit;
|
||||
return j;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ class UI_slider : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_slider(const json &j, QObject *parrent = nullptr);
|
||||
@@ -26,4 +28,5 @@ class UI_slider : public UI_item
|
||||
double m_min;
|
||||
double m_max;
|
||||
double m_value;
|
||||
std::string m_unit;
|
||||
};
|
||||
|
||||
+10
-2
@@ -1,8 +1,14 @@
|
||||
#include "UI_thermo.hpp"
|
||||
|
||||
UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max,
|
||||
UI_thermo::UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
|
||||
double value, QObject *parrent)
|
||||
: UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value)
|
||||
: UI_item(UI_THERMO_TYPE, text, 12, fg_color, bg_color, parrent), m_min(min), m_max(max), m_value(value), m_unit(unit)
|
||||
{
|
||||
}
|
||||
|
||||
UI_thermo::UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent)
|
||||
: UI_thermo(text, "", fg_color, bg_color, min, max, value, parrent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,6 +100,7 @@ void UI_thermo::from_json(const json &j)
|
||||
this->m_min = j.at("min");
|
||||
this->m_max = j.at("max");
|
||||
this->m_value = j.at("value");
|
||||
this->m_unit = j.at("unit");
|
||||
this->m_color_map.clear();
|
||||
for (auto &i : j["color_map"])
|
||||
{
|
||||
@@ -109,6 +116,7 @@ json UI_thermo::to_json(size_t id) const
|
||||
j["min"] = this->m_min;
|
||||
j["max"] = this->m_max;
|
||||
j["value"] = this->m_value;
|
||||
j["unit"] = this->m_unit;
|
||||
j["color_map"] = json::array();
|
||||
for (auto &[key, value] : this->m_color_map)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@ class UI_thermo : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parrent = nullptr);
|
||||
UI_thermo(const json &j, QObject *parrent = nullptr);
|
||||
@@ -32,5 +34,6 @@ class UI_thermo : public UI_item
|
||||
double m_min;
|
||||
double m_max;
|
||||
double m_value;
|
||||
std::string m_unit;
|
||||
std::unordered_map<double, Color> m_color_map;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user