stacked widget

tested and working
This commit is contained in:
2026-02-14 14:32:07 +01:00
parent faac84821c
commit 4da26083a7
9 changed files with 236 additions and 96 deletions
+27
View File
@@ -15,6 +15,7 @@ Simulator_base::Simulator_base(QString name, Web_socket_wrapper *web_socket, QWi
{
setWindowTitle(m_name);
}
this->setWindowState(Qt::WindowMaximized);
m_error_dialog->set_error("Connection timed out\nCheck if the server is running");
m_ui_lookup.reserve(40);
}
@@ -179,6 +180,11 @@ void Simulator_base::UI_item_parser(json &input)
process_ui_tab_widget(ui_item, widget);
continue;
}
if (ui_item["type"] == "ui_stacked_widget")
{
process_ui_stacked_widget(ui_item, widget);
continue;
}
if (ui_item["type"] == "ui_plot")
{
process_ui_plot(ui_item, widget);
@@ -644,6 +650,27 @@ void Simulator_base::process_ui_tab_widget(json &ui_item, QWidget *widget)
}
}
void Simulator_base::process_ui_stacked_widget(json &ui_item, QWidget *widget)
{
auto stacked_widget = qobject_cast<QStackedWidget *>(widget);
if (stacked_widget == nullptr)
{
SPDLOG_WARN("widget is not of type QStackedWidget");
return;
}
if (stacked_widget->count() != ui_item.at("tab_count"))
{
SPDLOG_ERROR("QStackedWidget has not the same amount of tabs as the server");
return;
}
if (stacked_widget->currentIndex() != ui_item.at("current_tab"))
{
stacked_widget->setCurrentIndex(ui_item.at("current_tab"));
}
}
void Simulator_base::process_ui_plot(json &ui_item, QWidget *widget)
{
auto plot = qobject_cast<Plot_wrapper *>(widget);