2026-03-03 18:15:34 +08:00
|
|
|
|
#ifndef GLOBALDEFINE_H
|
|
|
|
|
|
#define GLOBALDEFINE_H
|
2026-03-02 11:07:51 +08:00
|
|
|
|
|
|
|
|
|
|
#include "MainWindow.h"
|
|
|
|
|
|
#include "QsLog.h"
|
2026-03-03 18:15:34 +08:00
|
|
|
|
#include <QTextCodec>
|
2026-03-17 18:38:50 +08:00
|
|
|
|
#include <QRegularExpression>
|
2026-03-12 20:23:55 +08:00
|
|
|
|
#include <QDebug>
|
2026-03-03 18:15:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 转换Qt字符串路径为系统编码的C字符串(解决中文路径问题)
|
|
|
|
|
|
static const char* QStrToSysPath(const QString& qstr_path)
|
|
|
|
|
|
{
|
|
|
|
|
|
static std::string sys_path; // 静态变量避免内存释放
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
|
// Windows:转为GBK编码
|
|
|
|
|
|
QTextCodec* gbkCodec = QTextCodec::codecForName("GBK");
|
|
|
|
|
|
if (!gbkCodec) gbkCodec = QTextCodec::codecForLocale();
|
|
|
|
|
|
sys_path = gbkCodec->fromUnicode(qstr_path).toStdString();
|
|
|
|
|
|
#else
|
|
|
|
|
|
// Linux/Mac:转为UTF-8编码
|
|
|
|
|
|
sys_path = qstr_path.toUtf8().toStdString();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
return sys_path.c_str();
|
|
|
|
|
|
}
|
2026-03-02 11:07:51 +08:00
|
|
|
|
|
2026-03-17 18:38:50 +08:00
|
|
|
|
static int ExtractNumberFromString(const QString& str) {
|
|
|
|
|
|
int ret_num = -1;
|
|
|
|
|
|
QRegularExpression regex("\\d+");
|
|
|
|
|
|
QRegularExpressionMatch match = regex.match(str);
|
|
|
|
|
|
if (match.hasMatch()) {
|
|
|
|
|
|
ret_num = match.captured().toInt();
|
|
|
|
|
|
}
|
|
|
|
|
|
return ret_num;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-02 11:07:51 +08:00
|
|
|
|
|
|
|
|
|
|
#define STATUS_BAR_MSG(msg) \
|
|
|
|
|
|
{ \
|
|
|
|
|
|
MainWindow::ShowStatusBarMsg(msg); \
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define LOG_INFO(out_info) \
|
|
|
|
|
|
{ \
|
|
|
|
|
|
MainWindow::OutputInfo(MainWindow::eInfo, out_info); \
|
|
|
|
|
|
QLOG_INFO() << out_info; \
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define LOG_WARN(warn_info) \
|
|
|
|
|
|
{ \
|
|
|
|
|
|
MainWindow::OutputInfo(MainWindow::eWarning, warn_info); \
|
|
|
|
|
|
QLOG_WARN() << warn_info; \
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define LOG_ERROR(error_info) \
|
|
|
|
|
|
{ \
|
|
|
|
|
|
MainWindow::OutputInfo(MainWindow::eError, error_info); \
|
|
|
|
|
|
QLOG_ERROR() << error_info; \
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LOG_DEBUG(debug_info) \
|
|
|
|
|
|
{ \
|
|
|
|
|
|
MainWindow::OutputInfo(MainWindow::eDebug, debug_info); \
|
|
|
|
|
|
QLOG_DEBUG() << debug_info; \
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-03 18:15:34 +08:00
|
|
|
|
#endif // GLOBALDEFINE_H
|