mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
UI base
fix for windows
This commit is contained in:
+55
-5
@@ -243,13 +243,21 @@ void UI_base::process_ui_label(json &ui_item, QWidget *widget)
|
||||
void UI_base::process_ui_slider(json &ui_item, QWidget *widget)
|
||||
{
|
||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||
|
||||
#ifdef __WIN32
|
||||
if (!widget->inherits("QwtSlider"))
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtSlider");
|
||||
return;
|
||||
}
|
||||
auto slider = static_cast<QwtSlider *>(widget);
|
||||
#else
|
||||
auto slider = qobject_cast<QwtSlider *>(widget);
|
||||
if (slider == nullptr)
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtSlider");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
double value = ui_item.at("value");
|
||||
bool enable = ui_item.at("enabled");
|
||||
@@ -283,12 +291,21 @@ void UI_base::process_ui_dial(json &ui_item, QWidget *widget)
|
||||
{
|
||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||
|
||||
#ifdef __WIN32
|
||||
if (!widget->inherits("QwtDial"))
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtDial");
|
||||
return;
|
||||
}
|
||||
auto dial = static_cast<QwtDial *>(widget);
|
||||
#else
|
||||
auto dial = qobject_cast<QwtDial *>(widget);
|
||||
if (dial == nullptr)
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtDial");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
double value = ui_item.at("value");
|
||||
bool visible = ui_item.at("visible");
|
||||
@@ -315,12 +332,21 @@ void UI_base::process_ui_thermo(json &ui_item, QWidget *widget)
|
||||
{
|
||||
QLabel *label = id_to_label(id_to_ui(ui_item.at("id")));
|
||||
|
||||
#ifdef __WIN32
|
||||
if (!widget->inherits("QwtThermo"))
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtThermo");
|
||||
return;
|
||||
}
|
||||
auto thermo = static_cast<QwtThermo *>(widget);
|
||||
#else
|
||||
auto thermo = qobject_cast<QwtThermo *>(widget);
|
||||
if (thermo == nullptr)
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtThermo");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
double value = ui_item.at("value");
|
||||
bool visible = ui_item.at("visible");
|
||||
@@ -1010,18 +1036,42 @@ void UI_base::setup_checkbox(QWidget *item, size_t index)
|
||||
|
||||
void UI_base::setup_dial(QWidget *item, size_t index)
|
||||
{
|
||||
QwtDial *dial = qobject_cast<QwtDial *>(item);
|
||||
if (dial == nullptr)
|
||||
#ifdef __WIN32
|
||||
if (!item->inherits("QwtDial"))
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtDial");
|
||||
return;
|
||||
}
|
||||
auto dial = static_cast<QwtDial *>(item);
|
||||
#else
|
||||
auto dial = qobject_cast<QwtDial *>(item);
|
||||
if (dial == nullptr)
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtDial");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
create_dial_needle(dial);
|
||||
}
|
||||
|
||||
void UI_base::setup_slider(QWidget *item, size_t index)
|
||||
{
|
||||
QwtSlider *slider = qobject_cast<QwtSlider *>(item);
|
||||
if (slider == nullptr)
|
||||
#ifdef __WIN32
|
||||
if (!item->inherits("QwtSlider"))
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtSlider");
|
||||
return;
|
||||
}
|
||||
auto slider = static_cast<QwtSlider *>(item);
|
||||
#else
|
||||
auto slider = qobject_cast<QwtSlider *>(item);
|
||||
if (slider == nullptr)
|
||||
{
|
||||
LOG_WARN("widget is not of type QwtSlider");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
connect(slider, &QwtSlider::sliderMoved, this,
|
||||
[=, this] { m_web_socket->send_event(Web_socket_wrapper::Event::value_changed, index, slider->value()); });
|
||||
|
||||
Reference in New Issue
Block a user