From 2041f813de2e4928df29b4e62cdda3f6e5fae63c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 30 Dec 2022 19:48:12 +0800 Subject: [PATCH] - 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. --- NEWS.md | 3 ++ RedPandaIDE/compiler/projectcompiler.cpp | 31 ++++++++++--------- RedPandaIDE/project.cpp | 10 +----- RedPandaIDE/project.h | 2 +- .../settingsdialog/projectgeneralwidget.cpp | 14 +++++---- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/NEWS.md b/NEWS.md index fb06224d..e5e622a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 382c1627..6da7b87f 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -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); diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 7dc7c72d..c3863b7a 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -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! */"); diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index e6cef1e3..44800c6d 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -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); diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index 4d0f69aa..911bb020 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -104,6 +104,7 @@ void ProjectGeneralWidget::doSave() project->options().isCpp = ui->cbDefaultCpp->isChecked(); project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked(); + qDebug()<= QT_VERSION_CHECK(5,15,0) || ui->lbIcon->pixmap(Qt::ReturnByValue).isNull()) { @@ -112,15 +113,16 @@ void ProjectGeneralWidget::doSave() #endif project->options().icon = ""; } else { - QString iconPath = generateAbsolutePath(project->directory(),"app.ico"); + 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,10 +133,10 @@ void ProjectGeneralWidget::doSave() #endif } else copyFile(mIconPath, iconPath,true); - project->options().icon = iconPath; - mIconPath = iconPath; - refreshIcon(); } + 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;