mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
UI
Add spinboxes
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
#include "ui_button.hpp"
|
||||
#include "ui_checkbox.hpp"
|
||||
#include "ui_combobox.hpp"
|
||||
#include "ui_double_spinbox.hpp"
|
||||
#include "ui_dial.hpp"
|
||||
#include "ui_hex_spinbox.hpp"
|
||||
#include "ui_label.hpp"
|
||||
#include "ui_led.hpp"
|
||||
#include "ui_plot.hpp"
|
||||
#include "ui_slider.hpp"
|
||||
#include "ui_spinbox.hpp"
|
||||
#include "ui_table.hpp"
|
||||
#include "ui_textbox.hpp"
|
||||
#include "ui_thermo.hpp"
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "ui_double_spinbox.hpp"
|
||||
|
||||
UI_double_spinbox::UI_double_spinbox(QObject* parent) : UI_item(UI_DOUBLE_SPINBOX_TYPE, parent)
|
||||
{
|
||||
}
|
||||
|
||||
UI_double_spinbox::UI_double_spinbox(double min, double max, double value, QObject* parent) : UI_item(UI_DOUBLE_SPINBOX_TYPE, parent)
|
||||
{
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
void UI_double_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_double_spinbox::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
double UI_double_spinbox::min() const
|
||||
{
|
||||
return m_min;
|
||||
}
|
||||
double UI_double_spinbox::max() const
|
||||
{
|
||||
return m_max;
|
||||
}
|
||||
|
||||
void UI_double_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_double_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_DOUBLE_SPINBOX_H
|
||||
#define UI_DOUBLE_SPINBOX_H
|
||||
|
||||
#include "ui_item.hpp"
|
||||
|
||||
#define UI_DOUBLE_SPINBOX_TYPE std::string("ui_double_spinbox")
|
||||
|
||||
class UI_double_spinbox : public UI_item {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UI_double_spinbox(QObject* parent = nullptr);
|
||||
UI_double_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_DOUBLE_SPINBOX_H
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "ui_hex_spinbox.hpp"
|
||||
|
||||
UI_hex_spinbox::UI_hex_spinbox(QObject* parent) : UI_item(UI_HEX_SPINBOX_TYPE, parent) {
|
||||
}
|
||||
|
||||
UI_hex_spinbox::UI_hex_spinbox(double min, double max, double value, QObject* parent) : UI_item(UI_HEX_SPINBOX_TYPE, parent)
|
||||
{
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
void UI_hex_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_hex_spinbox::value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
double UI_hex_spinbox::min() const
|
||||
{
|
||||
return m_min;
|
||||
}
|
||||
double UI_hex_spinbox::max() const
|
||||
{
|
||||
return m_max;
|
||||
}
|
||||
|
||||
void UI_hex_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_hex_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_HEX_SPINBOX_HPP
|
||||
#define UI_HEX_SPINBOX_HPP
|
||||
|
||||
#include "ui_item.hpp"
|
||||
|
||||
#define UI_HEX_SPINBOX_TYPE std::string("ui_hex_spinbox")
|
||||
|
||||
class UI_hex_spinbox : public UI_item {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UI_hex_spinbox(QObject* parent = nullptr);
|
||||
UI_hex_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_HEX_SPINBOX_HPP
|
||||
Reference in New Issue
Block a user