Ver Fonte

控件显示

JonYang há 23 horas atrás
pai
commit
2971e7cadd

+ 211 - 289
View/die-bonder-ui/OriginalWnd/DbTreeViewManager.cpp

@@ -2071,7 +2071,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
     scrollLayout->addLayout(separatorLayout);
     separator->show();
 
-    languageValue = gen_if.getLanguageValue();
+    m_nLanguageSwitch = gen_if.getLanguageValue();
 
     //不同表格的全部插进来
     int previousGroupId = -1;
@@ -2120,34 +2120,15 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                 }
                 previousGroupId = groupId;
 
-                // 每个字段一
+                // 每个控件的
                 QHBoxLayout* fieldLayout = new QHBoxLayout;
                 fieldLayout->setSpacing(5);
+                QLabel* pFieldDescribeLabel = JIoMapPage::JCreateName0(fieldDescribe, fieldDescribe_Eng,m_nLanguageSwitch);
 
-                QLabel* label = new QLabel();
-                if (languageValue == 0) 
-                {
-                    label->setText(fieldDescribe_Eng);
-                    if (fieldDescribe_Eng.isEmpty()) 
-                    {
-                        label->setText(fieldDescribe);
-                    }
-                }
-                else
-                {
-                    label->setText(fieldDescribe);
-                    if (fieldDescribe.isEmpty()) 
-                    {
-                        label->setText(fieldDescribe_Eng);
-                    }
-                }
-
-                label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
-                label->setFixedHeight(24);
-                label->setMinimumWidth(120);
-                fieldLayout->addWidget(label);
+                fieldLayout->addWidget(pFieldDescribeLabel);
                 fieldLayout->addStretch(1);
 
+                //这个是侧边的小部件
                 QWidget* rightWidget = new QWidget;
                 QHBoxLayout* rightLayout = new QHBoxLayout(rightWidget);
                 rightLayout->setContentsMargins(0, 0, 20, 0);
@@ -2167,50 +2148,53 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 
                         // 创建 QLineEdit 显示左边文本
                         QLineEdit* lineEdit = new QLineEdit();
-                        if ((fieldUpLimit == "") && (fieldDownLimit == ""))
+                        // 1.空值判断
+                        if (fieldValue == "")
                         {
-                            lineEdit->setText(fieldValue);
-                            lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-                            lineEdit->setFixedSize(105, 28);
-                            lineEdit->setAlignment(Qt::AlignLeft);
-                            //!!!提到前面
-                            /*lineEdit->setStyleSheet(R"(
-                        QLineEdit {
-                            background: #FFFFFF;
-                            border: 1px solid #BABBDC;
-                            border-radius: 6px;
-                            padding: 2px 5px;
+                            lineEdit->setPlaceholderText(tr("Please input number", "请输入数字"));
                         }
-                        QLineEdit:disabled {
-                            background: #eeeeee;
+                        else
+                        {
+                            lineEdit->setText(fieldValue);
                         }
-                    )");*/
-                        } else
-                        {//上下限至少设置了一个值
-                            if (fieldValue == "")
-                            {
-                                lineEdit->setPlaceholderText(tr("Please input number","请输入数字"));
-                            } else
-                            {
-                                lineEdit->setText(fieldValue);
-                            }
+                        lineEdit->setFixedSize(105, 28);
+                        lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
 
 
-                            lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-                            lineEdit->setFixedSize(105, 28);
-                            lineEdit->setAlignment(Qt::AlignLeft);
-                            /*lineEdit->setStyleSheet(R"(
-                        QLineEdit {
-                            background: #FFFFFF;
-                            border: 1px solid #BABBDC;
-                            border-radius: 6px;
-                            padding: 2px 5px;
+                        // 限制范围
+                        int     nMin    = -1000;
+                        int     nMax    = 1000;
+                        double  doMin   = -1000.0;
+                        double  doMan   = 1000.0;
+                        if ((fieldUpLimit == "") || (fieldDownLimit == ""))
+                        {
                         }
-                        QLineEdit:disabled {
-                            background: #eeeeee;
+                        else
+                        {
+                            nMin = fieldUpLimit.toInt();
+                            nMax = fieldDownLimit.toInt();
+
+                            doMin = fieldUpLimit.toDouble();
+                            doMan = fieldDownLimit.toDouble();
                         }
-                    )");*/
+
+                        if (fieldType == "input")
+                        {
+                            //int 类型
+                            QIntValidator* validator = new QIntValidator(nMin, nMax, lineEdit);
+                            lineEdit->setValidator(validator);
                         }
+                        else if (fieldType == "LONG")
+                        {
+                            QDoubleValidator* validator = new QDoubleValidator(doMin, doMan, 4, lineEdit);
+                            validator->setNotation(QDoubleValidator::StandardNotation);
+                            lineEdit->setValidator(validator);
+                        }
+                        
+
+
+                        lineEdit->setAlignment(Qt::AlignLeft);
+                    
 
                         // 创建 QLabel 显示右边文本(比如 "分钟")
                         QLabel* unitLabel = new QLabel(fieldUnits);
@@ -2280,7 +2264,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                         //    }
 
                         //    });
-						connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldUpLimit, fieldDownLimit, label]() {
+						connect(lineEdit, &QLineEdit::textChanged, [this, lineEdit, fieldUpLimit, fieldDownLimit, pFieldDescribeLabel]() {
 							if ((fieldUpLimit != "") && (fieldDownLimit != ""))
 							{
 								int uplimit = fieldUpLimit.toInt();
@@ -2288,10 +2272,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 								int inputvalue = (lineEdit->text()).toInt();
 								if ((inputvalue <= uplimit) && (inputvalue >= downlimit))
 								{
-									label->setProperty("value", lineEdit->text());
-                                    label->setDisabled(true);
+									pFieldDescribeLabel->setProperty("value", lineEdit->text());
+                                    pFieldDescribeLabel->setDisabled(true);
 									//label->setStyleSheet("color: #5c63be;");
-									modifiedLabels.insert(label);
+									modifiedLabels.insert(pFieldDescribeLabel);
 									// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
 									//updateDb(fieldTableName, fieldId, lineEdit->text());
 								}
@@ -2306,10 +2290,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 								int inputvalue = (lineEdit->text()).toInt();
 								if (inputvalue >= downlimit)
 								{
-									label->setProperty("value", lineEdit->text());
-                                    label->setDisabled(true);
+									pFieldDescribeLabel->setProperty("value", lineEdit->text());
+                                    pFieldDescribeLabel->setDisabled(true);
 									//label->setStyleSheet("color: #5c63be;");
-									modifiedLabels.insert(label);
+									modifiedLabels.insert(pFieldDescribeLabel);
 									// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
 									//updateDb(fieldTableName, fieldId, lineEdit->text());
 								}
@@ -2324,10 +2308,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 								int inputvalue = (lineEdit->text()).toInt();
 								if (inputvalue <= uplimit)
 								{
-									label->setProperty("value", lineEdit->text());
-                                    label->setDisabled(true);
+									pFieldDescribeLabel->setProperty("value", lineEdit->text());
+                                    pFieldDescribeLabel->setDisabled(true);
 									//label->setStyleSheet("color: #5c63be;");
-									modifiedLabels.insert(label);
+									modifiedLabels.insert(pFieldDescribeLabel);
 									// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
 									//updateDb(fieldTableName, fieldId, lineEdit->text());
 								}
@@ -2338,52 +2322,29 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 							}
 							else
 							{
-								label->setProperty("value", lineEdit->text());
-                                label->setDisabled(true);
+								pFieldDescribeLabel->setProperty("value", lineEdit->text());
+                                pFieldDescribeLabel->setDisabled(true);
 								//label->setStyleSheet("color: #5c63be;");
-								modifiedLabels.insert(label);
+								modifiedLabels.insert(pFieldDescribeLabel);
 								// m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit->text());
 								//updateDb(fieldTableName, fieldId, lineEdit->text());
 							}
 
 							});
 
-						connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-							if (modifiedLabels.contains(label)) {
-								m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                                label->setDisabled(false);
+						connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+							if (modifiedLabels.contains(pFieldDescribeLabel)) {
+								m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                                pFieldDescribeLabel->setDisabled(false);
 								//label->setStyleSheet("color: black;");
-								modifiedLabels.remove(label);
+								modifiedLabels.remove(pFieldDescribeLabel);
 							}
 							});
+                        JIoMapPage::JCreateMenu(rightWidget, { fieldDefult ,lineEdit ,privilege ,fieldUserGrade });
 
-						QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
-						btnDefault->setFixedSize(60, 28);
-                        btnDefault->setProperty("type", "default");
-						/*btnDefault->setStyleSheet(R"(
-                            QPushButton {
-                                background: #FFFFFF;
-                                border: 1px solid #BABBDC;
-                                border-radius: 5px;
-                            }
-                            QPushButton:hover {
-                                background-color: #F0F0F0;
-                            }
-                            QPushButton:disabled {
-                                background-color: #cccccc;
-                            }
-                        )");*/
-						rightLayout->addWidget(btnDefault);
-
-						connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, lineEdit]() {
-							if (!fieldDefult.isEmpty()) {
-								lineEdit->setText(fieldDefult);
-							}
-							});
-
-                        if ((privilege &fieldUserGrade) == 1) {
+                        if ((privilege &fieldUserGrade) == 1) 
+                        {
                             lineEdit->setEnabled(false);
-                            btnDefault->setEnabled(false);
                         }
 
                         ST_INPUT_CONT _a;
@@ -2420,23 +2381,23 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                         //    //updateDb(fieldTableName, fieldId, lineEdit1->text());
                         //    loginput(fieldTableName, fieldName, lineEdit1->text());
                         //    });
-                        connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, label]() {
-                            label->setProperty("value", lineEdit1->text());
-                            label->setDisabled(true);
+                        connect(lineEdit1, &QLineEdit::textChanged, [this, lineEdit1, pFieldDescribeLabel]() {
+                            pFieldDescribeLabel->setProperty("value", lineEdit1->text());
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, lineEdit1->text());
                             //updateDb(fieldTableName, fieldId, lineEdit1->text());
                             // loginput(fieldTableName, fieldName, lineEdit1->text());
                             });
 
-                        connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                            if (modifiedLabels.contains(label)) {
-                                m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                                loginput(fieldTableName, fieldName, label->property("value").toString());
-                                label->setDisabled(false);
+                        connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                            if (modifiedLabels.contains(pFieldDescribeLabel)) {
+                                m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                                loginput(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                                pFieldDescribeLabel->setDisabled(false);
                                 //label->setStyleSheet("color: black;");
-                                modifiedLabels.remove(label);
+                                modifiedLabels.remove(pFieldDescribeLabel);
                             }
                             });
 
@@ -2478,7 +2439,7 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                         m_veInputCont.push_back(_a);
                     }
                 } 
-                else if (fieldType == "radio")
+                else if (fieldType == "JRadio")
                 {
                     // 用逗号分隔的选项
                     QStringList optionList = fieldUnits.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
@@ -2488,7 +2449,10 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     for (const QString& optionText : optionList)
                     {
                         QString trimmedOpt = optionText.trimmed();
-                        if (trimmedOpt.isEmpty()) continue;
+                        if (trimmedOpt.isEmpty())
+                        {
+                            continue;
+                        }
                         QRadioButton* radioButton = new QRadioButton(trimmedOpt);
                         radioGroup->addButton(radioButton);
                         radioLayout->addWidget(radioButton);
@@ -2508,13 +2472,13 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     //        //updateDb(fieldTableName, fieldId, button->text());
                     //    }
                     //    });
-                    connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, label](QAbstractButton* button, bool checked) {
+                    connect(radioGroup, static_cast<void (QButtonGroup::*)(QAbstractButton*, bool)>(&QButtonGroup::buttonToggled), [this, pFieldDescribeLabel](QAbstractButton* button, bool checked) {
                         if (checked)
                         {
-                            label->setProperty("value", button->text());
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", button->text());
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                             // qDebug() << "Button toggled:" << button->text();
                             // 在这里添加你想要执行的操作
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, button->text());
@@ -2522,50 +2486,38 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                         }
                         });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel)) {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
                     rightLayout->addLayout(radioLayout);
-
-                    QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
-                    btnDefault->setFixedSize(60, 28);
-                    btnDefault->setProperty("type", "default");
-                    /*btnDefault->setStyleSheet(R"(
-                            QPushButton {
-                                background: #FFFFFF;
-                                border: 1px solid #BABBDC;
-                                border-radius: 5px;
-                            }
-                            QPushButton:hover {
-                                background-color: #F0F0F0;
-                            }
-                            QPushButton:disabled {
-                                background-color: #cccccc;
-                            }
-                        )");*/
-                    rightLayout->addWidget(btnDefault);
-
-                    connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, radioGroup]() {
-                        if (!fieldDefult.isEmpty()) {
-                            for (QAbstractButton* button : radioGroup->buttons()) {
-                                if (button->text() == fieldDefult) {
+                    JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, radioGroup]()
+                        {
+                        if (!fieldDefult.isEmpty())
+                        {
+                            for (QAbstractButton* button : radioGroup->buttons()) 
+                            {
+                                // 这个选中逻辑需要重新做
+                                if (button->text() == fieldDefult)
+                                {
                                     button->setChecked(true);
                                     break;
                                 }
                             }
                         }
                         });
-                    if ((privilege &fieldUserGrade) == 1) {
-                        for (QAbstractButton* btn : radioGroup->buttons()) {
+
+                    if ((privilege &fieldUserGrade) == 1)
+                    {
+                        for (QAbstractButton* btn : radioGroup->buttons()) 
+                        {
                             btn->setEnabled(false);
                         }
-                        btnDefault->setEnabled(false);
                     }
 
                     ST_RADIO_CONT _a;
@@ -2576,13 +2528,14 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 
                     m_veRadioCont.push_back(_a);
                 } 
-                else if (fieldType == "checkbox" || fieldType == "BOOL")
+                else if (fieldType == "BOOL")
                 {
                     bool isChecked;
                     if (fieldValue == "")
                     {
                         isChecked = (fieldValue == "1");
-                    } else
+                    } 
+                    else
                     {
                         isChecked = (fieldValue == "1");
                     }
@@ -2612,94 +2565,63 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                 )");*/
                     rightLayout->addWidget(checkBox);
                     createdWidget = checkBox;
-                    //connect(checkBox, &QCheckBox::stateChanged, [this, fieldTableName, fieldName](int state) {
-                    //    if (state == Qt::Checked)
-                    //    {
-                    //        // qDebug() << "CheckBox is checked"<<fieldId;
-                    //        m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
-                    //        //updateDb(fieldTableName, fieldId, "1");
-                    //    } else if (state == Qt::Unchecked)
-                    //    {
-                    //        // qDebug() << "CheckBox is unchecked"<<fieldId;
-                    //        // 在这里添加你想要执行的操作
-                    //        m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
-                    //        //updateDb(fieldTableName, fieldId, "0");
-                    //    } else if (state == Qt::PartiallyChecked)
-                    //    {
-                    //        qDebug() << "CheckBox is partially checked";
-                    //        // 在这里添加你想要执行的操作
-                    //    }
-                    //    });
-                    connect(checkBox, &QCheckBox::stateChanged, [this, label](int state) {
+                    connect(checkBox, &QCheckBox::stateChanged, [this, pFieldDescribeLabel](int state)
+                    {
                         if (state == Qt::Checked)
                         {
-                            // qDebug() << "CheckBox is checked"<<fieldId;
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, "1");
                             //updateDb(fieldTableName, fieldId, "1");
-                            label->setProperty("value", "1");
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", "1");
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                         }
                         else if (state == Qt::Unchecked)
                         {
-                            // qDebug() << "CheckBox is unchecked"<<fieldId;
                             // 在这里添加你想要执行的操作
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, "0");
                             //updateDb(fieldTableName, fieldId, "0");
-                            label->setProperty("value", "0");
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", "0");
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                         }
                         else if (state == Qt::PartiallyChecked)
                         {
                             qDebug() << "CheckBox is partially checked";
                             // 在这里添加你想要执行的操作
                         }
-                        });
+                    });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel))
+                        {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
-                    QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
-                    btnDefault->setFixedSize(60, 28);
-                    btnDefault->setProperty("type", "default");
-                    /*btnDefault->setStyleSheet(R"(
-                            QPushButton {
-                                background: #FFFFFF;
-                                border: 1px solid #BABBDC;
-                                border-radius: 5px;
-                            }
-                            QPushButton:hover {
-                                background-color: #F0F0F0;
-                            }
-                            QPushButton:disabled {
-                                background-color: #cccccc;
-                            }
-                        )");*/
-                    rightLayout->addWidget(btnDefault);
-
-                    connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, checkBox]() {
-                        if (!fieldDefult.isEmpty()) {
-                            if (fieldDefult == "1") {
-                                checkBox->setChecked(true);
-                            }
-                            else {
-                                checkBox->setChecked(false);
+                    JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, checkBox]()
+                        {
+                            if (!fieldDefult.isEmpty())
+                            {
+                                if (fieldDefult == "1")
+                                {
+                                    checkBox->setChecked(true);
+                                }
+                                else
+                                {
+                                    checkBox->setChecked(false);
+                                }
                             }
-                        }
                         });
 
-                    if ((privilege &fieldUserGrade) == 1) {
+
+                    if ((privilege & fieldUserGrade) == 1)
+                    {
                         checkBox->setEnabled(false);
-                        btnDefault->setEnabled(false);
                     }
 
                     ST_CHECKBOX_CONT _a;
@@ -2710,6 +2632,16 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 
                     m_veCheckBoxCont.push_back(_a);
                 } 
+                else if (fieldType == "JCheckBox")
+                {
+                    QList<ST_DATA_ITEM> dataList = JIoMapPage::parseJsonToDataList(fieldUnits);
+
+                    // 创建 CheckBoxWidget , 将数据绑定
+                    JCheckBoxCont* window = new JCheckBoxCont(dataList);
+                    rightLayout->addWidget(window);
+                    createdWidget = window;
+
+                }
                 else if (fieldType == "ComboBox")
                 {
                     //QStringList optionList = fieldValue.split(QRegExp("[,,]"), Qt::SkipEmptyParts);
@@ -2753,14 +2685,16 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     int matchedIndex = -1;
                     int currentIndex = 0;
 
-                    for (const QJsonValue& val : jsonArray) {
+                    for (const QJsonValue& val : jsonArray)
+                    {
                         QJsonObject obj = val.toObject();
                         QString key = obj["key"].toString();
                         QString valueStr = QString::number(obj["value"].toInt()); // 统一转字符串对比
 
                         comboBox->addItem(key);
 
-                        if (valueStr == fieldValue.trimmed()) {
+                        if (valueStr == fieldValue.trimmed()) 
+                        {
                             matchedIndex = currentIndex;
                         }
                         currentIndex++;
@@ -2778,61 +2712,52 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     //    // 在这里添加你想要执行的操作
                     //    });
                     connect(comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
-                        [this, comboBox, jsonArray, label](int index) {
+                        [this, comboBox, jsonArray, pFieldDescribeLabel](int index)
+                        {
                             QString selectedText = comboBox->itemText(index);
                             QString valueString;
-                            for (const QJsonValue& val : jsonArray) {
+                            for (const QJsonValue& val : jsonArray) 
+                            {
                                 QJsonObject obj = val.toObject();
-                                if (obj["key"].toString() == selectedText) {
+                                if (obj["key"].toString() == selectedText) 
+                                {
                                     valueString = QString::number(obj["value"].toInt());
                                     break;
                                 }
                             }
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, valueString);
-                            label->setProperty("value", valueString);
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", valueString);
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                         });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel)) 
+                        {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
-                    QPushButton* btnDefault = new QPushButton(QStringLiteral("默认"));
-                    btnDefault->setFixedSize(60, 28);
-                    btnDefault->setProperty("type", "default");
-                    /*btnDefault->setStyleSheet(R"(
-                            QPushButton {
-                                background: #FFFFFF;
-                                border: 1px solid #BABBDC;
-                                border-radius: 5px;
-                            }
-                            QPushButton:hover {
-                                background-color: #F0F0F0;
-                            }
-                            QPushButton:disabled {
-                                background-color: #cccccc;
-                            }
-                        )");*/
-                    rightLayout->addWidget(btnDefault);
 
-                    connect(btnDefault, &QPushButton::clicked, [this, fieldDefult, comboBox, jsonArray]() {
-                        if (!fieldDefult.isEmpty()) {
+                    JIoMapPage::JCreateMenuReDefault(rightWidget, [this, fieldDefult, comboBox, jsonArray]() 
+                        {
+                        if (!fieldDefult.isEmpty()) 
+                        {
                             int matchedIndex = -1;
                             int currentIndex = 0;
 
-                            for (const QJsonValue& val : jsonArray) {
+                            for (const QJsonValue& val : jsonArray)
+                            {
                                 QJsonObject obj = val.toObject();
                                 QString key = obj["key"].toString();
                                 QString valueStr = QString::number(obj["value"].toInt());
 
-                                if (valueStr == fieldDefult.trimmed()) {
+                                if (valueStr == fieldDefult.trimmed()) 
+                                {
                                     matchedIndex = currentIndex;
                                     break;
                                 }
@@ -2842,9 +2767,9 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                         }
                         });
 
-                    if ((privilege &fieldUserGrade) == 1) {
+                    if ((privilege &fieldUserGrade) == 1) 
+                    {
                         comboBox->setEnabled(false);
-                        btnDefault->setEnabled(false);
                     }
 
                     ST_COMBOBOX_CONT _a;
@@ -2854,7 +2779,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     _a.strfieldDescribe = fieldDescribe;
 
                     m_veComboBoxCont.push_back(_a);
-                } else if (fieldType == "time")
+                } 
+                else if (fieldType == "time")
                 {
                     QTimeEdit* timeEdit = new QTimeEdit;
                     timeEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -2874,20 +2800,20 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     timeEdit->setTime(QTime::fromString(fieldValue, "HH:mm:ss"));
                     rightLayout->addWidget(timeEdit);
                     createdWidget = timeEdit;
-                    connect(timeEdit, &QTimeEdit::timeChanged, [this, timeEdit, label]() {
+                    connect(timeEdit, &QTimeEdit::timeChanged, [this, timeEdit, pFieldDescribeLabel]() {
                         QString timeString = timeEdit->time().toString("HH:mm:ss");
-                        label->setProperty("value", timeString);
-                        label->setDisabled(true);
+                        pFieldDescribeLabel->setProperty("value", timeString);
+                        pFieldDescribeLabel->setDisabled(true);
                         //label->setStyleSheet("color: #5c63be;");
-                        modifiedLabels.insert(label);
+                        modifiedLabels.insert(pFieldDescribeLabel);
                         });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel)) {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
@@ -2927,7 +2853,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     _a.strfieldDescribe = fieldDescribe;
 
                     m_veTimeCont.push_back(_a);
-                } else if (fieldType == "switch")
+                } 
+                else if (fieldType == "switch")
                 {
                     QWidget* switchContainer = new QWidget;
                     QHBoxLayout* switchLayout = new QHBoxLayout(switchContainer);
@@ -2983,35 +2910,35 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                     //        //updateDb(fieldTableName, fieldId, "off");
                     //    }
                     //    });
-                    connect(switchBox, &QCheckBox::stateChanged, [switchLabel, this, label](int state) {
+                    connect(switchBox, &QCheckBox::stateChanged, [switchLabel, this, pFieldDescribeLabel](int state) {
                         if (state == Qt::Checked)
                         {
                             switchLabel->setText(tr("Open","开"));
-                            label->setProperty("value", "on");
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", "on");
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, "on");
                             //updateDb(fieldTableName, fieldId, "on");
                         }
                         else
                         {
                             switchLabel->setText(tr("Close","关"));
-                            label->setProperty("value", "off");
-                            label->setDisabled(true);
+                            pFieldDescribeLabel->setProperty("value", "off");
+                            pFieldDescribeLabel->setDisabled(true);
                             //label->setStyleSheet("color: #5c63be;");
-                            modifiedLabels.insert(label);
+                            modifiedLabels.insert(pFieldDescribeLabel);
                             // m_sqlOper->updateControlData(fieldTableName, fieldName, "off");
                             //updateDb(fieldTableName, fieldId, "off");
                         }
                         });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel)) {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
@@ -3209,19 +3136,19 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
 
                     m_veCombinedCont.push_back(_a);
 
-                    connect(comboInput, &QLineEdit::textChanged, [this, comboInput, label]() {
-                        label->setProperty("value", comboInput->text());
-                        label->setDisabled(true);
+                    connect(comboInput, &QLineEdit::textChanged, [this, comboInput, pFieldDescribeLabel]() {
+                        pFieldDescribeLabel->setProperty("value", comboInput->text());
+                        pFieldDescribeLabel->setDisabled(true);
                         //label->setStyleSheet("color: #5c63be;");
-                        modifiedLabels.insert(label);
+                        modifiedLabels.insert(pFieldDescribeLabel);
                         });
 
-                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, label]() {
-                        if (modifiedLabels.contains(label)) {
-                            m_sqlOper->updateControlData(fieldTableName, fieldName, label->property("value").toString());
-                            label->setDisabled(false);
+                    connect(this, &DbTreeViewManager::saveClicked, [this, fieldTableName, fieldName, pFieldDescribeLabel]() {
+                        if (modifiedLabels.contains(pFieldDescribeLabel)) {
+                            m_sqlOper->updateControlData(fieldTableName, fieldName, pFieldDescribeLabel->property("value").toString());
+                            pFieldDescribeLabel->setDisabled(false);
                             //label->setStyleSheet("color: black;");
-                            modifiedLabels.remove(label);
+                            modifiedLabels.remove(pFieldDescribeLabel);
                         }
                         });
 
@@ -3259,13 +3186,8 @@ void DbTreeViewManager::displayThirdLevelFields(const QList<ST_TABLE_CONTROL_DAT
                 } 
                 else if (fieldType == "Text")
                 {
-                    QLabel* label = new QLabel();
-                    label->setText(fieldValue);
-                    label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
-                    label->setFixedHeight(24);
-                    label->setMinimumWidth(120);
-                    rightLayout->addWidget(label);
-
+                    rightLayout->addWidget(JIoMapPage::JCreateJText(fieldValue));
+                    rightLayout->addWidget(JIoMapPage::JCreateJText(fieldUnits));
                 } 
                 else if (fieldType == "IoPage")
                 {

+ 1 - 1
View/die-bonder-ui/OriginalWnd/DbTreeViewManager.h

@@ -263,7 +263,7 @@ private:
     const QString                   m_strShowName = "DisplayName";
 
     GetMainUiConfigFormDB                   gen_if;
-    int                             languageValue;
+    int                             m_nLanguageSwitch;
 private:
 
     //  每次切换控制屏幕时,清空历史

+ 221 - 0
View/die-bonder-ui/OriginalWnd/TreeViewManager/JCustomLabelControls.h

@@ -0,0 +1,221 @@
+// *****************************************************************************
+// 版权所有(C)2023~2099 上海骄成超声波技术有限公司
+// 保留所有权利
+// *****************************************************************************
+// 作者 : 杨坚
+// 版本 : 1.0
+// 功能说明:
+//             自定义lab
+// *****************************************************************************
+#ifndef __CUSTOMLABELCONTROLS_H__
+#define __CUSTOMLABELCONTROLS_H__ 1
+
+#include "TreeViewManagerHead.h"
+#include "Src/common/JLogAllOutput.h"
+#include <QMouseEvent>
+
+class IoStateLab : public QLabel {
+    Q_OBJECT
+
+public:
+    IoStateLab(QWidget* parent = nullptr)
+        : QLabel(parent)
+    {
+        setFixedSize(30, 30);
+    }
+
+public:
+    /**设置io 轴名称
+     */
+    void setIoName(const QString& strName)
+    {
+        m_strName = strName;
+        UpDataIoStatus(true);
+    }
+
+    void UpDataIoStatus(bool isInit)
+    {
+        if (m_pCamera == nullptr)
+        {
+            m_pCamera = ns_module::CViewInterface::GetInstance();
+            if (m_pCamera == nullptr)
+            {
+                // 为了调试准备的
+                JLogAllOutput::cmd_error("io 轴设置失败");
+                return;
+            }
+        }
+
+        if (isInit)
+        {
+            // 信号量
+            ns_db::DIGIT_IO_LEVEL nOutput;
+            m_pCamera->GetViewMotion()->GetIoStatus(m_strName.toStdString(), nOutput);
+            m_bClicked = nOutput;
+        }
+        else
+        {
+            m_pCamera->GetViewMotion()->SetIoStatus(m_strName.toStdString(), m_bClicked);
+        }
+    }
+
+protected:
+    void paintEvent(QPaintEvent* event) override
+    {
+        QLabel::paintEvent(event);
+
+        QPainter painter(this);
+        painter.setRenderHint(QPainter::Antialiasing);
+        int radius = qMin(width(), height()) / 2 - 5;
+        int x = (width() - 2 * radius) / 2;
+        int y = (height() - 2 * radius) / 2;
+
+        painter.setPen(Qt::NoPen);
+        painter.setBrush(m_bClicked ? Qt::green : Qt::red);
+        painter.drawEllipse(x, y, 2 * radius, 2 * radius);
+    }
+
+    void mousePressEvent(QMouseEvent* event) override
+    {
+        if (event->button() == Qt::LeftButton)
+        {
+            m_bClicked = !m_bClicked;
+            UpDataIoStatus(false);
+
+            update();
+        }
+        QLabel::mousePressEvent(event);
+    }
+
+private:
+    bool                       m_bClicked; // 当前状态
+
+    QString                    m_strName;
+
+    ns_module::CViewInterface* m_pCamera = nullptr;
+};
+
+// 自适应控件
+class AutoResizeLabel : public QLabel
+{
+public:
+    explicit AutoResizeLabel(QWidget* parent = nullptr) : QLabel(parent)
+    {
+        setWordWrap(true);
+    }
+
+protected:
+    void resizeEvent(QResizeEvent* event) override
+    {
+        adjustFontSize();
+        QLabel::resizeEvent(event);
+    }
+
+private:
+    void adjustFontSize()
+    {
+        int labelWidth = width();
+        int labelHeight = height();
+
+        QString text = this->text();
+
+        if (text.isEmpty())
+        {
+            return;
+        }
+
+        QFont font = this->font();
+        int fontSize = font.pointSize();
+
+        // 简单算法:逐步减小字体,直到文字适合标签
+        while (fontSize > 1)
+        {
+            font.setPointSize(fontSize);
+            this->setFont(font);
+            // 测量文本的像素大小
+            QFontMetrics fm(font);
+            QRect rect = fm.boundingRect(this->rect(), Qt::TextWordWrap, text);
+            if (rect.width() <= labelWidth && rect.height() <= labelHeight)
+            {
+                break;
+            }
+            fontSize--;
+        }
+        // 设置调整后的字体
+        font.setPointSize(fontSize);
+        this->setFont(font);
+    }
+};
+
+
+
+
+// 定义一个结构体来表示你的数据项
+struct ST_DATA_ITEM
+{
+    QString key;
+    QString value; // "1" 表示选中, "2" 表示未选中
+};
+
+
+class JCheckBoxCont : public QWidget {
+    Q_OBJECT
+
+public:
+    JCheckBoxCont(QList<ST_DATA_ITEM>& data, QWidget* parent = nullptr) : 
+        QWidget(parent), 
+        m_data(data)
+    {
+        QHBoxLayout* layout = new QHBoxLayout(this);
+
+        for (ST_DATA_ITEM& item : m_data)
+        {
+            // 创建 QCheckBox
+            QCheckBox* checkBox = new QCheckBox(item.key, this);
+
+            // 设置状态
+            checkBox->setChecked(item.value == "1");
+
+            // 连接信号和槽,checkbox的状态发生改变时调用指定函数
+            connect(checkBox, &QCheckBox::stateChanged, this, &JCheckBoxCont::onStateChanged);
+
+            // 存储 QCheckBox 指针,方便后续访问
+            m_checkboxMap[item.key] = checkBox;
+
+            // 添加到布局
+            layout->addWidget(checkBox);
+        }
+
+        setLayout(layout);
+    }
+
+private slots:
+    void onStateChanged(int state)
+    {
+        QCheckBox* checkBox = qobject_cast<QCheckBox*>(sender());
+        if (!checkBox) 
+        {
+            return;
+        }
+
+        QString name = checkBox->text();
+
+        //// 更新数据
+        //for (ST_DATA_ITEM& item : m_data)
+        //{
+        //    if (item.key == name)
+        //    {
+        //        item.value = checkBox->isChecked() ? "1" : "2";
+        //        //qDebug() << name << " 状态变为: " << item.value;
+        //        break;
+        //    }
+        //}
+    }
+
+private:
+    QList<ST_DATA_ITEM>&        m_data;  // 数据的引用
+    QMap<QString, QCheckBox*>   m_checkboxMap; // 保存checkbox的指针,以便更新
+};
+
+
+#endif  //__CUSTOMLABELCONTROLS_H__

+ 107 - 0
View/die-bonder-ui/OriginalWnd/TreeViewManager/JIoMapPage.cpp

@@ -1,5 +1,6 @@
 #include "JIoMapPage.h"
 #include <Machine.h>
+#include <QJsonObject>
 
 JIoMapPage::JIoMapPage() {}
 
@@ -77,3 +78,109 @@ QWidget* JIoMapPage::CreateAxisTestPage(const CONFIG_BASE_STRUCT& control)
     pWidget->setLayout(pHLayout);
     return pWidget;
 }
+
+void JIoMapPage::JCreateMenu(QWidget* pWidget)
+{
+    // 设置上下文菜单策略
+    pWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+    // 连接信号到槽函数
+    connect(pWidget, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
+        {
+        QMenu menu;
+        QAction* pGetAct = menu.addAction(tr("Get","获取"));
+        QAction* pSetUpAct = menu.addAction(tr("set up","设置"));
+        QAction* pDefValUpAct = menu.addAction(tr("default value", "默认值"));
+        // 连接动作的触发信号
+        connect(pGetAct, &QAction::triggered, []() { qDebug() << "Get"; });
+        connect(pSetUpAct, &QAction::triggered, []() { qDebug() << "set up"; });
+        connect(pDefValUpAct, &QAction::triggered, []() { qDebug() << "default value"; });
+        // 显示菜单
+        menu.exec(pWidget->mapToGlobal(pos));
+        });
+}
+
+void JIoMapPage::JCreateMenu(QWidget* pWidget, ST_DEFAULT_VAL defaultVal)
+{
+    pWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(pWidget, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
+        {
+            QMenu menu;
+            QAction* pDefValUpAct = menu.addAction(tr("default value", "默认值"));
+            connect(pDefValUpAct, &QAction::triggered, [defaultVal]() 
+            {
+                    if (!defaultVal.fieldDefult.isEmpty())
+                    {
+                        defaultVal.lineEdit->setText(defaultVal.fieldDefult);
+                    }
+            });
+            menu.exec(pWidget->mapToGlobal(pos));
+        });
+}
+
+
+QLabel* JIoMapPage::JCreateName0(const QString& fieldDescribe, const QString& fieldDescribe_Eng, int nlanguage)
+{
+    QLabel* pNameLable = new QLabel();
+    if (nlanguage == 0)
+    {
+        pNameLable->setText(fieldDescribe_Eng);
+        if (fieldDescribe_Eng.isEmpty())
+        {
+            pNameLable->setText(fieldDescribe);
+        }
+    }
+    else
+    {
+        pNameLable->setText(fieldDescribe);
+        if (fieldDescribe.isEmpty())
+        {
+            pNameLable->setText(fieldDescribe_Eng);
+        }
+    }
+
+    pNameLable->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+    pNameLable->setFixedHeight(24);
+    pNameLable->setMinimumWidth(120);
+
+    return pNameLable;
+}
+
+AutoResizeLabel* JIoMapPage::JCreateJText(const QString& name)
+{
+    AutoResizeLabel* pLabel = new AutoResizeLabel();
+    pLabel->setText(name);
+    pLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+    //pLabel->setFixedHeight(24);
+    //pLabel->setMinimumWidth(120);
+
+    return pLabel;
+}
+
+QList<ST_DATA_ITEM> JIoMapPage::parseJsonToDataList(const QString& jsonString)
+{
+    QList<ST_DATA_ITEM> dataList;
+    QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonString.toUtf8());
+
+    if (jsonDoc.isNull() || !jsonDoc.isArray())
+    {
+        qWarning() << "解析失败或JSON不是数组";
+        return dataList;
+    }
+
+    QJsonArray jsonArray = jsonDoc.array();
+
+    // 遍历数组
+    for (const QJsonValue& val : jsonArray) 
+    {
+        if (val.isObject())
+        {
+            QJsonObject obj = val.toObject();
+            ST_DATA_ITEM item;
+            item.key    = obj.value("key").toString();
+            item.value  = obj.value("value").toString();
+            dataList.append(item);
+        }
+    }
+
+    return dataList;
+}

+ 37 - 81
View/die-bonder-ui/OriginalWnd/TreeViewManager/JIoMapPage.h

@@ -1,90 +1,17 @@
 #ifndef JIOMAPPAGE_H
 #define JIOMAPPAGE_H
-#include "TreeViewManagerHead.h"
-#include "Src/common/JLogAllOutput.h"
-#include <QMouseEvent>
 
-class IoStateLab : public QLabel {
-    Q_OBJECT
-
-public:
-    IoStateLab(QWidget* parent = nullptr)
-        : QLabel(parent) 
-    {
-        setFixedSize(30, 30);
-    }
-
-public:
-    /**设置io 轴名称
-     */
-    void setIoName(const QString& strName) 
-    {
-        m_strName = strName;
-        UpDataIoStatus(true);
-    }
+#include "JCustomLabelControls.h"
 
-    void UpDataIoStatus(bool isInit)
-    {
-        if (m_pCamera == nullptr)
-        {
-            m_pCamera = ns_module::CViewInterface::GetInstance();
-            if (m_pCamera == nullptr)
-            {
-                // 为了调试准备的
-                JLogAllOutput::cmd_error("io 轴设置失败");
-                return;
-            }
-        }
-
-        if (isInit)
-        {
-            // 信号量
-            ns_db::DIGIT_IO_LEVEL nOutput;
-            m_pCamera->GetViewMotion()->GetIoStatus(m_strName.toStdString(), nOutput);
-            m_bClicked = nOutput;
-        }
-        else
-        {
-            m_pCamera->GetViewMotion()->SetIoStatus(m_strName.toStdString(), m_bClicked);
-        }
-    }
-
-protected:
-    void paintEvent(QPaintEvent* event) override 
-    {
-        QLabel::paintEvent(event);
-
-        QPainter painter(this);
-        painter.setRenderHint(QPainter::Antialiasing);
-        int radius = qMin(width(), height()) / 2 - 5;
-        int x = (width() - 2 * radius) / 2;
-        int y = (height() - 2 * radius) / 2;
-
-        painter.setPen(Qt::NoPen);
-        painter.setBrush(m_bClicked ? Qt::green : Qt::red);
-        painter.drawEllipse(x, y, 2 * radius, 2 * radius);
-    }
-
-    void mousePressEvent(QMouseEvent* event) override 
-    {
-        if (event->button() == Qt::LeftButton) 
-        {
-            m_bClicked = !m_bClicked;
-            UpDataIoStatus(false);
-
-            update(); 
-        }
-        QLabel::mousePressEvent(event);
-    }
-
-private:
-    bool                       m_bClicked; // 当前状态
-
-    QString                    m_strName;
-
-    ns_module::CViewInterface* m_pCamera = nullptr;
+struct ST_DEFAULT_VAL
+{
+    QString fieldDefult;
+    QLineEdit* lineEdit;
+    int privilege;
+    int fieldUserGrade;
 };
 
+
 class JIoMapPage :public QObject
 {
     Q_OBJECT
@@ -98,8 +25,37 @@ public:
     /**轴测试页面
      */
     static QWidget* CreateAxisTestPage(const CONFIG_BASE_STRUCT& control);
+
+    static void JCreateMenu(QWidget* pWidget);
+    static void JCreateMenu(QWidget* pWidget, ST_DEFAULT_VAL defaultVal);
+
+    /**恢复默认值
+     */
+    template <typename Func1>
+    static void JCreateMenuReDefault(QWidget* pWidget, Func1 fun) 
+    {
+        pWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+        connect(pWidget, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
+            {
+                QMenu menu;
+                QAction* pDefValUpAct = menu.addAction(tr("default value", "默认值"));
+                connect(pDefValUpAct, &QAction::triggered, fun);
+                menu.exec(pWidget->mapToGlobal(pos));
+            });
+    }
+
+    /**创建第一行名称
+     */
+    static QLabel* JCreateName0(const QString& fieldDescribe, const QString& fieldDescribe_Eng, int nlanguage);
+
+    static AutoResizeLabel* JCreateJText(const QString& name);
+
+    /**解析json
+     */
+    static QList<ST_DATA_ITEM> parseJsonToDataList(const QString& jsonString);
 };
 
+// 以下废弃了
 #include <QApplication>
 #include <QTableWidget>
 #include <QHeaderView>

+ 1 - 0
View/die-bonder-ui/SBTdie-bonder-ui.vcxproj

@@ -285,6 +285,7 @@
     <ClInclude Include="JUserAccountsData.h" />
     <QtMoc Include="Src\common\GlobalUse\JMouseMonitorThread.h" />
     <QtMoc Include="OriginalWnd\TreeViewManager\JIoMapPage.h" />
+    <QtMoc Include="OriginalWnd\TreeViewManager\JCustomLabelControls.h" />
     <ClInclude Include="OriginalWnd\TreeViewManager\TreeViewManagerHead.h" />
     <QtMoc Include="Src\BondMatrixProgramPage.h" />
     <ClInclude Include="Src\common\JLogAllOutput.h" />

+ 3 - 1
View/die-bonder-ui/SBTdie-bonder-ui.vcxproj.filters

@@ -431,6 +431,9 @@
     <QtMoc Include="Src\WaffleProgramPage.h">
       <Filter>Source Files\Src</Filter>
     </QtMoc>
+    <QtMoc Include="OriginalWnd\TreeViewManager\JCustomLabelControls.h">
+      <Filter>Header Files\OriginalWnd\TreeViewManager</Filter>
+    </QtMoc>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="debug\moc_predefs.h.cbt">
@@ -811,7 +814,6 @@
     <None Include="dark.qss" />
     <None Include="dark.qss" />
     <None Include="dark.qss" />
-    <None Include="dark.qss" />
     <None Include="dark.qss">
       <Filter>Resource Files</Filter>
     </None>