- enhancement: Use relative paths to save project settings
- fix: Layout for project options dialog's general page is not correct. - fix: modifitions in the project options dialogs's dll host page is not correctly saved. - enhancement: In the project options dialog, autoset the default folder in the openning dialog when choosing file/directory paths.
This commit is contained in:
parent
eceba8b8f2
commit
ca9976e9e0
4
NEWS.md
4
NEWS.md
|
@ -15,6 +15,10 @@ Red Panda C++ Version 2.4
|
||||||
- fix: function args not correctly handled in code parser;
|
- fix: function args not correctly handled in code parser;
|
||||||
- fix: crash when alt+mouse drag selection
|
- fix: crash when alt+mouse drag selection
|
||||||
- enhancement: show completion tips for when define a function that already has a declaration.
|
- enhancement: show completion tips for when define a function that already has a declaration.
|
||||||
|
- enhancement: Use relative paths to save project settings
|
||||||
|
- fix: Layout for project options dialog's general page is not correct.
|
||||||
|
- fix: modifitions in the project options dialogs's dll host page is not correctly saved.
|
||||||
|
- enhancement: In the project options dialog, autoset the default folder in the openning dialog when choosing file/directory paths.
|
||||||
|
|
||||||
Red Panda C++ Version 2.3
|
Red Panda C++ Version 2.3
|
||||||
|
|
||||||
|
|
|
@ -1009,11 +1009,11 @@ bool Project::saveAsTemplate(const QString &templateFolder,
|
||||||
if (mOptions.supportXPThemes)
|
if (mOptions.supportXPThemes)
|
||||||
ini->SetBoolValue("Project", "SupportXPThemes", true);
|
ini->SetBoolValue("Project", "SupportXPThemes", true);
|
||||||
if (!mOptions.exeOutput.isEmpty())
|
if (!mOptions.exeOutput.isEmpty())
|
||||||
ini->SetValue("Project", "ExeOutput", mOptions.exeOutput.toUtf8());
|
ini->SetValue("Project", "ExeOutput", extractRelativePath(directory(),mOptions.exeOutput).toUtf8());
|
||||||
if (!mOptions.objectOutput.isEmpty())
|
if (!mOptions.objectOutput.isEmpty())
|
||||||
ini->SetValue("Project", "ObjectOutput", mOptions.objectOutput.toUtf8());
|
ini->SetValue("Project", "ObjectOutput", extractRelativePath(directory(),mOptions.objectOutput).toUtf8());
|
||||||
if (!mOptions.logOutput.isEmpty())
|
if (!mOptions.logOutput.isEmpty())
|
||||||
ini->SetValue("Project", "LogOutput", mOptions.logOutput.toUtf8());
|
ini->SetValue("Project", "LogOutput", extractRelativePath(directory(),mOptions.logOutput).toUtf8());
|
||||||
if (mOptions.execEncoding!=ENCODING_SYSTEM_DEFAULT)
|
if (mOptions.execEncoding!=ENCODING_SYSTEM_DEFAULT)
|
||||||
ini->SetValue("Project","ExecEncoding", mOptions.execEncoding);
|
ini->SetValue("Project","ExecEncoding", mOptions.execEncoding);
|
||||||
|
|
||||||
|
@ -1089,9 +1089,9 @@ void Project::saveOptions()
|
||||||
ini.SetValue("Project","Linker", toByteArray(mOptions.linkerCmd));
|
ini.SetValue("Project","Linker", toByteArray(mOptions.linkerCmd));
|
||||||
ini.SetLongValue("Project","IsCpp", mOptions.isCpp);
|
ini.SetLongValue("Project","IsCpp", mOptions.isCpp);
|
||||||
ini.SetValue("Project","Icon", toByteArray(extractRelativePath(directory(), mOptions.icon)));
|
ini.SetValue("Project","Icon", toByteArray(extractRelativePath(directory(), mOptions.icon)));
|
||||||
ini.SetValue("Project","ExeOutput", toByteArray(mOptions.exeOutput));
|
ini.SetValue("Project","ExeOutput", toByteArray(extractRelativePath(directory(),mOptions.exeOutput)));
|
||||||
ini.SetValue("Project","ObjectOutput", toByteArray(mOptions.objectOutput));
|
ini.SetValue("Project","ObjectOutput", toByteArray(extractRelativePath(directory(),mOptions.objectOutput)));
|
||||||
ini.SetValue("Project","LogOutput", toByteArray(mOptions.logOutput));
|
ini.SetValue("Project","LogOutput", toByteArray(extractRelativePath(directory(),mOptions.logOutput)));
|
||||||
ini.SetLongValue("Project","LogOutputEnabled", mOptions.logOutputEnabled);
|
ini.SetLongValue("Project","LogOutputEnabled", mOptions.logOutputEnabled);
|
||||||
ini.SetLongValue("Project","OverrideOutput", mOptions.overrideOutput);
|
ini.SetLongValue("Project","OverrideOutput", mOptions.overrideOutput);
|
||||||
ini.SetValue("Project","OverrideOutputName", toByteArray(mOptions.overridenOutput));
|
ini.SetValue("Project","OverrideOutputName", toByteArray(mOptions.overridenOutput));
|
||||||
|
@ -1929,9 +1929,9 @@ void Project::loadOptions(SimpleIni& ini)
|
||||||
#endif
|
#endif
|
||||||
));
|
));
|
||||||
mOptions.isCpp = ini.GetBoolValue("Project", "IsCpp", false);
|
mOptions.isCpp = ini.GetBoolValue("Project", "IsCpp", false);
|
||||||
mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", ""));
|
mOptions.exeOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "ExeOutput", "")));
|
||||||
mOptions.objectOutput = fromByteArray(ini.GetValue("Project", "ObjectOutput", ""));
|
mOptions.objectOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "ObjectOutput", "")));
|
||||||
mOptions.logOutput = fromByteArray(ini.GetValue("Project", "LogOutput", ""));
|
mOptions.logOutput = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "LogOutput", "")));
|
||||||
mOptions.logOutputEnabled = ini.GetBoolValue("Project", "LogOutputEnabled", false);
|
mOptions.logOutputEnabled = ini.GetBoolValue("Project", "LogOutputEnabled", false);
|
||||||
mOptions.overrideOutput = ini.GetBoolValue("Project", "OverrideOutput", false);
|
mOptions.overrideOutput = ini.GetBoolValue("Project", "OverrideOutput", false);
|
||||||
mOptions.overridenOutput = fromByteArray(ini.GetValue("Project", "OverrideOutputName", ""));
|
mOptions.overridenOutput = fromByteArray(ini.GetValue("Project", "OverrideOutputName", ""));
|
||||||
|
@ -2068,37 +2068,6 @@ void Project::loadOptions(SimpleIni& ini)
|
||||||
mOptions.versionInfo.autoIncBuildNr = ini.GetBoolValue("VersionInfo", "AutoIncBuildNr", false);
|
mOptions.versionInfo.autoIncBuildNr = ini.GetBoolValue("VersionInfo", "AutoIncBuildNr", false);
|
||||||
mOptions.versionInfo.syncProduct = ini.GetBoolValue("VersionInfo", "SyncProduct", false);
|
mOptions.versionInfo.syncProduct = ini.GetBoolValue("VersionInfo", "SyncProduct", false);
|
||||||
|
|
||||||
} else { // dev-c < 4
|
|
||||||
mOptions.version = 3;
|
|
||||||
if (!ini.GetBoolValue("VersionInfo", "NoConsole", true))
|
|
||||||
mOptions.type = ProjectType::Console;
|
|
||||||
else if (ini.GetBoolValue("VersionInfo", "IsDLL", false))
|
|
||||||
mOptions.type = ProjectType::DynamicLib;
|
|
||||||
else
|
|
||||||
mOptions.type = ProjectType::GUI;
|
|
||||||
|
|
||||||
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
|
|
||||||
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
|
||||||
Qt::SkipEmptyParts
|
|
||||||
#else
|
|
||||||
QString::SkipEmptyParts
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
|
|
||||||
Qt::SkipEmptyParts
|
|
||||||
#else
|
|
||||||
QString::SkipEmptyParts
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "CompilerOptions", ""));
|
|
||||||
mOptions.isCpp = ini.GetBoolValue("Project", "Use_GPP", false);
|
|
||||||
mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", ""));
|
|
||||||
mOptions.objectOutput = fromByteArray(ini.GetValue("Project", "ObjectOutput", ""));
|
|
||||||
mOptions.overrideOutput = ini.GetBoolValue("Project", "OverrideOutput", false);
|
|
||||||
mOptions.overridenOutput = fromByteArray(ini.GetValue("Project", "OverrideOutputName", ""));
|
|
||||||
mOptions.hostApplication = absolutePath(directory(), fromByteArray(ini.GetValue("Project", "HostApplication", "")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,19 @@ void ProjectDLLHostWidget::doLoad()
|
||||||
void ProjectDLLHostWidget::doSave()
|
void ProjectDLLHostWidget::doSave()
|
||||||
{
|
{
|
||||||
pMainWindow->project()->options().hostApplication = ui->txtHost->text();
|
pMainWindow->project()->options().hostApplication = ui->txtHost->text();
|
||||||
|
pMainWindow->project()->saveOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectDLLHostWidget::on_btnBrowse_clicked()
|
void ProjectDLLHostWidget::on_btnBrowse_clicked()
|
||||||
{
|
{
|
||||||
|
QString currentFile=ui->txtHost->text();
|
||||||
|
if (currentFile.isEmpty()) {
|
||||||
|
currentFile = pMainWindow->project()->directory();
|
||||||
|
}
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
tr("Choose host application"),
|
tr("Choose host application"),
|
||||||
pMainWindow->project()->directory(),
|
currentFile,
|
||||||
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
||||||
if (!filename.isEmpty() && fileExists(filename)) {
|
if (!filename.isEmpty() && fileExists(filename)) {
|
||||||
ui->txtHost->setText(filename);
|
ui->txtHost->setText(filename);
|
||||||
|
|
|
@ -21,19 +21,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -58,10 +58,14 @@ void ProjectMakefileWidget::doSave()
|
||||||
|
|
||||||
void ProjectMakefileWidget::on_btnBrowse_clicked()
|
void ProjectMakefileWidget::on_btnBrowse_clicked()
|
||||||
{
|
{
|
||||||
|
QString currentFile=ui->txtCustomMakefile->text();
|
||||||
|
if (currentFile.isEmpty()) {
|
||||||
|
currentFile = pMainWindow->project()->directory();
|
||||||
|
}
|
||||||
QString fileName = QFileDialog::getOpenFileName(
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
this,
|
this,
|
||||||
tr("Custom makefile"),
|
tr("Custom makefile"),
|
||||||
pMainWindow->project()->directory(),
|
currentFile,
|
||||||
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
||||||
if (!fileName.isEmpty() && QFileInfo(fileName).exists()) {
|
if (!fileName.isEmpty() && QFileInfo(fileName).exists()) {
|
||||||
ui->txtCustomMakefile->setText(fileName);
|
ui->txtCustomMakefile->setText(fileName);
|
||||||
|
|
|
@ -59,35 +59,47 @@ void ProjectOutputWidget::doSave()
|
||||||
|
|
||||||
void ProjectOutputWidget::on_btnOutputDir_clicked()
|
void ProjectOutputWidget::on_btnOutputDir_clicked()
|
||||||
{
|
{
|
||||||
|
QString currentName = ui->txtOutputDir->text();
|
||||||
|
if (currentName.isEmpty())
|
||||||
|
currentName = pMainWindow->project()->directory();
|
||||||
QString dirName = QFileDialog::getExistingDirectory(
|
QString dirName = QFileDialog::getExistingDirectory(
|
||||||
this,
|
this,
|
||||||
tr("Executable output directory"),
|
tr("Executable output directory"),
|
||||||
pMainWindow->project()->directory());
|
currentName);
|
||||||
if (!dirName.isEmpty())
|
if (!dirName.isEmpty())
|
||||||
ui->txtOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
|
ui->txtOutputDir->setText(dirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProjectOutputWidget::on_btnObjOutputDir_clicked()
|
void ProjectOutputWidget::on_btnObjOutputDir_clicked()
|
||||||
{
|
{
|
||||||
|
QString currentName = ui->txtObjOutputDir->text();
|
||||||
|
if (currentName.isEmpty())
|
||||||
|
currentName = pMainWindow->project()->directory();
|
||||||
QString dirName = QFileDialog::getExistingDirectory(
|
QString dirName = QFileDialog::getExistingDirectory(
|
||||||
this,
|
this,
|
||||||
tr("Object files output directory"),
|
tr("Object files output directory"),
|
||||||
pMainWindow->project()->directory());
|
currentName);
|
||||||
if (!dirName.isEmpty())
|
if (!dirName.isEmpty())
|
||||||
ui->txtObjOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
|
ui->txtObjOutputDir->setText(dirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProjectOutputWidget::on_btnCompileLog_clicked()
|
void ProjectOutputWidget::on_btnCompileLog_clicked()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(
|
QString currentFile=ui->txtCompileLog->text();
|
||||||
|
if (currentFile.isEmpty()) {
|
||||||
|
currentFile = pMainWindow->project()->directory();
|
||||||
|
}
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
tr("Log file"),
|
tr("Log file"),
|
||||||
pMainWindow->project()->directory(),
|
currentFile,
|
||||||
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
tr("All files (%1)").arg(ALL_FILE_WILDCARD),
|
||||||
|
nullptr,
|
||||||
|
QFileDialog::Options() | QFileDialog::DontConfirmOverwrite);
|
||||||
if (!fileName.isEmpty() ) {
|
if (!fileName.isEmpty() ) {
|
||||||
ui->txtCompileLog->setText(extractRelativePath(pMainWindow->project()->folder(),fileName));
|
ui->txtCompileLog->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,21 @@ void ProjectPreCompileWidget::doSave()
|
||||||
|
|
||||||
void ProjectPreCompileWidget::on_btnBrowse_clicked()
|
void ProjectPreCompileWidget::on_btnBrowse_clicked()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(
|
QString currentFile=ui->txtPrecompileHeader->text();
|
||||||
|
QString currentDir;
|
||||||
|
if (currentFile.isEmpty()) {
|
||||||
|
currentDir = pMainWindow->project()->directory();
|
||||||
|
} else {
|
||||||
|
currentDir = extractFilePath(currentFile);
|
||||||
|
}
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(
|
||||||
this,
|
this,
|
||||||
tr("Precompiled header"),
|
tr("Precompiled header"),
|
||||||
pMainWindow->project()->directory(),
|
currentDir,
|
||||||
tr("header files (*.h)"));
|
tr("precompiled header files (*.pch)"),
|
||||||
if (!fileName.isEmpty() && QFileInfo(fileName).exists()) {
|
nullptr,
|
||||||
|
QFileDialog::Options()|QFileDialog::DontConfirmOverwrite);
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
ui->txtPrecompileHeader->setText(fileName);
|
ui->txtPrecompileHeader->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,6 +542,9 @@ QString changeFileExt(const QString& filename, QString ext)
|
||||||
|
|
||||||
QString extractRelativePath(const QString &base, const QString &dest)
|
QString extractRelativePath(const QString &base, const QString &dest)
|
||||||
{
|
{
|
||||||
|
if (dest.isEmpty())
|
||||||
|
return QString();
|
||||||
|
|
||||||
QFileInfo baseInfo(base);
|
QFileInfo baseInfo(base);
|
||||||
QDir baseDir;
|
QDir baseDir;
|
||||||
if (baseInfo.isDir()) {
|
if (baseInfo.isDir()) {
|
||||||
|
@ -687,6 +690,8 @@ QString cleanPath(const QString &dirPath)
|
||||||
|
|
||||||
QString absolutePath(const QString &dirPath, const QString &relativePath)
|
QString absolutePath(const QString &dirPath, const QString &relativePath)
|
||||||
{
|
{
|
||||||
|
if (relativePath.isEmpty())
|
||||||
|
return QString();
|
||||||
return QDir::cleanPath(QDir(dirPath).absoluteFilePath(relativePath));
|
return QDir::cleanPath(QDir(dirPath).absoluteFilePath(relativePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,3 +700,21 @@ QString escapeSpacesInString(const QString &str)
|
||||||
QString result=str;
|
QString result=str;
|
||||||
return result.replace(' ',"%20");
|
return result.replace(' ',"%20");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList extractRelativePaths(const QString &base, const QStringList &destList)
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
foreach(const QString& dest,destList) {
|
||||||
|
list.append(extractRelativePath(base,dest));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList absolutePaths(const QString &dirPath, const QStringList &relativePaths)
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
foreach(const QString& path,relativePaths) {
|
||||||
|
list.append(absolutePath(dirPath,path));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
|
@ -124,12 +124,14 @@ QString changeFileExt(const QString& filename, QString ext);
|
||||||
QString localizePath(const QString& path);
|
QString localizePath(const QString& path);
|
||||||
|
|
||||||
QString extractRelativePath(const QString& base, const QString& dest);
|
QString extractRelativePath(const QString& base, const QString& dest);
|
||||||
|
QStringList extractRelativePaths(const QString& base, const QStringList& destList);
|
||||||
QString extractFileName(const QString& fileName);
|
QString extractFileName(const QString& fileName);
|
||||||
QString extractFileDir(const QString& fileName);
|
QString extractFileDir(const QString& fileName);
|
||||||
QString extractFilePath(const QString& filePath);
|
QString extractFilePath(const QString& filePath);
|
||||||
QString extractAbsoluteFilePath(const QString& filePath);
|
QString extractAbsoluteFilePath(const QString& filePath);
|
||||||
QString cleanPath(const QString& dirPath);
|
QString cleanPath(const QString& dirPath);
|
||||||
QString absolutePath(const QString& dirPath, const QString& relativePath);
|
QString absolutePath(const QString& dirPath, const QString& relativePath);
|
||||||
|
QStringList absolutePaths(const QString& dirPath, const QStringList& relativePaths);
|
||||||
QString escapeSpacesInString(const QString& str);
|
QString escapeSpacesInString(const QString& str);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue