mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
stacked widget
tested and working
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -57,6 +57,7 @@ class Simulator_base : public QMainWindow
|
||||
virtual void process_ui_double_spinbox(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_hex_spinbox(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_tab_widget(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_stacked_widget(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_plot(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_table(json &ui_item, QWidget *widget);
|
||||
virtual void process_ui_can(json &ui_item, QWidget *widget);
|
||||
|
||||
@@ -7,8 +7,6 @@ Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
||||
: Simulator_base("Test Sim", web_socket, parent), ui(new Ui::Test_Sim)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle("Test Sim");
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
|
||||
PUSH_UI_ITEM(button);
|
||||
PUSH_UI_ITEM(combobox);
|
||||
@@ -24,6 +22,7 @@ Test_Sim::Test_Sim(Web_socket_wrapper *web_socket, QWidget *parent)
|
||||
PUSH_UI_ITEM(doubleSpinBox);
|
||||
PUSH_UI_ITEM(hexSpinBox);
|
||||
PUSH_UI_ITEM(tabWidget);
|
||||
PUSH_UI_ITEM(stackedWidget);
|
||||
}
|
||||
|
||||
Test_Sim::~Test_Sim()
|
||||
|
||||
+133
-93
@@ -15,6 +15,20 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="slider_label">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QwtSlider" name="slider"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
@@ -22,6 +36,125 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Tab 3</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="thermo_label">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QwtThermo" name="thermo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="button">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Led" name="led">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QComboBox" name="combobox"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Page 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Page 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Page 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QTableWidget" name="table"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>CheckBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="Plot_wrapper" name="plot">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
@@ -49,102 +182,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QComboBox" name="combobox"/>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="button">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Led" name="led">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QTableWidget" name="table"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="Plot_wrapper" name="plot">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="thermo_label">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QwtThermo" name="thermo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>CheckBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="slider_label">
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QwtSlider" name="slider"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="HexSpinBox" name="hexSpinBox"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>Tab 3</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
|
||||
Reference in New Issue
Block a user