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-04-17 23:17:22 +08:00
|
|
|
#include "compilersetoptionwidget.h"
|
|
|
|
#include "ui_compilersetoptionwidget.h"
|
|
|
|
#include "../settings.h"
|
|
|
|
#include "../mainwindow.h"
|
|
|
|
#include "compilersetdirectorieswidget.h"
|
|
|
|
#include <QMessageBox>
|
2023-08-06 00:05:58 +08:00
|
|
|
#include <QProgressDialog>
|
2021-04-17 23:17:22 +08:00
|
|
|
#include "../utils.h"
|
2021-12-23 00:24:52 +08:00
|
|
|
#include "../iconsmanager.h"
|
2023-08-13 18:53:48 +08:00
|
|
|
#include "../systemconsts.h"
|
2022-09-26 14:54:28 +08:00
|
|
|
#include <qt_utils/charsetinfo.h>
|
2021-04-17 23:17:22 +08:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
|
|
|
CompilerSetOptionWidget::CompilerSetOptionWidget(const QString& name, const QString& group, QWidget* parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
|
|
|
ui(new Ui::CompilerSetOptionWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
mBinDirWidget = new CompilerSetDirectoriesWidget();
|
|
|
|
ui->dirTabs->addTab(mBinDirWidget,QObject::tr("Binaries"));
|
|
|
|
mLibDirWidget = new CompilerSetDirectoriesWidget();
|
|
|
|
ui->dirTabs->addTab(mLibDirWidget,QObject::tr("Libraries"));
|
|
|
|
mCIncludeDirWidget = new CompilerSetDirectoriesWidget();
|
|
|
|
ui->dirTabs->addTab(mCIncludeDirWidget,QObject::tr("C Includes"));
|
|
|
|
mCppIncludeDirWidget = new CompilerSetDirectoriesWidget();
|
|
|
|
ui->dirTabs->addTab(mCppIncludeDirWidget,QObject::tr("C++ Includes"));
|
|
|
|
|
|
|
|
connect(ui->chkUseCustomCompilerParams, &QCheckBox::stateChanged,
|
|
|
|
ui->txtCustomCompileParams, &QPlainTextEdit::setEnabled);
|
|
|
|
connect(ui->chkUseCustomLinkParams, &QCheckBox::stateChanged,
|
|
|
|
ui->txtCustomLinkParams, &QPlainTextEdit::setEnabled);
|
2021-12-23 00:24:52 +08:00
|
|
|
|
2022-10-12 19:48:35 +08:00
|
|
|
updateIcons(pIconsManager->actionIconSize());
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
ui->txtExecutableSuffix->setReadOnly(true);
|
|
|
|
#endif
|
2022-12-13 15:58:27 +08:00
|
|
|
ui->settingTabs->setCurrentWidget(ui->tabGeneral);
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CompilerSetOptionWidget::~CompilerSetOptionWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2022-01-24 01:08:47 +08:00
|
|
|
void CompilerSetOptionWidget::init()
|
|
|
|
{
|
|
|
|
ui->cbEncodingDetails->setVisible(false);
|
|
|
|
ui->cbEncoding->clear();
|
|
|
|
ui->cbEncoding->addItem(tr("ANSI"),ENCODING_SYSTEM_DEFAULT);
|
|
|
|
ui->cbEncoding->addItem(tr("UTF-8"),ENCODING_UTF8);
|
|
|
|
foreach (const QString& langName, pCharsetInfoManager->languageNames()) {
|
|
|
|
ui->cbEncoding->addItem(langName,langName);
|
|
|
|
}
|
|
|
|
SettingsWidget::init();
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:17:22 +08:00
|
|
|
|
|
|
|
static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSetOptionWidget* ui) {
|
2023-08-13 14:46:53 +08:00
|
|
|
bool supportCharset = CompilerInfoManager::supportCovertingCharset(pSet->compilerType());
|
|
|
|
ui->chkAutoAddCharset->setEnabled(supportCharset);
|
|
|
|
ui->cbEncoding->setEnabled(supportCharset);
|
|
|
|
ui->cbEncodingDetails->setEnabled(supportCharset);
|
|
|
|
ui->panelCharset->setVisible(supportCharset);
|
|
|
|
ui->chkAutoAddCharset->setEnabled(supportCharset);
|
|
|
|
ui->chkAutoAddCharset->setVisible(supportCharset);
|
|
|
|
|
|
|
|
bool supportStaticLink = CompilerInfoManager::supportStaticLink(pSet->compilerType());
|
|
|
|
ui->chkStaticLink->setEnabled(supportStaticLink);
|
|
|
|
ui->chkStaticLink->setVisible(supportStaticLink);
|
2022-04-25 21:48:04 +08:00
|
|
|
|
2021-04-17 23:17:22 +08:00
|
|
|
ui->chkUseCustomCompilerParams->setChecked(pSet->useCustomCompileParams());
|
|
|
|
ui->txtCustomCompileParams->setPlainText(pSet->customCompileParams());
|
|
|
|
ui->txtCustomCompileParams->setEnabled(pSet->useCustomCompileParams());
|
|
|
|
ui->chkUseCustomLinkParams->setChecked(pSet->useCustomLinkParams());
|
|
|
|
ui->txtCustomLinkParams->setPlainText(pSet->customLinkParams());
|
|
|
|
ui->txtCustomLinkParams->setEnabled(pSet->useCustomLinkParams());
|
|
|
|
ui->chkAutoAddCharset->setChecked(pSet->autoAddCharsetParams());
|
2021-09-02 21:01:23 +08:00
|
|
|
ui->chkStaticLink->setChecked(pSet->staticLink());
|
2021-04-17 23:17:22 +08:00
|
|
|
//rest tabs in the options widget
|
2022-05-14 11:21:59 +08:00
|
|
|
|
|
|
|
ui->optionTabs->resetUI(pSet,pSet->compileOptions());
|
2021-04-17 23:17:22 +08:00
|
|
|
|
|
|
|
ui->txtCCompiler->setText(pSet->CCompiler());
|
|
|
|
ui->txtCppCompiler->setText(pSet->cppCompiler());
|
|
|
|
ui->txtMake->setText(pSet->make());
|
|
|
|
ui->txtDebugger->setText(pSet->debugger());
|
2021-12-25 18:09:50 +08:00
|
|
|
ui->txtGDBServer->setText(pSet->debugServer());
|
2021-04-17 23:17:22 +08:00
|
|
|
ui->txtResourceCompiler->setText(pSet->resourceCompiler());
|
2022-01-24 11:23:30 +08:00
|
|
|
|
|
|
|
if (pSet->execCharset() == ENCODING_AUTO_DETECT
|
|
|
|
|| pSet->execCharset() == ENCODING_SYSTEM_DEFAULT
|
|
|
|
|| pSet->execCharset() == ENCODING_UTF8) {
|
2022-03-12 17:37:53 +08:00
|
|
|
int index =ui->cbEncoding->findData(pSet->execCharset());
|
|
|
|
ui->cbEncoding->setCurrentIndex(index);
|
2022-01-24 11:23:30 +08:00
|
|
|
ui->cbEncodingDetails->clear();
|
|
|
|
ui->cbEncodingDetails->setVisible(false);
|
|
|
|
} else {
|
|
|
|
QString encoding = pSet->execCharset();
|
|
|
|
QString language = pCharsetInfoManager->findLanguageByCharsetName(encoding);
|
|
|
|
ui->cbEncoding->setCurrentText(language);
|
|
|
|
ui->cbEncodingDetails->setVisible(true);
|
|
|
|
ui->cbEncodingDetails->clear();
|
|
|
|
QList<PCharsetInfo> infos = pCharsetInfoManager->findCharsetsByLanguageName(language);
|
|
|
|
foreach (const PCharsetInfo& info, infos) {
|
|
|
|
ui->cbEncodingDetails->addItem(info->name);
|
|
|
|
}
|
|
|
|
ui->cbEncodingDetails->setCurrentText(encoding);
|
|
|
|
}
|
2022-10-12 19:48:35 +08:00
|
|
|
|
|
|
|
ui->txtPreprocessingSuffix->setText(pSet->preprocessingSuffix());
|
2023-03-13 22:00:55 +08:00
|
|
|
ui->txtCompilationSuffix->setText(pSet->compilationProperSuffix());
|
2022-10-12 19:48:35 +08:00
|
|
|
ui->txtExecutableSuffix->setText(pSet->executableSuffix());
|
|
|
|
switch(pSet->compilationStage()) {
|
|
|
|
case Settings::CompilerSet::CompilationStage::PreprocessingOnly:
|
|
|
|
ui->rbPreprocessingOnly->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Settings::CompilerSet::CompilationStage::CompilationProperOnly:
|
|
|
|
ui->rbCompilationProperOnly->setChecked(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ui->rbGenerateExecutable->setChecked(true);
|
|
|
|
}
|
2023-08-13 18:53:48 +08:00
|
|
|
#ifdef ENABLE_SDCC
|
|
|
|
bool isSDCC = (pSet->compilerType()==CompilerType::SDCC);
|
|
|
|
ui->grpCompilationStages->setVisible(!isSDCC);
|
|
|
|
ui->lbPreprocessingSuffix->setVisible(!isSDCC);
|
|
|
|
ui->txtPreprocessingSuffix->setVisible(!isSDCC);
|
|
|
|
ui->lbCompilingSuffix->setVisible(!isSDCC);
|
|
|
|
ui->txtCompilationSuffix->setVisible(!isSDCC);
|
|
|
|
ui->lbExecSuffix->setVisible(!isSDCC);
|
|
|
|
ui->txtExecutableSuffix->setVisible(!isSDCC);
|
|
|
|
ui->lbBinarySuffix->setVisible(isSDCC);
|
|
|
|
ui->cbBinarySuffix->setVisible(isSDCC);
|
|
|
|
if (isSDCC) {
|
|
|
|
ui->cbBinarySuffix->clear();
|
|
|
|
ui->cbBinarySuffix->addItem(SDCC_IHX_SUFFIX);
|
|
|
|
ui->cbBinarySuffix->addItem(SDCC_HEX_SUFFIX);
|
|
|
|
ui->cbBinarySuffix->addItem(SDCC_BIN_SUFFIX);
|
|
|
|
ui->cbBinarySuffix->setCurrentText(pSet->executableSuffix());
|
|
|
|
} else {
|
|
|
|
ui->txtExecutableSuffix->setText(pSet->executableSuffix());
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ui->grpCompilationStages->setVisible(true);
|
|
|
|
ui->lbPreprocessingSuffix->setVisible(true);
|
|
|
|
ui->txtPreprocessingSuffix->setVisible(true);
|
|
|
|
ui->lbCompilingSuffix->setVisible(true);
|
|
|
|
ui->txtCompilationSuffix->setVisible(true);
|
|
|
|
ui->lbExecSuffix->setVisible(true);
|
|
|
|
ui->txtExecutableSuffix->setVisible(true);
|
|
|
|
ui->lbBinarySuffix->setVisible(false);
|
|
|
|
ui->cbBinarySuffix->setVisible(false);
|
|
|
|
ui->txtExecutableSuffix->setText(pSet->executableSuffix());
|
|
|
|
#endif
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::doLoad()
|
|
|
|
{
|
2021-04-18 11:25:40 +08:00
|
|
|
disconnectInputs();
|
2021-04-17 23:17:22 +08:00
|
|
|
ui->cbCompilerSet->clear();
|
2022-03-11 20:51:33 +08:00
|
|
|
if (pSettings->compilerSets().size()<=0) {
|
2021-04-18 11:25:40 +08:00
|
|
|
ui->btnRenameCompilerSet->setEnabled(false);
|
|
|
|
ui->btnRemoveCompilerSet->setEnabled(false);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
ui->btnRenameCompilerSet->setEnabled(true);
|
|
|
|
ui->btnRemoveCompilerSet->setEnabled(true);
|
|
|
|
}
|
2021-04-17 23:17:22 +08:00
|
|
|
int index=pSettings->compilerSets().defaultIndex();
|
2022-07-04 11:39:06 +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-04-17 23:17:22 +08:00
|
|
|
}
|
2021-04-18 11:25:40 +08:00
|
|
|
if (index < 0 || index>=ui->cbCompilerSet->count()) {
|
|
|
|
index = 0;
|
|
|
|
}
|
2021-04-17 23:17:22 +08:00
|
|
|
ui->cbCompilerSet->setCurrentIndex(index);
|
2021-04-18 11:25:40 +08:00
|
|
|
reloadCurrentCompilerSet();
|
|
|
|
connectInputs();
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::doSave()
|
|
|
|
{
|
2022-03-11 20:51:33 +08:00
|
|
|
if (pSettings->compilerSets().size()>0) {
|
2021-04-18 11:25:40 +08:00
|
|
|
saveCurrentCompilerSet();
|
|
|
|
}
|
2023-10-15 16:28:55 +08:00
|
|
|
//update default index timestamp
|
|
|
|
pSettings->compilerSets().setDefaultIndex(pSettings->compilerSets().defaultIndex());
|
2021-04-17 23:17:22 +08:00
|
|
|
pSettings->compilerSets().saveSets();
|
2021-06-24 20:43:09 +08:00
|
|
|
pMainWindow->updateCompilerSet();
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_cbCompilerSet_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
if (index<0)
|
|
|
|
return;
|
2021-04-18 11:25:40 +08:00
|
|
|
setSettingsChanged();
|
2021-04-17 23:17:22 +08:00
|
|
|
pSettings->compilerSets().setDefaultIndex(index);
|
2021-04-18 11:25:40 +08:00
|
|
|
disconnectInputs();
|
2021-04-17 23:17:22 +08:00
|
|
|
reloadCurrentCompilerSet();
|
2021-04-18 11:25:40 +08:00
|
|
|
connectInputs();
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::reloadCurrentCompilerSet()
|
|
|
|
{
|
|
|
|
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
|
|
|
loadCompilerSetSettings(pSet, ui);
|
|
|
|
|
|
|
|
mBinDirWidget->setDirList(pSet->binDirs());
|
|
|
|
mLibDirWidget->setDirList(pSet->libDirs());
|
|
|
|
mCIncludeDirWidget->setDirList(pSet->CIncludeDirs());
|
|
|
|
mCppIncludeDirWidget->setDirList(pSet->CppIncludeDirs());
|
2021-04-18 11:25:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::saveCurrentCompilerSet()
|
|
|
|
{
|
|
|
|
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
|
|
|
|
|
|
|
pSet->setUseCustomCompileParams(ui->chkUseCustomCompilerParams->isChecked());
|
2021-04-20 22:24:33 +08:00
|
|
|
pSet->setCustomCompileParams(ui->txtCustomCompileParams->toPlainText().trimmed());
|
2021-04-18 11:25:40 +08:00
|
|
|
pSet->setUseCustomLinkParams(ui->chkUseCustomLinkParams->isChecked());
|
2021-04-20 22:24:33 +08:00
|
|
|
pSet->setCustomLinkParams(ui->txtCustomLinkParams->toPlainText().trimmed());
|
2021-04-18 11:25:40 +08:00
|
|
|
pSet->setAutoAddCharsetParams(ui->chkAutoAddCharset->isChecked());
|
2021-09-02 21:01:23 +08:00
|
|
|
pSet->setStaticLink(ui->chkStaticLink->isChecked());
|
2021-04-18 11:25:40 +08:00
|
|
|
|
2021-04-20 22:24:33 +08:00
|
|
|
pSet->setCCompiler(ui->txtCCompiler->text().trimmed());
|
|
|
|
pSet->setCppCompiler(ui->txtCppCompiler->text().trimmed());
|
|
|
|
pSet->setMake(ui->txtMake->text().trimmed());
|
|
|
|
pSet->setDebugger(ui->txtDebugger->text().trimmed());
|
2021-12-25 18:09:50 +08:00
|
|
|
pSet->setDebugServer(ui->txtGDBServer->text().trimmed());
|
2021-04-20 22:24:33 +08:00
|
|
|
pSet->setResourceCompiler(ui->txtResourceCompiler->text().trimmed());
|
2021-04-18 11:25:40 +08:00
|
|
|
|
|
|
|
pSet->binDirs()=mBinDirWidget->dirList();
|
|
|
|
|
|
|
|
pSet->libDirs()=mLibDirWidget->dirList();
|
|
|
|
pSet->CIncludeDirs()=mCIncludeDirWidget->dirList();
|
|
|
|
pSet->CppIncludeDirs()=mCppIncludeDirWidget->dirList();
|
|
|
|
|
2022-01-24 11:23:30 +08:00
|
|
|
if (ui->cbEncodingDetails->isVisible()) {
|
|
|
|
pSet->setExecCharset(ui->cbEncodingDetails->currentText());
|
|
|
|
} else {
|
2022-02-15 00:01:50 +08:00
|
|
|
pSet->setExecCharset(ui->cbEncoding->currentData().toString());
|
2022-01-24 11:23:30 +08:00
|
|
|
}
|
|
|
|
|
2021-04-18 11:25:40 +08:00
|
|
|
//read values in the options widget
|
2022-05-14 11:21:59 +08:00
|
|
|
pSet->setCompileOptions(ui->optionTabs->arguments(false));
|
|
|
|
|
2022-10-12 19:48:35 +08:00
|
|
|
if (ui->rbPreprocessingOnly->isChecked()) {
|
|
|
|
pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::PreprocessingOnly);
|
|
|
|
} else if (ui->rbCompilationProperOnly->isChecked()) {
|
|
|
|
pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::CompilationProperOnly);
|
|
|
|
} else if (ui->rbGenerateExecutable->isChecked()) {
|
|
|
|
pSet->setCompilationStage(Settings::CompilerSet::CompilationStage::GenerateExecutable);
|
|
|
|
}
|
|
|
|
pSet->setPreprocessingSuffix(ui->txtPreprocessingSuffix->text());
|
|
|
|
pSet->setCompilationProperSuffix(ui->txtCompilationSuffix->text());
|
2023-08-13 18:53:48 +08:00
|
|
|
#ifdef ENABLE_SDCC
|
|
|
|
if (pSet->compilerType()==CompilerType::SDCC) {
|
|
|
|
pSet->setExecutableSuffix(ui->cbBinarySuffix->currentText());
|
|
|
|
} else {
|
|
|
|
pSet->setExecutableSuffix(ui->txtExecutableSuffix->text());
|
|
|
|
}
|
|
|
|
#else
|
2022-10-12 19:48:35 +08:00
|
|
|
pSet->setExecutableSuffix(ui->txtExecutableSuffix->text());
|
2023-08-13 18:53:48 +08:00
|
|
|
#endif
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
2022-12-13 15:58:27 +08:00
|
|
|
QString CompilerSetOptionWidget::getBinDir()
|
|
|
|
{
|
|
|
|
Settings::PCompilerSet pSet = pSettings->compilerSets().defaultSet();
|
|
|
|
if (!pSet->binDirs().isEmpty())
|
|
|
|
return pSet->binDirs().front();
|
|
|
|
if (!mBinDirWidget->dirList().isEmpty())
|
|
|
|
return mBinDirWidget->dirList().front();
|
|
|
|
return QDir().absolutePath();
|
|
|
|
}
|
|
|
|
|
2023-01-19 23:58:56 +08:00
|
|
|
void CompilerSetOptionWidget::on_btnFindCompilers_clicked()
|
2021-04-17 23:17:22 +08:00
|
|
|
{
|
2022-01-06 20:46:27 +08:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
QString msg = tr("Red Panda C++ will clear current compiler list and search"
|
|
|
|
" for compilers in the following locations:<br /> '%1'<br /> '%2'<br />Are you really want to continue?")
|
2021-12-26 15:08:54 +08:00
|
|
|
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW32")
|
2022-01-06 20:46:27 +08:00
|
|
|
.arg(includeTrailingPathDelimiter(pSettings->dirs().appDir()) + "MinGW64");
|
|
|
|
#else
|
|
|
|
QString msg = tr("Red Panda C++ will clear current compiler list and search"
|
|
|
|
" for compilers in the the PATH. <br />Are you really want to continue?");
|
|
|
|
#endif
|
|
|
|
if (QMessageBox::warning(this,tr("Confirm"),msg,
|
2021-04-17 23:17:22 +08:00
|
|
|
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok )
|
|
|
|
return;
|
2023-08-06 00:05:58 +08:00
|
|
|
QProgressDialog progressDlg(
|
|
|
|
tr("Searching for compilers..."),
|
|
|
|
tr("Abort"),
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
pMainWindow);
|
|
|
|
|
|
|
|
progressDlg.setWindowModality(Qt::WindowModal);
|
|
|
|
progressDlg.setMaximum(3);
|
|
|
|
progressDlg.setLabelText(tr("Searching..."));
|
2021-04-17 23:17:22 +08:00
|
|
|
pSettings->compilerSets().clearSets();
|
2023-08-06 00:05:58 +08:00
|
|
|
progressDlg.setValue(1);
|
2021-04-17 23:17:22 +08:00
|
|
|
pSettings->compilerSets().findSets();
|
2023-08-06 00:05:58 +08:00
|
|
|
progressDlg.setValue(2);
|
2021-04-17 23:17:22 +08:00
|
|
|
doLoad();
|
2023-08-06 00:05:58 +08:00
|
|
|
progressDlg.setValue(3);
|
2021-06-24 20:43:09 +08:00
|
|
|
setSettingsChanged();
|
2021-06-24 16:05:19 +08:00
|
|
|
if (pSettings->compilerSets().size()==0) {
|
|
|
|
QMessageBox::warning(this,tr("Failed"),tr("Can't find any compiler."));
|
|
|
|
}
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
2023-01-19 23:58:56 +08:00
|
|
|
void CompilerSetOptionWidget::on_btnAddBlankCompilerSet_clicked()
|
2021-04-17 23:17:22 +08:00
|
|
|
{
|
|
|
|
QString name = QInputDialog::getText(this,tr("Compiler Set Name"),tr("Name"));
|
|
|
|
pSettings->compilerSets().addSet();
|
2022-03-11 20:51:33 +08:00
|
|
|
pSettings->compilerSets().setDefaultIndex(pSettings->compilerSets().size()-1);
|
2021-04-17 23:17:22 +08:00
|
|
|
pSettings->compilerSets().defaultSet()->setName(name);
|
|
|
|
doLoad();
|
|
|
|
}
|
|
|
|
|
2023-01-19 23:58:56 +08:00
|
|
|
void CompilerSetOptionWidget::on_btnAddCompilerSetByFolder_clicked()
|
2021-04-17 23:17:22 +08:00
|
|
|
{
|
|
|
|
QString folder = QFileDialog::getExistingDirectory(this, tr("Compiler Set Folder"));
|
2021-06-24 16:05:19 +08:00
|
|
|
int oldSize = pSettings->compilerSets().size();
|
|
|
|
|
2021-12-25 18:09:50 +08:00
|
|
|
if (!pSettings->compilerSets().addSets(folder)) {
|
|
|
|
pSettings->compilerSets().addSets(folder+QDir::separator()+"bin");
|
|
|
|
}
|
2021-04-17 23:17:22 +08:00
|
|
|
doLoad();
|
2021-06-24 16:05:19 +08:00
|
|
|
int newSize = pSettings->compilerSets().size();
|
|
|
|
if (oldSize == newSize) {
|
|
|
|
QMessageBox::warning(this,tr("Failed"),tr("Can't find any compiler."));
|
|
|
|
}
|
2021-04-17 23:17:22 +08:00
|
|
|
}
|
|
|
|
|
2023-01-19 23:58:56 +08:00
|
|
|
void CompilerSetOptionWidget::on_btnRenameCompilerSet_clicked()
|
2021-04-17 23:17:22 +08:00
|
|
|
{
|
2023-01-20 00:08:16 +08:00
|
|
|
Settings::PCompilerSet set=pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
|
|
|
|
if (!set)
|
|
|
|
return;
|
2021-04-18 11:25:40 +08:00
|
|
|
QString name = QInputDialog::getText(this,tr("Compiler Set Name"),tr("New name"),QLineEdit::Normal,
|
2023-01-20 00:08:16 +08:00
|
|
|
set->name());
|
2021-04-17 23:17:22 +08:00
|
|
|
if (!name.isEmpty())
|
2023-01-20 00:08:16 +08:00
|
|
|
set->setName(name);
|
2021-04-17 23:17:22 +08:00
|
|
|
doLoad();
|
|
|
|
}
|
2021-04-18 11:25:40 +08:00
|
|
|
|
2023-01-19 23:58:56 +08:00
|
|
|
void CompilerSetOptionWidget::on_btnRemoveCompilerSet_clicked()
|
2021-04-18 11:25:40 +08:00
|
|
|
{
|
2023-01-20 00:08:16 +08:00
|
|
|
Settings::PCompilerSet set=pSettings->compilerSets().getSet(ui->cbCompilerSet->currentIndex());
|
|
|
|
if (!set)
|
|
|
|
return;
|
|
|
|
if (QMessageBox::question(this,
|
|
|
|
QObject::tr("Remove"),
|
|
|
|
QString(QObject::tr("Do you really want to remove \"%1\"?")).arg(set->name()),
|
|
|
|
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel)==QMessageBox::Yes) {
|
|
|
|
|
|
|
|
pSettings->compilerSets().deleteSet(ui->cbCompilerSet->currentIndex());
|
|
|
|
doLoad();
|
|
|
|
}
|
2021-04-18 11:25:40 +08:00
|
|
|
}
|
2021-12-23 00:24:52 +08:00
|
|
|
|
2022-10-12 19:48:35 +08:00
|
|
|
void CompilerSetOptionWidget::updateIcons(const QSize& /*size*/)
|
2021-12-23 00:24:52 +08:00
|
|
|
{
|
|
|
|
pIconsManager->setIcon(ui->btnFindCompilers, IconsManager::ACTION_EDIT_SEARCH);
|
2021-12-23 09:11:58 +08:00
|
|
|
pIconsManager->setIcon(ui->btnAddCompilerSetByFolder, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
2021-12-23 00:24:52 +08:00
|
|
|
pIconsManager->setIcon(ui->btnAddBlankCompilerSet, IconsManager::ACTION_MISC_ADD);
|
|
|
|
pIconsManager->setIcon(ui->btnRemoveCompilerSet, IconsManager::ACTION_MISC_REMOVE);
|
|
|
|
pIconsManager->setIcon(ui->btnRenameCompilerSet, IconsManager::ACTION_MISC_RENAME);
|
|
|
|
|
2021-12-25 18:09:50 +08:00
|
|
|
pIconsManager->setIcon(ui->btnChooseCCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnChooseCppCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnChooseGDB, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnChooseGDBServer, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnChooseMake, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnChooseResourceCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
2021-12-23 00:24:52 +08:00
|
|
|
}
|
2022-01-24 11:23:30 +08:00
|
|
|
|
2022-07-04 11:39:06 +08:00
|
|
|
void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/)
|
2022-01-24 11:23:30 +08:00
|
|
|
{
|
|
|
|
QString userData = ui->cbEncoding->currentData().toString();
|
|
|
|
if (userData == ENCODING_AUTO_DETECT
|
|
|
|
|| userData == ENCODING_SYSTEM_DEFAULT
|
|
|
|
|| userData == ENCODING_UTF8) {
|
|
|
|
ui->cbEncodingDetails->setVisible(false);
|
|
|
|
ui->cbEncodingDetails->clear();
|
|
|
|
} else {
|
|
|
|
ui->cbEncodingDetails->setVisible(true);
|
|
|
|
ui->cbEncodingDetails->clear();
|
|
|
|
QList<PCharsetInfo> infos = pCharsetInfoManager->findCharsetsByLanguageName(userData);
|
|
|
|
foreach (const PCharsetInfo& info, infos) {
|
|
|
|
ui->cbEncodingDetails->addItem(info->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-04 11:39:06 +08:00
|
|
|
void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QString &/*arg1*/)
|
2022-01-24 11:23:30 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-12-13 15:58:27 +08:00
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseCCompiler_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate C Compiler"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtCCompiler->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseCppCompiler_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate C++ Compiler"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtCppCompiler->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseMake_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate Make"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtMake->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseGDB_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate GDB"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtDebugger->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseGDBServer_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate GDB Server"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtGDBServer->setText(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CompilerSetOptionWidget::on_btnChooseResourceCompiler_clicked()
|
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Locate windres"),
|
|
|
|
getBinDir(),
|
|
|
|
tr("Executable files (*.exe)"));
|
|
|
|
if (fileExists(fileName))
|
|
|
|
ui->txtResourceCompiler->setText(fileName);
|
|
|
|
}
|
|
|
|
|