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>();
|
||||
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) {
|
||||
|
|
|
@ -94,6 +94,7 @@ void ProjectCompilerWidget::doSave()
|
|||
return;
|
||||
//read values in the options widget
|
||||
QTabWidget* pTab = ui->tabOptions;
|
||||
mOptions.clear();
|
||||
for (int i=0;i<pTab->count();i++) {
|
||||
QString section = pTab->tabText(i);
|
||||
QWidget* pWidget = pTab->widget(i);
|
||||
|
@ -102,7 +103,6 @@ void ProjectCompilerWidget::doSave()
|
|||
for (int j=1;j<pLayout->rowCount()-1;j++) {
|
||||
QString name = static_cast<QLabel *>(pLayout->itemAtPosition(j,0)->widget())->text();
|
||||
QComboBox* pCombo = static_cast<QComboBox *>(pLayout->itemAtPosition(j,1)->widget());
|
||||
mOptions.clear();
|
||||
for (int index=0;index<pSet->options().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();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,8 @@ protected:
|
|||
// SettingsWidget interface
|
||||
public:
|
||||
void init() override;
|
||||
private slots:
|
||||
void on_cbCompilerSet_currentIndexChanged(int index);
|
||||
};
|
||||
|
||||
#endif // PROJECTCOMPILERWIDGET_H
|
||||
|
|
|
@ -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<FolderNode*>(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();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
#include <QMessageBox>
|
||||
#include <QTextCodec>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue