diff --git a/Contributors.md b/Contributors.md
index c08fe391..009baa06 100644
--- a/Contributors.md
+++ b/Contributors.md
@@ -35,8 +35,8 @@ author: С
### Sea Lite
-author:
+author: PerryDing
### Ochre_Butter
-author:
+author: PerryDing
diff --git a/NEWS.md b/NEWS.md
index c324e44f..3b8bc546 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -9,6 +9,8 @@ Red Panda C++ Version 2.25
- change: Use freetype as the fontengine in windows ( from cyano.CN )
- fix: Custom compile options is not used when retrieve macros defined by the compiler.
- fix: Processing for #if/#elif/#else is not correct.
+ - Change: Empty project template won't auto create main.c/main.cpp
+ - enhancement: When creating project, warn user if the project folder is not empty.
Red Panda C++ Version 2.24
diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp
index 4d11aed0..67b95e5d 100644
--- a/RedPandaIDE/mainwindow.cpp
+++ b/RedPandaIDE/mainwindow.cpp
@@ -7036,7 +7036,20 @@ void MainWindow::on_actionNew_Project_triggered()
// if cbDefault.Checked then
// devData.DefCpp := rbCpp.Checked;
-
+ QDir projectDir = QDir(location);
+ if (!projectDir.isEmpty()) {
+ if (QMessageBox::question(
+ nullptr,
+ tr("Folder Not Empty"),
+ tr("The project folder is not empty, existing files may be overwritten.")
+ + "
"
+ +tr("Do you want to proceed?"),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No
+ ) == QMessageBox::No) {
+ return;
+ }
+ }
s = includeTrailingPathDelimiter(location)
+ dialog.getProjectName() + "." + DEV_PROJECT_EXT;
@@ -7060,6 +7073,7 @@ void MainWindow::on_actionNew_Project_triggered()
tr("New project fail"),
tr("Can't assign project template"),
QMessageBox::Ok);
+ return;
}
mProject->saveAll();
updateProjectView();
diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp
index 3fa5190c..cdf273fd 100644
--- a/RedPandaIDE/project.cpp
+++ b/RedPandaIDE/project.cpp
@@ -92,13 +92,13 @@ std::shared_ptr Project::create(
ini.SetValue("Project","filename", toByteArray(extractRelativePath(project->directory(),
project->mFilename)));
ini.SetValue("Project","name", toByteArray(project->mName));
- ini.SaveFile(project->mFilename.toLocal8Bit());
project->mParser->setEnabled(false);
if (!project->assignTemplate(pTemplate,useCpp))
return std::shared_ptr();
resetCppParser(project->mParser, project->mOptions.compilerSet);
project->mModified = true;
+ ini.SaveFile(project->mFilename.toLocal8Bit());
return project;
}
@@ -934,8 +934,9 @@ void Project::setCompilerSet(int compilerSetIndex)
bool Project::assignTemplate(const std::shared_ptr aTemplate, bool useCpp)
{
if (!aTemplate) {
- return true;
+ return false;
}
+
mModel.beginUpdate();
mRootNode = makeProjectNode();
rebuildNodes();
@@ -974,10 +975,12 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate, b
PProjectUnit unit;
if (!templateUnit->Target.isEmpty())
target = templateUnit->Target;
- QFile::copy(
- cleanPath(dir.absoluteFilePath(templateUnit->Source)),
- includeTrailingPathDelimiter(this->directory())+target);
unit = newUnit(mRootNode, target);
+ if (templateUnit->overwrite || !fileExists(unit->fileName()) ) {
+ QFile::copy(
+ cleanPath(dir.absoluteFilePath(templateUnit->Source)),
+ includeTrailingPathDelimiter(this->directory())+target);
+ }
FileType fileType=getFileType(unit->fileName());
if ( fileType==FileType::GAS
@@ -1006,20 +1009,22 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate, b
this,
true);
- QString s2 = cleanPath(dir.absoluteFilePath(s));
- if (fileExists(s2) && !s.isEmpty()) {
- try {
- editor->loadFile(s2);
- } catch(FileError& e) {
- QMessageBox::critical(nullptr,
- tr("Error Load File"),
- e.reason());
+ if (templateUnit->overwrite || !fileExists(unit->fileName()) ) {
+ QString s2 = cleanPath(dir.absoluteFilePath(s));
+ if (fileExists(s2) && !s.isEmpty()) {
+ try {
+ editor->loadFile(s2);
+ } catch(FileError& e) {
+ QMessageBox::critical(nullptr,
+ tr("Error Load File"),
+ e.reason());
+ }
+ } else {
+ s.replace("#13#10","\r\n");
+ editor->insertString(s,false);
}
- } else {
- s.replace("#13#10","\r\n");
- editor->insertString(s,false);
+ editor->save(true,false);
}
- editor->save(true,false);
editor->activate();
}
}
diff --git a/RedPandaIDE/projecttemplate.cpp b/RedPandaIDE/projecttemplate.cpp
index 62acf0e3..4b9bdb3a 100644
--- a/RedPandaIDE/projecttemplate.cpp
+++ b/RedPandaIDE/projecttemplate.cpp
@@ -57,7 +57,7 @@ PTemplateUnit ProjectTemplate::unit(int index)
if (unit->CppName.isEmpty())
unit->CppName = unit->CName;
unit->Target = fromByteArray(mIni->GetValue(toByteArray(section), "Target", ""));
-
+ unit->overwrite = mIni->GetBoolValue(toByteArray(section), "Overwrite", true);
return unit;
}
diff --git a/RedPandaIDE/projecttemplate.h b/RedPandaIDE/projecttemplate.h
index 69690ef8..75ad3efe 100644
--- a/RedPandaIDE/projecttemplate.h
+++ b/RedPandaIDE/projecttemplate.h
@@ -28,6 +28,7 @@ struct TemplateUnit {
QString CppText;
QString Source;
QString Target;
+ bool overwrite;
};
using PTemplateUnit = std::shared_ptr;
diff --git a/RedPandaIDE/resources/templates/empty.template b/RedPandaIDE/resources/templates/empty.template
index 5f83aa53..1029a68c 100644
--- a/RedPandaIDE/resources/templates/empty.template
+++ b/RedPandaIDE/resources/templates/empty.template
@@ -8,10 +8,6 @@ Description[zh_CN]=一个空项目
Category=Basic
Category[zh_CN]=基础
-[Unit0]
-CName=main.c
-CppName=main.cpp
-
[Project]
UnitCount=1
Type=1
diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts
index 456901d3..9aec2cf7 100644
--- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts
+++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts
@@ -5375,6 +5375,18 @@
+
+
+
+
+
+
+
+
+
+
+
+ MemoryModel
diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts
index b3cbcaf8..c74207a1 100644
--- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts
+++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts
@@ -4453,7 +4453,7 @@ Are you really want to continue?
-
+ 编译器
@@ -4886,7 +4886,7 @@ Are you really want to continue?
-
+ 新建试题集
@@ -4908,7 +4908,7 @@ Are you really want to continue?
-
+ 保存试题集
@@ -4916,7 +4916,7 @@ Are you really want to continue?
-
+ 载入试题集
@@ -5047,14 +5047,14 @@ Are you really want to continue?
-
+ 导入FPS试题集
-
+ 导出FPS试题集
@@ -5710,7 +5710,7 @@ Are you really want to continue?
-
+ 重命名符号
@@ -5731,13 +5731,13 @@ Are you really want to continue?
-
+ 导出为RTF
-
+ 导出为HTML
@@ -6295,22 +6295,22 @@ Are you really want to continue?
全部复制
-
+ 跳转到行
-
+ 行
-
+ 模板已存在
-
+ 模板%1已存在。是否覆盖?
@@ -6336,7 +6336,7 @@ Are you really want to continue?
-
+ 试题集%1
@@ -6406,15 +6406,15 @@ Are you really want to continue?
-
-
+
+ 书签描述
-
-
+
+ 描述:
@@ -6636,7 +6636,7 @@ Are you really want to continue?
-
+ 删除
@@ -6731,12 +6731,27 @@ Are you really want to continue?
保存设置失败
-
+
+
+ 文件夹非空
+
+
+
+
+ 项目文件夹不是空的,已有的文件可能会被覆盖。
+
+
+
+
+ 您确定要继续吗?
+
+
+ 被监控的变量
-
+ 当下面的变量被修改时暂停执行(该变量必须可以从当前程序处访问):
@@ -6745,17 +6760,17 @@ Are you really want to continue?
中止
-
+ FPS试题集文件(*.fps;*.xml)
-
+ FPS试题集文件(*.fps)
-
+ 导出时出错
@@ -6817,7 +6832,7 @@ Are you really want to continue?
-
+ 需要保存吗?
@@ -6829,15 +6844,15 @@ Are you really want to continue?
-
-
+
+ 新建项目文件?
-
-
+
+ 您是否要将新建的文件加入项目?
@@ -6846,7 +6861,7 @@ Are you really want to continue?
-
+ 保存失败
@@ -6930,33 +6945,33 @@ Are you really want to continue?
创建文件夹'%1'失败。
-
+
-
+ 文件夹%1不是空的。
-
+ 你真的要删除它吗?
-
+ 改变工作文件夹
-
+ File '%1' is not in the current working folder文件'%1'不在当前工作文件夹中。
-
+ 是否将工作文件夹改设为'%1'?
@@ -6965,28 +6980,28 @@ Are you really want to continue?
正在删除试题...
-
+ 无法提交
-
+ Git需要用信息进行提交。
-
+ 选择输入数据文件
-
-
+
+ 所有文件 (*.*)
-
+ Choose Expected Input Data File选择期望输出文件
@@ -6998,59 +7013,59 @@ Are you really want to continue?
-
+ 选择工作文件夹
-
-
+
+ 头文件已存在
-
-
+
+ 头文件"%1"已存在!
-
+ 源文件已存在!
-
+ 源文件"%1"已存在!
-
+ 无法提交!
-
+ 下列文件处于冲突状态,请解决后重新添加和提交:
-
+ 提交信息
-
+ 提交信息:
-
+ 提交失败
-
+ 提交信息不能为空!
@@ -7059,22 +7074,22 @@ Are you really want to continue?
小熊猫Dev-C++项目文件 (*.dev)
-
+ 新建项目失败
-
+ 无法使用模板创建项目
-
+ 删除文件
-
+ 同时从硬盘上删除文件?
@@ -7083,27 +7098,27 @@ Are you really want to continue?
无标题
-
+ 新的项目文件名
-
+ 文件名:
-
+ 文件已存在!
-
+ 文件'%1'已经存在!
-
+ 添加到项目
@@ -7169,78 +7184,78 @@ Are you really want to continue?
请查看“工具输出”面板中的详细信息。
-
+ 小熊猫C++项目文件(*.dev)
-
+ 重命名出错
-
+ 符号'%1'在系统头文件中定义,无法修改。
-
+ 新名称
-
-
-
-
+
+
+
+ 替换出错
-
+ 无法打开文件'%1'进行替换!
-
+ 内容和上次查找时不一致。
-
+ RTF格式文件 (*.rtf)
-
+ HTML文件 (*.html)
-
+ 当前的试题集不是空的。
-
+ 试题%1
-
-
+
+ 试题集文件 (*.pbs)
-
-
+
+ 载入失败
-
+ 试题案例%1
@@ -7258,7 +7273,7 @@ Are you really want to continue?
-
+ 错误
@@ -7332,7 +7347,7 @@ Are you really want to continue?
-
+ 确认转换
@@ -7362,7 +7377,7 @@ Are you really want to continue?
-
+ 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗?
@@ -7835,105 +7850,117 @@ Are you really want to continue?
无法保存文件'%1'.
-
+
+ 文件夹非空
+
+
+
+ 项目文件夹不是空的,已有的文件可能会被覆盖。
+
+
+
+ 您确定要继续吗?
+
+
+ 载入文件错误
-
-
+
+ 错误
-
+ 无法创建文件夹%1
-
+ 警告
-
-
+
+ 无法保存文件%1
-
+ 文件已存在
-
+ 文件'%1'已在项目中
-
+ 项目已升级
-
+ 已成功将项目升级到新的格式
-
+ 旧项目文件备份在'%1'。
-
+ 头文件
-
+ 源文件
-
+ 其他文件
-
+ 设置需要更新
-
+ The compiler settings format of Dev-C++ has changed.小熊猫C++的编译器设置格式已发生改变。
-
+ 请在项目 >> 项目属性 >> 编译器设置中修改您的设置并保存您的项目
-
+ 未找到编译器
-
+ 您为该项目设置的编译器不存在。
-
+ 它将会被全局编译器设置代替。
-
+ Developed using the Red Panda Dev-C++ IDE使用小熊猫C++编辑器开发
@@ -8485,32 +8512,32 @@ Are you really want to continue?
ProjectModel
-
+ 文件已存在
-
+ 文件'%1'已存在。是否删除?
-
+ 删除失败
-
+ 无法删除文件'%1'
-
+ 改名失败
-
+ 无法将文件'%1'改名为'%2'
@@ -8967,7 +8994,7 @@ Are you really want to continue?
生成调试信息(-g3)
-
+ 您同意小熊猫C++在PATH路径中寻找gcc编译器吗?
@@ -9178,7 +9205,7 @@ Are you really want to continue?
只生成汇编代码(-S)
-
+ 确认
@@ -9199,13 +9226,13 @@ Are you really want to continue?
如果仍然保留这些设置,可能会导致编译错误。<br /><br />请选择“是”,除非您清楚的知道选择“否”的后果,
-
-
+
+ 未配置编译器设置。
-
+ 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2
@@ -9574,7 +9601,7 @@ Are you really want to continue?
-
+
@@ -10588,12 +10615,12 @@ Are you really want to continue?
Settings
-
+ 错误
-
+ 找不到合适的终端程序!
@@ -10792,8 +10819,8 @@ Are you really want to continue?
-
-
+
+
@@ -10801,7 +10828,7 @@ Are you really want to continue?
-
+
@@ -10813,7 +10840,7 @@ Are you really want to continue?
自动链接
-
+
@@ -10889,15 +10916,15 @@ Are you really want to continue?
杂项
-
-
+
+ 程序运行
-
+ 试题集
@@ -10957,7 +10984,7 @@ Are you really want to continue?
-
+
diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts
index 414bbe66..462425c4 100644
--- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts
+++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts
@@ -5096,6 +5096,18 @@
+
+
+
+
+
+
+
+
+
+
+
+ MemoryModel