2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-09-15 08:02:08 +08:00
|
|
|
#include "projectcompilerwidget.h"
|
|
|
|
#include "ui_projectcompilerwidget.h"
|
2021-09-15 11:23:42 +08:00
|
|
|
#include "../settings.h"
|
|
|
|
#include "../project.h"
|
|
|
|
#include "../mainwindow.h"
|
2021-09-15 08:02:08 +08:00
|
|
|
|
2021-09-15 11:23:42 +08:00
|
|
|
ProjectCompilerWidget::ProjectCompilerWidget(const QString &name, const QString &group, QWidget *parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
2021-09-15 08:02:08 +08:00
|
|
|
ui(new Ui::ProjectCompilerWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectCompilerWidget::~ProjectCompilerWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2021-09-15 11:23:42 +08:00
|
|
|
|
|
|
|
void ProjectCompilerWidget::refreshOptions()
|
|
|
|
{
|
2021-10-25 21:36:23 +08:00
|
|
|
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
|
2021-09-15 11:23:42 +08:00
|
|
|
if (!pSet)
|
|
|
|
return;
|
2022-05-02 21:47:01 +08:00
|
|
|
ui->chkAddCharset->setVisible(pSet->compilerType()!=COMPILER_CLANG);
|
|
|
|
ui->chkAddCharset->setEnabled(pSet->compilerType()!=COMPILER_CLANG);
|
2022-05-14 11:21:59 +08:00
|
|
|
mOptions = pMainWindow->project()->options().compilerOptions;
|
2022-05-12 22:42:19 +08:00
|
|
|
if (mOptions.isEmpty())
|
|
|
|
mOptions = pSet->compileOptions();
|
2021-09-15 11:23:42 +08:00
|
|
|
|
2022-05-14 11:21:59 +08:00
|
|
|
ui->tabOptions->resetUI(pSet,mOptions);
|
2021-10-25 21:36:23 +08:00
|
|
|
|
|
|
|
ui->chkStaticLink->setChecked(pSet->staticLink());
|
2021-09-15 11:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectCompilerWidget::doLoad()
|
|
|
|
{
|
2021-10-25 21:36:23 +08:00
|
|
|
ui->chkAddCharset->setChecked(pMainWindow->project()->options().addCharset);
|
|
|
|
ui->chkStaticLink->setChecked(pMainWindow->project()->options().staticLink);
|
|
|
|
|
2021-09-15 11:23:42 +08:00
|
|
|
mOptions = pMainWindow->project()->options().compilerOptions;
|
|
|
|
ui->cbCompilerSet->setCurrentIndex(pMainWindow->project()->options().compilerSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectCompilerWidget::doSave()
|
|
|
|
{
|
2022-05-02 21:47:01 +08:00
|
|
|
Settings::PCompilerSet pSet = pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
|
2021-09-15 11:23:42 +08:00
|
|
|
if (!pSet)
|
|
|
|
return;
|
2022-05-14 11:21:59 +08:00
|
|
|
|
2021-10-25 21:36:23 +08:00
|
|
|
pMainWindow->project()->setCompilerSet(ui->cbCompilerSet->currentIndex());
|
2022-05-14 11:21:59 +08:00
|
|
|
pMainWindow->project()->options().compilerOptions = ui->tabOptions->arguments(true);
|
2022-05-02 21:47:01 +08:00
|
|
|
if (pSet->compilerType()!=COMPILER_CLANG)
|
|
|
|
pMainWindow->project()->options().addCharset = ui->chkAddCharset->isChecked();
|
2021-10-25 21:36:23 +08:00
|
|
|
pMainWindow->project()->options().staticLink = ui->chkStaticLink->isChecked();
|
2021-09-15 12:19:09 +08:00
|
|
|
pMainWindow->project()->saveOptions();
|
2021-09-15 11:23:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectCompilerWidget::init()
|
|
|
|
{
|
|
|
|
ui->cbCompilerSet->clear();
|
2022-04-25 12:43:23 +08:00
|
|
|
for (size_t i=0;i<pSettings->compilerSets().size();i++) {
|
2022-03-11 20:51:33 +08:00
|
|
|
ui->cbCompilerSet->addItem(pSettings->compilerSets().getSet(i)->name());
|
2021-09-15 11:23:42 +08:00
|
|
|
}
|
2021-09-15 12:19:09 +08:00
|
|
|
SettingsWidget::init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int)
|
|
|
|
{
|
|
|
|
refreshOptions();
|
2021-09-15 11:23:42 +08:00
|
|
|
}
|
2021-09-15 12:19:09 +08:00
|
|
|
|