diff --git a/CFDStruct/CFDStructDataManager/CFDStructDataSolverKvislManager.cpp b/CFDStruct/CFDStructDataManager/CFDStructDataSolverKvislManager.cpp index 5a18b9c..c988fab 100644 --- a/CFDStruct/CFDStructDataManager/CFDStructDataSolverKvislManager.cpp +++ b/CFDStruct/CFDStructDataManager/CFDStructDataSolverKvislManager.cpp @@ -20,8 +20,10 @@ CUIConfig *CFDStructDataSolverKvislManager::genInviscidUIConfig() { return new CUIConfig( {{"type", "Widget"}}, - {new CUIConfig({{"type", "ButtonBox"}, // 组:模型 - {"name", tr("Model")}}, + {new CUIConfig({{"type", "RadioComponent"}, // 组:模型 + {"name", tr("Model")}, + {"widget","GroupBox"}, + }, {new CUIConfig({{"type", "RadioButton"}, // 按钮:无粘 {"name", tr("Inviscid")}}), new CUIConfig({{"type", "RadioButton"}, // 按钮:层流 diff --git a/CFDStruct/CUIProperty/CUI.cpp b/CFDStruct/CUIProperty/CUI.cpp index f94fbe1..2261841 100644 --- a/CFDStruct/CUIProperty/CUI.cpp +++ b/CFDStruct/CUIProperty/CUI.cpp @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include + /** * @brief CUI::CUI 构造函数 * @param conf 配置信息 @@ -53,6 +55,8 @@ void CUI::buildUI() widget = new CUIRadioButton(conf, subCUI); } else if(type == "ButtonBox") { widget = new CUIButtonBox(conf, subCUI); + } else if(type == "RadioComponent"){ + widget = new CUIRadioComponent(conf,subCUI); } if (widget) { qDebug() << "----------- ui widget is not null"; diff --git a/CFDStruct/CUIProperty/CUI.h b/CFDStruct/CUIProperty/CUI.h index dba3cd6..cca241a 100644 --- a/CFDStruct/CUIProperty/CUI.h +++ b/CFDStruct/CUIProperty/CUI.h @@ -17,6 +17,7 @@ class CUIPushButton; class CUICheckBox; class CUIRadioButton; class CUIButtonBox; +class CUIRadioComponent; /** * @brief The CUI class 管理类,通过处理config来创建相应的组件并提供服务 @@ -45,6 +46,7 @@ private: CUICheckBox* uiCheckBox; CUIRadioButton* uiRadioButton; CUIButtonBox* uiButtonBox; + CUIRadioComponent* uiRadioComponent; QVector subCUI; diff --git a/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp index 23a26a2..4e36363 100644 --- a/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp +++ b/CFDStruct/CUIProperty/CUIComponentBaseContainerWidget.cpp @@ -17,7 +17,7 @@ QLayout *CUIComponentBaseContainerWidget::getLayout(CUIConfig *conf) QString layoutConf = conf->getPropertyValue("layout"); if (layoutConf == "QVBoxLayout") { layout = new QVBoxLayout; - } else if (layoutConf == "QVBoxLayout") { + } else if (layoutConf == "QHBoxLayout") { layout = new QHBoxLayout; } else { layout = new QVBoxLayout; diff --git a/CFDStruct/CUIProperty/CUIProperty.pri b/CFDStruct/CUIProperty/CUIProperty.pri index c0bbedf..30b7271 100644 --- a/CFDStruct/CUIProperty/CUIProperty.pri +++ b/CFDStruct/CUIProperty/CUIProperty.pri @@ -3,6 +3,7 @@ HEADERS += \ $$PWD/CUIComponentBaseContainerWidget.h \ $$PWD/CUIComponentBaseWidget.h \ $$PWD/CUIDefine.h \ + $$PWD/CUIRadioComponent.h \ CUI.h \ CUIButtonBox.h \ CUICheckBox.h \ @@ -21,6 +22,7 @@ SOURCES += \ $$PWD/CUIComponentBase.cpp \ $$PWD/CUIComponentBaseContainerWidget.cpp \ $$PWD/CUIComponentBaseWidget.cpp \ + $$PWD/CUIRadioComponent.cpp \ CUI.cpp \ CUIButtonBox.cpp \ CUICheckBox.cpp \ diff --git a/CFDStruct/CUIProperty/CUIRadioComponent.cpp b/CFDStruct/CUIProperty/CUIRadioComponent.cpp new file mode 100644 index 0000000..b40df30 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIRadioComponent.cpp @@ -0,0 +1,56 @@ +#include "CUIRadioComponent.h" +#include "CUIConfig.h" +#include "QVBoxLayout" + +#include +#include +#include +#include + +CUIRadioComponent::CUIRadioComponent(CUIConfig *conf, QVector &subCUI, QWidget *parent) : CUIComponentBaseContainerWidget(parent) +{ + this->conf = conf; + iniUI(subCUI); +} + + +void CUIRadioComponent::iniUI(QVector &subCUI) +{ + QString widget_type = this->conf->getPropertyValue("widget"); + + QHBoxLayout* mainLayout = new QHBoxLayout; + m_layout = this->getLayout(conf); + + if(widget_type == "GroupBox"){ + iniUI_GroupBox(); + mainLayout->addWidget(m_GroupBox); + }else if(widget_type == "Component"){ + iniUI_Component(); + mainLayout->addWidget(m_label); + mainLayout->addWidget(m_Component); + } + + this->setLayout(mainLayout); +} + +void CUIRadioComponent::iniUI_GroupBox() +{ + m_GroupBox = new QGroupBox; + m_GroupBox->setTitle(conf->getPropertyValue("name")); + m_GroupBox->setLayout(m_layout); + for(auto conf:this->conf->getSub()){ + QRadioButton* radio = new QRadioButton(conf->getPropertyValue("name")); + m_layout->addWidget(radio); + } +} + +void CUIRadioComponent::iniUI_Component() +{ + m_label = new QLabel(conf->getPropertyValue("name")); + m_Component = new QWidget; + m_Component->setLayout(m_layout); + for(auto conf:this->conf->getSub()){ + QRadioButton* radio = new QRadioButton(conf->getPropertyValue("name")); + m_layout->addWidget(radio); + } +} diff --git a/CFDStruct/CUIProperty/CUIRadioComponent.h b/CFDStruct/CUIProperty/CUIRadioComponent.h new file mode 100644 index 0000000..ed15ca4 --- /dev/null +++ b/CFDStruct/CUIProperty/CUIRadioComponent.h @@ -0,0 +1,58 @@ +/** + * 单选框组件 + */ + +#ifndef CUIRADIOCOMPONENT_H +#define CUIRADIOCOMPONENT_H + +#include +#include + +class CUIConfig; +class CUI; +class QLabel; +class QHBoxLayout; +class QGroupBox; +class QWidget; + +class CUIRadioComponent : public CUIComponentBaseContainerWidget +{ + Q_OBJECT +public: + /** + * @brief CUIRadioComponent构造函数 + * @param conf配置信息 + * @param subCUI子组件 + * @param parent父组件 + */ + explicit CUIRadioComponent(CUIConfig* conf, QVector &subCUI, QWidget *parent = nullptr); + +private: + /** + * @brief iniUI渲染ui + * @param subCUI子组件 + */ + void iniUI(QVector &subCUI); + + /** + * @brief iniUI_GroupBox渲染groupbox类型 + */ + void iniUI_GroupBox(); + + /** + * @brief iniUI_Component渲染component类型 + */ + void iniUI_Component(); + + CUIConfig* conf; + QLabel* m_label; + QLayout* m_layout; + QGroupBox* m_GroupBox; + QWidget* m_Component; + + +signals: + +}; + +#endif // CUIRADIOCOMPONENT_H