diff --git a/NEWS.md b/NEWS.md index 5212ff5d..5ce0cd5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ Version 0.12.5 For Dev-C++ 7 Beta - fix: compile error in linux - fix: can't receive gdb async output for commands + - fix: can't reformat code + - enhancement: add option for setting astyle path + - fix: wrong file wildcard (*.*) in linux Version 0.12.4 For Dev-C++ 7 Beta - change: add copyright infos to each source file diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index ae5aaf17..4668c23e 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -322,12 +322,15 @@ win32: { unix { HEADERS += \ + settingsdialog/formatterpathwidget.h \ settingsdialog/environmentprogramswidget.h SOURCES += \ + settingsdialog/formatterpathwidget.cpp \ settingsdialog/environmentprogramswidget.cpp FORMS += \ + settingsdialog/formatterpathwidget.ui \ settingsdialog/environmentprogramswidget.ui } diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 40a9def0..2cb50614 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 b4725642..eb15d6a6 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -15,16 +15,31 @@ - <html><head/><body><p>Based on Qt %1 (%2)</p><p>Build time: %3 %4</p><p>Copyright 2020-2021 royqh1979@gmail.com</p><p>Homepage: <a href="https://sourceforge.net/projects/dev-cpp-2020/"><span style=" text-decoration: underline; color:#007af4;">https://sourceforge.net/projects/dev-cpp-2020/</span></a></p></body></html> - <html><head/><body><p>基于 Qt %1 (%2)</p><p>构建时间: %3 %4</p><p>Copyright 2020-2021 royqh1979@gmail.com</p><p>主页: <a href="https://royqh.net/devcpp/"><span style=" text-decoration: underline; color:#007af4;">https://royqh.net/devcpp/</span></a></p></body></html> + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Based on Qt %1 (%2)</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Build time: %3 %4</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (C) 2021-2022 royqh1979@gmail.com</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Old Delphi Version:</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (c) 2004 Bloodshed Software</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (c) 2011-2015 orwell devcpp </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Copyright (c) 2020-2021 royqh1979@gmail.com</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Homepage: <a href="https://sourceforge.net/projects/dev-cpp-2020/"><span style=" text-decoration: underline; color:#007af4;">https://sourceforge.net/projects/dev-cpp-2020/</span></a></p></body></html> + - + <html><head/><body><p>Based on Qt %1 (%2)</p><p>Build time: %3 %4</p><p>Copyright 2020-2021 royqh1979@gmail.com</p><p>Homepage: <a href="https://sourceforge.net/projects/dev-cpp-2020/"><span style=" text-decoration: underline; color:#007af4;">https://sourceforge.net/projects/dev-cpp-2020/</span></a></p></body></html> + <html><head/><body><p>基于 Qt %1 (%2)</p><p>构建时间: %3 %4</p><p>Copyright 2020-2021 royqh1979@gmail.com</p><p>主页: <a href="https://royqh.net/devcpp/"><span style=" text-decoration: underline; color:#007af4;">https://royqh.net/devcpp/</span></a></p></body></html> + + + GNU General Public License GNU通用公共许可 - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -93,17 +108,17 @@ BacktraceModel - + Function 函数 - + Filename 文件名 - + Line @@ -149,37 +164,37 @@ BreakpointModel - + Filename 文件名 - + Line - + Condition 条件 - + Save file '%1' failed. 保存文件'%1'失败。 - + Can't open file '%1' for write. 无法写入文件'%1'. - + Error in json file '%1':%2 : %3 JSON文件'%1':%2中存在错误:%3 - + Can't open file '%1' for read. 无法读取文件'%1'. @@ -1082,7 +1097,7 @@ Are you really want to continue? 无法在"%1"找到gdb server - + Execute to evaluate 执行以求值 @@ -1091,22 +1106,22 @@ Are you really want to continue? 不在当前语境中 - + Compile 编译 - + Source file is more recent than executable. 源文件比程序文件新。 - + Recompile? 重新编译? - + Signal "%1" Received: 收到信号"%1": @@ -1184,17 +1199,27 @@ Are you really want to continue? 未找到符号'%1'! - + + astyle not found + 找不到astyle程序 + + + + Can't find astyle in "%1". + 找不到astyle程序"%1". + + + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -2001,14 +2026,18 @@ Are you really want to continue? 终端 - + Choose Terminal Program 选择终端程序 - + + All files (%1) + 所有文件 (%1) + + All files (*.*) - 所有文件 (*.*) + 所有文件 (*.*) @@ -2103,14 +2132,18 @@ Are you really want to continue? 注意:由于gdb的bug,调试时不支持该功能 - + Choose input file 选择输入文件 - + + All files (%1) + 所有文件 (%1) + + All files (*.*) - 所有文件 (*.*) + 所有文件 (*.*) @@ -2693,6 +2726,30 @@ Are you really want to continue? 字符 + + FormatterPathWidget + + + Form + 表单 + + + + + Path to astyle + astyle程序 + + + + ... + ... + + + + All files (%1) + 所有文件 (%1) + + FormatterStyleModel @@ -5225,14 +5282,18 @@ Are you really want to continue? DLL文件的宿主程序: - + Choose host application 选择宿主程序 - + + All files (%1) + 所有文件 (%1) + + All files (*.*) - 所有文件 (*.*) + 所有文件 (*.*) @@ -5462,14 +5523,18 @@ Are you really want to continue? 在Makefile中包含下列文件: - + Custom makefile 自定义Makefile - + + All files (%1) + 所有文件 (%1) + + All files (*.*) - 所有文件 (*.*) + 所有文件 (*.*) @@ -5506,7 +5571,7 @@ Are you really want to continue? - + Executable output directory 可执行文件输出文件夹 @@ -5533,19 +5598,23 @@ Are you really want to continue? 自定义可执行文件名 - + Object files output directory 目标文件输出文件夹 - + Log file 日志文件 - + + All files (%1) + 所有文件 (%1) + + All files (*.*) - 所有文件 (*.*) + 所有文件 (*.*) @@ -6394,12 +6463,12 @@ Are you really want to continue? RegisterModel - + Register 寄存器 - + Value @@ -6730,7 +6799,7 @@ Are you really want to continue? SettingsDialog - + Options 选项 @@ -6756,233 +6825,239 @@ Are you really want to continue? 取消 - + Appearence 外观 - - - - - - + + + + + + Environment 环境 - + File Association 文件关联 - + Shortcuts 快捷键 - + Folders 文件夹 - + Terminal 终端程序 - + 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 代码排版 - + + Program + 程序 + + + Tools 工具 - + Project Options 项目选项 - - - - - - - - - - + + + + + + + + + + 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? 本页中有尚未保存的设置修改,是否保存后再切换到其他页? @@ -7309,49 +7384,49 @@ Are you really want to continue? WatchModel - + Save file '%1' failed. 保存文件'%1'失败。 - + Can't open file '%1' for write. 无法写入文件'%1'. - + Error in json file '%1':%2 : %3 JSON文件'%1':%2中存在错误:%3 - - + + Execute to evaluate 执行以求值 - - + + Not Valid 在当前作用域中无效 - + Can't open file '%1' for read. 无法读取文件'%1'. - + Expression 表达式 - + Type 类型 - + Value diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 69da7cb3..b65e6d6e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -3864,14 +3864,29 @@ void Editor::reformat() { if (readOnly()) return; +#ifndef Q_OS_WIN + if (!fileExists(pSettings->environment().AStylePath())) { + QMessageBox::critical(this, + tr("astyle not found"), + tr("Can't find astyle in \"%1\".").arg(pSettings->environment().AStylePath())); + return; + } +#endif //we must remove all breakpoints and syntax issues onLinesDeleted(1,lines()->count()); QByteArray content = text().toUtf8(); QStringList args = pSettings->codeFormatter().getArguments(); +#ifdef Q_OS_WIN QByteArray newContent = runAndGetOutput("astyle.exe", pSettings->dirs().appDir(), args, content); +#else + QByteArray newContent = runAndGetOutput(pSettings->environment().AStylePath(), + extractFileDir(pSettings->environment().AStylePath()), + args, + content); +#endif int oldTopLine = topLine(); BufferCoord mOldCaret = caretXY(); diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 27abeb49..17475a71 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -2833,6 +2833,7 @@ void Settings::Environment::doLoad() #ifdef Q_OS_LINUX mTerminalPath = stringValue("terminal_path","/usr/bin/x-terminal-emulator"); + mAStylePath = stringValue("asyle_path","/usr/bin/astyle"); #endif } @@ -2896,6 +2897,16 @@ void Settings::Environment::setTerminalPath(const QString &terminalPath) mTerminalPath = terminalPath; } +QString Settings::Environment::AStylePath() const +{ + return mAStylePath; +} + +void Settings::Environment::setAStylePath(const QString &aStylePath) +{ + mAStylePath = aStylePath; +} + void Settings::Environment::doSave() { //Appearence @@ -2909,6 +2920,7 @@ void Settings::Environment::doSave() saveValue("default_open_folder",mDefaultOpenFolder); #ifndef Q_OS_WIN saveValue("terminal_path",mTerminalPath); + saveValue("asyle_path",mAStylePath); #endif } diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 1fb5ed6f..c0a2931f 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -507,6 +507,9 @@ public: QString terminalPath() const; void setTerminalPath(const QString &terminalPath); + QString AStylePath() const; + void setAStylePath(const QString &aStylePath); + private: //Appearence @@ -519,6 +522,7 @@ public: QString mDefaultOpenFolder; QString mTerminalPath; + QString mAStylePath; // _Base interface protected: void doSave() override; diff --git a/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp b/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp index 9af46eaf..a336a240 100644 --- a/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentprogramswidget.cpp @@ -18,6 +18,7 @@ #include "ui_environmentprogramswidget.h" #include "../settings.h" #include "../iconsmanager.h" +#include "../systemconsts.h" #include @@ -55,7 +56,7 @@ void EnvironmentProgramsWidget::on_btnChooseTerminal_clicked() this, tr("Choose Terminal Program"), QString(), - tr("All files (*.*)")); + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); if (!filename.isEmpty() && fileExists(filename) ) { ui->txtTerminal->setText(filename); } diff --git a/RedPandaIDE/settingsdialog/environmentprogramswidget.h b/RedPandaIDE/settingsdialog/environmentprogramswidget.h index 2ed00e7b..50337757 100644 --- a/RedPandaIDE/settingsdialog/environmentprogramswidget.h +++ b/RedPandaIDE/settingsdialog/environmentprogramswidget.h @@ -36,9 +36,9 @@ private: // SettingsWidget interface protected: - void doLoad(); - void doSave(); - void updateIcons(const QSize &size); + void doLoad() override; + void doSave() override; + void updateIcons(const QSize &size) override; private slots: void on_btnChooseTerminal_clicked(); }; diff --git a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp index 5f9f68e4..07ee93b9 100644 --- a/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/executorgeneralwidget.cpp @@ -18,6 +18,7 @@ #include "ui_executorgeneralwidget.h" #include "../settings.h" #include "../iconsmanager.h" +#include "../systemconsts.h" #include @@ -61,7 +62,7 @@ void ExecutorGeneralWidget::on_btnBrowse_clicked() this, tr("Choose input file"), QString(), - tr("All files (*.*)")); + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); if (!filename.isEmpty() && fileExists(filename)) { ui->txtRedirectInputFile->setText(filename); } diff --git a/RedPandaIDE/settingsdialog/formatterpathwidget.cpp b/RedPandaIDE/settingsdialog/formatterpathwidget.cpp new file mode 100644 index 00000000..a8997440 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatterpathwidget.cpp @@ -0,0 +1,46 @@ +#include "formatterpathwidget.h" +#include "ui_formatterpathwidget.h" +#include "../iconsmanager.h" +#include "../settings.h" +#include "../systemconsts.h" + +#include + +FormatterPathWidget::FormatterPathWidget(const QString &name, const QString &group, QWidget *parent) : + SettingsWidget(name,group,parent), + ui(new Ui::FormatterPathWidget) +{ + ui->setupUi(this); +} + +FormatterPathWidget::~FormatterPathWidget() +{ + delete ui; +} + +void FormatterPathWidget::doLoad() +{ + ui->txtAstyle->setText(pSettings->environment().AStylePath()); +} + +void FormatterPathWidget::doSave() +{ + pSettings->environment().setAStylePath(ui->txtAstyle->text()); +} + +void FormatterPathWidget::updateIcons(const QSize &size) +{ + pIconsManager->setIcon(ui->btnChooseAstyle, IconsManager::ACTION_FILE_OPEN_FOLDER); +} + +void FormatterPathWidget::on_btnChooseAstyle_triggered(QAction *arg1) +{ + QString fileName = QFileDialog::getOpenFileName( + this, + tr("Path to astyle"), + QString(), + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); + if (!fileName.isEmpty() ) { + ui->txtAstyle->setText(fileName); + } +} diff --git a/RedPandaIDE/settingsdialog/formatterpathwidget.h b/RedPandaIDE/settingsdialog/formatterpathwidget.h new file mode 100644 index 00000000..93c54f4d --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatterpathwidget.h @@ -0,0 +1,31 @@ +#ifndef FORMATTERPATHWIDGET_H +#define FORMATTERPATHWIDGET_H + +#include "settingswidget.h" +#include + +namespace Ui { +class FormatterPathWidget; +} + +class FormatterPathWidget : public SettingsWidget +{ + Q_OBJECT + +public: + explicit FormatterPathWidget(const QString& name, const QString& group, QWidget *parent = nullptr); + ~FormatterPathWidget(); + +private: + Ui::FormatterPathWidget *ui; + + // SettingsWidget interface +protected: + void doLoad() override; + void doSave() override; + void updateIcons(const QSize &size) override; +private slots: + void on_btnChooseAstyle_triggered(QAction *arg1); +}; + +#endif // FORMATTERPATHWIDGET_H diff --git a/RedPandaIDE/settingsdialog/formatterpathwidget.ui b/RedPandaIDE/settingsdialog/formatterpathwidget.ui new file mode 100644 index 00000000..e02e4751 --- /dev/null +++ b/RedPandaIDE/settingsdialog/formatterpathwidget.ui @@ -0,0 +1,57 @@ + + + FormatterPathWidget + + + + 0 + 0 + 834 + 520 + + + + Form + + + + + + Path to astyle + + + + + + + ... + + + + :/icons/images/newlook/actions/01File-09Open_Folder.svg:/icons/images/newlook/actions/01File-09Open_Folder.svg + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp b/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp index 0032cf76..39aec518 100644 --- a/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectdllhostwidget.cpp @@ -19,6 +19,7 @@ #include "../project.h" #include "../mainwindow.h" #include "../iconsmanager.h" +#include "../systemconsts.h" #include @@ -50,7 +51,7 @@ void ProjectDLLHostWidget::on_btnBrowse_clicked() this, tr("Choose host application"), pMainWindow->project()->directory(), - tr("All files (*.*)")); + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); if (!filename.isEmpty() && fileExists(filename)) { ui->txtHost->setText(filename); } diff --git a/RedPandaIDE/settingsdialog/projectmakefilewidget.cpp b/RedPandaIDE/settingsdialog/projectmakefilewidget.cpp index d4413f9f..be7866a4 100644 --- a/RedPandaIDE/settingsdialog/projectmakefilewidget.cpp +++ b/RedPandaIDE/settingsdialog/projectmakefilewidget.cpp @@ -21,6 +21,7 @@ #include "../project.h" #include "../widgets/custommakefileinfodialog.h" #include "../iconsmanager.h" +#include "../systemconsts.h" #include @@ -61,7 +62,7 @@ void ProjectMakefileWidget::on_btnBrowse_clicked() this, tr("Custom makefile"), pMainWindow->project()->directory(), - tr("All files (*.*)")); + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); if (!fileName.isEmpty() && QFileInfo(fileName).exists()) { ui->txtCustomMakefile->setText(fileName); } diff --git a/RedPandaIDE/settingsdialog/projectoutputwidget.cpp b/RedPandaIDE/settingsdialog/projectoutputwidget.cpp index c8d1da6b..36c0fc08 100644 --- a/RedPandaIDE/settingsdialog/projectoutputwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectoutputwidget.cpp @@ -19,6 +19,7 @@ #include "../mainwindow.h" #include "../project.h" #include "../iconsmanager.h" +#include "../systemconsts.h" #include @@ -84,7 +85,7 @@ void ProjectOutputWidget::on_btnCompileLog_triggered(QAction *) this, tr("Log file"), pMainWindow->project()->directory(), - tr("All files (*.*)")); + tr("All files (%1)").arg(ALL_FILE_WILDCARD)); if (!fileName.isEmpty() ) { ui->txtCompileLog->setText(fileName); } diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index b0384c77..b90941f2 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -54,6 +54,7 @@ #endif #ifdef Q_OS_LINUX #include "environmentprogramswidget.h" +#include "formatterpathwidget.h" #endif #include #include @@ -232,6 +233,12 @@ PSettingsDialog SettingsDialog::optionDialog() widget->init(); dialog->addWidget(widget); +#ifdef Q_OS_LINUX + widget = new FormatterPathWidget(tr("Program"),tr("Code Formatter")); + widget->init(); + dialog->addWidget(widget); +#endif + widget = new ToolsGeneralWidget(tr("General"),tr("Tools")); widget->init(); dialog->addWidget(widget); diff --git a/RedPandaIDE/systemconsts.h b/RedPandaIDE/systemconsts.h index 36e4e5d4..756761c9 100644 --- a/RedPandaIDE/systemconsts.h +++ b/RedPandaIDE/systemconsts.h @@ -81,6 +81,7 @@ # define STATIC_LIB_EXT "a" # define DYNAMIC_LIB_EXT "dll" # define MAKEFILE_NAME "makefile.win" +# define ALL_FILE_WILDCARD "*.*" #elif defined(Q_OS_LINUX) # define PATH_SENSITIVITY Qt::CaseSensitive # define PATH_SEPARATOR ":" @@ -90,6 +91,7 @@ # define STATIC_LIB_EXT "a" # define DYNAMIC_LIB_EXT "d" # define MAKEFILE_NAME "makefile" +# define ALL_FILE_WILDCARD "*" #else #error "Only support windows and linux now!" #endif diff --git a/RedPandaIDE/version.h b/RedPandaIDE/version.h index 43e54985..7a5a8d52 100644 --- a/RedPandaIDE/version.h +++ b/RedPandaIDE/version.h @@ -19,6 +19,6 @@ #include -#define DEVCPP_VERSION "beta.0.12.4" +#define DEVCPP_VERSION "beta.0.12.5" #endif // VERSION_H