diff --git a/include/simpleTools/windowsCtrl.hpp b/include/simpleTools/windowsCtrl.hpp index 774fcaa..4afa251 100644 --- a/include/simpleTools/windowsCtrl.hpp +++ b/include/simpleTools/windowsCtrl.hpp @@ -6,6 +6,10 @@ #include // for strstr #include #include +#include +#include +#include +#include #pragma comment(lib, "setupapi.lib") static void DisableComPort(const char* portName) { @@ -140,4 +144,41 @@ static void restartAsAdmin() { } } } +// 解析 .lnk 文件,获取目标路径 +static QString getShortcutTarget(const QString& shortcutPath) { + HRESULT hres; + CoInitialize(NULL); + IShellLink* psl; + QString targetPath; + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if (SUCCEEDED(hres)) { + IPersistFile* ppf; + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); + if (SUCCEEDED(hres)) { + WCHAR wsz[MAX_PATH]; + shortcutPath.toWCharArray(wsz); + wsz[shortcutPath.length()] = 0; + hres = ppf->Load(wsz, STGM_READ); + if (SUCCEEDED(hres)) { + char szTarget[MAX_PATH]; + WIN32_FIND_DATA wfd; + if (SUCCEEDED(psl->GetPath(szTarget, MAX_PATH, &wfd, SLGP_UNCPRIORITY))) { + targetPath = QString::fromLocal8Bit(szTarget); + } + } + ppf->Release(); + } + psl->Release(); + } + CoUninitialize(); + return targetPath; +} +// 获取目标文件图标 +static QIcon getFileIcon(const QString& filePath, const QSize& size) { + QFileIconProvider iconProvider; + QFileInfo fileInfo(filePath); + QIcon icon = iconProvider.icon(fileInfo); + QPixmap pixmap = icon.pixmap(size); + return QIcon(pixmap); +} #pragma once \ No newline at end of file diff --git a/include/yhGlobal.h b/include/yhGlobal.h index ae354ab..f9c6591 100644 --- a/include/yhGlobal.h +++ b/include/yhGlobal.h @@ -159,7 +159,7 @@ public: auto camera = _serviceManager->_cameraManager->getCamera(cameraName); camera->clearCache(); std::shared_ptr data = _serviceManager->_detDataManager->createDetData( - QString::number(address[batteryOffset].triggerAddr), sn, 1, camera->config.oriSaveFormat);//创建数据包 + QString::fromStdString(cameraName), sn, 1, camera->config.oriSaveFormat);//创建数据包 camera->captureImage(data);//拍照 data->saveObjectName = saveObjectName; generalDet->ansyncProcess(data, address[batteryOffset]);//处理算法 @@ -233,7 +233,7 @@ public: auto camera = _serviceManager->_cameraManager->getCamera(cameraName); camera->clearCache(); std::shared_ptr data = _serviceManager->_detDataManager->createDetData( - QString::number(address[batteryOffset].triggerAddr), sn, 1, camera->config.oriSaveFormat);//创建数据包 + QString::fromStdString(cameraName), sn, 1, camera->config.oriSaveFormat);//创建数据包 camera->captureImage(data);//拍照 data->saveObjectName = saveObjectName; generalDet->ansyncProcess(data, address[batteryOffset]);//处理算法 diff --git a/src/launcher/GUI/front/pages/displayPageWidget.h b/src/launcher/GUI/front/pages/displayPageWidget.h index 5a5e699..92b2527 100644 --- a/src/launcher/GUI/front/pages/displayPageWidget.h +++ b/src/launcher/GUI/front/pages/displayPageWidget.h @@ -74,7 +74,7 @@ public: // 通用的创建工具按钮函数实现 bool createToolButton(const QString& iconPath, const QString& text, std::function clickHandler, - const QSize& buttonSize = QSize(60, 60), const QSize& iconSize = QSize(30, 30)){ + const QSize& buttonSize = QSize(100, 60), const QSize& iconSize = QSize(30, 30)){ // 参数验证 if (iconPath.isEmpty() || text.isEmpty() || !clickHandler) { @@ -105,10 +105,75 @@ public: return false; } + btn->setIcon(icon); btn->setText(text); btn->setIconSize(iconSize); - btn->setFixedSize(buttonSize.width() + 20, buttonSize.height() + 20); // 增加高度以容纳文字 + btn->setFixedSize(buttonSize.width(), buttonSize.height()); // 增加高度以容纳文字 + btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); // 文字在图标下方 + + // 设置按钮样式 + btn->setStyleSheet(R"( + QToolButton { + background-color: transparent; + border: none; + color: white; + font-family: "微软雅黑"; + font-size: 14px; + font-weight: bold; + } + QToolButton:hover { + background-color: black; + border-radius: 5px; + } + )"); + + btnLayout->addWidget(btn); + btnLayout->setAlignment(Qt::AlignCenter); + + // 连接点击事件 + if (!connect(btn, &QToolButton::clicked, clickHandler)) { + delete btn; + delete btnLayout; + return false; + } + + // 添加到按钮布局容器中 + buttonsLayout->addLayout(btnLayout); + + return true; + } + bool createToolButton(QIcon icon, const QString& text, + std::function clickHandler, + const QSize& buttonSize = QSize(100, 60), const QSize& iconSize = QSize(30, 30)) { + + // 参数验证 + if (text.isEmpty() || !clickHandler) { + return false; + } + + // 创建布局 + QVBoxLayout* btnLayout = new QVBoxLayout(); + if (!btnLayout) { + return false; + } + + btnLayout->setSpacing(0); + btnLayout->setContentsMargins(0, 0, 0, 0); + + // 使用 QToolButton 来实现图标在上文字在下的效果 + QToolButton* btn = new QToolButton(this); + if (!btn) { + delete btnLayout; + return false; + } + + // 设置图标,检查图标是否加载成功 + + btn->setIcon(icon); + btn->setText(text); + btn->setIconSize(iconSize); + btn->setFixedSize(buttonSize.width(), buttonSize.height()); // 增加高度以容纳文字 btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); // 文字在图标下方 // 设置按钮样式 @@ -364,7 +429,20 @@ public: }); } #pragma endregion - +#pragma region 读取bin目录下的tools文件夹并展示 + { + std::vector files; + fileManager::getAllFiles("./tools", files, "lnk"); + for (auto& lnkPath : files) { + std::string fileName = fileManager::getFileName(lnkPath); + auto exePath = getShortcutTarget(QString::fromStdString(lnkPath)); + auto icon = getFileIcon(exePath, QSize(30, 30)); + _toolBarWidget->createToolButton(icon, QString::fromLocal8Bit(fileName.c_str()), [=]() { + QProcess::startDetached(exePath); + }); + } + } +#pragma endregion vLayout->addWidget(_toolBarWidget); vLayout->addWidget(&_ImageWidgetManager); diff --git a/src/mission/581_YiCiZhuYe_canye/581_YiCiZhuYe_canye.cpp b/src/mission/581_YiCiZhuYe_canye/581_YiCiZhuYe_canye.cpp index b8479f2..e0da6a5 100644 --- a/src/mission/581_YiCiZhuYe_canye/581_YiCiZhuYe_canye.cpp +++ b/src/mission/581_YiCiZhuYe_canye/581_YiCiZhuYe_canye.cpp @@ -1,7 +1,7 @@ #include <581_YiCiZhuYe_canye.h> -void exceptionResume(std::shared_ptr data, canyeParams* _detParams, sx_581_address address) { - qDebug() << "[Error] " << QString::fromUtf8("检测失败!") << data->uuid << QString::fromStdString(data->SNcode); +void exceptionResume(std::shared_ptr data, canyeParams* _detParams, sx_581_address address,QString why = "") { + qDebug() << "[Error] " << QString::fromUtf8("检测失败!") << data->uuid << QString::fromStdString(data->SNcode)<< why; cv::Mat Paint; data->oriImgs[0].copyTo(Paint); if (Paint.channels() == 1) @@ -18,7 +18,7 @@ bool yizhuCanYe(std::shared_ptr data, canyeParams* _detParams, sx_581_a { if (!_detParams->DOGLIVE) { - exceptionResume(data, _detParams, address); + exceptionResume(data, _detParams, address,"未插加密狗"); return true; } else @@ -66,7 +66,7 @@ bool yizhuCanYe(std::shared_ptr data, canyeParams* _detParams, sx_581_a } } CATCH_EXCEPTIONS - exceptionResume(data, _detParams, address); + exceptionResume(data, _detParams, address,"检测程序异常"); return true; } diff --git a/updateLog/2025-10-15/增加了点位监控.png b/updateLog/2025-10-15/增加了点位监控.png new file mode 100644 index 0000000..69ece90 Binary files /dev/null and b/updateLog/2025-10-15/增加了点位监控.png differ diff --git a/updateLog/2025-10-15/放在bin目录的tools文件夹中的中的快捷方式现在会出现在顶端.png b/updateLog/2025-10-15/放在bin目录的tools文件夹中的中的快捷方式现在会出现在顶端.png new file mode 100644 index 0000000..1683d7a Binary files /dev/null and b/updateLog/2025-10-15/放在bin目录的tools文件夹中的中的快捷方式现在会出现在顶端.png differ diff --git a/updateLog/2025-10-15/自动填满窗口.png b/updateLog/2025-10-15/自动填满窗口.png new file mode 100644 index 0000000..ef6c549 Binary files /dev/null and b/updateLog/2025-10-15/自动填满窗口.png differ