diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index 5fc70872..692cc2fc 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 05d86e97..14cbe4a2 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -683,7 +683,7 @@ Are you really want to continue? Show keywords in suggestions - 提示C/C++关键字 + 提示C/C++关键字 @@ -718,7 +718,7 @@ Are you really want to continue? Completion suggestion window width: - 补全提示窗口宽度: + 补全提示窗口宽度: @@ -965,6 +965,39 @@ Are you really want to continue? 方块 + + EditorMiscWidget + + + Form + 表单 + + + + Open system header files in read only mode + 以只读方式打开系统头文件 + + + + Auto load files being open when Red Panda C++ last exited. + 自动打开上次退出时打开的文件 + + + + Default file type + 缺省文件类型 + + + + C++ files + C++语言文件 + + + + C files + C语言文件 + + EditorSymbolCompletionWidget @@ -1877,7 +1910,7 @@ Are you really want to continue? QApplication - + Error 错误 @@ -1979,27 +2012,178 @@ Are you really want to continue? 无法找到%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) + + + + 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) + + + + + Do not use standard system libraries (-nostdlib) + 不使用标准库和系统启动文件(-nostdlib) + + + + Do not create a console window (-mwindows) + 不产生控制台窗口(-mwindows) + + + + Strip executable (-s) + 剥除附加信息(-s) + + + + Link libraries statically (-static) + 链接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"时遇到了下列问题: - + 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 @@ -2504,158 +2688,124 @@ Are you really want to continue? Settings::CompilerSet - Support all ANSI standard C programs (-ansi) - 支持所有ANSI标准C程序(-ansi) + 支持所有ANSI标准C程序(-ansi) - Do not recognize asm,inline or typeof as a keyword (-fno-asm) - 不支持将asm、inline和typeof作为关键字(-fno-asm) + 不支持将asm、inline和typeof作为关键字(-fno-asm) - Imitate traditional C preprocessors (-traditional-cpp) - 模仿传统C预处理器行为(-traditional-cpp) + 模仿传统C预处理器行为(-traditional-cpp) - Optimize for the following machine (-march) - 生成特定机器的专用指令(-march) + 生成特定机器的专用指令(-march) - Optimize less, while maintaining full compatibility (-tune) - 完整兼容特定机器,较少优化(-tune) + 完整兼容特定机器,较少优化(-tune) - Enable use of specific instructions (-mx) - 启用特定指令集(-mx) + 启用特定指令集(-mx) - Optimization level (-Ox) - 优化级别(-Ox) + 优化级别(-Ox) - Compile with the following pointer size (-mx) - 使用下列指针大小编译(-mx) + 使用下列指针大小编译(-mx) - Language standard (-std) - 语言标准(-std) + 语言标准(-std) - Generate debugging information (-g3) - 生成调试信息(-g3) + 生成调试信息(-g3) - Generate profiling info for analysis (-pg) - 生成性能分析信息(-pg) + 生成性能分析信息(-pg) - Warnings - 代码警告 + 代码警告 - Inhibit all warning messages (-w) - 忽略所有警告信息(-w) + 忽略所有警告信息(-w) - Show most warnings (-Wall) - 启用常见问题警告(-Wall) + 启用常见问题警告(-Wall) - Show some more warnings (-Wextra) - 启用更多问题警告(-Wextra) + 启用更多问题警告(-Wextra) - Check ISO C/C++/C++0x conformance (-pedantic) - 检查ISO C/C++/C++0x语法一致性(-pedantic) + 检查ISO C/C++/C++0x语法一致性(-pedantic) - Only check the code for syntax errors (-fsyntax-only) - 只进行语法检查(不编译)(-fsyntax-only) + 只进行语法检查(不编译)(-fsyntax-only) - Make all warnings into errors (-Werror) - 将警告作为错误处理(-Werror) + 将警告作为错误处理(-Werror) - Abort compilation on first error (-Wfatal-errors) - 遇到第一个错误后立即中止编译(-Wfatal-errors) + 遇到第一个错误后立即中止编译(-Wfatal-errors) - Linker - 链接器 + 链接器 - - Link an Objective C program (-lobjc) - 链接Ojbective C程序(-lobjc) - - - - Do not use standard system libraries (-nostdlib) - 不使用标准库和系统启动文件(-nostdlib) - - - - Do not create a console window (-mwindows) - 不产生控制台窗口(-mwindows) - - - - Strip executable (-s) - 剥除附加信息(-s) - - - Link libraries statically (-static) - 静态链接二进制库(-static) + Link an Objective C program (-lobjc) + 链接Ojbective C程序(-lobjc) + + + Do not use standard system libraries (-nostdlib) + 不使用标准库和系统启动文件(-nostdlib) + + + Do not create a console window (-mwindows) + 不产生控制台窗口(-mwindows) + + + Strip executable (-s) + 剥除附加信息(-s) - Output - 输出 + 输出 - -fverbose-asm - + -fverbose-asm - Use pipes instead of temporary files during compilation (-pipe) - 编译时使用管道而不是临时文件(-pipe) + 编译时使用管道而不是临时文件(-pipe) - Do not assemble, compile and generate the assemble code (-S) - 只生成汇编代码(-S) + 只生成汇编代码(-S) Settings::CompilerSets - - Confirm - 确认 + 确认 @@ -2746,7 +2896,7 @@ Are you really want to continue? Symbol Completion - 符号补全 + 符号补全 diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp index 9b04dd72..32b1381f 100644 --- a/RedPandaIDE/main.cpp +++ b/RedPandaIDE/main.cpp @@ -14,7 +14,7 @@ #include "iconsmanager.h" #include "parser/parserutils.h" -Settings* createAppSettings(const QString& filepath = QString()) { +QString getSettingFilename(const QString& filepath = QString()) { QString filename; if (filepath.isEmpty()) { if (isGreenEdition()) { @@ -34,7 +34,7 @@ Settings* createAppSettings(const QString& filepath = QString()) { if (!dir.mkpath(dir.absolutePath())) { QMessageBox::critical(nullptr, QObject::tr("Error"), QString(QObject::tr("Can't create configuration folder %1")).arg(dir.absolutePath())); - return nullptr; + return ""; } } @@ -42,15 +42,28 @@ Settings* createAppSettings(const QString& filepath = QString()) { QMessageBox::critical(nullptr, QObject::tr("Error"), QString(QObject::tr("Can't write to configuration file %1")).arg(filename)); - return nullptr; + return ""; } - return new Settings(filename); + return filename; } int main(int argc, char *argv[]) { QApplication app(argc, argv); + //Translation must be loaded first + QTranslator trans; + QString settingFilename = getSettingFilename(); + if (settingFilename.isEmpty()) + return -1; + { +// 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); + } + qRegisterMetaType("PCompileIssue"); qRegisterMetaType("PCompileIssue&"); qRegisterMetaType>("QVector"); @@ -63,21 +76,9 @@ int main(int argc, char *argv[]) pSystemConsts = &systemConsts; //load settings - pSettings = createAppSettings(); - if (pSettings == nullptr) { - return -1; - } + pSettings = new Settings(settingFilename); auto settings = std::unique_ptr(pSettings); - - //Translation must be loaded after language setting is loaded - QTranslator trans; - trans.load("RedPandaIDE_"+pSettings->environment().language(),":/translations"); - app.installTranslator(&trans); - - //must do it after translation is loaded - pSettings->compilerSets().loadSets(); - //Color scheme settings must be loaded after translation pColorManager = new ColorManager(); pIconsManager = new IconsManager(); diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 304ee250..974ebb8f 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -74,7 +74,7 @@ QVariant Settings::value(const QString &key, const QVariant &defaultValue) void Settings::load() { - //mCompilerSets.loadSets(); + mCompilerSets.loadSets(); mEnvironment.load(); mEditor.load(); mExecutor.load(); @@ -1656,17 +1656,13 @@ void Settings::CompilerSet::setUserInput() mAutoAddCharsetParams = true; } -inline QString tr(const char* str) { - return QObject::tr(str); -} - void Settings::CompilerSet::setOptions() { // C options QString groupName = QObject::tr("C options"); - addOption(tr("Support all ANSI standard C programs (-ansi)"), groupName, true, true, false, 0, "-ansi"); - addOption(tr("Do not recognize asm,inline or typeof as a keyword (-fno-asm)"), groupName, true, true, false, 0, "-fno-asm"); - addOption(tr("Imitate traditional C preprocessors (-traditional-cpp)"), groupName, true, true, false, 0, "-traditional-cpp"); + addOption(QObject::tr("Support all ANSI standard C programs (-ansi)"), groupName, true, true, false, 0, "-ansi"); + addOption(QObject::tr("Do not recognize asm,inline or typeof as a keyword (-fno-asm)"), groupName, true, true, false, 0, "-fno-asm"); + addOption(QObject::tr("Imitate traditional C preprocessors (-traditional-cpp)"), groupName, true, true, false, 0, "-traditional-cpp"); // Optimization for cpu type groupName = QObject::tr("Code Generation"); @@ -1698,8 +1694,8 @@ void Settings::CompilerSet::setOptions() sl.append("K8 Rev.E=k8-sse3"); sl.append("K10=barcelona"); sl.append("Bulldozer=bdver1"); - addOption(tr("Optimize for the following machine (-march)"), groupName, true, true, false, 0, "-march=", sl); - addOption(tr("Optimize less, while maintaining full compatibility (-tune)"), groupName, true, true, false, 0, "-mtune=", sl); + addOption(QObject::tr("Optimize for the following machine (-march)"), groupName, true, true, false, 0, "-march=", sl); + addOption(QObject::tr("Optimize less, while maintaining full compatibility (-tune)"), groupName, true, true, false, 0, "-mtune=", sl); // Enable use of the specific instructions sl.clear(); @@ -1719,7 +1715,7 @@ void Settings::CompilerSet::setOptions() sl.append("FMA4=fma4"); sl.append("XOP=xop"); sl.append("AES=aes"); - addOption(tr("Enable use of specific instructions (-mx)"), groupName, true, true, false, 0, "-m", sl); + addOption(QObject::tr("Enable use of specific instructions (-mx)"), groupName, true, true, false, 0, "-m", sl); // Optimization sl.clear(); @@ -1730,14 +1726,14 @@ void Settings::CompilerSet::setOptions() sl.append("Highest (fast)=fast"); sl.append("Size (s)=s"); sl.append("Debug (g)=g"); - addOption(tr("Optimization level (-Ox)"), groupName, true, true, false, 0, "-O", sl); + addOption(QObject::tr("Optimization level (-Ox)"), groupName, true, true, false, 0, "-O", sl); // 32bit/64bit sl.clear(); sl.append(""); sl.append("32bit=m32"); sl.append("64bit=m64"); - addOption(tr("Compile with the following pointer size (-mx)"), groupName, true, true, true, 0, "-", sl); + addOption(QObject::tr("Compile with the following pointer size (-mx)"), groupName, true, true, true, 0, "-", sl); // Language Standards sl.clear(); @@ -1760,33 +1756,33 @@ void Settings::CompilerSet::setOptions() sl.append("GNU C++14=gnu++14"); sl.append("GNU C++17=gnu++17"); sl.append("GNU C++20=gnu++20"); - addOption(tr("Language standard (-std)"), groupName, true, true, false, 0, "-std=", sl); - addOption(tr("Generate debugging information (-g3)"), groupName, true, true, false, 0, "-g3"); - addOption(tr("Generate profiling info for analysis (-pg)"), groupName, true, true, true, 0, "-pg"); + addOption(QObject::tr("Language standard (-std)"), groupName, true, true, false, 0, "-std=", sl); + addOption(QObject::tr("Generate debugging information (-g3)"), groupName, true, true, false, 0, "-g3"); + addOption(QObject::tr("Generate profiling info for analysis (-pg)"), groupName, true, true, true, 0, "-pg"); // Warnings - groupName = tr("Warnings"); - addOption(tr("Inhibit all warning messages (-w)"), groupName, true, true, false, 0, "-w"); - addOption(tr("Show most warnings (-Wall)"), groupName, true, true, false, 0, "-Wall"); - addOption(tr("Show some more warnings (-Wextra)"), groupName, true, true, false, 0, "-Wextra"); - addOption(tr("Check ISO C/C++/C++0x conformance (-pedantic)"), groupName, true, true, false, 0, "-pedantic"); - addOption(tr("Only check the code for syntax errors (-fsyntax-only)"), groupName, true, true, false, 0, "-fsyntax-only"); - addOption(tr("Make all warnings into errors (-Werror)"), groupName, true, true, false, 0, "-Werror"); - addOption(tr("Abort compilation on first error (-Wfatal-errors)"), groupName, true, true, false, 0, "-Wfatal-errors"); + groupName = QObject::tr("Warnings"); + addOption(QObject::tr("Inhibit all warning messages (-w)"), groupName, true, true, false, 0, "-w"); + addOption(QObject::tr("Show most warnings (-Wall)"), groupName, true, true, false, 0, "-Wall"); + addOption(QObject::tr("Show some more warnings (-Wextra)"), groupName, true, true, false, 0, "-Wextra"); + addOption(QObject::tr("Check ISO C/C++/C++0x conformance (-pedantic)"), groupName, true, true, false, 0, "-pedantic"); + addOption(QObject::tr("Only check the code for syntax errors (-fsyntax-only)"), groupName, true, true, false, 0, "-fsyntax-only"); + addOption(QObject::tr("Make all warnings into errors (-Werror)"), groupName, true, true, false, 0, "-Werror"); + addOption(QObject::tr("Abort compilation on first error (-Wfatal-errors)"), groupName, true, true, false, 0, "-Wfatal-errors"); // Linker - groupName = tr("Linker"); - addOption(tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, 0, "-lobjc"); - addOption(tr("Do not use standard system libraries (-nostdlib)"), groupName, false, false, true, 0, "-nostdlib"); - addOption(tr("Do not create a console window (-mwindows)"), groupName,false, false, true, 0, "-mwindows"); - addOption(tr("Strip executable (-s)"), groupName, false, false, true, 0, "-s"); - addOption(tr("Link libraries statically (-static)"), groupName, false, false, true, 0, "-static"); + groupName = QObject::tr("Linker"); + addOption(QObject::tr("Link an Objective C program (-lobjc)"), groupName, false, false, true, 0, "-lobjc"); + addOption(QObject::tr("Do not use standard system libraries (-nostdlib)"), groupName, false, false, true, 0, "-nostdlib"); + addOption(QObject::tr("Do not create a console window (-mwindows)"), groupName,false, false, true, 0, "-mwindows"); + addOption(QObject::tr("Strip executable (-s)"), groupName, false, false, true, 0, "-s"); + addOption(QObject::tr("Link libraries statically (-static)"), groupName, false, false, true, 0, "-static"); // Output - groupName = tr("Output"); - addOption(tr("-fverbose-asm"), groupName, true, true, false, 0, "-fverbose-asm"); - addOption(tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, 0, "-pipe"); - addOption(tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, 0, "-S"); + groupName = QObject::tr("Output"); + addOption(QObject::tr("Put comments in generated assembly code (-fverbose-asm)"), groupName, true, true, false, 0, "-fverbose-asm"); + addOption(QObject::tr("Use pipes instead of temporary files during compilation (-pipe)"), groupName, true, true, false, 0, "-pipe"); + addOption(QObject::tr("Do not assemble, compile and generate the assemble code (-S)"), groupName, true, true, false, 0, "-S"); } QString Settings::CompilerSet::findProgramInBinDirs(const QString name) @@ -1979,7 +1975,7 @@ void Settings::CompilerSets::loadSets() if (pCurrentSet) { QString msg; if (!pCurrentSet->dirsValid(msg) || !pCurrentSet->validateExes(msg)) { - if (QMessageBox::warning(nullptr,tr("Confirm"), + if (QMessageBox::warning(nullptr,QObject::tr("Confirm"), QObject::tr("The following problems were found during validation of compiler set \"%1\":") .arg(pCurrentSet->name()) +"

" @@ -2004,7 +2000,7 @@ void Settings::CompilerSets::loadSets() return; } } else { - if (QMessageBox::warning(nullptr,tr("Confirm"), + if (QMessageBox::warning(nullptr,QObject::tr("Confirm"), QObject::tr("Compiler set not configuared.") +"

" +QObject::tr("Would you like Red Panda C++ to search for compilers in the following locations:
'%1'
'%2'? ") diff --git a/RedPandaIDE/settingsdialog/editormiscwidget.cpp b/RedPandaIDE/settingsdialog/editormiscwidget.cpp index a4b10ef3..6fd6526b 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.cpp +++ b/RedPandaIDE/settingsdialog/editormiscwidget.cpp @@ -1,5 +1,6 @@ #include "editormiscwidget.h" #include "ui_editormiscwidget.h" +#include "../settings.h" EditorMiscWidget::EditorMiscWidget(const QString& name, const QString& group, QWidget *parent) : @@ -16,41 +17,10 @@ EditorMiscWidget::~EditorMiscWidget() void EditorMiscWidget::doLoad() { - ui->grpEnabled->setChecked(pSettings->codeCompletion().enabled()); - ui->chkParseLocalFiles->setChecked(pSettings->codeCompletion().parseLocalHeaders()); - ui->chkParseSystemFiles->setChecked(pSettings->codeCompletion().parseGlobalHeaders()); - - ui->spinWidth->setValue(pSettings->codeCompletion().width()); - ui->spinHeight->setValue(pSettings->codeCompletion().height()); - - ui->chkShowSuggestionWhileTyping->setChecked(pSettings->codeCompletion().showCompletionWhileInput()); - ui->chkRecordUsage->setChecked(pSettings->codeCompletion().recordUsage()); - ui->chkSortByScope->setChecked(pSettings->codeCompletion().sortByScope()); - ui->chkShowKeywords->setChecked(pSettings->codeCompletion().showKeywords()); - ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase()); - ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc()); - ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns()); } void EditorMiscWidget::doSave() { - //font - pSettings->codeCompletion().setEnabled(ui->grpEnabled->isChecked()); - - pSettings->codeCompletion().setParseLocalHeaders(ui->chkParseLocalFiles->isChecked()); - pSettings->codeCompletion().setParseGlobalHeaders(ui->chkParseSystemFiles->isChecked()); - - pSettings->codeCompletion().setWidth(ui->spinWidth->value()); - pSettings->codeCompletion().setHeight(ui->spinHeight->value()); - - pSettings->codeCompletion().setShowCompletionWhileInput(ui->chkShowSuggestionWhileTyping->isChecked()); - pSettings->codeCompletion().setRecordUsage(ui->chkRecordUsage->isChecked()); - pSettings->codeCompletion().setSortByScope(ui->chkSortByScope->isChecked()); - pSettings->codeCompletion().setShowKeywords(ui->chkShowKeywords->isChecked()); - pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked()); - pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked()); - pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked()); - pSettings->editor().save(); }