2016-02-26 17:50:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-03-02 07:07:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2016-02-26 17:50:38 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-03-02 07:07:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2016-02-26 17:50:38 +01:00
|
|
|
**
|
2016-03-02 07:07:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2016-02-26 17:50:38 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "clangprojectsettingswidget.h"
|
|
|
|
|
|
2018-01-22 16:31:05 +01:00
|
|
|
#include "clangmodelmanagersupport.h"
|
2016-02-26 17:50:38 +01:00
|
|
|
#include "clangprojectsettings.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <cpptools/clangdiagnosticconfig.h>
|
|
|
|
|
#include <cpptools/clangdiagnosticconfigswidget.h>
|
|
|
|
|
#include <cpptools/cppcodemodelsettings.h>
|
|
|
|
|
#include <cpptools/cpptoolsreuse.h>
|
|
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2016-02-26 17:50:38 +01:00
|
|
|
|
|
|
|
|
namespace ClangCodeModel {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
static Core::Id configIdForProject(ClangProjectSettings &projectSettings)
|
2016-02-26 17:50:38 +01:00
|
|
|
{
|
2017-05-23 09:49:22 +02:00
|
|
|
if (projectSettings.useGlobalConfig())
|
|
|
|
|
return CppTools::codeModelSettings()->clangDiagnosticConfigId();
|
|
|
|
|
Core::Id configId = projectSettings.warningConfigId();
|
|
|
|
|
if (!configId.isValid()) {
|
|
|
|
|
configId = CppTools::codeModelSettings()->clangDiagnosticConfigId();
|
|
|
|
|
projectSettings.setWarningConfigId(configId);
|
|
|
|
|
}
|
|
|
|
|
return configId;
|
2016-02-26 17:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClangProjectSettingsWidget::ClangProjectSettingsWidget(ProjectExplorer::Project *project)
|
2018-01-22 16:31:05 +01:00
|
|
|
: m_projectSettings(ModelManagerSupportClang::instance()->projectSettings(project))
|
2016-02-26 17:50:38 +01:00
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
|
|
using namespace CppTools;
|
|
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
m_ui.generalConfigurationGroupBox->setVisible(Utils::HostOsInfo::isWindowsHost());
|
|
|
|
|
|
|
|
|
|
m_ui.clangSettings->setCurrentIndex(m_projectSettings.useGlobalConfig() ? 0 : 1);
|
|
|
|
|
|
2018-05-04 15:58:41 +02:00
|
|
|
connect(m_ui.clangDiagnosticConfigsSelectionWidget,
|
|
|
|
|
&ClangDiagnosticConfigsSelectionWidget::currentConfigChanged,
|
2016-02-26 17:50:38 +01:00
|
|
|
this, &ClangProjectSettingsWidget::onCurrentWarningConfigChanged);
|
2018-05-04 15:58:41 +02:00
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
connect(m_ui.delayedTemplateParse, &QCheckBox::toggled,
|
|
|
|
|
this, &ClangProjectSettingsWidget::onDelayedTemplateParseClicked);
|
|
|
|
|
connect(m_ui.clangSettings,
|
|
|
|
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &ClangProjectSettingsWidget::onClangSettingsChanged);
|
2018-01-22 16:01:09 +01:00
|
|
|
connect(project, &ProjectExplorer::Project::aboutToSaveSettings,
|
|
|
|
|
this, &ClangProjectSettingsWidget::onAboutToSaveProjectSettings);
|
2016-02-26 17:50:38 +01:00
|
|
|
|
2018-05-04 15:58:41 +02:00
|
|
|
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
|
|
|
|
this, &ClangProjectSettingsWidget::syncOtherWidgetsToComboBox);
|
|
|
|
|
|
|
|
|
|
connectToClangDiagnosticConfigsDialog(m_ui.manageButton);
|
|
|
|
|
|
|
|
|
|
syncOtherWidgetsToComboBox();
|
2016-02-26 17:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangProjectSettingsWidget::onCurrentWarningConfigChanged(const Core::Id ¤tConfigId)
|
|
|
|
|
{
|
2017-05-23 09:49:22 +02:00
|
|
|
// Don't save it when we reset the global config in code
|
|
|
|
|
if (m_projectSettings.useGlobalConfig())
|
|
|
|
|
return;
|
2016-02-26 17:50:38 +01:00
|
|
|
m_projectSettings.setWarningConfigId(currentConfigId);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
void ClangProjectSettingsWidget::onDelayedTemplateParseClicked(bool checked)
|
|
|
|
|
{
|
|
|
|
|
// Don't save it when we reset the global config in code
|
|
|
|
|
if (m_projectSettings.useGlobalConfig())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const QLatin1String extraFlag{checked ? ClangProjectSettings::DelayedTemplateParsing
|
|
|
|
|
: ClangProjectSettings::NoDelayedTemplateParsing};
|
|
|
|
|
QStringList options = m_projectSettings.commandLineOptions();
|
|
|
|
|
options.removeAll(QLatin1String{ClangProjectSettings::DelayedTemplateParsing});
|
|
|
|
|
options.removeAll(QLatin1String{ClangProjectSettings::NoDelayedTemplateParsing});
|
|
|
|
|
options.append(extraFlag);
|
|
|
|
|
m_projectSettings.setCommandLineOptions(options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ClangProjectSettingsWidget::onClangSettingsChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings.setUseGlobalConfig(index == 0 ? true : false);
|
|
|
|
|
syncOtherWidgetsToComboBox();
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 16:01:09 +01:00
|
|
|
void ClangProjectSettingsWidget::onAboutToSaveProjectSettings()
|
|
|
|
|
{
|
|
|
|
|
CppTools::codeModelSettings()->toSettings(Core::ICore::settings());
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 09:49:22 +02:00
|
|
|
void ClangProjectSettingsWidget::syncOtherWidgetsToComboBox()
|
|
|
|
|
{
|
|
|
|
|
const QStringList options = m_projectSettings.commandLineOptions();
|
|
|
|
|
m_ui.delayedTemplateParse->setChecked(
|
|
|
|
|
options.contains(QLatin1String{ClangProjectSettings::DelayedTemplateParsing}));
|
|
|
|
|
|
|
|
|
|
const bool isCustom = !m_projectSettings.useGlobalConfig();
|
|
|
|
|
m_ui.generalConfigurationGroupBox->setEnabled(isCustom);
|
2018-05-04 15:58:41 +02:00
|
|
|
m_ui.clangDiagnosticsLabel->setEnabled(isCustom);
|
|
|
|
|
m_ui.clangDiagnosticConfigsSelectionWidget->setEnabled(isCustom);
|
2017-05-23 09:49:22 +02:00
|
|
|
|
|
|
|
|
refreshDiagnosticConfigsWidgetFromSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-26 17:50:38 +01:00
|
|
|
void ClangProjectSettingsWidget::refreshDiagnosticConfigsWidgetFromSettings()
|
|
|
|
|
{
|
2018-05-04 15:58:41 +02:00
|
|
|
m_ui.clangDiagnosticConfigsSelectionWidget->refresh(configIdForProject(m_projectSettings));
|
2016-02-26 17:50:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ClangCodeModel
|