work save
- fix: copy icon file to project folder - fix: recopy units after they are sorted
This commit is contained in:
parent
6fc5f5995f
commit
e1977f1237
|
@ -157,11 +157,11 @@ static void initCodePages(){
|
|||
CodePages.insert(50937,std::make_shared<CodePageInfo>(50937,"",""));
|
||||
CodePages.insert(50939,std::make_shared<CodePageInfo>(50939,"",""));
|
||||
CodePages.insert(51932,std::make_shared<CodePageInfo>(51932,"euc-jp",""));
|
||||
CodePages.insert(51936,std::make_shared<CodePageInfo>(51936,"EUC-CN",""));
|
||||
CodePages.insert(51936,std::make_shared<CodePageInfo>(51936,"euc-cn",""));
|
||||
CodePages.insert(51949,std::make_shared<CodePageInfo>(51949,"euc-kr",""));
|
||||
CodePages.insert(51950,std::make_shared<CodePageInfo>(51950,"",""));
|
||||
CodePages.insert(52936,std::make_shared<CodePageInfo>(52936,"hz-gb-2312",""));
|
||||
CodePages.insert(54936,std::make_shared<CodePageInfo>(54936,"GB18030",""));
|
||||
CodePages.insert(54936,std::make_shared<CodePageInfo>(54936,"gb18030",""));
|
||||
CodePages.insert(57002,std::make_shared<CodePageInfo>(57002,"x-iscii-de",""));
|
||||
CodePages.insert(57003,std::make_shared<CodePageInfo>(57003,"x-iscii-be",""));
|
||||
CodePages.insert(57004,std::make_shared<CodePageInfo>(57004,"x-iscii-ta",""));
|
||||
|
|
|
@ -20,18 +20,7 @@ void ProjectFilesWidget::doLoad()
|
|||
std::shared_ptr<Project> project = pMainWindow->project();
|
||||
if (!project)
|
||||
return;
|
||||
mUnits.clear();
|
||||
foreach (const PProjectUnit& unit, project->units()) {
|
||||
PProjectUnit unitCopy = std::make_shared<ProjectUnit>(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> project = pMainWindow->project();
|
||||
if (!project)
|
||||
return;
|
||||
mUnits.clear();
|
||||
foreach (const PProjectUnit& unit, project->units()) {
|
||||
PProjectUnit unitCopy = std::make_shared<ProjectUnit>(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())
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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> 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());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ public:
|
|||
private:
|
||||
Ui::ProjectGeneralWidget *ui;
|
||||
QString mIconPath;
|
||||
|
||||
private:
|
||||
void refreshIcon();
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
|
|
Loading…
Reference in New Issue