diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 388eae08..ebd09bbe 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -205,6 +205,7 @@ PFolderNode Project::makeProjectNode() PFolderNode node = std::make_shared(); node->text = mName; node->level = 0; + node->unitIndex = -1; return node; } @@ -797,7 +798,7 @@ void Project::buildPrivateResource(bool forceSave) if (!mOptions.icon.isEmpty()) { contents.append(""); - QString icon = QDir(directory()).absoluteFilePath(mOptions.icon); + QString icon = mOptions.icon; if (fileExists(icon)) { icon = extractRelativePath(mFilename, icon); icon.replace('\\', '/'); @@ -1197,7 +1198,7 @@ void Project::loadLayout() void Project::loadOptions(SimpleIni& ini) { mName = fromByteArray(ini.GetValue("Project","name", "")); - mOptions.icon = fromByteArray(ini.GetValue("Project", "icon", "")); + mOptions.icon = QDir(directory()).absoluteFilePath(fromByteArray(ini.GetValue("Project", "icon", ""))); mOptions.version = ini.GetLongValue("Project", "Ver", 0); if (mOptions.version > 0) { // ver > 0 is at least a v5 project if (mOptions.version < 2) { diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp index 9411c796..d3448b1c 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.cpp @@ -94,6 +94,7 @@ void ProjectCompilerWidget::doSave() return; //read values in the options widget QTabWidget* pTab = ui->tabOptions; + mOptions.clear(); for (int i=0;icount();i++) { QString section = pTab->tabText(i); QWidget* pWidget = pTab->widget(i); @@ -102,7 +103,6 @@ void ProjectCompilerWidget::doSave() for (int j=1;jrowCount()-1;j++) { QString name = static_cast(pLayout->itemAtPosition(j,0)->widget())->text(); QComboBox* pCombo = static_cast(pLayout->itemAtPosition(j,1)->widget()); - mOptions.clear(); for (int index=0;indexoptions().count();index++) { PCompilerOption pOption = pSet->options()[index]; if (pOption->section == section && pOption->name == name) { @@ -115,13 +115,20 @@ void ProjectCompilerWidget::doSave() } pMainWindow->project()->options().compilerSet = ui->cbCompilerSet->currentIndex(); pMainWindow->project()->options().compilerOptions = mOptions; + pMainWindow->project()->saveOptions(); } void ProjectCompilerWidget::init() { - SettingsWidget::init(); ui->cbCompilerSet->clear(); for (const Settings::PCompilerSet& set:pSettings->compilerSets().list()){ ui->cbCompilerSet->addItem(set->name()); } + SettingsWidget::init(); } + +void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int) +{ + refreshOptions(); +} + diff --git a/RedPandaIDE/settingsdialog/projectcompilerwidget.h b/RedPandaIDE/settingsdialog/projectcompilerwidget.h index d19727f7..1dfb2c8b 100644 --- a/RedPandaIDE/settingsdialog/projectcompilerwidget.h +++ b/RedPandaIDE/settingsdialog/projectcompilerwidget.h @@ -29,6 +29,8 @@ protected: // SettingsWidget interface public: void init() override; +private slots: + void on_cbCompilerSet_currentIndexChanged(int index); }; #endif // PROJECTCOMPILERWIDGET_H diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.cpp b/RedPandaIDE/settingsdialog/projectfileswidget.cpp index 08799fdf..09c60894 100644 --- a/RedPandaIDE/settingsdialog/projectfileswidget.cpp +++ b/RedPandaIDE/settingsdialog/projectfileswidget.cpp @@ -42,6 +42,7 @@ void ProjectFilesWidget::doSave() pMainWindow->project()->sortUnitsByPriority(); pMainWindow->project()->saveUnits(); copyUnits(); + ui->treeProject->expandAll(); ui->treeProject->clicked(ui->treeProject->currentIndex()); } @@ -79,13 +80,28 @@ void ProjectFilesWidget::copyUnits() } } +void ProjectFilesWidget::disableFileOptions() +{ + ui->grpFileOptions->setEnabled(false); + ui->spinPriority->setValue(0); + ui->chkCompile->setChecked(false); + ui->chkLink->setChecked(false); + ui->chkCompileAsCPP->setChecked(false); + ui->chkOverrideBuildCommand->setChecked(false); + ui->txtBuildCommand->setPlainText(""); +} + void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index) { - if (!index.isValid()) + if (!index.isValid()) { + disableFileOptions(); return ; + } FolderNode* node = static_cast(index.internalPointer()); - if (!node) + if (!node) { + disableFileOptions(); return; + } int i = node->unitIndex; if (i>=0) { PProjectUnit unit = mUnits[i]; @@ -99,13 +115,7 @@ void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index) ui->txtBuildCommand->setEnabled(ui->chkOverrideBuildCommand->isChecked()); ui->cbEncoding->setCurrentText(unit->encoding()); } else { - ui->grpFileOptions->setEnabled(false); - ui->spinPriority->setValue(0); - ui->chkCompile->setChecked(false); - ui->chkLink->setChecked(false); - ui->chkCompileAsCPP->setChecked(false); - ui->chkOverrideBuildCommand->setChecked(false); - ui->txtBuildCommand->setPlainText(""); + disableFileOptions(); } } @@ -181,10 +191,10 @@ void ProjectFilesWidget::on_treeProject_clicked(const QModelIndex &index) void ProjectFilesWidget::init() { - SettingsWidget::init(); ui->spinPriority->setMinimum(0); ui->spinPriority->setMaximum(9999); ui->cbEncoding->clear(); ui->cbEncoding->addItems(pSystemConsts->codecNames()); + SettingsWidget::init(); } diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index 721e590c..bf00c32c 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -7,6 +7,7 @@ #include #include +#include #include ProjectGeneralWidget::ProjectGeneralWidget(const QString &name, const QString &group, QWidget *parent) : @@ -89,6 +90,15 @@ void ProjectGeneralWidget::doSave() project->options().icon = ""; } else { QString iconPath = changeFileExt(project->filename(),"ico"); + if (QFile(iconPath).exists()) { + 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); + } + } QFile::copy(mIconPath, iconPath); project->options().icon = iconPath; mIconPath = iconPath; @@ -108,6 +118,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked() mIconPath = fileName; QPixmap icon(mIconPath); refreshIcon(); + setSettingsChanged(); } ui->btnRemove->setEnabled(!mIconPath.isEmpty()); } @@ -118,12 +129,13 @@ void ProjectGeneralWidget::on_btnRemove_clicked() mIconPath = ""; ui->lblICon->setPixmap(QPixmap()); ui->btnRemove->setEnabled(!mIconPath.isEmpty()); + setSettingsChanged(); } void ProjectGeneralWidget::init() { - SettingsWidget::init(); ui->cbDefaultEncoding->clear(); ui->cbDefaultEncoding->addItems(pSystemConsts->codecNames()); + SettingsWidget::init(); }