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