- enhancement: Add "Resources" in project option's dialog's custom compiler parameter page

This commit is contained in:
Roy Qu 2022-12-26 22:55:00 +08:00
parent bd4478476d
commit 988afaac7a
10 changed files with 236 additions and 173 deletions

View File

@ -1,6 +1,7 @@
Red Panda C++ Version 2.8
- fix: Crash when editing makefile
- enhancement: Add "Resources" in project option's dialog's custom compiler parameter page
Red Panda C++ Version 2.7

View File

@ -266,6 +266,9 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
writeln(file,"PCH_H = " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->options().precompiledHeader )));
writeln(file,"PCH = " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->options().precompiledHeader+"."+GCH_EXT)));
}
#ifdef Q_OS_WIN
writeln(file,"WINDRESFLAGS = " + mProject->options().resourceCmd);
#endif
// This needs to be put in before the clean command.
@ -492,11 +495,11 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
if (mOnlyCheckSyntax) {
writeln(file);
writeln(file, ObjFileName + ':');
writeln(file, "\t$(WINDRES) -i " + PrivResName + WindresArgs + " --input-format=rc -o nul -O coff" + ResIncludes);
writeln(file, "\t$(WINDRES) -i " + PrivResName + WindresArgs + " --input-format=rc -o nul -O coff $(WINDRESFLAGS)" + ResIncludes);
} else {
writeln(file);
writeln(file, ObjFileName + ": " + PrivResName + ' ' + ResFiles);
writeln(file, "\t$(WINDRES) -i " + PrivResName + WindresArgs + " --input-format=rc -o " + ObjFileName + " -O coff"
writeln(file, "\t$(WINDRES) -i " + PrivResName + WindresArgs + " --input-format=rc -o " + ObjFileName + " -O coff $(WINDRESFLAGS)"
+ ResIncludes);
}
writeln(file);

View File

@ -1007,6 +1007,8 @@ bool Project::saveAsTemplate(const QString &templateFolder,
ini->SetValue("Project", "CppCompiler", mOptions.cppCompilerCmd.toUtf8());
if (!mOptions.linkerCmd.isEmpty())
ini->SetValue("Project", "Linker",mOptions.linkerCmd.toUtf8());
if (!mOptions.resourceCmd.isEmpty())
ini->SetValue("Project", "ResourceCommand",mOptions.resourceCmd.toUtf8());
ini->SetBoolValue("Project", "IsCpp", mOptions.isCpp);
if (mOptions.includeVersionInfo)
ini->SetBoolValue("Project", "IncludeVersionInfo", true);
@ -1091,6 +1093,7 @@ void Project::saveOptions()
ini.SetValue("Project","Compiler", toByteArray(mOptions.compilerCmd));
ini.SetValue("Project","CppCompiler", toByteArray(mOptions.cppCompilerCmd));
ini.SetValue("Project","Linker", toByteArray(mOptions.linkerCmd));
ini.SetValue("Project", "ResourceCommand", toByteArray(mOptions.resourceCmd));
ini.SetLongValue("Project","IsCpp", mOptions.isCpp);
ini.SetValue("Project","Icon", toByteArray(extractRelativePath(directory(), mOptions.icon)));
ini.SetValue("Project","ExeOutput", toByteArray(extractRelativePath(directory(),mOptions.exeOutput)));
@ -1896,6 +1899,7 @@ void Project::loadOptions(SimpleIni& ini)
mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "Compiler", ""));
mOptions.cppCompilerCmd = fromByteArray(ini.GetValue("Project", "CppCompiler", ""));
mOptions.linkerCmd = fromByteArray(ini.GetValue("Project", "Linker", ""));
mOptions.resourceCmd = fromByteArray(ini.GetValue("Project", "ResourceCommand", ""));
mOptions.binDirs = absolutePaths(fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts

View File

@ -66,6 +66,7 @@ struct ProjectOptions{
QString compilerCmd;
QString cppCompilerCmd;
QString linkerCmd;
QString resourceCmd;
QStringList binDirs;
QStringList includeDirs;
QStringList libDirs;

View File

@ -137,6 +137,7 @@ void ProjectTemplate::readTemplateFile(const QString &fileName)
mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", ""));
mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", ""));
mOptions.linkerCmd = fromByteArray(mIni->GetValue("Project", "Linker",""));
mOptions.resourceCmd = fromByteArray(mIni->GetValue("Project", "ResourceCommand", ""));
mOptions.isCpp = mIni->GetBoolValue("Project", "IsCpp", false);
mOptions.includeVersionInfo = mIni->GetBoolValue("Project", "IncludeVersionInfo", false);
mOptions.supportXPThemes = mIni->GetBoolValue("Project", "SupportXPThemes", false);

View File

@ -35,7 +35,10 @@ ProjectCompileParamatersWidget::ProjectCompileParamatersWidget(const QString &na
SYSTEM_INFO info;
GetSystemInfo(&info);
ui->spinParallelJobs->setMaximum(info.dwNumberOfProcessors);
#else
ui->tabResource->setVisible(false);
#endif
ui->tabCommands->setCurrentWidget(ui->tabCCompiler);
}
ProjectCompileParamatersWidget::~ProjectCompileParamatersWidget()
@ -48,6 +51,7 @@ void ProjectCompileParamatersWidget::doLoad()
ui->txtCCompiler->setPlainText(pMainWindow->project()->options().compilerCmd);
ui->txtCPPCompiler->setPlainText(pMainWindow->project()->options().cppCompilerCmd);
ui->txtLinker->setPlainText(pMainWindow->project()->options().linkerCmd);
ui->txtResource->setPlainText(pMainWindow->project()->options().resourceCmd);
ui->grpAllowParallelBuilding->setChecked(pMainWindow->project()->options().allowParallelBuilding);
ui->spinParallelJobs->setValue(pMainWindow->project()->options().parellelBuildingJobs);
}
@ -57,6 +61,7 @@ void ProjectCompileParamatersWidget::doSave()
pMainWindow->project()->options().compilerCmd = ui->txtCCompiler->toPlainText();
pMainWindow->project()->options().cppCompilerCmd = ui->txtCPPCompiler->toPlainText();
pMainWindow->project()->options().linkerCmd = ui->txtLinker->toPlainText();
pMainWindow->project()->options().resourceCmd = ui->txtResource->toPlainText();
pMainWindow->project()->options().allowParallelBuilding = ui->grpAllowParallelBuilding->isChecked();
pMainWindow->project()->options().parellelBuildingJobs = ui->spinParallelJobs->value();
pMainWindow->project()->saveOptions();

View File

@ -54,7 +54,7 @@
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<widget class="QWidget" name="tabCCompiler">
<attribute name="title">
<string>C Compiler</string>
</attribute>
@ -76,7 +76,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<widget class="QWidget" name="tabCppCompiler">
<attribute name="title">
<string>C++ Compiler</string>
</attribute>
@ -98,7 +98,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<widget class="QWidget" name="tabLinker">
<attribute name="title">
<string>Linker</string>
</attribute>
@ -159,6 +159,28 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabResource">
<attribute name="title">
<string>Resource</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPlainTextEdit" name="txtResource"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -2072,6 +2072,10 @@
<source>Please check the &quot;program&quot; page of compiler settings.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Checking single file...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilePropertiesDialog</name>
@ -5365,6 +5369,10 @@
<source>Parallel Jobs(0 means infinite):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resource</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectCompiler</name>

File diff suppressed because it is too large Load Diff

View File

@ -1941,6 +1941,10 @@
<source>Please check the &quot;program&quot; page of compiler settings.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Checking single file...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FilePropertiesDialog</name>
@ -5146,6 +5150,10 @@
<source>Parallel Jobs(0 means infinite):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Resource</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProjectCompiler</name>