diff --git a/RedPandaIDE/platform.cpp b/RedPandaIDE/platform.cpp index 589ed3ed..f32689d4 100644 --- a/RedPandaIDE/platform.cpp +++ b/RedPandaIDE/platform.cpp @@ -157,11 +157,11 @@ static void initCodePages(){ CodePages.insert(50937,std::make_shared(50937,"","")); CodePages.insert(50939,std::make_shared(50939,"","")); CodePages.insert(51932,std::make_shared(51932,"euc-jp","")); - CodePages.insert(51936,std::make_shared(51936,"EUC-CN","")); + CodePages.insert(51936,std::make_shared(51936,"euc-cn","")); CodePages.insert(51949,std::make_shared(51949,"euc-kr","")); CodePages.insert(51950,std::make_shared(51950,"","")); CodePages.insert(52936,std::make_shared(52936,"hz-gb-2312","")); - CodePages.insert(54936,std::make_shared(54936,"GB18030","")); + CodePages.insert(54936,std::make_shared(54936,"gb18030","")); CodePages.insert(57002,std::make_shared(57002,"x-iscii-de","")); CodePages.insert(57003,std::make_shared(57003,"x-iscii-be","")); CodePages.insert(57004,std::make_shared(57004,"x-iscii-ta","")); diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.cpp b/RedPandaIDE/settingsdialog/projectfileswidget.cpp index fda099d3..06c13d43 100644 --- a/RedPandaIDE/settingsdialog/projectfileswidget.cpp +++ b/RedPandaIDE/settingsdialog/projectfileswidget.cpp @@ -20,18 +20,7 @@ void ProjectFilesWidget::doLoad() std::shared_ptr project = pMainWindow->project(); if (!project) return; - mUnits.clear(); - foreach (const PProjectUnit& unit, project->units()) { - PProjectUnit unitCopy = std::make_shared(project.get()); - unitCopy->setPriority(unit->priority()); - unitCopy->setCompile(unit->compile()); - unitCopy->setLink(unit->link()); - unitCopy->setCompileCpp(unit->compileCpp()); - unitCopy->setOverrideBuildCmd(unit->overrideBuildCmd()); - unitCopy->setBuildCmd(unit->buildCmd()); - unitCopy->setEncoding(unit->encoding()); - mUnits.append(unitCopy); - } + copyUnits(); ui->treeProject->setModel(project->model()); ui->treeProject->expandAll(); ui->grpFileOptions->setEnabled(false); @@ -55,6 +44,8 @@ void ProjectFilesWidget::doSave() } pMainWindow->project()->sortUnitsByPriority(); pMainWindow->project()->saveUnits(); + copyUnits(); + ui->treeProject->clicked(ui->treeProject->currentIndex()); } PProjectUnit ProjectFilesWidget::currentUnit() @@ -72,6 +63,25 @@ PProjectUnit ProjectFilesWidget::currentUnit() return PProjectUnit(); } +void ProjectFilesWidget::copyUnits() +{ + std::shared_ptr project = pMainWindow->project(); + if (!project) + return; + mUnits.clear(); + foreach (const PProjectUnit& unit, project->units()) { + PProjectUnit unitCopy = std::make_shared(project.get()); + unitCopy->setPriority(unit->priority()); + unitCopy->setCompile(unit->compile()); + unitCopy->setLink(unit->link()); + unitCopy->setCompileCpp(unit->compileCpp()); + unitCopy->setOverrideBuildCmd(unit->overrideBuildCmd()); + unitCopy->setBuildCmd(unit->buildCmd()); + unitCopy->setEncoding(unit->encoding()); + mUnits.append(unitCopy); + } +} + void ProjectFilesWidget::on_treeProject_doubleClicked(const QModelIndex &index) { if (!index.isValid()) diff --git a/RedPandaIDE/settingsdialog/projectfileswidget.h b/RedPandaIDE/settingsdialog/projectfileswidget.h index 316e635c..aa7e2cc3 100644 --- a/RedPandaIDE/settingsdialog/projectfileswidget.h +++ b/RedPandaIDE/settingsdialog/projectfileswidget.h @@ -28,6 +28,7 @@ protected: void doSave() override; private: PProjectUnit currentUnit(); + void copyUnits(); private slots: void on_treeProject_doubleClicked(const QModelIndex &index); void on_spinPriority_valueChanged(int arg1); diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp index 33f59935..ac646c19 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.cpp @@ -21,6 +21,12 @@ ProjectGeneralWidget::~ProjectGeneralWidget() delete ui; } +void ProjectGeneralWidget::refreshIcon() +{ + QPixmap icon(mIconPath); + ui->lblICon->setPixmap(icon); +} + void ProjectGeneralWidget::doLoad() { std::shared_ptr project = pMainWindow->project(); @@ -61,11 +67,8 @@ void ProjectGeneralWidget::doLoad() ui->cbDefaultCpp->setChecked(project->options().useGPP); ui->cbSupportXPTheme->setChecked(project->options().supportXPThemes); mIconPath = project->options().icon; - if (!mIconPath.isEmpty()) { - QPixmap icon(mIconPath); - ui->lblICon->setPixmap(icon); - } - ui->btnRemove->setEnabled(!mIconPath.isEmpty()); + QPixmap icon(mIconPath); + refreshIcon(); } void ProjectGeneralWidget::doSave() @@ -82,7 +85,17 @@ void ProjectGeneralWidget::doSave() project->options().useGPP = ui->cbDefaultCpp->isChecked(); project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked(); - project->options().icon = mIconPath; + if (mIconPath.isEmpty() + || ui->lblICon->pixmap(Qt::ReturnByValue).isNull()) { + project->options().icon = ""; + } else { + QString iconPath = changeFileExt(project->filename(),"ico"); + QFile::copy(mIconPath, iconPath); + project->options().icon = iconPath; + mIconPath = iconPath; + refreshIcon(); + } + project->saveOptions(); } @@ -95,8 +108,7 @@ void ProjectGeneralWidget::on_btnBrowse_clicked() if (!fileName.isEmpty()) { mIconPath = fileName; QPixmap icon(mIconPath); - ui->lblICon->setPixmap(icon); - setSettingsChanged(); + refreshIcon(); } ui->btnRemove->setEnabled(!mIconPath.isEmpty()); } diff --git a/RedPandaIDE/settingsdialog/projectgeneralwidget.h b/RedPandaIDE/settingsdialog/projectgeneralwidget.h index e41fe56d..45a8d59b 100644 --- a/RedPandaIDE/settingsdialog/projectgeneralwidget.h +++ b/RedPandaIDE/settingsdialog/projectgeneralwidget.h @@ -19,7 +19,8 @@ public: private: Ui::ProjectGeneralWidget *ui; QString mIconPath; - +private: + void refreshIcon(); // SettingsWidget interface protected: void doLoad() override;