diff --git a/include/global.h b/include/global.h index 054e70e..67f0da2 100644 --- a/include/global.h +++ b/include/global.h @@ -11,7 +11,7 @@ #include #pragma execution_character_set("utf-8") -const std::string softwareVersion = "20251119-2.2.3"; +const std::string softwareVersion = "20251119-2.2.4"; const std::string euiJsonVersion = "1.0.6"; #define globalDatabasePth "./sqlDatabase/eui_db.db" //全局数据库路径 #define saveImgEnable 1 diff --git a/resources/icon/viewOnly.png b/resources/icon/viewOnly.png new file mode 100644 index 0000000..ec1582f Binary files /dev/null and b/resources/icon/viewOnly.png differ diff --git a/resources/resources.qrc b/resources/resources.qrc index 27412fa..5e19a83 100644 --- a/resources/resources.qrc +++ b/resources/resources.qrc @@ -48,6 +48,7 @@ icon/runningTime.png icon/biaoDingBanBiaoDing.png icon/jiuDianBiaoDingBiaoDing.png + icon/viewOnly.png TongYongUiIcon/0.cameraModule.png diff --git a/src/launcher/GUI/pages/displayPageWidget.h b/src/launcher/GUI/pages/displayPageWidget.h index 33a7bf0..8ec04ca 100644 --- a/src/launcher/GUI/pages/displayPageWidget.h +++ b/src/launcher/GUI/pages/displayPageWidget.h @@ -295,7 +295,7 @@ public: #pragma region 修改检测参数按钮 { _toolBarWidget->createToolButton(QIcon(":/TongYongUiIcon/TongYongUiIcon/search_1.png"), - QString::fromStdString(trans.translate("Param")), + QString::fromStdString(trans.translate("Param Edit")), [this]() { paramTableEditor* dlg = new paramTableEditor(this); std::vector> params; @@ -306,6 +306,20 @@ public: }, Auth::UserLevel::ADMIN); } #pragma endregion +#pragma region 预览检测参数按钮 + { + _toolBarWidget->createToolButton(QIcon(":/icon/icon/viewOnly.png"), + QString::fromStdString(trans.translate("View Param")), + [this]() { + paramTableEditor* dlg = new paramTableEditor(this,true); + std::vector> params; + auto b = fSignalHub::getInstance(); + emit fSignalHub::getInstance()->getAllParams(¶ms); + dlg->setParams(params); + dlg->show(); + }, Auth::UserLevel::GUEST); + } +#pragma endregion #pragma region 故障排查按钮 { _runCommandWidget = new runCommandWidget(); diff --git a/src/launcher/GUI/paramEditorDialog.h b/src/launcher/GUI/paramEditorDialog.h index 1e85221..afb989f 100644 --- a/src/launcher/GUI/paramEditorDialog.h +++ b/src/launcher/GUI/paramEditorDialog.h @@ -43,8 +43,8 @@ class paramTableEditor : public QDialog { Q_OBJECT public: - explicit paramTableEditor(QWidget* parent = nullptr) - : QDialog(parent) { + explicit paramTableEditor(QWidget* parent = nullptr,bool viewOnlyModeIN = false) + : QDialog(parent), viewOnlyMode(viewOnlyModeIN){ this->setWindowTitle("参数编辑器"); this->resize(900, 500); setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint); @@ -80,10 +80,7 @@ public: for(auto& data : params) { m_allParams.insert(data.first, data.second); } - //生成参数修改控件的缓存 - //for (auto& it = params.begin(); it != params.end(); it++) { - // m_paramsEditItemsCache.insert(it->first, createEditorWidget(it->second, it->second.type())); - //} + //清空现有数据 m_tableModel->setRowCount(0); m_editorWidgets.clear(); @@ -207,6 +204,7 @@ private slots: } private: + bool viewOnlyMode = false; WheelBlocker blocker; QTableView* m_tableView; QStandardItemModel* m_tableModel; @@ -223,8 +221,6 @@ private: // 参数数据 QMap m_allParams; QMap> m_groupedParamsNames;//分组 名字 - //QMap m_paramsEditItemsCache; - void createSidebar() { m_sidebarWidget = new QWidget(this); @@ -288,7 +284,7 @@ private: contentLayout->setSpacing(10); // 当前分组标签 - m_currentGroupLabel = new QLabel("所有参数"); + m_currentGroupLabel = new QLabel("所有参数" + viewOnlyMode == false ? "":"当前无法修改(权限不足,请登录后重新打开此界面)"); m_currentGroupLabel->setStyleSheet("color: white; font-weight: bold; font-size: 16px; padding: 5px;"); contentLayout->addWidget(m_currentGroupLabel); @@ -330,6 +326,9 @@ private: m_tableView->setColumnWidth(1, 250); fancyButtonText* okBtn = new fancyButtonText("保存", 70, 22, ""); + okBtn->setDisabled(viewOnlyMode); + okBtn->setVisible(!viewOnlyMode); + fancyButtonText* cancelBtn = new fancyButtonText("取消", 70, 22, ""); connect(okBtn, &QPushButton::clicked, this, ¶mTableEditor::onAccept); @@ -474,12 +473,15 @@ private: switch (type) { case QVariant::Type::Bool: { CircularSwitch* switchBtn = new CircularSwitch(); + switchBtn->setDisabled(viewOnlyMode); + switchBtn->setChecked(value.toBool()); switchBtn->setToolTip(generateTypeHint(type)); return switchBtn; } case QVariant::Type::Int: { QSpinBox* spinBox = new QSpinBox(); + spinBox->setDisabled(viewOnlyMode); spinBox->installEventFilter(&blocker); //安装滚轮事件过滤器 spinBox->setStyleSheet(R"( QSpinBox { @@ -501,6 +503,7 @@ private: } case QVariant::Type::Double: { QDoubleSpinBox* spinBox = new QDoubleSpinBox(); + spinBox->setDisabled(viewOnlyMode); spinBox->installEventFilter(&blocker); //安装滚轮事件过滤器 spinBox->setStyleSheet(R"( QDoubleSpinBox { @@ -523,6 +526,7 @@ private: } case QVariant::Type::String: { QLineEdit* lineEdit = new QLineEdit(); + lineEdit->setDisabled(viewOnlyMode); lineEdit->setText(value.toString()); lineEdit->setToolTip(generateTypeHint(type)); return lineEdit; diff --git a/src/launcher/appConfig/auth.hpp b/src/launcher/appConfig/auth.hpp index cae97ff..294415f 100644 --- a/src/launcher/appConfig/auth.hpp +++ b/src/launcher/appConfig/auth.hpp @@ -307,9 +307,10 @@ namespace Auth { return static_cast(currentUserLevel) >= static_cast(requiredLevel); } - void executeWithPermission(UserLevel requiredLevel, AuthCallback callback) { + bool executeWithPermission(UserLevel requiredLevel, AuthCallback callback) { if (hasPermission(requiredLevel)) { callback(); + return true; } else { std::string errorMessage = "Access denied. Required level: " + userLevelToString(requiredLevel) + ", Current level: " + userLevelToString(currentUserLevel); @@ -321,6 +322,7 @@ namespace Auth { QString(TR("You do not have sufficient permissions to perform this action.\n\nRequired level: %1\nCurrent level: %2")) .arg(QString::fromStdString(userLevelToString(requiredLevel))) .arg(QString::fromStdString(userLevelToString(currentUserLevel)))); + return false; } } diff --git a/translation.json b/translation.json index 393f7d3..3bbf466 100644 --- a/translation.json +++ b/translation.json @@ -511,6 +511,16 @@ "us-EN": "Param", "zh-CN": "参数设置" }, + "Param Edit": { + "ms-MY": "Sunting Parameter", + "us-EN": "Param Edit", + "zh-CN": "参数编辑" + }, + "View Param": { + "ms-MY": "Lihat Parameter", + "us-EN": "View Param", + "zh-CN": "预览参数" + }, "Parse Error": { "ms-MY": "Ralat Parse", "us-EN": "Parse Error",