v1.1: 修复 Windows 跨平台兼容性 & 按钮高对比度配色

【跨平台修复】
- cmakegenerator.cpp: CMAKE_C_COMPILER / CMAKE_MAKE_PROGRAM 提前到 project() 之前设置,避免 CMake 在 Windows 回退 NMake
- cmakegenerator.cpp: MinGW 编译器路径下自动推导 mingw32-make.exe
- mainwindow.cpp: generateCMake() 在 Windows 下添加 -G 'MinGW Makefiles'
- mainwindow.cpp: compileProject() cmake 添加生成器参数 & mingw32-make 替代 make

【UI 改进】
- 全部操作按钮升级为 Material Design 高对比度配色(Darker 系列)
- 按钮添加圆角和内边距,提升可读性和视觉层次

【工程规范】
- 新增 .gitignore,排除编译产物 (.o / moc_*.cpp / Makefile / 二进制)
- README.md 重写,补充 Windows 编译指南和技术要点
- 需求规格说明书更新至 v1.1
This commit is contained in:
虾哥
2026-04-28 18:26:10 +08:00
parent 2ab1924d1d
commit 1f7328174b
17 changed files with 150 additions and 1020 deletions

View File

@@ -1,5 +1,6 @@
#include "cmakegenerator.h"
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QDir>
#include <QDateTime>
@@ -93,7 +94,36 @@ QString CMakeGenerator::generateProjectConfig(const ProjectConfig *config)
projectName = "UntitledProject";
}
content += "# 项目名称\n";
// ===== 编译器必须在 project() 之前设置,否则 CMake 会默认用 NMake =====
content += "# ========================================\n";
content += "# 编译器配置(必须在 project() 之前)\n";
content += "# ========================================\n\n";
QString compilerPath = config->getCompilerPath();
QString assemblerPath = config->getAssemblerPath();
QString linkerPath = config->getLinkerPath();
if (!compilerPath.isEmpty() && compilerPath != "gcc") {
content += "set(CMAKE_C_COMPILER \"" + compilerPath + "\")\n";
// 如果编译器是 MinGW 路径,自动推导 make 程序目录
// 例如C:/msys2/mingw64/bin/gcc.exe → C:/msys2/mingw64/bin/mingw32-make.exe
if (compilerPath.contains("mingw", Qt::CaseInsensitive)) {
QString makeDir = QFileInfo(compilerPath).path(); // path() 正确保留绝对路径的盘符
content += "set(CMAKE_MAKE_PROGRAM \"" + makeDir + "/mingw32-make.exe\")\n";
}
}
if (!assemblerPath.isEmpty() && assemblerPath != "gcc") {
content += "set(CMAKE_ASM_COMPILER \"" + assemblerPath + "\")\n";
}
if (!linkerPath.isEmpty() && linkerPath != "gcc" && linkerPath != compilerPath) {
content += "set(CMAKE_C_LINK_EXECUTABLE \"" + linkerPath + " <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>\")\n";
}
content += "\n";
content += "# 项目名称(编译器已设置,不再尝试检测)\n";
content += "project(" + projectName + " C)\n\n";
content += "# C 标准\n";
@@ -111,13 +141,6 @@ QString CMakeGenerator::generateProjectConfig(const ProjectConfig *config)
content += "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/" + outputDir + ")\n";
content += "set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/" + outputDir + ")\n\n";
// 编译器配置
content += "# 编译器配置\n";
if (!config->getCompilerPath().isEmpty() && config->getCompilerPath() != "gcc") {
content += "set(CMAKE_C_COMPILER \"" + config->getCompilerPath() + "\")\n";
}
content += "\n";
return content;
}
@@ -244,7 +267,7 @@ QString CMakeGenerator::generateCompilerOptions(const ProjectConfig *config)
return content;
}
QString CMakeGenerator::generateBuildTargets(const ProjectConfig *config)
QString CMakeGenerator::generateBuildTargets(const ProjectConfig * /*config*/)
{
QString content;