备份
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
#include <string.h> // for strstr
|
||||
#include <devguid.h>
|
||||
#include <shellapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <QPixmap>
|
||||
#include <QFileIconProvider>
|
||||
#include <QFileInfo>
|
||||
#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
|
||||
+2
-2
@@ -159,7 +159,7 @@ public:
|
||||
auto camera = _serviceManager->_cameraManager->getCamera(cameraName);
|
||||
camera->clearCache();
|
||||
std::shared_ptr <detData> 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 <detData> 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]);//处理算法
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
// 通用的创建工具按钮函数实现
|
||||
bool createToolButton(const QString& iconPath, const QString& text,
|
||||
std::function<void()> 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<void()> 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<std::string> 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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <581_YiCiZhuYe_canye.h>
|
||||
|
||||
void exceptionResume(std::shared_ptr<detData> data, canyeParams* _detParams, sx_581_address address) {
|
||||
qDebug() << "[Error] " << QString::fromUtf8("检测失败!") << data->uuid << QString::fromStdString(data->SNcode);
|
||||
void exceptionResume(std::shared_ptr<detData> 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<detData> 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<detData> data, canyeParams* _detParams, sx_581_a
|
||||
}
|
||||
}
|
||||
CATCH_EXCEPTIONS
|
||||
exceptionResume(data, _detParams, address);
|
||||
exceptionResume(data, _detParams, address,"检测程序异常");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Reference in New Issue
Block a user