From 148e99e4833a1ae885e5558f279ab2d428f229fe Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Mon, 25 Oct 2021 13:16:15 +0800 Subject: [PATCH] - enhancement: prompt for filename when create new project unit file --- NEWS.md | 1 + RedPandaIDE/RedPandaIDE_zh_CN.ts | 191 ++++++++++++++++++------------- RedPandaIDE/mainwindow.cpp | 29 ++++- RedPandaIDE/project.cpp | 2 +- 4 files changed, 139 insertions(+), 84 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7faa75c2..2ae32135 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ Version 0.7.3 - fix: syntax issues' filepath info not correct when build projects - fix: compiler autolinks options widget don't show autolink infos - fix: autolink parameters are repeated when compile single files + - enhancement: prompt for filename when create new project unit file Version 0.7.2 - fix: rainbow parenthesis stop functioning when change editor's general options diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index c59fa963..ff10c43d 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -485,7 +485,7 @@ [说明] - + The compiler process for '%1' failed to start. 无法启动编译器进程'%1'。 @@ -494,27 +494,27 @@ 无法启动编译进程。 - + The compiler process crashed after starting successfully. 编译进程启动后崩溃。 - + The last waitFor...() function timed out. waitFor()函数等待超时。 - + An error occurred when attempting to write to the compiler process. 在向编译进程输入内容时出错。 - + An error occurred when attempting to read from the compiler process. 在从编译进程读取内容时出错。 - + An unknown error occurred. 发生了未知错误。 @@ -550,44 +550,44 @@ CompilerManager - - - - - + + + + + No compiler set 无编译器设置 - - - - - + + + + + No compiler set is configured. 没有配置编译器设置。 - - - - - + + + + + Can't start debugging. 无法启动调试器 - + Encoding not support 不支持字符编码 - + Clang only support utf-8 encoding. Clang只支持UTF-8编码 - + Strings in the program might be wrongly processed. 程序中的文字内容可能无法被正确处理和显示。 @@ -1077,23 +1077,23 @@ Are you really want to continue? Ctrl+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -1872,7 +1872,7 @@ Are you really want to continue? ExecutableRunner - + The runner process '%1' failed to start. The runner process failed to start. 无法启动程序运行进程'%1'。 @@ -1882,17 +1882,17 @@ Are you really want to continue? 程序运行进程启动后崩溃。 - + The last waitFor...() function timed out. waitFor()函数等待超时。 - + An error occurred when attempting to write to the runner process. 在向程序运行进程写入内容时出错。 - + An error occurred when attempting to read from the runner process. 在从程序运行进程读取内容时出错。 @@ -1982,7 +1982,7 @@ Are you really want to continue? - + Can't delete the old executable file "%1". 无法删除旧的可执行文件"%1". @@ -1994,22 +1994,22 @@ Are you really want to continue? 找不到适合文件%1的编译器 - + The Compiler '%1' doesn't exists! 编译器程序"%1"不存在! - + Processing %1 source file: 正在处理%1源程序文件: - + %1 Compiler: %2 %1编译器: %2 - + Command: %1 %2 命令: %1 %2 @@ -2811,6 +2811,7 @@ Are you really want to continue? + Issues 编译器 @@ -3566,7 +3567,7 @@ Are you really want to continue? - + Rename Symbol 重命名符号 @@ -3587,13 +3588,13 @@ Are you really want to continue? - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML @@ -3639,7 +3640,7 @@ Are you really want to continue? - + Open Folder 打开文件夹 @@ -3890,15 +3891,15 @@ Are you really want to continue? - - + + Bookmark Description 书签描述 - - + + Description: 描述: @@ -4102,48 +4103,73 @@ Are you really want to continue? 无法使用模板创建项目 - + + untitled + 无标题 + + + + New Project File Name + + + + + File Name: + 文件名: + + + + File Already Exists! + + + + + File '%1' already exists! + + + + Add to project 添加到项目 - + Rename Error 重命名出错 - + Symbol '%1' is defined in system header. 符号'%1'在系统头文件中定义,无法修改。 - + New Name 新名称 - - + + Replace Error 替换出错 - + Can't open file '%1' for replace! 无法打开文件'%1'进行替换! - + Contents has changed since last search! 内容和上次查找时不一致。 - + Rich Text Format Files (*.rtf) RTF格式文件 (*.rtf) - + HTML Files (*.html) HTML文件 (*.html) @@ -4322,62 +4348,67 @@ Are you really want to continue? 无法保存文件'%1'. - + + Error Load File + + + + File Exists 文件已存在 - + File '%1' is already in the project 文件'%1'已在项目中 - + Project Updated 项目已升级 - + Your project was succesfully updated to a newer file format! 已成功将项目升级到新的格式 - + If something has gone wrong, we kept a backup-file: '%1'... 旧项目文件备份在'%1'。 - + Settings need update 设置需要更新 - + The compiler settings format of Dev-C++ has changed. Dev-C++的编译器设置格式已发生改变。 - + Please update your settings at Project >> Project Options >> Compiler and save your project. 请在项目 >> 项目属性 >> 编译器设置中修改您的设置并保存您的项目 - + Compiler not found 未找到编译器 - + The compiler set you have selected for this project, no longer exists. 您为该项目设置的编译器不存在。 - + It will be substituted by the global compiler set. 它将会被全局编译器设置代替。 - + Developed using the Red Panda Dev-C++ IDE 使用小熊猫Dev-C++编辑器开发 @@ -4763,24 +4794,24 @@ Are you really want to continue? ProjectModel - + File exists 文件已存在 - + File '%1' already exists. Delete it now? 文件'%1'已存在。是否删除? - - + + Remove failed 删除失败 - - + + Failed to remove file '%1' 无法删除文件'%1' @@ -6039,7 +6070,7 @@ Are you really want to continue? 自动链接 - + @@ -6115,7 +6146,7 @@ Are you really want to continue? 杂项 - + Program Runner 程序运行 @@ -6271,22 +6302,22 @@ Are you really want to continue? 找不到适合文件%1的编译器 - + The Compiler '%1' doesn't exists! 编译器程序'%1'不存在! - + Processing %1 source file: 正在处理%1源程序文件: - + %1 Compiler: %2 %1编译器: %2 - + Command: %1 %2 命令: %1 %2 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 4cf5341b..065e329e 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -4209,14 +4209,37 @@ void MainWindow::on_actionProject_New_File_triggered() if (current.isValid()) { node = static_cast(current.internalPointer()); } + QString newFileName; + do { + newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber()); + if (mProject->options().useGPP) { + newFileName+=".cpp"; + } else { + newFileName+=".c"; + } + } while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))); + + newFileName = QInputDialog::getText( + this, + tr("New Project File Name"), + tr("File Name:"), + QLineEdit::Normal, + newFileName); + if (newFileName.isEmpty()) + return; + if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) { + QMessageBox::critical(this,tr("File Already Exists!"), + tr("File '%1' already exists!").arg(newFileName)); + return; + } PProjectUnit newUnit = mProject->newUnit( - mProject->pointerToNode(node)); + mProject->pointerToNode(node),newFileName); idx = mProject->units().count()-1; mProject->saveUnits(); updateProjectView(); Editor * editor = mProject->openUnit(idx); - editor->setUseCppSyntax(mProject->options().useGPP); - editor->setModified(true); + //editor->setUseCppSyntax(mProject->options().useGPP); + //editor->setModified(true); editor->activate(); } diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index c3a56574..c85ed724 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1725,7 +1725,7 @@ bool ProjectUnit::save() // file is neither open, nor saved QStringList temp; StringsToFile(temp,mFileName); - } else if (mEditor and modified()) { + } else if (mEditor && mEditor->modified()) { result = mEditor->save(); } if (mNode) {