- enhancement: project's custom compile include/lib/bin directory is under folder of the app, save them using the path relative to the app
This commit is contained in:
parent
2123f1b297
commit
82564239b9
3
NEWS.md
3
NEWS.md
|
@ -3,6 +3,9 @@ Red Panda C++ Version 2.5
|
|||
- enhancement: new color scheme Monokai (contributed by 小龙Dev(XiaoLoong@github))
|
||||
- enhancemnet: add "Reserve word for Types" item in color scheme
|
||||
- enhancement: auto save / load problem set
|
||||
- enhancement: project's custom compile include/lib/bin directory is under folder of the app, save them using the path relative to the app
|
||||
|
||||
|
||||
|
||||
Red Panda C++ Version 2.4
|
||||
|
||||
|
|
|
@ -30,6 +30,20 @@ HighlighterManager::HighlighterManager()
|
|||
|
||||
}
|
||||
|
||||
QSynedit::PHighlighter HighlighterManager::getHighlighter(QSynedit::HighlighterLanguage language)
|
||||
{
|
||||
switch(language) {
|
||||
case QSynedit::HighlighterLanguage::Cpp:
|
||||
return getCppHighlighter();
|
||||
case QSynedit::HighlighterLanguage::Asssembly:
|
||||
return getAsmHighlighter();
|
||||
case QSynedit::HighlighterLanguage::GLSL:
|
||||
return getGLSLHighlighter();
|
||||
default:
|
||||
return QSynedit::PHighlighter();
|
||||
}
|
||||
}
|
||||
|
||||
QSynedit::PHighlighter HighlighterManager::getHighlighter(const QString &filename)
|
||||
{
|
||||
QFileInfo info(filename);
|
||||
|
@ -42,6 +56,8 @@ QSynedit::PHighlighter HighlighterManager::getHighlighter(const QString &filenam
|
|||
return getCppHighlighter();
|
||||
} else if (suffix == "vs" || suffix == "fs" || suffix == "frag") {
|
||||
return getGLSLHighlighter();
|
||||
} else if (suffix == "s" || suffix == "asm") {
|
||||
return getAsmHighlighter();
|
||||
}
|
||||
return QSynedit::PHighlighter();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class HighlighterManager
|
|||
public:
|
||||
HighlighterManager();
|
||||
|
||||
QSynedit::PHighlighter getHighlighter(QSynedit::HighlighterLanguage language);
|
||||
QSynedit::PHighlighter getHighlighter(const QString& filename);
|
||||
QSynedit::PHighlighter copyHighlighter(QSynedit::PHighlighter highlighter);
|
||||
QSynedit::PHighlighter getCppHighlighter();
|
||||
|
|
|
@ -115,7 +115,7 @@ QString Compiler::getFileNameFromOutputLine(QString &line) {
|
|||
}
|
||||
if (!mDirectory.isEmpty()) {
|
||||
QFileInfo info(temp);
|
||||
return info.isRelative()?absolutePath(mDirectory,temp):cleanPath(temp);
|
||||
return info.isRelative()?generateAbsolutePath(mDirectory,temp):cleanPath(temp);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
|||
|
||||
// Mention progress in the logs
|
||||
if (!ObjResFile.isEmpty()) {
|
||||
log(tr("- Resource File: %1").arg(absolutePath(mProject->directory(),ObjResFile)));
|
||||
log(tr("- Resource File: %1").arg(generateAbsolutePath(mProject->directory(),ObjResFile)));
|
||||
}
|
||||
log("");
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ void Debugger::loadForProject(const QString &filename, const QString &projectFol
|
|||
PDebugConfig pConfig = load(filename, forProject);
|
||||
if (pConfig->timestamp>0) {
|
||||
foreach (const PBreakpoint& breakpoint, pConfig->breakpoints) {
|
||||
breakpoint->filename = absolutePath(projectFolder,breakpoint->filename);
|
||||
breakpoint->filename = generateAbsolutePath(projectFolder,breakpoint->filename);
|
||||
}
|
||||
mBreakpointModel->setBreakpoints(pConfig->breakpoints,forProject);
|
||||
mWatchModel->setWatchVars(pConfig->watchVars,forProject);
|
||||
|
@ -689,7 +689,7 @@ void Debugger::save(const QString &filename, const QString& projectFolder)
|
|||
if (!breakpointCompareSet.contains(key)) {
|
||||
breakpointCompareSet.insert(key);
|
||||
if (forProject)
|
||||
breakpoint->filename=absolutePath(projectFolder,breakpoint->filename);
|
||||
breakpoint->filename=generateAbsolutePath(projectFolder,breakpoint->filename);
|
||||
mBreakpointModel->addBreakpoint(breakpoint,forProject);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6723,7 +6723,7 @@ void MainWindow::newProjectUnitFile()
|
|||
if (newProjectUnitDialog.exec()!=QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
newFileName= absolutePath(newProjectUnitDialog.folder(),newProjectUnitDialog.filename());
|
||||
newFileName= generateAbsolutePath(newProjectUnitDialog.folder(),newProjectUnitDialog.filename());
|
||||
if (newFileName.isEmpty())
|
||||
return;
|
||||
} else {
|
||||
|
@ -6742,7 +6742,7 @@ void MainWindow::newProjectUnitFile()
|
|||
newFileName);
|
||||
if (newFileName.isEmpty())
|
||||
return;
|
||||
newFileName = absolutePath(mProject->directory(),newFileName);
|
||||
newFileName = generateAbsolutePath(mProject->directory(),newFileName);
|
||||
}
|
||||
if (fileExists(newFileName)) {
|
||||
QMessageBox::critical(this,tr("File Already Exists!"),
|
||||
|
|
|
@ -988,15 +988,15 @@ bool Project::saveAsTemplate(const QString &templateFolder,
|
|||
|
||||
ini->SetLongValue("Project", "Type", static_cast<int>(mOptions.type));
|
||||
if (!mOptions.includeDirs.isEmpty())
|
||||
ini->SetValue("Project", "Includes", extractRelativePaths(directory(), mOptions.includeDirs).join(";").toUtf8());
|
||||
ini->SetValue("Project", "Includes", relativePaths(mOptions.includeDirs).join(";").toUtf8());
|
||||
if (!mOptions.resourceIncludes.isEmpty())
|
||||
ini->SetValue("Project", "ResourceIncludes", extractRelativePaths(directory(), mOptions.resourceIncludes).join(";").toUtf8());
|
||||
ini->SetValue("Project", "ResourceIncludes", relativePaths(mOptions.resourceIncludes).join(";").toUtf8());
|
||||
if (!mOptions.makeIncludes.isEmpty())
|
||||
ini->SetValue("Project", "MakeIncludes", extractRelativePaths(directory(), mOptions.makeIncludes).join(";").toUtf8());
|
||||
ini->SetValue("Project", "MakeIncludes", relativePaths(mOptions.makeIncludes).join(";").toUtf8());
|
||||
if (!mOptions.binDirs.isEmpty())
|
||||
ini->SetValue("Project", "Bins", extractRelativePaths(directory(), mOptions.binDirs).join(";").toUtf8());
|
||||
ini->SetValue("Project", "Bins", relativePaths(mOptions.binDirs).join(";").toUtf8());
|
||||
if (!mOptions.libDirs.isEmpty())
|
||||
ini->SetValue("Project", "Libs", extractRelativePaths(directory(), mOptions.libDirs).join(";").toUtf8());
|
||||
ini->SetValue("Project", "Libs", relativePaths(mOptions.libDirs).join(";").toUtf8());
|
||||
if (!mOptions.compilerCmd.isEmpty())
|
||||
ini->SetValue("Project", "Compiler", mOptions.compilerCmd.toUtf8());
|
||||
if (!mOptions.cppCompilerCmd.isEmpty())
|
||||
|
@ -1078,12 +1078,12 @@ void Project::saveOptions()
|
|||
ini.SetValue("Project","Name", toByteArray(mName));
|
||||
ini.SetLongValue("Project","Type", static_cast<int>(mOptions.type));
|
||||
ini.SetLongValue("Project","Ver", 3); // Is 3 as of Red Panda C++.0
|
||||
ini.SetValue("Project","Includes", toByteArray(extractRelativePaths(directory(),mOptions.includeDirs).join(";")));
|
||||
ini.SetValue("Project","Libs", toByteArray(extractRelativePaths(directory(),mOptions.libDirs).join(";")));
|
||||
ini.SetValue("Project","Bins", toByteArray(extractRelativePaths(directory(),mOptions.binDirs).join(";")));
|
||||
ini.SetValue("Project","Includes", toByteArray(relativePaths(mOptions.includeDirs).join(";")));
|
||||
ini.SetValue("Project","Libs", toByteArray(relativePaths(mOptions.libDirs).join(";")));
|
||||
ini.SetValue("Project","Bins", toByteArray(relativePaths(mOptions.binDirs).join(";")));
|
||||
ini.SetValue("Project","ResourceIncludes", toByteArray(relativePaths(mOptions.resourceIncludes).join(";")));
|
||||
ini.SetValue("Project","MakeIncludes", toByteArray(relativePaths(mOptions.makeIncludes).join(";")));
|
||||
ini.SetValue("Project","PrivateResource", toByteArray(mOptions.privateResource));
|
||||
ini.SetValue("Project","ResourceIncludes", toByteArray(extractRelativePaths(directory(),mOptions.resourceIncludes).join(";")));
|
||||
ini.SetValue("Project","MakeIncludes", toByteArray(extractRelativePaths(directory(),mOptions.makeIncludes).join(";")));
|
||||
ini.SetValue("Project","Compiler", toByteArray(mOptions.compilerCmd));
|
||||
ini.SetValue("Project","CppCompiler", toByteArray(mOptions.cppCompilerCmd));
|
||||
ini.SetValue("Project","Linker", toByteArray(mOptions.linkerCmd));
|
||||
|
@ -1439,7 +1439,7 @@ void Project::buildPrivateResource(bool forceSave)
|
|||
contents.append("}");
|
||||
}
|
||||
|
||||
rcFile = absolutePath(directory(),rcFile);
|
||||
rcFile = generateAbsolutePath(directory(),rcFile);
|
||||
if (contents.count() > 3) {
|
||||
stringsToFile(contents,rcFile);
|
||||
mOptions.privateResource = extractRelativePath(directory(), rcFile);
|
||||
|
@ -1874,7 +1874,7 @@ void Project::loadOptions(SimpleIni& ini)
|
|||
if (icon.isEmpty()) {
|
||||
mOptions.icon = "";
|
||||
} else {
|
||||
mOptions.icon = absolutePath(directory(),icon);
|
||||
mOptions.icon = generateAbsolutePath(directory(),icon);
|
||||
}
|
||||
mOptions.version = ini.GetLongValue("Project", "Ver", 0);
|
||||
if (mOptions.version > 0) { // ver > 0 is at least a v5 project
|
||||
|
@ -1892,21 +1892,21 @@ 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.binDirs = absolutePaths(directory(), fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",
|
||||
mOptions.binDirs = absolutePaths(fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
Qt::SkipEmptyParts
|
||||
#else
|
||||
QString::SkipEmptyParts
|
||||
#endif
|
||||
));
|
||||
mOptions.libDirs = absolutePaths(directory(), fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",
|
||||
mOptions.libDirs = absolutePaths(fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
Qt::SkipEmptyParts
|
||||
#else
|
||||
QString::SkipEmptyParts
|
||||
#endif
|
||||
));
|
||||
mOptions.includeDirs = absolutePaths(directory(), fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",
|
||||
mOptions.includeDirs = absolutePaths(fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
Qt::SkipEmptyParts
|
||||
#else
|
||||
|
@ -1914,14 +1914,14 @@ void Project::loadOptions(SimpleIni& ini)
|
|||
#endif
|
||||
));
|
||||
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
|
||||
mOptions.resourceIncludes = absolutePaths(directory(), fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",
|
||||
mOptions.resourceIncludes = absolutePaths(fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
Qt::SkipEmptyParts
|
||||
#else
|
||||
QString::SkipEmptyParts
|
||||
#endif
|
||||
));
|
||||
mOptions.makeIncludes = absolutePaths(directory(), fromByteArray(ini.GetValue("Project", "MakeIncludes", "")).split(";",
|
||||
mOptions.makeIncludes = absolutePaths(fromByteArray(ini.GetValue("Project", "MakeIncludes", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
Qt::SkipEmptyParts
|
||||
#else
|
||||
|
@ -1929,17 +1929,17 @@ void Project::loadOptions(SimpleIni& ini)
|
|||
#endif
|
||||
));
|
||||
mOptions.isCpp = ini.GetBoolValue("Project", "IsCpp", false);
|
||||
mOptions.exeOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "ExeOutput", "")));
|
||||
mOptions.objectOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "ObjectOutput", "")));
|
||||
mOptions.logOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "LogOutput", "")));
|
||||
mOptions.exeOutput = generateAbsolutePath(directory(), fromByteArray(ini.GetValue("Project", "ExeOutput", "")));
|
||||
mOptions.objectOutput = generateAbsolutePath(directory(), fromByteArray(ini.GetValue("Project", "ObjectOutput", "")));
|
||||
mOptions.logOutput = generateAbsolutePath(directory(), fromByteArray(ini.GetValue("Project", "LogOutput", "")));
|
||||
mOptions.logOutputEnabled = ini.GetBoolValue("Project", "LogOutputEnabled", false);
|
||||
mOptions.overrideOutput = ini.GetBoolValue("Project", "OverrideOutput", false);
|
||||
mOptions.overridenOutput = fromByteArray(ini.GetValue("Project", "OverrideOutputName", ""));
|
||||
mOptions.hostApplication = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "HostApplication", "")));
|
||||
mOptions.hostApplication = generateAbsolutePath(directory(), fromByteArray(ini.GetValue("Project", "HostApplication", "")));
|
||||
mOptions.useCustomMakefile = ini.GetBoolValue("Project", "UseCustomMakefile", false);
|
||||
mOptions.customMakefile = absolutePath(directory(),fromByteArray(ini.GetValue("Project", "CustomMakefile", "")));
|
||||
mOptions.customMakefile = generateAbsolutePath(directory(),fromByteArray(ini.GetValue("Project", "CustomMakefile", "")));
|
||||
mOptions.usePrecompiledHeader = ini.GetBoolValue("Project", "UsePrecompiledHeader", false);
|
||||
mOptions.precompiledHeader = absolutePath(directory(),fromByteArray(ini.GetValue("Project", "PrecompiledHeader", "")));
|
||||
mOptions.precompiledHeader = generateAbsolutePath(directory(),fromByteArray(ini.GetValue("Project", "PrecompiledHeader", "")));
|
||||
mOptions.cmdLineArgs = fromByteArray(ini.GetValue("Project", "CommandLine", ""));
|
||||
mFolders = fromByteArray(ini.GetValue("Project", "Folders", "")).split(";",
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
||||
|
@ -2087,6 +2087,49 @@ void Project::loadUnitLayout(Editor *e)
|
|||
}
|
||||
}
|
||||
|
||||
QString Project::relativePath(const QString &filename)
|
||||
{
|
||||
QString appPath = includeTrailingPathDelimiter(pSettings->dirs().appDir());
|
||||
QString projectPath = includeTrailingPathDelimiter(directory());
|
||||
if (filename.startsWith(appPath) && !filename.startsWith(projectPath)) {
|
||||
return "%APP_PATH%/"+filename.mid(appPath.length());
|
||||
}
|
||||
QDir projectDir(directory());
|
||||
QDir grandparentDir(projectDir.absoluteFilePath("../../"));
|
||||
QString grandparentPath=grandparentDir.absolutePath();
|
||||
if (grandparentDir.exists()
|
||||
&& filename.startsWith(grandparentPath))
|
||||
return extractRelativePath(directory(),filename);
|
||||
return filename;
|
||||
}
|
||||
|
||||
QStringList Project::relativePaths(const QStringList &files)
|
||||
{
|
||||
QStringList lst;
|
||||
foreach(const QString& file,files) {
|
||||
lst.append(relativePath(file));
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
QString Project::absolutePath(const QString &filename)
|
||||
{
|
||||
QString appSuffix = "%APP_PATH%/";
|
||||
if (filename.startsWith(appSuffix)) {
|
||||
return includeTrailingPathDelimiter(pSettings->dirs().appDir()) + filename.mid(appSuffix.length());
|
||||
}
|
||||
return generateAbsolutePath(directory(),filename);
|
||||
}
|
||||
|
||||
QStringList Project::absolutePaths(const QStringList &files)
|
||||
{
|
||||
QStringList lst;
|
||||
foreach(const QString& file,files) {
|
||||
lst.append(absolutePath(file));
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
PCppParser Project::cppParser()
|
||||
{
|
||||
return mParser;
|
||||
|
@ -2582,7 +2625,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
return false;
|
||||
QString oldName = unit->fileName();
|
||||
QString curDir = extractFilePath(oldName);
|
||||
newName = absolutePath(curDir,newName);
|
||||
newName = generateAbsolutePath(curDir,newName);
|
||||
// Only continue if the user says so...
|
||||
if (fileExists(newName) && newName.compare(oldName, PATH_SENSITIVITY)!=0) {
|
||||
// don't remove when changing case for example
|
||||
|
|
|
@ -297,6 +297,11 @@ signals:
|
|||
void modifyChanged(bool value);
|
||||
|
||||
private:
|
||||
QString relativePath(const QString& filename);
|
||||
QStringList relativePaths(const QStringList& files);
|
||||
QString absolutePath(const QString& filename);
|
||||
QStringList absolutePaths(const QStringList& files);
|
||||
|
||||
bool internalRemoveUnit(PProjectUnit& unit, bool doClose, bool removeFile);
|
||||
PProjectUnit internalAddUnit(const QString& inFileName,
|
||||
PProjectModelNode parentNode);
|
||||
|
|
|
@ -112,7 +112,7 @@ void ProjectGeneralWidget::doSave()
|
|||
#endif
|
||||
project->options().icon = "";
|
||||
} else {
|
||||
QString iconPath = absolutePath(project->directory(),"app.ico");
|
||||
QString iconPath = generateAbsolutePath(project->directory(),"app.ico");
|
||||
if (iconPath!=mIconPath) {
|
||||
if (QFile(iconPath).exists()) {
|
||||
if (!QFile::remove(iconPath)) {
|
||||
|
|
|
@ -68,6 +68,7 @@ enum class HighlighterClass {
|
|||
};
|
||||
|
||||
enum class HighlighterLanguage {
|
||||
DecideBySuffix,
|
||||
Asssembly,
|
||||
Cpp,
|
||||
GLSL
|
||||
|
|
|
@ -688,7 +688,7 @@ QString cleanPath(const QString &dirPath)
|
|||
return QDir::cleanPath(dirPath);
|
||||
}
|
||||
|
||||
QString absolutePath(const QString &dirPath, const QString &relativePath)
|
||||
QString generateAbsolutePath(const QString &dirPath, const QString &relativePath)
|
||||
{
|
||||
if (relativePath.isEmpty())
|
||||
return QString();
|
||||
|
@ -714,7 +714,7 @@ QStringList absolutePaths(const QString &dirPath, const QStringList &relativePat
|
|||
{
|
||||
QStringList list;
|
||||
foreach(const QString& path,relativePaths) {
|
||||
list.append(absolutePath(dirPath,path));
|
||||
list.append(generateAbsolutePath(dirPath,path));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ QString extractFileDir(const QString& fileName);
|
|||
QString extractFilePath(const QString& filePath);
|
||||
QString extractAbsoluteFilePath(const QString& filePath);
|
||||
QString cleanPath(const QString& dirPath);
|
||||
QString absolutePath(const QString& dirPath, const QString& relativePath);
|
||||
QString generateAbsolutePath(const QString& dirPath, const QString& relativePath);
|
||||
QStringList absolutePaths(const QString& dirPath, const QStringList& relativePaths);
|
||||
QString escapeSpacesInString(const QString& str);
|
||||
|
||||
|
|
Loading…
Reference in New Issue