diff --git a/NEWS.md b/NEWS.md index d62addf8..5462ca58 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,45 @@ +Version 0.9.2 For Dev-C++ 7 Beta + - fix: gutter of the disassembly code control in the cpu info dialog is grayed + - fix: problem set & problem views not correctly hidden when disabled in the executor / problem set options + - fix: executor / problem set options not correctly saved + +Version 0.9.1 For Dev-C++ 7 Beta + - enhancement: code completion suggestion for "__func__" variable + - fix: ide failed to start, if there are errors in the compiler set settings + - fix: numpad's enter key doesn't work + - enhancement: code completion suggestion for phrase after long/short/signed/unsigned + - enhancement: save/load default projects folder + - enhancement: add editor general options "highlight current word" and "highlight matching braces" + +Version 0.9.0 For Dev-C++ 7 Beta + - fix: control keys in the numpad doesn't work in the editor + - fix: project layout infos are wrongly saved to registry + - fix: project layout infos are not correctly saved/loaded + +Version 0.8.11 For Dev-C++ 7 Beta + - fix: text color for cpu info dialog not correctly setted + +Version 0.8.10 For Dev-C++ 7 Beta + - fix: Shouldn't update auto link settings, if the header name to be modified is unchanged + - fix: add unit to project not correctly set new unit file's encoding + - fix: correctly set encoding for the new added project unit file + - fix: if there's a project openned, new file should ask user if he want to add the new file to the project + - fix: when adding a file openned in the editor to the project, properties of it are not correctly setted. + - enhancement: when remove a file from the project, also ask if user want to remove it from disk + - fix: double click a project's .dev file in the Files panel should load the project + +Version 0.8.9 For Dev-C++ 7 Beta + - fix: text color of labels in statusbar not correctly updated when change theme + +Version 0.8.8 For Dev-C++ 7 Beta + - enhancement: drag & drop text in the editor + - enhancement: auto calcuate caret line size basing on font size + - enhancement: shift+mouse wheel to scroll horizontally + - fix: greatly reduces paste time + - fix: auto indent shouldn't use preprocessor's indent to calculate + - fix: option "don't add leading zeros to line numbers" not work + - fix: "collapse all" and "uncollapse all" doesn't work + Version 0.8.7 For Dev-C++ 7 Beta - enhancement: auto indent line to column 1 when enter '#' at beginning of line - fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 33da8b50..0dea66be 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -199,6 +199,7 @@ HEADERS += \ thememanager.h \ todoparser.h \ toolsmanager.h \ + version.h \ widgets/aboutdialog.h \ widgets/bookmarkmodel.h \ widgets/classbrowser.h \ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index db25ebd2..743bdf76 100644 Binary files a/RedPandaIDE/RedPandaIDE_zh_CN.qm and b/RedPandaIDE/RedPandaIDE_zh_CN.qm differ diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 4e524a55..4088ca1d 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -51,7 +51,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. - + Version: 版本: @@ -82,12 +82,12 @@ 链接参数 - + Header exists 头文件已存在 - + Header already exists. 头文件已存在。 @@ -1029,12 +1029,12 @@ Are you really want to continue? 失败 - - - - - - + + + + + + Error 错误 @@ -1043,60 +1043,60 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 - - + + Symbol '%1' not found! 未找到符号'%1'! - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -1715,7 +1715,7 @@ Are you really want to continue? Check when count of lines changed - 在文件函数变化时检查 + 在文件行数或者光标所在行变化时检查 @@ -2857,11 +2857,11 @@ Are you really want to continue? - - - - - + + + + + Issues 编译器 @@ -3012,7 +3012,7 @@ Are you really want to continue? 工具栏2 - + New 新建 @@ -3070,10 +3070,8 @@ Are you really want to continue? - - - - + + Compile 编译 @@ -3119,8 +3117,8 @@ Are you really want to continue? - - + + Copy 复制 @@ -3131,7 +3129,7 @@ Are you really want to continue? - + Paste 粘贴 @@ -3142,7 +3140,7 @@ Are you really want to continue? - + Select All 选择全部 @@ -3262,14 +3260,14 @@ Are you really want to continue? - + Problem Set 试题集 - + New Problem Set 新建试题集 @@ -3288,14 +3286,14 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 @@ -3331,7 +3329,7 @@ Are you really want to continue? - + Problem 试题 @@ -3630,7 +3628,7 @@ Are you really want to continue? - + Clear all breakpoints 删除所有断点 @@ -3731,7 +3729,7 @@ Are you really want to continue? - + Rename Symbol 重命名符号 @@ -3752,13 +3750,13 @@ Are you really want to continue? - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML @@ -3824,7 +3822,7 @@ Are you really want to continue? - + Open Folder 打开文件夹 @@ -3834,42 +3832,42 @@ Are you really want to continue? 运行参数... - + File Encoding 文件编码 - + Recent Files 文件历史 - - - - - - + + + + + + Debugging 正在调试 - - - - - - + + + + + + Running 正在运行 - - - - - - + + + + + + Compiling 正在编译 @@ -3878,184 +3876,184 @@ Are you really want to continue? 行:%1 列:%2 已选择:%3 总行数:%4 总长度:%5 - + Line:%1 Col:%2 Selected:%3 Lines:%4 Length:%5 Line: %1 Col: %2 Selected: %3 Lines: %4 Length: %5 行: %1 列: %2 已选择 :%3 总行数: %4 总长度: %5 - + Read Only 只读 - + Insert 插入 - + Overwrite 覆写 - + Close project 关闭项目 - + Are you sure you want to close %1? 你确定要关闭'%1'吗? - - + + Confirm 确认 - - - + + + Source file is not compiled. 源文件尚未编译。 - - + + Compile now? 现在编译? - - - + + + Source file is more recent than executable. 源文件比可执行程序新。 - + Recompile now? 重新编译? - + No compiler set 无编译器设置 - + No compiler set is configured. 没有配置编译器设置。 - + Can't start debugging. 无法启动调试器 - - + + Enable debugging 启用调试参数 - - + + You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now? 当前编译设置中未启用调试选项(-g3),或启用了信息剥除选项(-s)<br /><br/>是否纠正这一问题? - + Project not built 项目尚未构建 - + Project hasn't been built. Build it now? 项目尚未构建。是否构建? - + Host applcation missing 宿主程序不存在 - + DLL project needs a host application to run. 动态链接库(DLL)需要一个宿主程序来运行。 - + But it's missing. 但它不存在。 - + Host application not exists 宿主程序不存在 - + Host application file '%1' doesn't exist. 宿主程序'%1'不存在。 - + Recompile? 重新编译? - - + + Save last open info error 保存上次打开信息失败 - + Can't remove old last open information file '%1' 无法删除旧上次打开信息文件'%1' - + Can't save last open info file '%1' 无法保存上次打开信息文件'%1' - + Load last open info error 载入上次打开信息失败 - + Can't load last open info file '%1' 无法载入上次打开信息文件'%1' - + Copy all 全部复制 - - + + Clear 清除 - + Export 导出 - + Insert Snippet 插入代码段 - - + + Problem Set %1 试题集%1 @@ -4076,488 +4074,524 @@ Are you really want to continue? 或者选择使用其他的网络端口。 - + Red Panda Dev-C++ 小熊猫Dev-C++ - + + Auto Save Error + 自动保存出错 + + + + Auto save "%1" to "%2" failed:%3 + 自动保存"%1"到"%2"失败:%3 + + + Properties... 试题属性... - + Set Problem Set Name 设置试题集名称 - + Problem Set Name: 试题集名称: - + Remove 删除 - + Remove All Bookmarks 删除全部书签 - + Modify Description 修改描述 - - - + + + Bookmark Description 书签描述 - - - + + + Description: 描述: - + Show debug logs in the debug console 在调试主控台中显示调试器输出 - + Remove this search 清除这次搜索 - + Clear all searches 删除所有搜索 - + Breakpoint condition... 断点条件... - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Remove All Breakpoints Remove all breakpoints 删除所有断点 - + Remove Breakpoint 删除当前断点 - + Rename File 重命名文件 - - + + Add Folder 添加文件夹 - + New folder 新文件夹 - + Folder name: 文件夹: - + Rename Folder 重命名 - + Remove Folder 删除文件夹 - + Sort By Type 按类型排序 - + Sort alphabetically 按名称排序 - + Show inherited members 显示继承的成员 - + Goto declaration 跳转到声明处 - + Goto definition 跳转到定义处 - + Open in Editor 在编辑器中打开 - + Open in External Program 使用外部程序打开 - + Open in Terminal 在终端中打开 - + Open in Windows Explorer 在Windows浏览器中打开 - + Character sets 字符集 - + %1 files autosaved 已自动保存%1个文件 - + Set answer to... 设置答案源代码... - + select other file... 选择其他文件... - + Select Answer Source File 选择答案源代码文件 - + C/C++Source Files (*.c *.cpp *.cc *.cxx) C/C++Source Files (*.c *.cpp *.cc *.cxx C/C++源代码文件 (*.c *.cpp *.cc *.cxx) - + Save project 保存项目 - + The project '%1' has modifications. 项目'%1'有改动。 - - + + Do you want to save it? 需要保存吗? - - - - + + + File Changed + 文件已发生变化 + + + + New Project File? + 新建项目文件? + + + + Do you want to add the new file to the project? + 您是否要将新建的文件加入项目? + + + + + + Save Error 保存失败 - + Change Project Compiler Set 改变项目编译器配置集 - + Change the project's compiler set will lose all custom compiler set options. 改变项目的编译器配置集会导致所有的自定义编译器选项被重置。 - + Do you really want to do that? 你真的想要做那些吗? - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Red panda Dev-C++ project file (*.dev) 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + + Remove file + 删除文件 + + + + Remove the file from disk? + 同时从硬盘上删除文件? + + + untitled 无标题 - + New Project File Name 新的项目文件名 - + File Name: 文件名: - + File Already Exists! 文件已存在! - + File '%1' already exists! 文件'%1'已经存在! - + 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) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - + Load Error 载入失败 - - + + Problem Case %1 试题案例%1 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + Error 错误 - + Recent Projects 项目历史 - + File '%1' was changed. 磁盘文件'%1'已被修改。 - + Reload its content from disk? 是否重新读取它的内容? - + File '%1' was removed. 磁盘文件'%1'已被删除。 - + Keep it open? 是否保持它在小熊猫C++中打开的编辑窗口? - + Open 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - + + Confirm Convertion 确认转换 - - + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -4585,28 +4619,37 @@ Are you really want to continue? C++语言项目 - + Name: 项目名称: - - Location: - 文件夹: + + Create in + 创建在 - + + Use as the default project location + 设为缺省项目位置 + + + Location: + 文件夹: + + + ... ... - + Project%1 项目%1 - - + + Default 缺省 @@ -4685,77 +4728,77 @@ Are you really want to continue? 无标题 - + Can't save file 无法保存文件 - + Can't save file '%1' 无法保存文件'%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++编辑器开发 @@ -4796,52 +4839,52 @@ Are you really want to continue? ProjectCompiler - + Building makefile... 正在构建makefile... - + - Filename: %1 - 文件名: %1 - + Can't open '%1' for write! 无法写入文件'%1'! - + - Resource File: %1 - 资源文件: %1 - + Compiling project changes... 正在编译项目修改... - + - Project Filename: %1 - 项目文件名: %1 - + - Compiler Set Name: %1 - 编译器配置: %1 - + Processing makefile: 正在处理makefile... - + - makefile processer: %1 - makefile处理器: %1 - + - Command: %1 %2 - 命令: %1 %2 @@ -5146,24 +5189,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' @@ -5382,7 +5425,7 @@ Are you really want to continue? QApplication - + Error 错误 @@ -5452,180 +5495,180 @@ Are you really want to continue? 无法写入配置文件夹"%1" - + Can't load autolink settings 无法载入自动链接设置 - - - - + + + + The following %1 directories don't exist: 下列%1文件夹不存在: - - + + binary 二进制 - + No %1 directories have been specified. 未指定%1文件夹 - + C include C包含 - - + + C++ include C++包含 - - - - + + + + Cannot find the %1 "%2" 无法找到%1程序"%2" - + C options C语言选项 - + Support all ANSI standard C programs (-ansi) 支持所有ANSI标准C程序(-ansi) - + Do not recognize asm,inline or typeof as a keyword (-fno-asm) 不支持将asm、inline和typeof作为关键字(-fno-asm) - + Imitate traditional C preprocessors (-traditional-cpp) 模仿传统C预处理器行为(-traditional-cpp) - + Code Generation 代码生成 - + Optimize for the following machine (-march) 生成特定机器的专用指令(-march) - + Optimize less, while maintaining full compatibility (-tune) 完整兼容特定机器,较少优化(-tune) - + Enable use of specific instructions (-mx) 启用特定指令集(-mx) - + Optimization level (-Ox) 优化级别(-Ox) - + Compile with the following pointer size (-mx) 使用下列指针大小编译(-mx) - + Language standard (-std) 语言标准(-std) - + Profile 性能分析 - + Generate debugging information (-g3) 生成调试信息(-g3) - + Generate profiling info for analysis (-pg) 生成性能分析信息(-pg) - + Warnings 代码警告 - + Inhibit all warning messages (-w) 忽略所有警告信息(-w) - + Show most warnings (-Wall) 启用常见问题警告(-Wall) - + Show some more warnings (-Wextra) 启用更多问题警告(-Wextra) - + Check ISO C/C++/C++0x conformance (-pedantic) 检查ISO C/C++/C++0x语法一致性(-pedantic) - + Only check the code for syntax errors (-fsyntax-only) 只进行语法检查(不编译)(-fsyntax-only) - + Make all warnings into errors (-Werror) 将警告作为错误处理(-Werror) - + Abort compilation on first error (-Wfatal-errors) 遇到第一个错误后立即中止编译(-Wfatal-errors) - + Linker 链接器 - + Link an Objective C program (-lobjc) 链接Objective-C程序 (-lobjc) - + Do not use standard system libraries (-nostdlib) 不使用标准库和系统启动文件(-nostdlib) - + Do not create a console window (-mwindows) 不产生控制台窗口(-mwindows) - + Strip executable (-s) 剥除附加信息(-s) @@ -5634,53 +5677,53 @@ Are you really want to continue? 链接Ojbective C程序(-lobjc) - + Output 输出 - + Put comments in generated assembly code (-fverbose-asm) 在生成的汇编代码中加入注释(-fverbose-asm) - + Use pipes instead of temporary files during compilation (-pipe) 编译时使用管道而不是临时文件(-pipe) - + Do not assemble, compile and generate the assemble code (-S) 只生成汇编代码(-S) - - + + Confirm 确认 - + The following problems were found during validation of compiler set "%1": 在验证编译器设置"%1"时遇到了下列问题: - + Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths? 是否让小熊猫C++删除这些配置,并尝试重新建立配置? - + Leaving those directories will lead to problems during compilation.<br /><br />Unless you know exactly what you're doing, it is recommended that you click Yes. 如果仍然保留这些设置,可能会导致编译错误。<br /><br />请选择“是”,除非您清楚的知道选择“否”的后果, - + Compiler set not configuared. 未配置编译器设置。 - + Would you like Red Panda C++ to search for compilers in the following locations: <BR />'%1'<BR />'%2'? 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2 @@ -5723,27 +5766,27 @@ Are you really want to continue? 无标题 - + Index %1 out of range 下标"%1"越界 - + bytes 字节 - + KB KB - + MB MB - + GB GB @@ -6397,8 +6440,9 @@ Are you really want to continue? SettingsDialog + Options - + 选项 @@ -6421,161 +6465,165 @@ Are you really want to continue? 取消 - + Appearence 外观 - - - - - + + + + + Environment 环境 - + File Association 文件关联 - + Shortcuts 快捷键 - + Folders 文件夹 - + Performance 性能 - - + + Compiler Set 编译器配置集 - - + + Compiler 编译器 - + Auto Link 自动链接 - - - - - - - + + + + + + + General 通用 - - - - - - - - - - - + + + + + + + + + + + Editor 编辑器 - + Font 字体 - + Copy & Export 复制/导出 - + Color 配色 - + Code Completion 代码补全 - + Symbol Completion 符号补全 - + Snippet 代码模板 - + Auto Syntax Checking 自动语法检查 - + Tooltips 信息提示 - + Auto save 自动保存 - + Misc 杂项 - - - + + + Program Runner 程序运行 - + Problem Set 试题集 - + Debugger 调试器 - + Code Formatter 代码排版 - + Tools 工具 - + + Project Options + 项目选项 + + @@ -6585,56 +6633,57 @@ Are you really want to continue? + Project 项目 - + Files 文件 - + Custom Compile options 自定义编译选项 - + Directories 文件夹 - + Precompiled Header 预编译头文件 - + Makefile Makefile - + Output 输出 - + DLL host DLL宿主 - + Version info 版本信息 - + Save Changes 保存修改 - + There are changes in the settings, do you want to save them before swtich to other page? 本页中有尚未保存的设置修改,是否保存后再切换到其他页? @@ -6777,12 +6826,12 @@ Are you really want to continue? SynEditStringList - + Can't open file '%1' for read! 无法读取文件'%1'! - + Can't open file '%1' for save! 无法写入文件'%2'! @@ -7051,51 +7100,66 @@ Are you really want to continue? + Highlight + 高亮显示 + + + + Highlight matching braces + 高亮显示与光标处相匹配的括号 + + + + Highlight current word + 高亮显示光标所在的单词 + + + Scroll 滚动条 - + Auto hide scroll bars 自动隐藏滚动条 - + Can scroll the last char to the left edge of the editor 可以将每行末尾字符滚动到编辑器最左侧 - + Can scroll the last line to the top edge of the editor 可以将最后一行滚动到编辑器最上方 - + Page Up/Down scrolls half a page 翻页键只滚动半页 - + Forces page scroll to be one line less 在滚动页时少滚动一行 - + Mouse Wheel Scroll Speed 鼠标滚轮卷轴速度(行) - + Show right edge line 显示右边缘线 - + Right egde width 右边缘宽度 - + Right edge line color 右边缘颜色 diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 0cefe35a..d6b65313 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -4,6 +4,7 @@ #include "../systemconsts.h" #include "../platform.h" #include "../editor.h" +#include "../version.h" #include @@ -339,14 +340,14 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file) encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") .arg(unit->editor()->fileEncoding(), defaultSystemEncoding); - } else if (unit->encoding()!=ENCODING_ASCII) { - encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") - .arg(unit->encoding(), - defaultSystemEncoding); - } else if (unit->encoding()!=ENCODING_SYSTEM_DEFAULT) { + } else if (unit->encoding()==ENCODING_SYSTEM_DEFAULT) { encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") .arg(defaultSystemEncoding, defaultSystemEncoding); + } else if (unit->encoding()!=ENCODING_ASCII && !unit->encoding().isEmpty()) { + encodingStr = QString(" -finput-charset=%1 -fexec-charset=%2") + .arg(unit->encoding(), + defaultSystemEncoding); } } diff --git a/RedPandaIDE/cpprefacter.cpp b/RedPandaIDE/cpprefacter.cpp index 37eb56e9..1fcb5958 100644 --- a/RedPandaIDE/cpprefacter.cpp +++ b/RedPandaIDE/cpprefacter.cpp @@ -48,7 +48,7 @@ bool CppRefacter::findOccurence(Editor *editor, const BufferCoord &pos) bool CppRefacter::findOccurence(const QString &statementFullname, SearchFileScope scope) { PCppParser parser; - Editor * editor; + Editor * editor=nullptr; std::shared_ptr project; if (scope == SearchFileScope::currentFile) { editor = pMainWindow->editorList()->getEditor(); diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 25941177..e837b76f 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -692,6 +692,16 @@ void Editor::keyPressEvent(QKeyEvent *event) QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); if (!lastWord.isEmpty()) { if (CppTypeKeywords.contains(lastWord)) { + if (lastWord == "long" || + lastWord == "short" || + lastWord == "signed" || + lastWord == "unsigned" + ) { + setSelText(ch); + showCompletion(lastWord,false); + handled=true; + return; + } //last word is a type keyword, this is a var or param define, and dont show suggestion // if devEditor.UseTabnine then // ShowTabnineCompletion; @@ -713,7 +723,7 @@ void Editor::keyPressEvent(QKeyEvent *event) } } setSelText(ch); - showCompletion(false); + showCompletion("",false); handled=true; return; } @@ -727,7 +737,7 @@ void Editor::keyPressEvent(QKeyEvent *event) && pSettings->codeCompletion().showCompletionWhileInput() ) { mLastIdCharPressed++; setSelText(ch); - showCompletion(false); + showCompletion("",false); handled=true; return; } @@ -739,7 +749,7 @@ void Editor::keyPressEvent(QKeyEvent *event) && pSettings->codeCompletion().showCompletionWhileInput() ) { mLastIdCharPressed++; setSelText(ch); - showCompletion(false); + showCompletion("",false); handled=true; return; } @@ -910,7 +920,8 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to foreground = mCurrentHighlighWordForeground; if (mCurrentHighlighWordBackground.isValid()) background = mCurrentHighlighWordBackground; - } else if (!selAvail() && attr->name() == SYNS_AttrSymbol) { + } else if (!selAvail() && attr->name() == SYNS_AttrSymbol + && pSettings->editor().highlightMathingBraces()) { // qDebug()<=0) { if (mTabStopY==caretY()) { if (mLineAfterTabStop.isEmpty()) { @@ -1427,7 +1434,11 @@ void Editor::onStatusChanged(SynStatusChanges changes) clearUserCodeInTabStops(); } } - } else if (!selAvail() && highlighter()){ + } else if (!selAvail() && highlighter() && pSettings->editor().highlightMathingBraces()){ + invalidateLine(mHighlightCharPos1.Line); + invalidateLine(mHighlightCharPos2.Line); + mHighlightCharPos1 = BufferCoord{0,0}; + mHighlightCharPos2 = BufferCoord{0,0}; // Is there a bracket char before us? int lineLength = lineText().length(); int ch = caretX() - 2; @@ -1461,8 +1472,11 @@ void Editor::onStatusChanged(SynStatusChanges changes) // scSelection includes anything caret related if (changes.testFlag(SynStatusChange::scSelection)) { - if (!selAvail()) { + if (!selAvail() && pSettings->editor().highlightCurrentWord()) { mCurrentHighlightedWord = wordAtCursor(); + } else if (selAvail() && blockBegin() == wordStart() + && blockEnd() == wordEnd()){ + mCurrentHighlightedWord = selText(); } else { mCurrentHighlightedWord = ""; } @@ -1904,20 +1918,20 @@ bool Editor::handleCodeCompletion(QChar key) switch(key.unicode()) { case '.': setSelText(key); - showCompletion(false); + showCompletion("",false); return true; case '>': setSelText(key); if ((caretX() > 2) && (lineText().length() >= 2) && (lineText()[caretX() - 3] == '-')) - showCompletion(false); + showCompletion("",false); return true; case ':': ExecuteCommand(SynEditorCommand::ecChar,':',nullptr); //setSelText(key); if ((caretX() > 2) && (lineText().length() >= 2) && (lineText()[caretX() - 3] == ':')) - showCompletion(false); + showCompletion("",false); return true; case '/': case '\\': @@ -2260,7 +2274,7 @@ void Editor::exportAsHTML(const QString &htmlFilename) exporter.SaveToFile(htmlFilename); } -void Editor::showCompletion(bool autoComplete) +void Editor::showCompletion(const QString& preWord,bool autoComplete) { if (!pSettings->codeCompletion().enabled()) return; @@ -2337,8 +2351,7 @@ void Editor::showCompletion(bool autoComplete) if (word.isEmpty()) word=getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion); - //if not fCompletionBox.Visible then - mCompletionPopup->prepareSearch(word, mFilename, pBeginPos.Line); + mCompletionPopup->prepareSearch(preWord, word, mFilename, pBeginPos.Line); // Filter the whole statement list if (mCompletionPopup->search(word, autoComplete)) { //only one suggestion and it's not input while typing diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 70e44cfb..05c11159 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -202,7 +202,7 @@ private: void undoSymbolCompletion(int pos); QuoteStatus getQuoteStatus(); - void showCompletion(bool autoComplete); + void showCompletion(const QString& preWord, bool autoComplete); void showHeaderCompletion(bool autoComplete); bool testInFunc(int x,int y); diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp index 7a5fa913..c3709e8a 100644 --- a/RedPandaIDE/main.cpp +++ b/RedPandaIDE/main.cpp @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); //Translation must be loaded first - QTranslator trans; + QTranslator trans,transQt; QString settingFilename = getSettingFilename(); if (!isGreenEdition()) { QDir::setCurrent(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]); @@ -91,8 +91,13 @@ int main(int argc, char *argv[]) QSettings languageSetting(settingFilename,QSettings::IniFormat); languageSetting.beginGroup(SETTING_ENVIRONMENT); QString language = languageSetting.value("language",QLocale::system().name()).toString(); - trans.load("RedPandaIDE_"+language,":/translations"); - app.installTranslator(&trans); + + if (trans.load("RedPandaIDE_"+language,":/translations")) { + app.installTranslator(&trans); + } + if (transQt.load("qt_"+language,":/translations")) { + app.installTranslator(&transQt); + } } qRegisterMetaType("PCompileIssue"); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 72ccf83f..35dec8aa 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -20,6 +20,7 @@ #include "widgets/darkfusionstyle.h" #include "problems/problemcasevalidator.h" #include "widgets/ojproblempropertywidget.h" +#include "version.h" #include #include @@ -511,6 +512,10 @@ void MainWindow::applySettings() else QApplication::setStyle("fusion"); qApp->setPalette(appTheme->palette()); + //fix for qstatusbar bug + mFileEncodingStatus->setPalette(appTheme->palette()); + mFileModeStatus->setPalette(appTheme->palette()); + mFileInfoStatus->setPalette(appTheme->palette()); updateEditorColorSchemes(); QFont font(pSettings->environment().interfaceFont(), @@ -529,7 +534,7 @@ void MainWindow::applySettings() if (!mTcpServer.listen(QHostAddress::LocalHost,pSettings->executor().competivieCompanionPort())) { // QMessageBox::critical(nullptr, // tr("Listen failed"), -// tr("Can't listen to port %1 form Competitve Companion.").arg(10045) +// tr("Can't listen to port %1 form Competitive Companion.").arg(10045) // + "
" // +tr("You can turn off competitive companion support in the Problem Set options.") // + "
" @@ -569,7 +574,8 @@ void MainWindow::applyUISettings() ui->actionFiles->setChecked(settings.showFiles()); showHideInfosTab(ui->tabFiles,settings.showFiles()); ui->actionProblem_Set->setChecked(settings.showProblemSet()); - showHideInfosTab(ui->tabProblemSet,settings.showProblemSet()); + showHideInfosTab(ui->tabProblemSet,settings.showProblemSet() + && pSettings->executor().enableProblemSet()); ui->actionIssues->setChecked(settings.showIssues()); showHideMessagesTab(ui->tabIssues,settings.showIssues()); @@ -584,7 +590,8 @@ void MainWindow::applyUISettings() ui->actionBookmark->setChecked(settings.showBookmark()); showHideMessagesTab(ui->tabBookmark,settings.showBookmark()); ui->actionProblem->setChecked(settings.showProblem()); - showHideMessagesTab(ui->tabProblem,settings.showProblem()); + showHideMessagesTab(ui->tabProblem,settings.showProblem() + && pSettings->executor().enableProblemSet()); //we can't show/hide left/bottom panels here, cause mainwindow layout is not calculated } @@ -2669,12 +2676,14 @@ void MainWindow::onLstProblemSetContextMenu(const QPoint &pos) QAction * action = new QAction(tr("select other file..."),menuSetAnswer); connect(action, &QAction::triggered, [problem,this](){ + QFileDialog dialog; QString filename = QFileDialog::getOpenFileName( this, tr("Select Answer Source File"), QString(), - tr("C/C++Source Files (*.c *.cpp *.cc *.cxx)") - ); + tr("C/C++Source Files (*.c *.cpp *.cc *.cxx)"), + nullptr, + dialog.options() | QFileDialog::DontUseNativeDialog); if (!filename.isEmpty()) { QDir::setCurrent(extractFileDir(filename)); problem->answerProgram = filename; @@ -3133,7 +3142,7 @@ void MainWindow::onFileChanged(const QString &path) if (e) { if (fileExists(path)) { e->activate(); - if (QMessageBox::question(this,tr("Compile"), + if (QMessageBox::question(this,tr("File Changed"), tr("File '%1' was changed.").arg(path)+"

" + tr("Reload its content from disk?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { @@ -3144,7 +3153,7 @@ void MainWindow::onFileChanged(const QString &path) } } } else { - if (QMessageBox::question(this,tr("Compile"), + if (QMessageBox::question(this,tr("File Changed"), tr("File '%1' was removed.").arg(path)+"

" + tr("Keep it open?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::No) { @@ -3201,6 +3210,15 @@ CPUDialog *MainWindow::cpuDialog() const void MainWindow::on_actionNew_triggered() { + if (mProject) { + if (QMessageBox::question(this, + tr("New Project File?"), + tr("Do you want to add the new file to the project?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + newProjectUnitFile(); + return; + } + } newEditor(); } @@ -3770,7 +3788,7 @@ void MainWindow::on_actionUnfoldAll_triggered() { Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { - //editor->clearFolds(); + editor->unCollpaseAll(); } } @@ -3778,8 +3796,7 @@ void MainWindow::on_actionFoldAll_triggered() { Editor * editor = mEditorList->getEditor(); if (editor != NULL ) { - //editor->clearFolds(); - //editor->foldAll(); + editor->collapseAll(); } } @@ -4549,6 +4566,10 @@ void MainWindow::on_actionNew_Project_triggered() { NewProjectDialog dialog; if (dialog.exec() == QDialog::Accepted) { + if (dialog.useAsDefaultProjectDir()) { + pSettings->dirs().setProjectDir(dialog.getLocation()); + pSettings->dirs().save(); + } // Take care of the currently opened project QString s; if (mProject) { @@ -4569,19 +4590,20 @@ void MainWindow::on_actionNew_Project_triggered() } //Create the project folder - QDir dir(dialog.getLocation()); + QString location = includeTrailingPathDelimiter(dialog.getLocation())+dialog.getProjectName(); + QDir dir(location); if (!dir.exists()) { if (QMessageBox::question(this, tr("Folder not exist"), - tr("Folder '%1' doesn't exist. Create it now?").arg(dialog.getLocation()), + tr("Folder '%1' doesn't exist. Create it now?").arg(location), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) { return; } - if (!dir.mkpath(dialog.getLocation())) { + if (!dir.mkpath(location)) { QMessageBox::critical(this, tr("Can't create folder"), - tr("Failed to create folder '%1'.").arg(dialog.getLocation()), + tr("Failed to create folder '%1'.").arg(location), QMessageBox::Yes); return; } @@ -4590,14 +4612,14 @@ void MainWindow::on_actionNew_Project_triggered() // if cbDefault.Checked then // devData.DefCpp := rbCpp.Checked; - s = includeTrailingPathDelimiter(dialog.getLocation()) + s = includeTrailingPathDelimiter(location) + dialog.getProjectName() + "." + DEV_PROJECT_EXT; if (fileExists(s)) { QString saveName = QFileDialog::getSaveFileName( this, tr("Save new project as"), - dialog.getLocation(), + location, tr("Red panda Dev-C++ project file (*.dev)")); if (!saveName.isEmpty()) { s = saveName; @@ -4645,46 +4667,7 @@ void MainWindow::on_actionSaveAll_triggered() void MainWindow::on_actionProject_New_File_triggered() { - int idx = -1; - if (!mProject) - return; - QModelIndex current = ui->projectView->currentIndex(); - FolderNode * node = nullptr; - 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),newFileName); - idx = mProject->units().count()-1; - mProject->saveUnits(); - updateProjectView(); - Editor * editor = mProject->openUnit(idx); - //editor->setUseCppSyntax(mProject->options().useGPP); - //editor->setModified(true); - editor->activate(); + newProjectUnitFile(); } @@ -4733,9 +4716,14 @@ void MainWindow::on_actionRemove_from_project_triggered() continue; selected.insert(folderNode->unitIndex); }; + + bool removeFile = (QMessageBox::question(this,tr("Remove file"), + tr("Remove the file from disk?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes); + for (int i=mProject->units().count()-1;i>=0;i--) { if (selected.contains(i)) { - mProject->removeEditor(i,true); + mProject->removeUnit(i,true,removeFile); } } @@ -4943,6 +4931,50 @@ void MainWindow::prepareTabMessagesData() mTabMessagesData[widget]=info; } } + +void MainWindow::newProjectUnitFile() +{ + if (!mProject) + return; + int idx = -1; + QModelIndex current = ui->projectView->currentIndex(); + FolderNode * node = nullptr; + 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),newFileName); + idx = mProject->units().count()-1; + mProject->saveUnits(); + updateProjectView(); + Editor * editor = mProject->openUnit(idx); + //editor->setUseCppSyntax(mProject->options().useGPP); + //editor->setModified(true); + editor->activate(); +} void MainWindow::on_EditorTabsLeft_currentChanged(int) { Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft); @@ -5374,9 +5406,10 @@ void MainWindow::on_treeFiles_doubleClicked(const QModelIndex &index) QString filepath = mFileSystemModel.filePath(index); QFileInfo file(filepath); if (file.isFile()) { - Editor * editor = mEditorList->getEditorByFilename(filepath); - if (editor) { - editor->activate(); + if (getFileType(filepath)==FileType::Project) { + openProject(filepath); + } else { + openFile(filepath); } } } diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 03a9b403..c11f45b7 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -226,6 +226,7 @@ private: void showHideMessagesTab(QWidget *widget, bool show); void prepareTabInfosData(); void prepareTabMessagesData(); + void newProjectUnitFile(); private slots: void onAutoSaveTimeout(); diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 507115f3..70747547 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -85,7 +85,7 @@ QTabWidget::West - 1 + 3 true diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 03360fe0..ac324a9a 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2153,6 +2153,21 @@ void CppParser::handleMethod(const QString &sType, const QString &sName, const Q true, false); } + // add "__func__ variable" + addStatement( + functionStatement, + mCurrentFile, + "", //dont override hint + "static const char ", + "__func__", + "[]", + "\""+scopelessName+"\"", + startLine+1, + StatementKind::skVariable, + StatementScope::ssLocal, + StatementClassScope::scsNone, + true, + false); } else { functionStatement = addStatement( functionClass, diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index 6ba40616..e6254b2b 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -154,6 +154,8 @@ void initParser() //CppTypeKeywords.insert("unsigned"); CppTypeKeywords.insert("void"); CppTypeKeywords.insert("wchar_t"); + CppTypeKeywords.insert("signed"); + CppTypeKeywords.insert("unsigned"); // it's part of type info CppKeywords.insert("const",SkipType::skNone); diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 0951d0c8..021f2ba3 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -260,7 +260,7 @@ PProjectUnit Project::newUnit(PFolderNode parentNode, const QString& customFileN newUnit->setOverrideBuildCmd(false); newUnit->setBuildCmd(""); newUnit->setModified(true); - newUnit->setEncoding(toByteArray(options().encoding)); + newUnit->setEncoding(toByteArray(mOptions.encoding)); return newUnit; } @@ -285,7 +285,7 @@ Editor *Project::openUnit(int index) editor = pMainWindow->editorList()->newEditor(fullPath, encoding, true, unit->isNew()); editor->setInProject(true); unit->setEditor(editor); - unit->setEncoding(encoding); + //unit->setEncoding(encoding); editor->activate(); loadUnitLayout(editor,index); return editor; @@ -340,7 +340,7 @@ void Project::rebuildNodes() emit nodesChanged(); } -bool Project::removeEditor(int index, bool doClose) +bool Project::removeUnit(int index, bool doClose , bool removeFile) { mModel.beginUpdate(); auto action = finally([this]{ @@ -357,6 +357,10 @@ bool Project::removeEditor(int index, bool doClose) return false; } + if (removeFile) { + QFile::remove(unit->fileName()); + } + //if not fUnits.GetItem(index).fNew then PFolderNode node = unit->node(); PFolderNode parent = node->parent.lock(); @@ -416,7 +420,7 @@ void Project::saveAll() void Project::saveLayout() { - QSettings layIni(changeFileExt(mFilename, "layout"),QSettings::IniFormat); + SimpleIni layIni; QStringList sl; // Write list of open project files for (int i=0;ieditorList()->pageCount();i++) { @@ -424,39 +428,37 @@ void Project::saveLayout() if (e && e->inProject()) sl.append(QString("%1").arg(indexInUnits(e))); } - layIni.beginGroup("Editors"); - layIni.setValue("Order",sl.join(",")); + layIni.SetValue("Editors","Order",sl.join(",").toUtf8()); Editor *e, *e2; // Remember what files were visible pMainWindow->editorList()->getVisibleEditors(e, e2); if (e) - layIni.setValue("Focused", indexInUnits(e)); - layIni.endGroup(); + layIni.SetLongValue("Editors","Focused", indexInUnits(e)); // save editor info for (int i=0;ieditor(); if (editor) { - layIni.setValue("CursorCol", editor->caretX()); - layIni.setValue("CursorRow", editor->caretY()); - layIni.setValue("TopLine", editor->topLine()); - layIni.setValue("LeftChar", editor->leftChar()); + layIni.SetLongValue(groupName,"CursorCol", editor->caretX()); + layIni.SetLongValue(groupName,"CursorRow", editor->caretY()); + layIni.SetLongValue(groupName,"TopLine", editor->topLine()); + layIni.SetLongValue(groupName,"LeftChar", editor->leftChar()); } - layIni.endGroup(); // remove old data from project file SimpleIni ini; - ini.LoadFile(mFilename.toLocal8Bit()); - QByteArray groupName = toByteArray(QString("Unit%1").arg(i+1)); + ini.LoadFile(filename().toLocal8Bit()); + groupName = toByteArray(QString("Unit%1").arg(i+1)); ini.Delete(groupName,"Open"); ini.Delete(groupName,"Top"); ini.Delete(groupName,"CursorCol"); ini.Delete(groupName,"CursorRow"); ini.Delete(groupName,"TopLine"); ini.Delete(groupName,"LeftChar"); - ini.SaveFile(mFilename.toLocal8Bit()); + ini.SaveFile(filename().toLocal8Bit()); } + layIni.SaveFile(changeFileExt(filename(), "layout").toLocal8Bit()); } void Project::saveUnitAs(int i, const QString &sFileName, bool syncEditor) @@ -496,20 +498,22 @@ void Project::saveUnitLayout(Editor *e, int index) { if (!e) return; - QSettings layIni = QSettings(changeFileExt(filename(), "layout")); - layIni.beginGroup(QString("Editor_%1").arg(index)); - layIni.setValue("CursorCol", e->caretX()); - layIni.setValue("CursorRow", e->caretY()); - layIni.setValue("TopLine", e->topLine()); - layIni.setValue("LeftChar", e->leftChar()); - layIni.endGroup(); + SimpleIni layIni; + QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8(); + layIni.SetLongValue(groupName,"CursorCol", e->caretX()); + layIni.SetLongValue(groupName,"CursorRow", e->caretY()); + layIni.SetLongValue(groupName,"TopLine", e->topLine()); + layIni.SetLongValue(groupName,"LeftChar", e->leftChar()); + layIni.SaveFile((changeFileExt(filename(), "layout")).toLocal8Bit()); } bool Project::saveUnits() { int count = 0; SimpleIni ini; - ini.LoadFile(mFilename.toLocal8Bit()); + SI_Error error = ini.LoadFile(mFilename.toLocal8Bit()); + if (error != SI_Error::SI_OK) + return false; for (int idx = 0; idx < mUnits.count(); idx++) { PProjectUnit unit = mUnits[idx]; bool rd_only = false; @@ -790,7 +794,15 @@ PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode, // Set all properties newUnit->setFileName(QDir(directory()).filePath(inFileName)); newUnit->setNew(false); - newUnit->setEditor(nullptr); + Editor * e= pMainWindow->editorList()->getOpenedEditorByFilename(newUnit->fileName()); + if (e) { + newUnit->setEditor(e); + newUnit->setEncoding(e->encodingOption()); + e->setInProject(true); + } else { + newUnit->setEditor(nullptr); + newUnit->setEncoding(ENCODING_AUTO_DETECT); + } newUnit->setFolder(getFolderPath(parentNode)); newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode)); newUnit->node()->unitIndex = mUnits.count(); @@ -1290,12 +1302,13 @@ QString Project::listUnitStr(const QChar &separator) void Project::loadLayout() { - QSettings layIni = QSettings(changeFileExt(filename(), "layout"),QSettings::IniFormat); - layIni.beginGroup("Editors"); - int topLeft = layIni.value("Focused", -1).toInt(); + SimpleIni layIni; + SI_Error error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit()); + if (error!=SI_OK) + return; + int topLeft = layIni.GetLongValue("Editors","Focused",1); //TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1); - QString temp =layIni.value("Order", "").toString(); - layIni.endGroup(); + QString temp =layIni.GetValue("Editors","Order", ""); QStringList sl = temp.split(",",Qt::SkipEmptyParts); foreach (const QString& s,sl) { @@ -1308,7 +1321,6 @@ void Project::loadLayout() if (topLeft>=0 && topLefteditor()) { mUnits[topLeft]->editor()->activate(); } - } void Project::loadOptions(SimpleIni& ini) @@ -1444,13 +1456,16 @@ void Project::loadUnitLayout(Editor *e, int index) { if (!e) return; - QSettings layIni(changeFileExt(filename(), "layout"), QSettings::IniFormat); - layIni.beginGroup(QString("Editor_%1").arg(index)); - e->setCaretY(layIni.value("CursorRow",1).toInt()); - e->setCaretX(layIni.value("CursorCol",1).toInt()); - e->setTopLine(layIni.value("TopLine",1).toInt()); - e->setLeftChar(layIni.value("LeftChar",1).toInt()); - layIni.endGroup(); + SimpleIni layIni; + SI_Error error; + error = layIni.LoadFile(changeFileExt(filename(), "layout").toLocal8Bit()); + if (error != SI_Error::SI_OK) + return; + QByteArray groupName = (QString("Editor_%1").arg(index)).toUtf8(); + e->setCaretY(layIni.GetLongValue(groupName,"CursorRow",1)); + e->setCaretX(layIni.GetLongValue(groupName,"CursorCol",1)); + e->setTopLine(layIni.GetLongValue(groupName,"TopLine",1)); + e->setLeftChar(layIni.GetLongValue(groupName,"LeftChar",1)); } PCppParser Project::cppParser() @@ -1514,7 +1529,7 @@ void Project::removeFolderRecurse(PFolderNode node) } else if (childNode->unitIndex >= 0 && childNode->level > 0) { // Remove editor in folder from project int editorIndex = childNode->unitIndex; - if (!removeEditor(editorIndex,true)) + if (!removeUnit(editorIndex,true)) return; } } @@ -1919,7 +1934,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int // Remove it from the current project... int projindex = mProject->indexInUnits(newName); if (projindex>=0) { - mProject->removeEditor(projindex,false); + mProject->removeUnit(projindex,false); } // All references to the file are removed. Delete the file from disk @@ -1954,7 +1969,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int } // Add new filename to file minitor - pMainWindow->fileSystemWatcher()->removePath(oldName); + pMainWindow->fileSystemWatcher()->addPath(newName); return true; } else { //change folder name diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index 3c37f000..e5f6f392 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -148,7 +148,7 @@ public: const QString& customFileName=""); Editor* openUnit(int index); void rebuildNodes(); - bool removeEditor(int index, bool doClose); + bool removeUnit(int index, bool doClose, bool removeFile = false); bool removeFolder(PFolderNode node); void resetParserProjectFiles(); void saveAll(); // save [Project] and all [UnitX] diff --git a/RedPandaIDE/qsynedit/KeyStrokes.cpp b/RedPandaIDE/qsynedit/KeyStrokes.cpp index a9151463..e0c991e2 100644 --- a/RedPandaIDE/qsynedit/KeyStrokes.cpp +++ b/RedPandaIDE/qsynedit/KeyStrokes.cpp @@ -108,7 +108,9 @@ PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command) PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) { for (PSynEditKeyStroke& keyStroke:mList) { - if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==0) + if (keyStroke->key() == key + && keyStroke->keyModifiers() == (modifiers & ~ Qt::KeypadModifier) + && keyStroke->key2()==0) return keyStroke; } return PSynEditKeyStroke(); @@ -118,8 +120,10 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers int key2, Qt::KeyboardModifiers modifiers2) { for (PSynEditKeyStroke& keyStroke:mList) { - if (keyStroke->key() == key && keyStroke->keyModifiers()==modifiers && keyStroke->key2()==key2 - && keyStroke->keyModifiers2() ==modifiers2) + if (keyStroke->key() == key + && keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier) + && keyStroke->key2()==key2 + && keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier)) return keyStroke; } return PSynEditKeyStroke(); @@ -202,8 +206,8 @@ void SynEditKeyStrokes::resetDefaults() add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier); add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::KeypadModifier|Qt::ShiftModifier); + add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier); + add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier); add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier); add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier); diff --git a/RedPandaIDE/qsynedit/MiscClasses.cpp b/RedPandaIDE/qsynedit/MiscClasses.cpp index 823edcd7..01e60b5c 100644 --- a/RedPandaIDE/qsynedit/MiscClasses.cpp +++ b/RedPandaIDE/qsynedit/MiscClasses.cpp @@ -95,7 +95,11 @@ QString SynGutter::formatLineNumber(int line) { line += (mLineNumberStart - 1); QString result = QString::number(line); - return QString(mAutoSizeDigitCount - result.length(),'0') + result; + if (mLeadingZeros) { + return QString(mAutoSizeDigitCount - result.length(),'0') + result; + } else { + return result; + } } int SynGutter::realGutterWidth(int charWidth) @@ -315,10 +319,9 @@ void SynGutter::setBorderColor(const QColor &value) } -SynEditMark::SynEditMark(QObject *parent) +SynEditMark::SynEditMark(QObject * /*parent*/) { mBookmarkNum = -1; - } int SynEditMark::Char() const @@ -405,7 +408,7 @@ void SynEditMark::setLine(int line) } } -SynBookMarkOpt::SynBookMarkOpt(QObject *parent) +SynBookMarkOpt::SynBookMarkOpt(QObject */*parent*/) { mDrawBookmarksFirst = true; mEnableKeys = true; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index cbaed964..fafc06e4 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) { @@ -57,6 +59,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onRedoAdded); mOrigRedoList = mRedoList; + mForegroundColor=palette().color(QPalette::Text); + mBackgroundColor=palette().color(QPalette::Base); mCaretColor = QColorConstants::Red; mCaretUseTextColor = false; mActiveLineColor = QColorConstants::Svg::lightblue; @@ -115,7 +119,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) mBlockEnd = mBlockBegin; mOptions = eoAutoIndent | eoDragDropEditing | eoEnhanceEndKey | eoTabIndent | - eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick; + eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick + | eoHideShowScrollbars ; mScrollTimer = new QTimer(this); mScrollTimer->setInterval(100); @@ -142,6 +147,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent) setAttribute(Qt::WA_InputMethodEnabled); //setMouseTracking(true); + setAcceptDrops(true); } int SynEdit::displayLineCount() const @@ -1063,6 +1069,20 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord setBlockEnd(ptAfter); } +void SynEdit::collapseAll() +{ + for (int i = mAllFoldRanges.count()-1;i>=0;i--){ + collapse(mAllFoldRanges[i]); + } +} + +void SynEdit::unCollpaseAll() +{ + for (int i = mAllFoldRanges.count()-1;i>=0;i--){ + uncollapse(mAllFoldRanges[i]); + } +} + void SynEdit::processGutterClick(QMouseEvent *event) { int X = event->pos().x(); @@ -1208,6 +1228,8 @@ void SynEdit::showCaret() { if (m_blinkTimerId==0) m_blinkTimerId = startTimer(500); + m_blinkStatus = 1; + updateCaret(); } void SynEdit::hideCaret() @@ -1429,7 +1451,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) QString s; while (startLine>=1) { s = mLines->getString(startLine-1); - if (!s.trimmed().isEmpty()) { + if (!s.startsWith('#') && !s.trimmed().isEmpty()) { break; } startLine -- ; @@ -3580,25 +3602,40 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) } else { ct =mOverwriteCaret; } + QColor caretColor; if (mCaretUseTextColor) { - painter.setPen(mForegroundColor); + caretColor = mForegroundColor; } else { - painter.setPen(mCaretColor); + caretColor = mCaretColor; } switch(ct) { - case SynEditCaretType::ctVerticalLine: - painter.drawLine(rcClip.left()+1,rcClip.top(),rcClip.left()+1,rcClip.bottom()); + case SynEditCaretType::ctVerticalLine: { + QRect caretRC; + int size = std::max(1,(rcClip.bottom()-rcClip.top())/15); + caretRC.setLeft(rcClip.left()+1); + caretRC.setTop(rcClip.top()); + caretRC.setBottom(rcClip.bottom()); + caretRC.setRight(rcClip.left()+1+size); + painter.fillRect(caretRC,caretColor); break; - case SynEditCaretType::ctHorizontalLine: - painter.drawLine(rcClip.left(),rcClip.bottom()-1,rcClip.right(),rcClip.bottom()-1); + } + case SynEditCaretType::ctHorizontalLine: { + QRect caretRC; + int size = std::max(1,(rcClip.bottom()-rcClip.top())/15); + caretRC.setLeft(rcClip.left()); + caretRC.setTop(rcClip.bottom()-1+size); + caretRC.setBottom(rcClip.bottom()-1); + caretRC.setRight(rcClip.right()); + painter.fillRect(caretRC,caretColor); break; + } case SynEditCaretType::ctBlock: - painter.fillRect(rcClip, mCaretColor); + painter.fillRect(rcClip, caretColor); break; case SynEditCaretType::ctHalfBlock: QRect rc=rcClip; rc.setTop(rcClip.top()+rcClip.height() / 2); - painter.fillRect(rcClip, mCaretColor); + painter.fillRect(rcClip, caretColor); break; } } @@ -4922,12 +4959,13 @@ void SynEdit::doLinesInserted(int firstLine, int count) // end; } -void SynEdit::properSetLine(int ALine, const QString &ALineText) +void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify) { - if (mOptions.testFlag(eoTrimTrailingSpaces)) - mLines->putString(ALine,TrimRight(ALineText)); - else - mLines->putString(ALine,ALineText); + if (mOptions.testFlag(eoTrimTrailingSpaces)) { + mLines->putString(ALine,TrimRight(ALineText),notify); + } else { + mLines->putString(ALine,ALineText,notify); + } } void SynEdit::deleteSelection(const BufferCoord &BB, const BufferCoord &BE) @@ -5021,6 +5059,10 @@ void SynEdit::insertText(const QString &Value, SynSelectionMode PasteMode,bool A int SynEdit::insertTextByNormalMode(const QString &Value) { + mLines->beginUpdate(); + auto actionLines = finally([this] { + mLines->endUpdate(); + }); QString sLeftSide; QString sRightSide; QString Str; @@ -5029,6 +5071,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value) bool bChangeScroll; // int SpaceCount; int Result = 0; + int startLine = mCaretY; sLeftSide = lineText().mid(0, mCaretX - 1); if (mCaretX - 1 > sLeftSide.length()) { if (StringIsBlank(sLeftSide)) @@ -5070,9 +5113,9 @@ int SynEdit::insertTextByNormalMode(const QString &Value) Start = P; P = GetEOL(Value,Start); if (P == Start) { - if (P= mGutterWidth + 2) && (mSelectionMode == SynSelectionMode::smNormal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { - bStartDrag = true; + bStartDrag = true; } if (bStartDrag) { mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); @@ -5959,7 +6003,15 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { - mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); + mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + + mimeData->setText(selText()); + drag->setMimeData(mimeData); + + drag->exec(Qt::CopyAction | Qt::MoveAction); + //drag->setPixmap(iconPixmap); //BeginDrag(false); } // } else if ((buttons == Qt::LeftButton) && (X > mGutterWidth)) { @@ -6017,14 +6069,26 @@ void SynEdit::leaveEvent(QEvent *) void SynEdit::wheelEvent(QWheelEvent *event) { - if (event->angleDelta().y()>0) { - verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); - event->accept(); - return; - } else if (event->angleDelta().y()<0) { - verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); - event->accept(); - return; + if (event->modifiers() == Qt::ShiftModifier) { + if (event->angleDelta().y()>0) { + horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); + event->accept(); + return; + } else if (event->angleDelta().y()<0) { + horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed); + event->accept(); + return; + } + } else { + if (event->angleDelta().y()>0) { + verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); + event->accept(); + return; + } else if (event->angleDelta().y()<0) { + verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); + event->accept(); + return; + } } QAbstractScrollArea::wheelEvent(event); } @@ -6052,6 +6116,63 @@ QVariant SynEdit::inputMethodQuery(Qt::InputMethodQuery property) const } +void SynEdit::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasFormat("text/plain")) { + event->acceptProposedAction(); + mDragCaretSave = caretXY(); + mDragSelBeginSave = blockBegin(); + mDragSelEndSave = blockEnd(); + BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(), + event->pos().y())); + setCaretXY(coord); + setBlockBegin(mDragSelBeginSave); + setBlockEnd(mDragSelEndSave); + showCaret(); + } +} + +void SynEdit::dropEvent(QDropEvent *event) +{ + mUndoList->BeginBlock(); + auto action = finally([this] { + mUndoList->EndBlock(); + }); + if (event->proposedAction() == Qt::DropAction::MoveAction) { + setBlockBegin(mDragSelBeginSave); + setBlockEnd(mDragSelEndSave); + setSelText(""); + } + BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(), + event->pos().y())); + setCaretXY(coord); + setSelText(event->mimeData()->text()); + event->acceptProposedAction(); +} + +void SynEdit::dragMoveEvent(QDragMoveEvent *event) +{ + if (event->keyboardModifiers() == Qt::ControlModifier) { + event->setDropAction(Qt::CopyAction); + } else { + event->setDropAction(Qt::MoveAction); + } + BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(), + event->pos().y())); + setCaretXY(coord); + setBlockBegin(mDragSelBeginSave); + setBlockEnd(mDragSelEndSave); + showCaret(); +} + +void SynEdit::dragLeaveEvent(QDragLeaveEvent *) +{ + setCaretXY(mDragCaretSave); + setBlockBegin(mDragSelBeginSave); + setBlockEnd(mDragSelEndSave); + showCaret(); +} + int SynEdit::maxScrollHeight() const { if (mOptions.testFlag(eoScrollPastEof)) diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index 234c6637..596bdc63 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -219,6 +219,8 @@ public: const BufferCoord& ptBefore, const BufferCoord& ptAfter); + void collapseAll(); + void unCollpaseAll(); void uncollapseAroundLine(int line); PSynEditFoldRange foldHidesLine(int line); void setSelLength(int Value); @@ -504,7 +506,7 @@ private: const QString& Value, bool AddToUndoList); void doLinesDeleted(int FirstLine, int Count); void doLinesInserted(int FirstLine, int Count); - void properSetLine(int ALine, const QString& ALineText); + void properSetLine(int ALine, const QString& ALineText, bool notify = true); void deleteSelection(const BufferCoord& BB, const BufferCoord& BE); void insertText(const QString& Value, SynSelectionMode PasteMode,bool AddToUndoList); int insertTextByNormalMode(const QString& Value); @@ -696,6 +698,10 @@ private: int mMouseWheelScrollSpeed; + BufferCoord mDragCaretSave; + BufferCoord mDragSelBeginSave; + BufferCoord mDragSelEndSave; + friend class SynEditTextPainter; // QWidget interface @@ -722,6 +728,13 @@ bool viewportEvent(QEvent * event) override; // QWidget interface public: QVariant inputMethodQuery(Qt::InputMethodQuery property) const override; + +// QWidget interface +protected: +void dragEnterEvent(QDragEnterEvent *event) override; +void dropEvent(QDropEvent *event) override; +void dragMoveEvent(QDragMoveEvent *event) override; +void dragLeaveEvent(QDragLeaveEvent *event) override; }; #endif // SYNEDIT_H diff --git a/RedPandaIDE/qsynedit/TextBuffer.cpp b/RedPandaIDE/qsynedit/TextBuffer.cpp index 50a334b6..f94ef389 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.cpp +++ b/RedPandaIDE/qsynedit/TextBuffer.cpp @@ -397,7 +397,7 @@ QString SynEditStringList::getTextStr() const return result; } -void SynEditStringList::putString(int Index, const QString &s) { +void SynEditStringList::putString(int Index, const QString &s, bool notify) { QMutexLocker locker(&mMutex); if (Index == mList.count()) { add(s); @@ -409,7 +409,8 @@ void SynEditStringList::putString(int Index, const QString &s) { mIndexOfLongestLine = -1; mList[Index]->fString = s; mList[Index]->fColumns = -1; - emit putted(Index,1); + if (notify) + emit putted(Index,1); endUpdate(); } } diff --git a/RedPandaIDE/qsynedit/TextBuffer.h b/RedPandaIDE/qsynedit/TextBuffer.h index 50b387dd..4d484c5b 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.h +++ b/RedPandaIDE/qsynedit/TextBuffer.h @@ -67,7 +67,7 @@ public: void setContents(const QStringList& text); QStringList contents(); - void putString(int Index, const QString& s); + void putString(int Index, const QString& s, bool notify=true); void putObject(int Index, void * AObject); void beginUpdate(); diff --git a/RedPandaIDE/qsynedit/Types.cpp b/RedPandaIDE/qsynedit/Types.cpp index 19d93538..e4e985eb 100644 --- a/RedPandaIDE/qsynedit/Types.cpp +++ b/RedPandaIDE/qsynedit/Types.cpp @@ -234,3 +234,8 @@ void ContentsCoord::setCh(int newChar) { mChar = newChar; } + +bool BufferCoord::operator==(const BufferCoord &coord) +{ + return coord.Char == Char && coord.Line == Line; +} diff --git a/RedPandaIDE/qsynedit/Types.h b/RedPandaIDE/qsynedit/Types.h index 09b11c88..ce7fe313 100644 --- a/RedPandaIDE/qsynedit/Types.h +++ b/RedPandaIDE/qsynedit/Types.h @@ -10,6 +10,7 @@ enum class SynSelectionMode {smNormal, smLine, smColumn}; struct BufferCoord { int Char; int Line; + bool operator==(const BufferCoord& coord); }; class SynEdit; diff --git a/RedPandaIDE/qt_zh_CN.qm b/RedPandaIDE/qt_zh_CN.qm new file mode 100644 index 00000000..77ff1441 Binary files /dev/null and b/RedPandaIDE/qt_zh_CN.qm differ diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index acc904c6..29adba9e 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -87,6 +87,7 @@ void Settings::load() mCodeCompletion.load(); mCodeFormatter.load(); mUI.load(); + mDirs.load(); } Settings::Dirs &Settings::dirs() @@ -161,12 +162,7 @@ QString Settings::Dirs::templateDir() const QString Settings::Dirs::projectDir() const { - if (isGreenEdition()) { - return includeTrailingPathDelimiter(app()) + "projects"; - } else { - return includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]) - + "projects"; - } + return mProjectDir; } QString Settings::Dirs::data(Settings::Dirs::DataType dataType) const @@ -205,12 +201,24 @@ QString Settings::Dirs::executable() const void Settings::Dirs::doSave() { - + saveValue("projectDir",mProjectDir); } void Settings::Dirs::doLoad() { + QString defaultProjectDir; + if (isGreenEdition()) { + defaultProjectDir = includeTrailingPathDelimiter(app()) + "projects"; + } else { + defaultProjectDir = includeTrailingPathDelimiter(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation)[0]) + + "projects"; + } + mProjectDir = stringValue("projectDir",defaultProjectDir); +} +void Settings::Dirs::setProjectDir(const QString &newProjectDir) +{ + mProjectDir = newProjectDir; } Settings::_Base::_Base(Settings *settings, const QString &groupName): @@ -524,6 +532,26 @@ void Settings::Editor::setUseUTF8ByDefault(bool newUseUTF8ByDefault) mUseUTF8ByDefault = newUseUTF8ByDefault; } +bool Settings::Editor::highlightMathingBraces() const +{ + return mHighlightMathingBraces; +} + +void Settings::Editor::setHighlightMathingBraces(bool newHighlightMathingBraces) +{ + mHighlightMathingBraces = newHighlightMathingBraces; +} + +bool Settings::Editor::highlightCurrentWord() const +{ + return mHighlightCurrentWord; +} + +void Settings::Editor::setHighlightCurrentWord(bool newHighlightCurrentWord) +{ + mHighlightCurrentWord = newHighlightCurrentWord; +} + bool Settings::Editor::enableTooltips() const { return mEnableTooltips; @@ -994,6 +1022,7 @@ void Settings::Editor::doSave() saveValue("show_indent_lines", mShowIndentLines); saveValue("indent_line_color",mIndentLineColor); saveValue("fill_indents",mfillIndents); + // caret saveValue("enhance_home_key",mEnhanceHomeKey); saveValue("enhance_end_key",mEnhanceEndKey); @@ -1003,6 +1032,10 @@ void Settings::Editor::doSave() saveValue("caret_use_text_color",mCaretUseTextColor); saveValue("caret_color",mCaretColor); + //highlight + saveValue("highlight_matching_braces",mHighlightMathingBraces); + saveValue("highlight_current_word",mHighlightCurrentWord); + //scroll saveValue("auto_hide_scroll_bar", mAutoHideScrollbar); saveValue("scroll_past_eof", mScrollPastEof); @@ -1112,6 +1145,10 @@ void Settings::Editor::doLoad() mCaretUseTextColor = boolValue("caret_use_text_color",true); mCaretColor = colorValue("caret_color",QColorConstants::Svg::yellow); + //highlight + mHighlightMathingBraces = boolValue("highlight_matching_braces",true); + mHighlightCurrentWord = boolValue("highlight_current_word",true); + //scroll mAutoHideScrollbar = boolValue("auto_hide_scroll_bar", false); mScrollPastEof = boolValue("scroll_past_eof", true); @@ -2393,11 +2430,19 @@ void Settings::CompilerSets::loadSets() mDefaultIndex =mSettings->mSettings.value(SETTING_COMPILTER_SETS_DEFAULT_INDEX,-1).toInt(); int listSize = mSettings->mSettings.value(SETTING_COMPILTER_SETS_COUNT,0).toInt(); mSettings->mSettings.endGroup(); + bool loadError = false; for (int i=0;imSettings.endGroup(); + if (pSet->binDirs().isEmpty()) + return PCompilerSet(); pSet->setDirectories(pSet->binDirs()[0]); pSet->setDefines(); return pSet; @@ -2835,6 +2888,9 @@ void Settings::Executor::doSave() saveValue("redirect_input",mRedirectInput); saveValue("input_filename",mInputFilename); //problem set + saveValue("enable_proble_set", mEnableProblemSet); + saveValue("enable_competivie_companion", mEnableCompetitiveCompanion); + saveValue("competitive_companion_port", mCompetivieCompanionPort); } diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index d6d6f0a4..23bfb885 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -96,10 +96,13 @@ public: QString config(DataType dataType = DataType::None) const; QString executable() const; - // _Base interface + void setProjectDir(const QString &newProjectDir); + protected: void doSave() override; void doLoad() override; + private: + QString mProjectDir; }; class Editor: public _Base { @@ -336,6 +339,12 @@ public: bool useUTF8ByDefault() const; void setUseUTF8ByDefault(bool newUseUTF8ByDefault); + bool highlightCurrentWord() const; + void setHighlightCurrentWord(bool newHighlightCurrentWord); + + bool highlightMathingBraces() const; + void setHighlightMathingBraces(bool newHighlightMathingBraces); + private: //General // indents @@ -354,6 +363,10 @@ public: bool mCaretUseTextColor; QColor mCaretColor; + //highlights + bool mHighlightCurrentWord; + bool mHighlightMathingBraces; + //scroll bool mAutoHideScrollbar; bool mScrollPastEof; diff --git a/RedPandaIDE/settingsdialog/compilerautolinkwidget.cpp b/RedPandaIDE/settingsdialog/compilerautolinkwidget.cpp index 74bf6cae..bb4dc463 100644 --- a/RedPandaIDE/settingsdialog/compilerautolinkwidget.cpp +++ b/RedPandaIDE/settingsdialog/compilerautolinkwidget.cpp @@ -110,6 +110,8 @@ bool AutolinkModel::setData(const QModelIndex &index, const QVariant &value, int if (index.column() == 0) { if (s.isEmpty()) return false; + if (link->header == s) + return false; if (findLink(s)>=0) { QMessageBox::warning(pMainWindow, tr("Header exists"), diff --git a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp index c31c91c8..acd839a3 100644 --- a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp @@ -52,6 +52,9 @@ void EditorGeneralWidget::doLoad() setCaretTypeIndex(ui->cbCaretForOverwrite,pSettings->editor().caretForOverwrite()); ui->chkCaretUseTextColor->setChecked(pSettings->editor().caretUseTextColor()); ui->colorCaret->setColor(pSettings->editor().caretColor()); + //highlight + ui->chkHighlightCurrentWord->setChecked(pSettings->editor().highlightCurrentWord()); + ui->chkHighlightMatchingBraces->setChecked(pSettings->editor().highlightMathingBraces()); //scrolls; ui->chkAutoHideScrollBars->setChecked(pSettings->editor().autoHideScrollbar()); ui->chkScrollPastEOF->setChecked(pSettings->editor().scrollPastEof()); @@ -84,6 +87,10 @@ void EditorGeneralWidget::doSave() pSettings->editor().setCaretForOverwrite(getCaretTypeIndex(ui->cbCaretForOverwrite)); pSettings->editor().setCaretUseTextColor(ui->chkCaretUseTextColor->isChecked()); pSettings->editor().setCaretColor(ui->colorCaret->color()); + //highlight + pSettings->editor().setHighlightCurrentWord(ui->chkHighlightCurrentWord->isChecked()); + pSettings->editor().setHighlightMathingBraces(ui->chkHighlightMatchingBraces->isChecked()); + //scrolls; pSettings->editor().setAutoHideScrollbar(ui->chkAutoHideScrollBars->isChecked()); pSettings->editor().setScrollPastEof(ui->chkScrollPastEOF->isChecked()); diff --git a/RedPandaIDE/settingsdialog/editorgeneralwidget.ui b/RedPandaIDE/settingsdialog/editorgeneralwidget.ui index 488070f8..760f4900 100644 --- a/RedPandaIDE/settingsdialog/editorgeneralwidget.ui +++ b/RedPandaIDE/settingsdialog/editorgeneralwidget.ui @@ -228,6 +228,29 @@ + + + + Highlight + + + + + + Highlight matching braces + + + + + + + Highlight current word + + + + + + diff --git a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp index 21c604af..67e9af55 100644 --- a/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentappearencewidget.cpp @@ -58,6 +58,7 @@ void EnvironmentAppearenceWidget::doSave() pSettings->environment().setInterfaceFontSize(ui->spinFontSize->value()); pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString()); + pSettings->editor().save(); pSettings->environment().save(); pMainWindow->applySettings(); } diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index 19fda5df..646993ef 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -99,6 +99,8 @@ PSettingsDialog SettingsDialog::optionDialog() { PSettingsDialog dialog = std::make_shared(); + dialog->setWindowTitle(tr("Options")); + SettingsWidget* widget = new EnvironmentAppearenceWidget(tr("Appearence"),tr("Environment")); widget->init(); dialog->addWidget(widget); @@ -206,6 +208,8 @@ PSettingsDialog SettingsDialog::projectOptionDialog() { PSettingsDialog dialog = std::make_shared(); + dialog->setWindowTitle(tr("Project Options")); + SettingsWidget* widget = new ProjectGeneralWidget(tr("General"),tr("Project")); widget->init(); dialog->addWidget(widget); diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index de3b4b01..df92700d 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -3,8 +3,6 @@ #include -#define DEVCPP_VERSION "beta.0.8.6" - #define APP_SETTSINGS_FILENAME "redpandacpp.ini" #ifdef Q_OS_WIN #define GCC_PROGRAM "gcc.exe" diff --git a/RedPandaIDE/translations.qrc b/RedPandaIDE/translations.qrc index e8eb9d01..6d8b6359 100644 --- a/RedPandaIDE/translations.qrc +++ b/RedPandaIDE/translations.qrc @@ -1,5 +1,6 @@ RedPandaIDE_zh_CN.qm + qt_zh_CN.qm diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 0c66cc6c..1a7551a5 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -22,6 +22,7 @@ #include "editorlist.h" #include "editor.h" #include "project.h" +#include "version.h" const QByteArray GuessTextEncoding(const QByteArray& text){ bool allAscii; diff --git a/RedPandaIDE/version.h b/RedPandaIDE/version.h new file mode 100644 index 00000000..30938498 --- /dev/null +++ b/RedPandaIDE/version.h @@ -0,0 +1,7 @@ +#ifndef VERSION_H +#define VERSION_H +#include + +#define DEVCPP_VERSION "beta.0.9.2" + +#endif // VERSION_H diff --git a/RedPandaIDE/widgets/aboutdialog.cpp b/RedPandaIDE/widgets/aboutdialog.cpp index 2f11ac5f..4999f53a 100644 --- a/RedPandaIDE/widgets/aboutdialog.cpp +++ b/RedPandaIDE/widgets/aboutdialog.cpp @@ -1,6 +1,8 @@ #include "aboutdialog.h" #include "ui_aboutdialog.h" #include "../systemconsts.h" +#include "../version.h" + AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), @@ -8,9 +10,20 @@ AboutDialog::AboutDialog(QWidget *parent) : { ui->setupUi(this); ui->lblTitle->setText(ui->lblTitle->text() + tr("Version: ") + DEVCPP_VERSION); + +#ifdef __GNUC__ ui->lblContent->setText(ui->lblContent->text() .arg(qVersion()) - .arg("GCC 10.3.0",__DATE__, __TIME__)); + .arg(QString("GCC %1.%2") + .arg(__GNUC__) + .arg(__GNUC_MINOR__) + ,__DATE__, __TIME__)); +#else + ui->lblContent->setText(ui->lblContent->text() + .arg(qVersion()) + .arg("Non-GCC Compiler" + ,__DATE__, __TIME__)); +#endif } AboutDialog::~AboutDialog() diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index 78dbc867..a37331d1 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -59,7 +59,7 @@ void CodeCompletionPopup::setKeypressedCallback(const KeyPressedCallback &newKey mListView->setKeypressedCallback(newKeypressedCallback); } -void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &filename, int line) +void CodeCompletionPopup::prepareSearch(const QString& preWord,const QString &phrase, const QString &filename, int line) { QMutexLocker locker(&mMutex); if (!isEnabled()) @@ -69,19 +69,19 @@ void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &fi QCursor oldCursor = cursor(); setCursor(Qt::CursorShape::WaitCursor); - mIncludedFiles = mParser->getFileIncludes(filename); - getCompletionFor(filename,phrase,line); + if (preWord.isEmpty()) { + mIncludedFiles = mParser->getFileIncludes(filename); + getCompletionFor(filename,phrase,line); - if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) { - mPhrase = phrase.mid(1); - getCompletionFor(filename,mPhrase,line); + if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) { + mPhrase = phrase.mid(1); + getCompletionFor(filename,mPhrase,line); + } + } else { + mPhrase = phrase; + getFullCompletionListFor(preWord); } - //todo: notify model -//CodeComplForm.lbCompletion.Font.Size := FontSize; -//CodeComplForm.lbCompletion.ItemHeight := CodeComplForm.lbCompletion.Canvas.TextHeight('F')+6; -// Round(2 * FontSize); -//CodeComplForm.Update; setCursor(oldCursor); } @@ -453,13 +453,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin if (phrase.startsWith('#')) { if (mShowKeywords) { foreach (const QString& keyword, CppDirectives) { - PStatement statement = std::make_shared(); - statement->command = keyword; - statement->kind = StatementKind::skKeyword; - statement->fullName = keyword; - statement->usageCount = 0; - statement->freqTop = 0; - mFullCompletionStatementList.append(statement); + addKeyword(keyword); +// PStatement statement = std::make_shared(); +// statement->command = keyword; +// statement->kind = StatementKind::skKeyword; +// statement->fullName = keyword; +// statement->usageCount = 0; +// statement->freqTop = 0; +// mFullCompletionStatementList.append(statement); } } return; @@ -469,13 +470,14 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin if (phrase.startsWith('@')) { if (mShowKeywords) { foreach (const QString& keyword,JavadocTags) { - PStatement statement = std::make_shared(); - statement->command = keyword; - statement->kind = StatementKind::skKeyword; - statement->fullName = keyword; - statement->usageCount = 0; - statement->freqTop = 0; - mFullCompletionStatementList.append(statement); + addKeyword(keyword); +// PStatement statement = std::make_shared(); +// statement->command = keyword; +// statement->kind = StatementKind::skKeyword; +// statement->fullName = keyword; +// statement->usageCount = 0; +// statement->freqTop = 0; +// mFullCompletionStatementList.append(statement); } } return; @@ -506,23 +508,25 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin //add keywords if (mUseCppKeyword) { foreach (const QString& keyword,CppKeywords.keys()) { - PStatement statement = std::make_shared(); - statement->command = keyword; - statement->kind = StatementKind::skKeyword; - statement->fullName = keyword; - statement->usageCount = 0; - statement->freqTop = 0; - mFullCompletionStatementList.append(statement); + addKeyword(keyword); +// PStatement statement = std::make_shared(); +// statement->command = keyword; +// statement->kind = StatementKind::skKeyword; +// statement->fullName = keyword; +// statement->usageCount = 0; +// statement->freqTop = 0; +// mFullCompletionStatementList.append(statement); } } else { foreach (const QString& keyword,CKeywords) { - PStatement statement = std::make_shared(); - statement->command = keyword; - statement->kind = StatementKind::skKeyword; - statement->fullName = keyword; - statement->usageCount = 0; - statement->freqTop = 0; - mFullCompletionStatementList.append(statement); + addKeyword(keyword); +// PStatement statement = std::make_shared(); +// statement->command = keyword; +// statement->kind = StatementKind::skKeyword; +// statement->fullName = keyword; +// statement->usageCount = 0; +// statement->freqTop = 0; +// mFullCompletionStatementList.append(statement); } } } @@ -750,6 +754,39 @@ void CodeCompletionPopup::getCompletionFor(const QString &fileName, const QStrin } } +void CodeCompletionPopup::getFullCompletionListFor(const QString &preWord) +{ + mFullCompletionStatementList.clear(); + if (preWord == "long") { + addKeyword("long"); + addKeyword("double"); + addKeyword("int"); + } else if (preWord == "short") { + addKeyword("int"); + } else if (preWord == "signed") { + addKeyword("long"); + addKeyword("short"); + addKeyword("int"); + addKeyword("char"); + } else if (preWord == "unsigned") { + addKeyword("long"); + addKeyword("short"); + addKeyword("int"); + addKeyword("char"); + } +} + +void CodeCompletionPopup::addKeyword(const QString &keyword) +{ + PStatement statement = std::make_shared(); + statement->command = keyword; + statement->kind = StatementKind::skKeyword; + statement->fullName = keyword; + statement->usageCount = 0; + statement->freqTop = 0; + mFullCompletionStatementList.append(statement); +} + bool CodeCompletionPopup::isIncluded(const QString &fileName) { return mIncludedFiles.contains(fileName); diff --git a/RedPandaIDE/widgets/codecompletionpopup.h b/RedPandaIDE/widgets/codecompletionpopup.h index 1f94db9b..17284c09 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.h +++ b/RedPandaIDE/widgets/codecompletionpopup.h @@ -31,7 +31,7 @@ public: ~CodeCompletionPopup(); void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback); - void prepareSearch(const QString& phrase, const QString& filename, int line); + void prepareSearch(const QString& preWord, const QString& phrase, const QString& filename, int line); bool search(const QString& phrase, bool autoHideOnSingleResult); PStatement selectedStatement(); @@ -74,6 +74,8 @@ private: void addStatement(PStatement statement, const QString& fileName, int line); void filterList(const QString& member); void getCompletionFor(const QString& fileName,const QString& phrase, int line); + void getFullCompletionListFor(const QString& preWord); + void addKeyword(const QString& keyword); bool isIncluded(const QString& fileName); private: CodeCompletionListView * mListView; diff --git a/RedPandaIDE/widgets/cpudialog.cpp b/RedPandaIDE/widgets/cpudialog.cpp index 7edf6159..75d8ff4d 100644 --- a/RedPandaIDE/widgets/cpudialog.cpp +++ b/RedPandaIDE/widgets/cpudialog.cpp @@ -13,12 +13,28 @@ CPUDialog::CPUDialog(QWidget *parent) : setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); ui->setupUi(this); ui->txtCode->setHighlighter(highlighterManager.getCppHighlighter()); + ui->txtCode->setReadOnly(true); + ui->txtCode->gutter().setShowLineNumbers(false); + ui->txtCode->setCaretUseTextColor(true); + + ui->txtCode->codeFolding().indentGuides = false; + ui->txtCode->codeFolding().fillIndents = false; + ui->txtCode->setGutterWidth(0); + ui->txtCode->setUseCodeFolding(false); highlighterManager.applyColorScheme(ui->txtCode->highlighter(), pSettings->editor().colorScheme()); PColorSchemeItem item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_ACTIVE_LINE); if (item) { ui->txtCode->setActiveLineColor(item->background()); } + item = pColorManager->getItem(pSettings->editor().colorScheme(),COLOR_SCHEME_TEXT); + if (item) { + ui->txtCode->setForegroundColor(item->foreground()); + ui->txtCode->setBackgroundColor(item->background()); + } else { + ui->txtCode->setForegroundColor(palette().color(QPalette::Text)); + ui->txtCode->setBackgroundColor(palette().color(QPalette::Base)); + } ui->lstRegister->setModel(pMainWindow->debugger()->registerModel()); ui->rdIntel->setChecked(pSettings->debugger().useIntelStyle()); diff --git a/RedPandaIDE/widgets/darkfusionstyle.cpp b/RedPandaIDE/widgets/darkfusionstyle.cpp index ac5560fc..ad65c51e 100644 --- a/RedPandaIDE/widgets/darkfusionstyle.cpp +++ b/RedPandaIDE/widgets/darkfusionstyle.cpp @@ -794,6 +794,11 @@ QIcon DarkFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOpt return QProxyStyle::standardIcon(standardIcon, option, widget); } +void DarkFusionStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const +{ + QProxyStyle::drawComplexControl(control,option,painter,widget); +} + void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { @@ -807,8 +812,8 @@ void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *op case CE_MenuItem: // Draws one item in a popup menu. if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - QColor highlightOutline = highlightedOutline; - QColor highlight = option->palette.highlight().color(); + //QColor highlightOutline = highlightedOutline; + //QColor highlight = option->palette.highlight().color(); if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { painter->save(); int w = 0; diff --git a/RedPandaIDE/widgets/darkfusionstyle.h b/RedPandaIDE/widgets/darkfusionstyle.h index d31c1627..2aa6694d 100644 --- a/RedPandaIDE/widgets/darkfusionstyle.h +++ b/RedPandaIDE/widgets/darkfusionstyle.h @@ -16,6 +16,11 @@ public: const QWidget *widget) const override; QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; + + // QStyle interface +public: + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, + QPainter *painter, const QWidget *widget) const override; }; #endif // DARKFUSIONSTYLE_H diff --git a/RedPandaIDE/widgets/newprojectdialog.cpp b/RedPandaIDE/widgets/newprojectdialog.cpp index fc212347..076fa4d2 100644 --- a/RedPandaIDE/widgets/newprojectdialog.cpp +++ b/RedPandaIDE/widgets/newprojectdialog.cpp @@ -20,11 +20,12 @@ NewProjectDialog::NewProjectDialog(QWidget *parent) : int i=0; QString projectName; QString location; + location = excludeTrailingPathDelimiter(pSettings->dirs().projectDir()); while (true) { i++; projectName = tr("Project%1").arg(i); - location = includeTrailingPathDelimiter(pSettings->dirs().projectDir()) + projectName; - if (!QDir(location).exists()) + QString tempLocation = includeTrailingPathDelimiter(location)+projectName; + if (!QDir(tempLocation).exists()) break; } ui->txtProjectName->setText(projectName); @@ -65,6 +66,11 @@ QString NewProjectDialog::getProjectName() return ui->txtProjectName->text(); } +bool NewProjectDialog::useAsDefaultProjectDir() +{ + return ui->chkAsDefaultLocation->isChecked(); +} + bool NewProjectDialog::isCProject() { return ui->rdCProject->isChecked(); @@ -159,12 +165,7 @@ void NewProjectDialog::updateView() void NewProjectDialog::updateProjectLocation() { - ui->txtLocation->setText( - includeTrailingPathDelimiter( - extractFilePath( - ui->txtLocation->text())) - + ui->txtProjectName->text() - ); + QString newLocation = ui->txtLocation->text(); QListWidgetItem * current = ui->lstTemplates->currentItem(); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled( @@ -210,7 +211,7 @@ void NewProjectDialog::on_btnBrowse_clicked() } QString dir = QFileDialog::getExistingDirectory( this, - "Project directory", + "Choose directory", dirPath ); if (!dir.isEmpty()) { diff --git a/RedPandaIDE/widgets/newprojectdialog.h b/RedPandaIDE/widgets/newprojectdialog.h index 1c8b20b0..95690fd0 100644 --- a/RedPandaIDE/widgets/newprojectdialog.h +++ b/RedPandaIDE/widgets/newprojectdialog.h @@ -20,6 +20,7 @@ public: PProjectTemplate getTemplate(); QString getLocation(); QString getProjectName(); + bool useAsDefaultProjectDir(); bool isCProject(); bool isCppProject(); bool makeProjectDefault(); diff --git a/RedPandaIDE/widgets/newprojectdialog.ui b/RedPandaIDE/widgets/newprojectdialog.ui index 533bad7e..414d8186 100644 --- a/RedPandaIDE/widgets/newprojectdialog.ui +++ b/RedPandaIDE/widgets/newprojectdialog.ui @@ -7,7 +7,7 @@ 0 0 670 - 528 + 546 @@ -85,6 +85,12 @@ + + + + + + @@ -92,16 +98,6 @@ - - - - Location: - - - - - - @@ -114,8 +110,19 @@ - - + + + + Create in + + + + + + + Use as the default project location + + diff --git a/tools/ConsolePauser/main.cpp b/tools/ConsolePauser/main.cpp index 96b7deac..a09d01bb 100644 --- a/tools/ConsolePauser/main.cpp +++ b/tools/ConsolePauser/main.cpp @@ -184,6 +184,8 @@ int main(int argc, char** argv) { SetStdHandle(STD_ERROR_HANDLE, hOutput); freopen("CONOUT$","w+",stdout); freopen("CONOUT$","w+",stderr); + } else { + FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); } // Save starting timestamp