mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
rename ui
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "UI_button.hpp"
|
|
||||||
#include "UI_checkbox.hpp"
|
|
||||||
#include "UI_combobox.hpp"
|
|
||||||
#include "UI_dial.hpp"
|
|
||||||
#include "UI_label.hpp"
|
|
||||||
#include "UI_led.hpp"
|
|
||||||
#include "UI_plot.hpp"
|
|
||||||
#include "UI_slider.hpp"
|
|
||||||
#include "UI_table.hpp"
|
|
||||||
#include "UI_textbox.hpp"
|
|
||||||
#include "UI_thermo.hpp"
|
|
||||||
|
|
||||||
#include "custom/UI_can.hpp"
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_can.hpp"
|
#include "ui_can.hpp"
|
||||||
|
|
||||||
template <class T> T ByteArrayToStdArray(const QByteArray &byteArray)
|
template <class T> T ByteArrayToStdArray(const QByteArray &byteArray)
|
||||||
{
|
{
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include <QCanBusFrame>
|
#include <QCanBusFrame>
|
||||||
|
|
||||||
#define UI_CAN_TYPE std::string("UI_can")
|
#define UI_CAN_TYPE std::string("ui_can")
|
||||||
|
|
||||||
class CanFrame
|
class CanFrame
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui_button.hpp"
|
||||||
|
#include "ui_checkbox.hpp"
|
||||||
|
#include "ui_combobox.hpp"
|
||||||
|
#include "ui_dial.hpp"
|
||||||
|
#include "ui_label.hpp"
|
||||||
|
#include "ui_led.hpp"
|
||||||
|
#include "ui_plot.hpp"
|
||||||
|
#include "ui_slider.hpp"
|
||||||
|
#include "ui_table.hpp"
|
||||||
|
#include "ui_textbox.hpp"
|
||||||
|
#include "ui_thermo.hpp"
|
||||||
|
|
||||||
|
#include "custom/ui_can.hpp"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_button.hpp"
|
#include "ui_button.hpp"
|
||||||
|
|
||||||
UI_button::UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent)
|
UI_button::UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent)
|
||||||
: UI_item(UI_BUTTON_TYPE, text, 12, fg_color, bg_color, parent)
|
: UI_item(UI_BUTTON_TYPE, text, 12, fg_color, bg_color, parent)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
#define UI_BUTTON_TYPE std::string("UI_button")
|
#define UI_BUTTON_TYPE std::string("ui_button")
|
||||||
|
|
||||||
class UI_button : public UI_item
|
class UI_button : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_checkbox.hpp"
|
#include "ui_checkbox.hpp"
|
||||||
|
|
||||||
UI_checkbox::UI_checkbox(QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_checked()
|
UI_checkbox::UI_checkbox(QObject *parent) : UI_item(UI_CHECKBOX_TYPE, parent), m_checked()
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define UI_CHECKBOX_TYPE std::string("UI_checkbox")
|
#define UI_CHECKBOX_TYPE std::string("ui_checkbox")
|
||||||
|
|
||||||
class UI_checkbox : public UI_item
|
class UI_checkbox : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_combobox.hpp"
|
#include "ui_combobox.hpp"
|
||||||
|
|
||||||
UI_combobox::UI_combobox(QObject *parent) : UI_x_boxes(UI_COMBOBOX_TYPE, parent)
|
UI_combobox::UI_combobox(QObject *parent) : UI_x_boxes(UI_COMBOBOX_TYPE, parent)
|
||||||
{
|
{
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include "UI_x_boxes.hpp"
|
#include "ui_x_boxes.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#define UI_COMBOBOX_TYPE std::string("UI_combobox")
|
#define UI_COMBOBOX_TYPE std::string("ui_combobox")
|
||||||
|
|
||||||
class UI_combobox : public UI_x_boxes
|
class UI_combobox : public UI_x_boxes
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_dial.hpp"
|
#include "ui_dial.hpp"
|
||||||
|
|
||||||
UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
|
UI_dial::UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max,
|
||||||
double value, QObject *parent)
|
double value, QObject *parent)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
#define UI_DIAL_TYPE std::string("UI_dial")
|
#define UI_DIAL_TYPE std::string("ui_dial")
|
||||||
|
|
||||||
class UI_dial : public UI_item
|
class UI_dial : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
UI_item::UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, Color bg_color, QObject *parent)
|
UI_item::UI_item(std::string type, std::string text, uint8_t text_size, Color fg_color, Color bg_color, QObject *parent)
|
||||||
: QObject(parent), m_id((size_t)-1), m_type(type), m_text(text), m_text_size(text_size), m_fg_color(fg_color),
|
: QObject(parent), m_id((size_t)-1), m_type(type), m_text(text), m_text_size(text_size), m_fg_color(fg_color),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_label.hpp"
|
#include "ui_label.hpp"
|
||||||
|
|
||||||
UI_label::UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent)
|
UI_label::UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent)
|
||||||
: UI_item(UI_LABEL_TYPE, text, 12, fg_color, bg_color, parent)
|
: UI_item(UI_LABEL_TYPE, text, 12, fg_color, bg_color, parent)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define UI_LABEL_TYPE std::string("UI_label")
|
#define UI_LABEL_TYPE std::string("ui_label")
|
||||||
|
|
||||||
class UI_label : public UI_item
|
class UI_label : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_led.hpp"
|
#include "ui_led.hpp"
|
||||||
|
|
||||||
UI_led::UI_led(QObject *parent) : UI_item(UI_LED_TYPE, "", 12, Color::Default, Color::Default, parent)
|
UI_led::UI_led(QObject *parent) : UI_item(UI_LED_TYPE, "", 12, Color::Default, Color::Default, parent)
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define UI_LED_TYPE std::string("UI_led")
|
#define UI_LED_TYPE std::string("ui_led")
|
||||||
|
|
||||||
class UI_led : public UI_item
|
class UI_led : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_plot.hpp"
|
#include "ui_plot.hpp"
|
||||||
|
|
||||||
UI_plot::UI_plot(QObject *parent) : UI_item{UI_PLOT_TYPE, parent}
|
UI_plot::UI_plot(QObject *parent) : UI_item{UI_PLOT_TYPE, parent}
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef UI_PLOT_H
|
#ifndef UI_PLOT_H
|
||||||
#define UI_PLOT_H
|
#define UI_PLOT_H
|
||||||
|
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#define UI_PLOT_TYPE std::string("UI_plot")
|
#define UI_PLOT_TYPE std::string("ui_plot")
|
||||||
|
|
||||||
class UI_plot : public UI_item
|
class UI_plot : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_slider.hpp"
|
#include "ui_slider.hpp"
|
||||||
|
|
||||||
UI_slider::UI_slider(std::string text, std::string unit, 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 *parent)
|
double value, QObject *parent)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
#define UI_SLIDER_TYPE std::string("UI_slider")
|
#define UI_SLIDER_TYPE std::string("ui_slider")
|
||||||
|
|
||||||
class UI_slider : public UI_item
|
class UI_slider : public UI_item
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include "ui_spinbox.hpp"
|
||||||
|
|
||||||
|
UI_spinbox::UI_spinbox(QObject* parent) : UI_item(UI_SPINBOX_TYPE, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UI_spinbox::UI_spinbox(double min, double max, double value, QObject* parent) : UI_item(UI_SPINBOX_TYPE, parent)
|
||||||
|
{
|
||||||
|
m_min = min;
|
||||||
|
m_max = max;
|
||||||
|
m_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI_spinbox::set_value(double value)
|
||||||
|
{
|
||||||
|
if (value < m_min || value > m_max)
|
||||||
|
return;
|
||||||
|
if (value == m_value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->m_value = value;
|
||||||
|
emit ui_changed();
|
||||||
|
emit changed(m_value);
|
||||||
|
}
|
||||||
|
double UI_spinbox::value() const
|
||||||
|
{
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double UI_spinbox::min() const
|
||||||
|
{
|
||||||
|
return m_min;
|
||||||
|
}
|
||||||
|
double UI_spinbox::max() const
|
||||||
|
{
|
||||||
|
return m_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI_spinbox::from_json(const json &j)
|
||||||
|
{
|
||||||
|
UI_item::from_json(j);
|
||||||
|
|
||||||
|
this->m_min = j.at("min");
|
||||||
|
this->m_max = j.at("max");
|
||||||
|
this->m_value = j.at("value");
|
||||||
|
}
|
||||||
|
|
||||||
|
json UI_spinbox::to_json(size_t id) const
|
||||||
|
{
|
||||||
|
json j = UI_item::to_json(id);
|
||||||
|
j["min"] = this->m_min;
|
||||||
|
j["max"] = this->m_max;
|
||||||
|
j["value"] = this->m_value;
|
||||||
|
return j;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef UI_SPINBOX_HPP
|
||||||
|
#define UI_SPINBOX_HPP
|
||||||
|
|
||||||
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
|
#define UI_SPINBOX_TYPE std::string("ui_spinbox")
|
||||||
|
|
||||||
|
class UI_spinbox : public UI_item {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit UI_spinbox(QObject* parent = nullptr);
|
||||||
|
UI_spinbox(double min, double max, double value, QObject* parent = nullptr);
|
||||||
|
|
||||||
|
void set_value(double value) override;
|
||||||
|
double value() const;
|
||||||
|
|
||||||
|
double min() const;
|
||||||
|
double max() const;
|
||||||
|
|
||||||
|
void from_json(const json &j) override;
|
||||||
|
json to_json(size_t id) const override;
|
||||||
|
signals:
|
||||||
|
void changed(double value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
double m_min;
|
||||||
|
double m_max;
|
||||||
|
double m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UI_SPINBOX_HPP
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_table.hpp"
|
#include "ui_table.hpp"
|
||||||
|
|
||||||
UI_table::UI_table(QObject *parent) : UI_item(UI_TABLE_TYPE, parent), m_row_count(0), m_column_count(0)
|
UI_table::UI_table(QObject *parent) : UI_item(UI_TABLE_TYPE, parent), m_row_count(0), m_column_count(0)
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#ifndef UI_TABLE_HPP
|
#ifndef UI_TABLE_HPP
|
||||||
#define UI_TABLE_HPP
|
#define UI_TABLE_HPP
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
#define UI_TABLE_TYPE std::string("UI_table")
|
#define UI_TABLE_TYPE std::string("ui_table")
|
||||||
|
|
||||||
class UI_table : public UI_item
|
class UI_table : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_textbox.hpp"
|
#include "ui_textbox.hpp"
|
||||||
|
|
||||||
UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent)
|
UI_textbox::UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent)
|
||||||
: UI_item(UI_TEXTBOX_TYPE, "", 0, fg_color, bg_color, parent), m_hint(hint)
|
: UI_item(UI_TEXTBOX_TYPE, "", 0, fg_color, bg_color, parent), m_hint(hint)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define UI_TEXTBOX_TYPE std::string("UI_textbox")
|
#define UI_TEXTBOX_TYPE std::string("ui_textbox")
|
||||||
|
|
||||||
class UI_textbox : public UI_item
|
class UI_textbox : public UI_item
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_thermo.hpp"
|
#include "ui_thermo.hpp"
|
||||||
|
|
||||||
UI_thermo::UI_thermo(std::string text, std::string unit, 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 *parent)
|
double value, QObject *parent)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
#define UI_THERMO_TYPE std::string("UI_thermo")
|
#define UI_THERMO_TYPE std::string("ui_thermo")
|
||||||
|
|
||||||
// TODO: Add color scale
|
// TODO: Add color scale
|
||||||
class UI_thermo : public UI_item
|
class UI_thermo : public UI_item
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "UI_x_boxes.hpp"
|
#include "ui_x_boxes.hpp"
|
||||||
|
|
||||||
UI_x_boxes::UI_x_boxes(std::string type, QObject *parent) : UI_item(type, parent), m_options()
|
UI_x_boxes::UI_x_boxes(std::string type, QObject *parent) : UI_item(type, parent), m_options()
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "UI_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
|
||||||
class UI_x_boxes : public UI_item
|
class UI_x_boxes : public UI_item
|
||||||
{
|
{
|
||||||
+13
-13
@@ -97,67 +97,67 @@ void Simulator_base::UI_item_parser(json &input)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui_item["type"] == "UI_button")
|
if (ui_item["type"] == "ui_button")
|
||||||
{
|
{
|
||||||
process_ui_button(ui_item, widget);
|
process_ui_button(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_led")
|
if (ui_item["type"] == "ui_led")
|
||||||
{
|
{
|
||||||
process_ui_led(ui_item, widget);
|
process_ui_led(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_slider")
|
if (ui_item["type"] == "ui_slider")
|
||||||
{
|
{
|
||||||
process_ui_slider(ui_item, widget);
|
process_ui_slider(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_dial")
|
if (ui_item["type"] == "ui_dial")
|
||||||
{
|
{
|
||||||
process_ui_dial(ui_item, widget);
|
process_ui_dial(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_thermo")
|
if (ui_item["type"] == "ui_thermo")
|
||||||
{
|
{
|
||||||
process_ui_thermo(ui_item, widget);
|
process_ui_thermo(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_textbox")
|
if (ui_item["type"] == "ui_textbox")
|
||||||
{
|
{
|
||||||
process_ui_textbox(ui_item, widget);
|
process_ui_textbox(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_label")
|
if (ui_item["type"] == "ui_label")
|
||||||
{
|
{
|
||||||
process_ui_label(ui_item, widget);
|
process_ui_label(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_combobox")
|
if (ui_item["type"] == "ui_combobox")
|
||||||
{
|
{
|
||||||
process_ui_combobox(ui_item, widget);
|
process_ui_combobox(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_RadioButton")
|
if (ui_item["type"] == "ui_RadioButton")
|
||||||
{
|
{
|
||||||
process_ui_radiobutton(ui_item, widget);
|
process_ui_radiobutton(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_checkbox")
|
if (ui_item["type"] == "ui_checkbox")
|
||||||
{
|
{
|
||||||
process_ui_checkbox(ui_item, widget);
|
process_ui_checkbox(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_plot")
|
if (ui_item["type"] == "ui_plot")
|
||||||
{
|
{
|
||||||
process_ui_plot(ui_item, widget);
|
process_ui_plot(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_table")
|
if (ui_item["type"] == "ui_table")
|
||||||
{
|
{
|
||||||
process_ui_table(ui_item, widget);
|
process_ui_table(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ui_item["type"] == "UI_can")
|
if (ui_item["type"] == "ui_can")
|
||||||
{
|
{
|
||||||
process_ui_can(ui_item, widget);
|
process_ui_can(ui_item, widget);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
#include "UI.hpp"
|
#include "ui.hpp"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ TEST(UI_label, to_from_json)
|
|||||||
{
|
{
|
||||||
UI_label label("label_text", Color(0, 0, 0), Color(255, 255, 255));
|
UI_label label("label_text", Color(0, 0, 0), Color(255, 255, 255));
|
||||||
json j = label.to_json(0);
|
json j = label.to_json(0);
|
||||||
EXPECT_EQ(j["type"], "UI_label");
|
EXPECT_EQ(j["type"], "ui_label");
|
||||||
EXPECT_EQ(j["id"], 0);
|
EXPECT_EQ(j["id"], 0);
|
||||||
EXPECT_EQ(j["text"], "label_text");
|
EXPECT_EQ(j["text"], "label_text");
|
||||||
EXPECT_EQ(j["text_size"], 12);
|
EXPECT_EQ(j["text_size"], 12);
|
||||||
|
|||||||
Reference in New Issue
Block a user