修复两个 BUG:
1. 文件浏览窗口现在使用 JSON 文件所在目录作为初始路径 2. 修复拖拽 JSON 文件打开工程功能 修改内容: - mainwindow.cpp: addSourceFile/addIncludeDir/addLibrary 添加初始目录 - mainwindow.cpp: dropEvent 完善所有 UI 组件的加载
This commit is contained in:
@@ -367,9 +367,13 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||
currentFilePath = file;
|
||||
modified = false;
|
||||
|
||||
// 更新 UI
|
||||
projectNameEdit->setText(config->getProjectName());
|
||||
compilerPathEdit->setText(config->getCompilerPath());
|
||||
assemblerPathEdit->setText(config->getAssemblerPath());
|
||||
linkerPathEdit->setText(config->getLinkerPath());
|
||||
|
||||
// 更新虚拟目录树
|
||||
sourceTree->clear();
|
||||
QMap<QString, VirtualDir> dirs = config->getVirtualDirs();
|
||||
for (auto it = dirs.begin(); it != dirs.end(); ++it) {
|
||||
@@ -381,22 +385,26 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||
fileItem->setToolTip(0, f);
|
||||
}
|
||||
}
|
||||
sourceTree->expandAll();
|
||||
|
||||
// 更新包含目录
|
||||
includeDirList->clear();
|
||||
includeDirList->addItems(config->getIncludeDirs());
|
||||
|
||||
// 更新库文件
|
||||
libraryList->clear();
|
||||
libraryList->addItems(config->getLibraries());
|
||||
|
||||
// 更新编译宏
|
||||
defineList->clear();
|
||||
defineList->addItems(config->getDefines());
|
||||
|
||||
// 更新编译选项
|
||||
optionList->clear();
|
||||
optionList->addItems(config->getCompilerOptions());
|
||||
|
||||
updateWindowTitle();
|
||||
statusBar()->showMessage("✅ 工程已加载:" + file, 5000);
|
||||
QMessageBox::information(this, "成功", "工程加载成功!\n" + file);
|
||||
} else {
|
||||
QMessageBox::critical(this, "错误", "无法加载工程文件:" + file);
|
||||
}
|
||||
@@ -606,7 +614,10 @@ void MainWindow::addSourceFile()
|
||||
|
||||
QString dirName = currentItem->text(0);
|
||||
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, "选择源文件", "",
|
||||
// 使用 JSON 文件所在目录作为初始目录
|
||||
QString initialDir = currentFilePath.isEmpty() ? "" : QFileInfo(currentFilePath).absolutePath();
|
||||
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, "选择源文件", initialDir,
|
||||
"C 源文件 (*.c);;所有文件 (*)");
|
||||
|
||||
for (const QString &file : files) {
|
||||
@@ -638,7 +649,10 @@ void MainWindow::removeSourceFile()
|
||||
|
||||
void MainWindow::addIncludeDir()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this, "选择包含目录");
|
||||
// 使用 JSON 文件所在目录作为初始目录
|
||||
QString initialDir = currentFilePath.isEmpty() ? "" : QFileInfo(currentFilePath).absolutePath();
|
||||
|
||||
QString dir = QFileDialog::getExistingDirectory(this, "选择包含目录", initialDir);
|
||||
if (!dir.isEmpty()) {
|
||||
config->addIncludeDir(dir);
|
||||
includeDirList->addItem(dir);
|
||||
@@ -656,7 +670,10 @@ void MainWindow::removeIncludeDir()
|
||||
|
||||
void MainWindow::addLibrary()
|
||||
{
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, "选择库文件", "",
|
||||
// 使用 JSON 文件所在目录作为初始目录
|
||||
QString initialDir = currentFilePath.isEmpty() ? "" : QFileInfo(currentFilePath).absolutePath();
|
||||
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, "选择库文件", initialDir,
|
||||
"库文件 (*.a *.so *.lib *.dll);;所有文件 (*)");
|
||||
|
||||
for (const QString &file : files) {
|
||||
|
||||
Reference in New Issue
Block a user