- fix: Can't set project icon to "app.ico" in the project folder, if the project doesn't has icon.

- fix: Resource compilation items is missing in the auto generated makefile, if the project's icon is removed and re-added.
This commit is contained in:
Roy Qu 2022-12-30 19:48:12 +08:00
parent babecbd3bc
commit 2041f813de
5 changed files with 29 additions and 31 deletions

View File

@ -4,6 +4,9 @@ Red Panda C++ Version 2.8
- enhancement: Add "Resources" in project option's dialog's custom compiler parameter page
- fix: Crash while input using input method in makefile
- enhancement: "Run" / "Generate Assembly" for project source files
- fix: Can't set project icon to "app.ico" in the project folder, if the project doesn't has icon.
- fix: Resource compilation items is missing in the auto generated makefile, if the project's icon is removed and re-added.
Red Panda C++ Version 2.7

View File

@ -462,7 +462,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
ResIncludes = ResIncludes + " --include-dir " + genMakePath1(filename);
}
QString ResFiles;
QString resFiles;
// Concatenate all resource filenames (not created when syntax checking)
if (!mOnlyCheckSyntax) {
foreach(const PProjectUnit& unit, mProject->unitList()) {
@ -470,36 +470,37 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
continue;
if (fileExists(unit->fileName())) {
QString ResFile = extractRelativePath(mProject->makeFileName(), unit->fileName());
ResFiles = ResFiles + genMakePath2(ResFile) + ' ';
resFiles = resFiles + genMakePath2(ResFile) + ' ';
}
}
ResFiles = ResFiles.trimmed();
resFiles = resFiles.trimmed();
}
// Determine resource output file
QString ObjFileName;
QString objFileName;
if (!mProject->options().objectOutput.isEmpty()) {
ObjFileName = includeTrailingPathDelimiter(mProject->options().objectOutput) +
objFileName = includeTrailingPathDelimiter(mProject->options().objectOutput) +
changeFileExt(mProject->options().privateResource, RES_EXT);
} else {
ObjFileName = changeFileExt(mProject->options().privateResource, RES_EXT);
objFileName = changeFileExt(mProject->options().privateResource, RES_EXT);
}
ObjFileName = genMakePath1(extractRelativePath(mProject->filename(), ObjFileName));
QString PrivResName = genMakePath1(extractRelativePath(mProject->filename(), mProject->options().privateResource));
objFileName = genMakePath1(extractRelativePath(mProject->filename(), objFileName));
QString privResName = genMakePath1(extractRelativePath(mProject->filename(), mProject->options().privateResource));
// Build final cmd
QString WindresArgs;
if (getCCompileArguments(mOnlyCheckSyntax).contains("-m32"))
WindresArgs = " -F pe-i386";
QString windresArgs;
if (mProject->getCompileOption(CC_CMD_OPT_POINTER_SIZE)=="32")
windresArgs = " -F pe-i386";
if (mOnlyCheckSyntax) {
writeln(file);
writeln(file, ObjFileName + ':');
writeln(file, "\t$(WINDRES) -i " + PrivResName + WindresArgs + " --input-format=rc -o nul -O coff $(WINDRESFLAGS)" + ResIncludes);
writeln(file, objFileName + ':');
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 $(WINDRESFLAGS)"
writeln(file, objFileName + ": " + privResName + ' ' + resFiles);
writeln(file, "\t$(WINDRES) -i " + privResName + windresArgs + " --input-format=rc -o " + objFileName + " -O coff $(WINDRESFLAGS)"
+ ResIncludes);
}
writeln(file);

View File

@ -1260,7 +1260,7 @@ QString Project::folder()
return extractFileDir(filename());
}
void Project::buildPrivateResource(bool forceSave)
void Project::buildPrivateResource()
{
int comp = 0;
foreach (const PProjectUnit& unit,mUnits) {
@ -1309,14 +1309,6 @@ void Project::buildPrivateResource(bool forceSave)
rcFile = extractRelativePath(mFilename, rcFile);
rcFile.replace(' ','_');
// don't run the private resource file and header if not modified,
// unless ForceSave is true
if (!forceSave
&& fileExists(rcFile)
&& fileExists(changeFileExt(rcFile, H_EXT))
&& !mModified)
return;
QStringList contents;
contents.append("/* THIS FILE WILL BE OVERWRITTEN BY Red Panda C++ */");
contents.append("/* DO NOT EDIT! */");

View File

@ -221,7 +221,7 @@ public:
PProjectUnit addUnit(const QString& inFileName,
PProjectModelNode parentNode);
QString folder();
void buildPrivateResource(bool forceSave=false);
void buildPrivateResource();
void closeUnit(PProjectUnit& unit);
PProjectUnit doAutoOpen();
bool fileAlreadyExists(const QString& s);

View File

@ -104,6 +104,7 @@ void ProjectGeneralWidget::doSave()
project->options().isCpp = ui->cbDefaultCpp->isChecked();
project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked();
qDebug()<<mIconPath;
if (mIconPath.isEmpty()
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|| ui->lbIcon->pixmap(Qt::ReturnByValue).isNull()) {
@ -114,13 +115,14 @@ void ProjectGeneralWidget::doSave()
} else {
QString iconPath = generateAbsolutePath(project->directory(),"app.ico");
if (iconPath!=mIconPath) {
if (QFile(iconPath).exists()) {
if (fileExists(iconPath)) {
if (!QFile::remove(iconPath)) {
QMessageBox::critical(this,
tr("Can't remove old icon file"),
tr("Can't remove old icon file '%1'")
.arg(iconPath),
QMessageBox::Ok);
return;
}
}
if (!mIconPath.endsWith(".ico",PATH_SENSITIVITY) && QImageWriter::supportedImageFormats().contains("ico")) {
@ -131,11 +133,11 @@ void ProjectGeneralWidget::doSave()
#endif
} else
copyFile(mIconPath, iconPath,true);
}
project->options().icon = iconPath;
mIconPath = iconPath;
refreshIcon();
}
}
project->saveOptions();
}
@ -144,7 +146,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select icon file"),
pSettings->dirs().appDir(),
pMainWindow->project()->directory(),
tr("Image Files (*.ico *.png *.jpg)"));
if (!fileName.isEmpty()) {
mIconPath = fileName;