|
|
|
|
#include "CUIComponentCheckBox.h"
|
|
|
|
|
|
|
|
|
|
#include <CUIConfig.h>
|
|
|
|
|
#include <CUIPropertyWidget.h>
|
|
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
CUIComponentCheckBox::CUIComponentCheckBox(CUIConfig *conf,
|
|
|
|
|
QVector<CUIPropertyWidget *> &subCUI,
|
|
|
|
|
QWidget *parent)
|
|
|
|
|
: CUIComponentBaseWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
this->m_conf = conf;
|
|
|
|
|
initUI(subCUI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUIComponentCheckBox::initUI(QVector<CUIPropertyWidget *> &subCUI)
|
|
|
|
|
{
|
|
|
|
|
m_checkBox = new QCheckBox();
|
|
|
|
|
m_checkBox->setText(m_conf->getPropertyValue("name"));
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
|
layout->addWidget(m_checkBox);
|
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
// 设置值和响应
|
|
|
|
|
QVariant vOrigin = m_conf->getPropertyOriginValue("value_origin");
|
|
|
|
|
int *ptr = qvariant_cast<int *>(vOrigin);
|
|
|
|
|
if (ptr != nullptr) {
|
|
|
|
|
if (*ptr == 1) {
|
|
|
|
|
m_checkBox->setCheckState(Qt::Checked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
connect(m_checkBox, QOverload<bool>::of(&QCheckBox::clicked),
|
|
|
|
|
[ = ](bool sign) {
|
|
|
|
|
this->m_conf->setValue((int)sign);
|
|
|
|
|
});
|
|
|
|
|
}
|