forked from qt-creator/qt-creator
Clang: Add option 'Build before analysis' to project settings
Diagnostic configuration Id was already there but not the checkbox whether to build project or not. Change-Id: Icb5fc15bda5eed5e375cd90df1a96060b30bf57e Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -71,7 +71,7 @@
|
|||||||
\image qtcreator-files-to-analyze.png
|
\image qtcreator-files-to-analyze.png
|
||||||
|
|
||||||
\li In the \uicontrol {Diagnostic Configuration} group, select
|
\li In the \uicontrol {Diagnostic Configuration} group, select
|
||||||
\uicontrol Custom, and then select \uicontrol Manage to
|
\uicontrol {Custom Settings}, and then select \uicontrol Manage to
|
||||||
specify the Clang-Tidy and Clazy checks to perform.
|
specify the Clang-Tidy and Clazy checks to perform.
|
||||||
|
|
||||||
\li Select the new custom configuration in the list of configurations
|
\li Select the new custom configuration in the list of configurations
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "clangselectablefilesdialog.h"
|
#include "clangselectablefilesdialog.h"
|
||||||
#include "ui_clangselectablefilesdialog.h"
|
#include "ui_clangselectablefilesdialog.h"
|
||||||
|
#include "ui_clangtoolsbasicsettings.h"
|
||||||
|
|
||||||
#include "clangtoolsprojectsettings.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
#include "clangtoolssettings.h"
|
#include "clangtoolssettings.h"
|
||||||
@@ -291,39 +292,54 @@ SelectableFilesDialog::SelectableFilesDialog(const ProjectInfo &projectInfo,
|
|||||||
m_ui->buttons->setStandardButtons(QDialogButtonBox::Cancel);
|
m_ui->buttons->setStandardButtons(QDialogButtonBox::Cancel);
|
||||||
m_ui->buttons->addButton(m_analyzeButton, QDialogButtonBox::AcceptRole);
|
m_ui->buttons->addButton(m_analyzeButton, QDialogButtonBox::AcceptRole);
|
||||||
|
|
||||||
m_ui->diagnosticConfigsSelectionWidget->showLabel(false);
|
CppTools::ClangDiagnosticConfigsSelectionWidget *diagnosticConfigsSelectionWidget
|
||||||
|
= m_ui->clangToolsBasicSettings->ui()->clangDiagnosticConfigsSelectionWidget;
|
||||||
|
QCheckBox *buildBeforeAnalysis = m_ui->clangToolsBasicSettings->ui()->buildBeforeAnalysis;
|
||||||
|
|
||||||
ClangToolsProjectSettings *settings = ClangToolsProjectSettingsManager::getSettings(m_project);
|
ClangToolsProjectSettings *settings = ClangToolsProjectSettingsManager::getSettings(m_project);
|
||||||
m_customDiagnosticConfig = diagnosticConfiguration(settings);
|
m_customDiagnosticConfig = diagnosticConfiguration(settings);
|
||||||
|
m_buildBeforeAnalysis = settings->buildBeforeAnalysis();
|
||||||
|
|
||||||
if (settings->useGlobalSettings()) {
|
if (settings->useGlobalSettings()) {
|
||||||
m_ui->globalOrCustom->setCurrentIndex(GlobalSettings);
|
m_ui->globalOrCustom->setCurrentIndex(GlobalSettings);
|
||||||
m_ui->diagnosticConfigsSelectionWidget->setEnabled(false);
|
m_ui->clangToolsBasicSettings->setEnabled(false);
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(
|
diagnosticConfigsSelectionWidget->refresh(
|
||||||
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
||||||
|
buildBeforeAnalysis->setCheckState(
|
||||||
|
ClangToolsSettings::instance()->savedBuildBeforeAnalysis()
|
||||||
|
? Qt::Checked : Qt::Unchecked);
|
||||||
} else {
|
} else {
|
||||||
m_ui->globalOrCustom->setCurrentIndex(CustomSettings);
|
m_ui->globalOrCustom->setCurrentIndex(CustomSettings);
|
||||||
m_ui->diagnosticConfigsSelectionWidget->setEnabled(true);
|
m_ui->clangToolsBasicSettings->setEnabled(true);
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
||||||
|
buildBeforeAnalysis->setCheckState(m_buildBeforeAnalysis ? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_ui->globalOrCustom,
|
connect(m_ui->globalOrCustom,
|
||||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
[this](int index){
|
[=](int index){
|
||||||
m_ui->diagnosticConfigsSelectionWidget->setEnabled(index == CustomSettings);
|
m_ui->clangToolsBasicSettings->setEnabled(index == CustomSettings);
|
||||||
if (index == CustomSettings) {
|
if (index == CustomSettings) {
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
||||||
|
buildBeforeAnalysis->setCheckState(m_buildBeforeAnalysis ? Qt::Checked : Qt::Unchecked);
|
||||||
} else {
|
} else {
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(
|
diagnosticConfigsSelectionWidget->refresh(
|
||||||
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
||||||
|
buildBeforeAnalysis->setCheckState(
|
||||||
|
ClangToolsSettings::instance()->savedBuildBeforeAnalysis()
|
||||||
|
? Qt::Checked : Qt::Unchecked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(m_ui->diagnosticConfigsSelectionWidget,
|
connect(diagnosticConfigsSelectionWidget,
|
||||||
&ClangDiagnosticConfigsSelectionWidget::currentConfigChanged,
|
&ClangDiagnosticConfigsSelectionWidget::currentConfigChanged,
|
||||||
[this](const Core::Id ¤tConfigId) {
|
[this](const Core::Id ¤tConfigId) {
|
||||||
if (m_ui->globalOrCustom->currentIndex() == CustomSettings)
|
if (m_ui->globalOrCustom->currentIndex() == CustomSettings)
|
||||||
m_customDiagnosticConfig = currentConfigId;
|
m_customDiagnosticConfig = currentConfigId;
|
||||||
});
|
});
|
||||||
|
connect(buildBeforeAnalysis, &QCheckBox::toggled, [this](bool checked) {
|
||||||
|
if (m_ui->globalOrCustom->currentIndex() == CustomSettings)
|
||||||
|
m_buildBeforeAnalysis = checked;
|
||||||
|
});
|
||||||
|
|
||||||
// Restore selection
|
// Restore selection
|
||||||
if (settings->selectedDirs().isEmpty() && settings->selectedFiles().isEmpty())
|
if (settings->selectedDirs().isEmpty() && settings->selectedFiles().isEmpty())
|
||||||
@@ -339,9 +355,9 @@ SelectableFilesDialog::SelectableFilesDialog(const ProjectInfo &projectInfo,
|
|||||||
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
||||||
this, [=]() {
|
this, [=]() {
|
||||||
if (m_ui->globalOrCustom->currentIndex() == CustomSettings) {
|
if (m_ui->globalOrCustom->currentIndex() == CustomSettings) {
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
diagnosticConfigsSelectionWidget->refresh(m_customDiagnosticConfig);
|
||||||
} else {
|
} else {
|
||||||
m_ui->diagnosticConfigsSelectionWidget->refresh(
|
diagnosticConfigsSelectionWidget->refresh(
|
||||||
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
ClangToolsSettings::instance()->savedDiagnosticConfigId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -358,9 +374,10 @@ void SelectableFilesDialog::accept()
|
|||||||
{
|
{
|
||||||
ClangToolsProjectSettings *settings = ClangToolsProjectSettingsManager::getSettings(m_project);
|
ClangToolsProjectSettings *settings = ClangToolsProjectSettingsManager::getSettings(m_project);
|
||||||
|
|
||||||
// Save diagnostic configuration
|
// Save diagnostic configuration and flag to build before analysis
|
||||||
settings->setUseGlobalSettings(m_ui->globalOrCustom->currentIndex() == GlobalSettings);
|
settings->setUseGlobalSettings(m_ui->globalOrCustom->currentIndex() == GlobalSettings);
|
||||||
settings->setDiagnosticConfig(m_customDiagnosticConfig);
|
settings->setDiagnosticConfig(m_customDiagnosticConfig);
|
||||||
|
settings->setBuildBeforeAnalysis(m_buildBeforeAnalysis);
|
||||||
|
|
||||||
// Save selection
|
// Save selection
|
||||||
QSet<FileName> checkedDirs;
|
QSet<FileName> checkedDirs;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ private:
|
|||||||
Core::Id m_customDiagnosticConfig;
|
Core::Id m_customDiagnosticConfig;
|
||||||
ProjectExplorer::Project *m_project;
|
ProjectExplorer::Project *m_project;
|
||||||
QPushButton *m_analyzeButton = nullptr;
|
QPushButton *m_analyzeButton = nullptr;
|
||||||
|
bool m_buildBeforeAnalysis = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -15,33 +15,44 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Diagnostic Configuration</string>
|
<string>General</string>
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="globalOrCustom">
|
<widget class="QComboBox" name="globalOrCustom">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Global</string>
|
<string>Global Settings</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Custom</string>
|
<string>Custom Settings</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="CppTools::ClangDiagnosticConfigsSelectionWidget" name="diagnosticConfigsSelectionWidget" native="true"/>
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="ClangTools::ClangToolsBasicSettings" name="clangToolsBasicSettings" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -76,9 +87,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CppTools::ClangDiagnosticConfigsSelectionWidget</class>
|
<class>ClangTools::ClangToolsBasicSettings</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>cpptools/clangdiagnosticconfigsselectionwidget.h</header>
|
<header>clangtools/clangtoolsbasicsettings.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "clangtool.h"
|
#include "clangtool.h"
|
||||||
#include "clangtoolslogfilereader.h"
|
#include "clangtoolslogfilereader.h"
|
||||||
|
#include "clangtoolsprojectsettings.h"
|
||||||
#include "clangtoolssettings.h"
|
#include "clangtoolssettings.h"
|
||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
#include "clangtoolrunner.h"
|
#include "clangtoolrunner.h"
|
||||||
@@ -237,12 +238,12 @@ ClangToolRunControl::ClangToolRunControl(RunControl *runControl,
|
|||||||
{
|
{
|
||||||
addStartDependency(m_projectBuilder);
|
addStartDependency(m_projectBuilder);
|
||||||
|
|
||||||
auto *settings = ClangToolsSettings::instance();
|
ClangToolsProjectSettings *projectSettings = ClangToolsProjectSettingsManager::getSettings(
|
||||||
m_projectBuilder->setEnabled(settings->savedBuildBeforeAnalysis());
|
target->project());
|
||||||
|
if (projectSettings->useGlobalSettings())
|
||||||
connect(settings, &ClangToolsSettings::buildBeforeAnalysisChanged, this, [this](bool checked) {
|
m_projectBuilder->setEnabled(ClangToolsSettings::instance()->savedBuildBeforeAnalysis());
|
||||||
m_projectBuilder->setEnabled(checked);
|
else
|
||||||
});
|
m_projectBuilder->setEnabled(projectSettings->buildBeforeAnalysis());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangToolRunControl::init()
|
void ClangToolRunControl::init()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ SOURCES += \
|
|||||||
clangtool.cpp \
|
clangtool.cpp \
|
||||||
clangtoolruncontrol.cpp \
|
clangtoolruncontrol.cpp \
|
||||||
clangtoolrunner.cpp \
|
clangtoolrunner.cpp \
|
||||||
|
clangtoolsbasicsettings.cpp \
|
||||||
clangtoolsdiagnostic.cpp \
|
clangtoolsdiagnostic.cpp \
|
||||||
clangtoolsdiagnosticmodel.cpp \
|
clangtoolsdiagnosticmodel.cpp \
|
||||||
clangtoolslogfilereader.cpp \
|
clangtoolslogfilereader.cpp \
|
||||||
@@ -41,6 +42,7 @@ HEADERS += \
|
|||||||
clangtoolruncontrol.h \
|
clangtoolruncontrol.h \
|
||||||
clangtoolrunner.h \
|
clangtoolrunner.h \
|
||||||
clangtools_global.h \
|
clangtools_global.h \
|
||||||
|
clangtoolsbasicsettings.h \
|
||||||
clangtoolsconstants.h \
|
clangtoolsconstants.h \
|
||||||
clangtoolsdiagnostic.h \
|
clangtoolsdiagnostic.h \
|
||||||
clangtoolsdiagnosticmodel.h \
|
clangtoolsdiagnosticmodel.h \
|
||||||
@@ -54,7 +56,8 @@ HEADERS += \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
clangtoolsprojectsettingswidget.ui \
|
clangtoolsprojectsettingswidget.ui \
|
||||||
clangtoolsconfigwidget.ui \
|
clangtoolsconfigwidget.ui \
|
||||||
clangselectablefilesdialog.ui
|
clangselectablefilesdialog.ui \
|
||||||
|
clangtoolsbasicsettings.ui
|
||||||
|
|
||||||
equals(TEST, 1) {
|
equals(TEST, 1) {
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
|||||||
@@ -48,11 +48,6 @@ QtcPlugin {
|
|||||||
"clangselectablefilesdialog.cpp",
|
"clangselectablefilesdialog.cpp",
|
||||||
"clangselectablefilesdialog.h",
|
"clangselectablefilesdialog.h",
|
||||||
"clangselectablefilesdialog.ui",
|
"clangselectablefilesdialog.ui",
|
||||||
"clangtoolsdiagnosticview.cpp",
|
|
||||||
"clangtoolsdiagnosticview.h",
|
|
||||||
"clangtoolsprojectsettingswidget.cpp",
|
|
||||||
"clangtoolsprojectsettingswidget.h",
|
|
||||||
"clangtoolsprojectsettingswidget.ui",
|
|
||||||
"clangtidyclazyruncontrol.cpp",
|
"clangtidyclazyruncontrol.cpp",
|
||||||
"clangtidyclazyruncontrol.h",
|
"clangtidyclazyruncontrol.h",
|
||||||
"clangtidyclazyrunner.cpp",
|
"clangtidyclazyrunner.cpp",
|
||||||
@@ -66,6 +61,9 @@ QtcPlugin {
|
|||||||
"clangtoolrunner.cpp",
|
"clangtoolrunner.cpp",
|
||||||
"clangtoolrunner.h",
|
"clangtoolrunner.h",
|
||||||
"clangtools_global.h",
|
"clangtools_global.h",
|
||||||
|
"clangtoolsbasicsettings.cpp",
|
||||||
|
"clangtoolsbasicsettings.h",
|
||||||
|
"clangtoolsbasicsettings.ui",
|
||||||
"clangtoolsconfigwidget.cpp",
|
"clangtoolsconfigwidget.cpp",
|
||||||
"clangtoolsconfigwidget.h",
|
"clangtoolsconfigwidget.h",
|
||||||
"clangtoolsconfigwidget.ui",
|
"clangtoolsconfigwidget.ui",
|
||||||
@@ -74,10 +72,15 @@ QtcPlugin {
|
|||||||
"clangtoolsdiagnostic.h",
|
"clangtoolsdiagnostic.h",
|
||||||
"clangtoolsdiagnosticmodel.cpp",
|
"clangtoolsdiagnosticmodel.cpp",
|
||||||
"clangtoolsdiagnosticmodel.h",
|
"clangtoolsdiagnosticmodel.h",
|
||||||
|
"clangtoolsdiagnosticview.cpp",
|
||||||
|
"clangtoolsdiagnosticview.h",
|
||||||
"clangtoolslogfilereader.cpp",
|
"clangtoolslogfilereader.cpp",
|
||||||
"clangtoolslogfilereader.h",
|
"clangtoolslogfilereader.h",
|
||||||
"clangtoolsprojectsettings.cpp",
|
"clangtoolsprojectsettings.cpp",
|
||||||
"clangtoolsprojectsettings.h",
|
"clangtoolsprojectsettings.h",
|
||||||
|
"clangtoolsprojectsettingswidget.cpp",
|
||||||
|
"clangtoolsprojectsettingswidget.h",
|
||||||
|
"clangtoolsprojectsettingswidget.ui",
|
||||||
"clangtoolssettings.cpp",
|
"clangtoolssettings.cpp",
|
||||||
"clangtoolssettings.h",
|
"clangtoolssettings.h",
|
||||||
"clangtoolsutils.cpp",
|
"clangtoolsutils.cpp",
|
||||||
|
|||||||
50
src/plugins/clangtools/clangtoolsbasicsettings.cpp
Normal file
50
src/plugins/clangtools/clangtoolsbasicsettings.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2018 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "clangtoolsbasicsettings.h"
|
||||||
|
#include "ui_clangtoolsbasicsettings.h"
|
||||||
|
|
||||||
|
#include "clangtoolsutils.h"
|
||||||
|
|
||||||
|
namespace ClangTools {
|
||||||
|
|
||||||
|
ClangToolsBasicSettings::ClangToolsBasicSettings(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_ui(new Ui::ClangToolsBasicSettings)
|
||||||
|
{
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClangToolsBasicSettings::~ClangToolsBasicSettings()
|
||||||
|
{
|
||||||
|
delete m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ui::ClangToolsBasicSettings *ClangToolsBasicSettings::ui()
|
||||||
|
{
|
||||||
|
return m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ClangTools
|
||||||
49
src/plugins/clangtools/clangtoolsbasicsettings.h
Normal file
49
src/plugins/clangtools/clangtoolsbasicsettings.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** 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
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
** 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.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace ClangTools {
|
||||||
|
|
||||||
|
namespace Ui { class ClangToolsBasicSettings; }
|
||||||
|
|
||||||
|
class ClangExecutableVersion;
|
||||||
|
|
||||||
|
class ClangToolsBasicSettings : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ClangToolsBasicSettings(QWidget *parent = 0);
|
||||||
|
~ClangToolsBasicSettings();
|
||||||
|
|
||||||
|
Ui::ClangToolsBasicSettings *ui();
|
||||||
|
private:
|
||||||
|
Ui::ClangToolsBasicSettings *m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ClangTools
|
||||||
50
src/plugins/clangtools/clangtoolsbasicsettings.ui
Normal file
50
src/plugins/clangtools/clangtoolsbasicsettings.ui
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ClangTools::ClangToolsBasicSettings</class>
|
||||||
|
<widget class="QWidget" name="ClangTools::ClangToolsBasicSettings">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="buildBeforeAnalysis">
|
||||||
|
<property name="text">
|
||||||
|
<string>Build the project before analysis</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="CppTools::ClangDiagnosticConfigsSelectionWidget" name="clangDiagnosticConfigsSelectionWidget" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>CppTools::ClangDiagnosticConfigsSelectionWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>cpptools/clangdiagnosticconfigsselectionwidget.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "clangtoolsconfigwidget.h"
|
#include "clangtoolsconfigwidget.h"
|
||||||
|
#include "ui_clangtoolsbasicsettings.h"
|
||||||
#include "ui_clangtoolsconfigwidget.h"
|
#include "ui_clangtoolsconfigwidget.h"
|
||||||
|
|
||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
@@ -54,24 +55,27 @@ ClangToolsConfigWidget::ClangToolsConfigWidget(
|
|||||||
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||||
[settings](int count) { settings->setSimultaneousProcesses(count); });
|
[settings](int count) { settings->setSimultaneousProcesses(count); });
|
||||||
|
|
||||||
m_ui->buildBeforeAnalysis->setCheckState(settings->savedBuildBeforeAnalysis()
|
QCheckBox *buildBeforeAnalysis = m_ui->clangToolsBasicSettings->ui()->buildBeforeAnalysis;
|
||||||
|
buildBeforeAnalysis->setCheckState(settings->savedBuildBeforeAnalysis()
|
||||||
? Qt::Checked : Qt::Unchecked);
|
? Qt::Checked : Qt::Unchecked);
|
||||||
connect(m_ui->buildBeforeAnalysis, &QCheckBox::toggled, [settings](bool checked) {
|
connect(buildBeforeAnalysis, &QCheckBox::toggled, [settings](bool checked) {
|
||||||
settings->setBuildBeforeAnalysis(checked);
|
settings->setBuildBeforeAnalysis(checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
m_ui->clangDiagnosticConfigsSelectionWidget->refresh(settings->savedDiagnosticConfigId());
|
CppTools::ClangDiagnosticConfigsSelectionWidget *clangDiagnosticConfigsSelectionWidget
|
||||||
|
= m_ui->clangToolsBasicSettings->ui()->clangDiagnosticConfigsSelectionWidget;
|
||||||
|
clangDiagnosticConfigsSelectionWidget->refresh(settings->savedDiagnosticConfigId());
|
||||||
|
|
||||||
connect(m_ui->clangDiagnosticConfigsSelectionWidget,
|
connect(clangDiagnosticConfigsSelectionWidget,
|
||||||
&CppTools::ClangDiagnosticConfigsSelectionWidget::currentConfigChanged,
|
&CppTools::ClangDiagnosticConfigsSelectionWidget::currentConfigChanged,
|
||||||
this, [this](const Core::Id ¤tConfigId) {
|
this, [this](const Core::Id ¤tConfigId) {
|
||||||
m_settings->setDiagnosticConfigId(currentConfigId);
|
m_settings->setDiagnosticConfigId(currentConfigId);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
connect(CppTools::codeModelSettings().data(), &CppTools::CppCodeModelSettings::changed,
|
||||||
this, [this]() {
|
this, [=]() {
|
||||||
// Settings were applied so apply also the current selection if possible.
|
// Settings were applied so apply also the current selection if possible.
|
||||||
m_ui->clangDiagnosticConfigsSelectionWidget->refresh(m_settings->diagnosticConfigId());
|
clangDiagnosticConfigsSelectionWidget->refresh(m_settings->diagnosticConfigId());
|
||||||
m_settings->writeSettings();
|
m_settings->writeSettings();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="buildBeforeAnalysis">
|
<widget class="ClangTools::ClangToolsBasicSettings" name="clangToolsBasicSettings" native="true"/>
|
||||||
<property name="text">
|
|
||||||
<string>Build the project before analysis</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="processesLayout">
|
<layout class="QHBoxLayout" name="processesLayout">
|
||||||
@@ -61,9 +57,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="CppTools::ClangDiagnosticConfigsSelectionWidget" name="clangDiagnosticConfigsSelectionWidget" native="true"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -84,9 +77,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CppTools::ClangDiagnosticConfigsSelectionWidget</class>
|
<class>ClangTools::ClangToolsBasicSettings</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>cpptools/clangdiagnosticconfigsselectionwidget.h</header>
|
<header>clangtools/clangtoolsbasicsettings.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace Internal {
|
|||||||
|
|
||||||
static const char SETTINGS_KEY_USE_GLOBAL_SETTINGS[] = "ClangTools.UseGlobalSettings";
|
static const char SETTINGS_KEY_USE_GLOBAL_SETTINGS[] = "ClangTools.UseGlobalSettings";
|
||||||
static const char SETTINGS_KEY_DIAGNOSTIC_CONFIG[] = "ClangTools.DiagnosticConfig";
|
static const char SETTINGS_KEY_DIAGNOSTIC_CONFIG[] = "ClangTools.DiagnosticConfig";
|
||||||
|
static const char SETTINGS_KEY_BUILD_BEFORE_ANALYSIS[] = "ClangTools.BuildBeforeAnalysis";
|
||||||
static const char SETTINGS_KEY_SELECTED_DIRS[] = "ClangTools.SelectedDirs";
|
static const char SETTINGS_KEY_SELECTED_DIRS[] = "ClangTools.SelectedDirs";
|
||||||
static const char SETTINGS_KEY_SELECTED_FILES[] = "ClangTools.SelectedFiles";
|
static const char SETTINGS_KEY_SELECTED_FILES[] = "ClangTools.SelectedFiles";
|
||||||
static const char SETTINGS_KEY_SUPPRESSED_DIAGS[] = "ClangTools.SuppressedDiagnostics";
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS[] = "ClangTools.SuppressedDiagnostics";
|
||||||
@@ -86,6 +87,7 @@ void ClangToolsProjectSettings::load()
|
|||||||
m_useGlobalSettings = useGlobalVariant.isValid() ? useGlobalVariant.toBool() : true;
|
m_useGlobalSettings = useGlobalVariant.isValid() ? useGlobalVariant.toBool() : true;
|
||||||
m_diagnosticConfig = Core::Id::fromSetting(
|
m_diagnosticConfig = Core::Id::fromSetting(
|
||||||
m_project->namedSettings(SETTINGS_KEY_DIAGNOSTIC_CONFIG));
|
m_project->namedSettings(SETTINGS_KEY_DIAGNOSTIC_CONFIG));
|
||||||
|
m_buildBeforeAnalysis = m_project->namedSettings(SETTINGS_KEY_BUILD_BEFORE_ANALYSIS).toBool();
|
||||||
|
|
||||||
auto toFileName = [](const QString &s) { return Utils::FileName::fromString(s); };
|
auto toFileName = [](const QString &s) { return Utils::FileName::fromString(s); };
|
||||||
|
|
||||||
@@ -124,6 +126,7 @@ void ClangToolsProjectSettings::store()
|
|||||||
{
|
{
|
||||||
m_project->setNamedSettings(SETTINGS_KEY_USE_GLOBAL_SETTINGS, m_useGlobalSettings);
|
m_project->setNamedSettings(SETTINGS_KEY_USE_GLOBAL_SETTINGS, m_useGlobalSettings);
|
||||||
m_project->setNamedSettings(SETTINGS_KEY_DIAGNOSTIC_CONFIG, m_diagnosticConfig.toSetting());
|
m_project->setNamedSettings(SETTINGS_KEY_DIAGNOSTIC_CONFIG, m_diagnosticConfig.toSetting());
|
||||||
|
m_project->setNamedSettings(SETTINGS_KEY_BUILD_BEFORE_ANALYSIS, m_buildBeforeAnalysis);
|
||||||
|
|
||||||
const QStringList dirs = Utils::transform(m_selectedDirs.toList(), &Utils::FileName::toString);
|
const QStringList dirs = Utils::transform(m_selectedDirs.toList(), &Utils::FileName::toString);
|
||||||
m_project->setNamedSettings(SETTINGS_KEY_SELECTED_DIRS, dirs);
|
m_project->setNamedSettings(SETTINGS_KEY_SELECTED_DIRS, dirs);
|
||||||
@@ -164,6 +167,16 @@ void ClangToolsProjectSettings::setDiagnosticConfig(const Core::Id &diagnosticCo
|
|||||||
m_diagnosticConfig = diagnosticConfig;
|
m_diagnosticConfig = diagnosticConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClangToolsProjectSettings::buildBeforeAnalysis() const
|
||||||
|
{
|
||||||
|
return m_buildBeforeAnalysis;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangToolsProjectSettings::setBuildBeforeAnalysis(bool build)
|
||||||
|
{
|
||||||
|
m_buildBeforeAnalysis = build;
|
||||||
|
}
|
||||||
|
|
||||||
ClangToolsProjectSettingsManager::ClangToolsProjectSettingsManager()
|
ClangToolsProjectSettingsManager::ClangToolsProjectSettingsManager()
|
||||||
{
|
{
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ public:
|
|||||||
Core::Id diagnosticConfig() const;
|
Core::Id diagnosticConfig() const;
|
||||||
void setDiagnosticConfig(const Core::Id &diagnosticConfig);
|
void setDiagnosticConfig(const Core::Id &diagnosticConfig);
|
||||||
|
|
||||||
|
bool buildBeforeAnalysis() const;
|
||||||
|
void setBuildBeforeAnalysis(bool build);
|
||||||
|
|
||||||
QSet<Utils::FileName> selectedDirs() const { return m_selectedDirs; }
|
QSet<Utils::FileName> selectedDirs() const { return m_selectedDirs; }
|
||||||
void setSelectedDirs(const QSet<Utils::FileName> &value) { m_selectedDirs = value; }
|
void setSelectedDirs(const QSet<Utils::FileName> &value) { m_selectedDirs = value; }
|
||||||
|
|
||||||
@@ -105,6 +108,7 @@ private:
|
|||||||
QSet<Utils::FileName> m_selectedDirs;
|
QSet<Utils::FileName> m_selectedDirs;
|
||||||
QSet<Utils::FileName> m_selectedFiles;
|
QSet<Utils::FileName> m_selectedFiles;
|
||||||
SuppressedDiagnosticsList m_suppressedDiagnostics;
|
SuppressedDiagnosticsList m_suppressedDiagnostics;
|
||||||
|
bool m_buildBeforeAnalysis = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClangToolsProjectSettingsManager
|
class ClangToolsProjectSettingsManager
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ bool ClangToolsSettings::savedBuildBeforeAnalysis() const
|
|||||||
return m_savedBuildBeforeAnalysis;
|
return m_savedBuildBeforeAnalysis;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ClangToolsSettings::buildBeforeAnalysis() const
|
bool ClangToolsSettings::buildBeforeAnalysis() const
|
||||||
{
|
{
|
||||||
return m_buildBeforeAnalysis;
|
return m_buildBeforeAnalysis;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
int simultaneousProcesses() const;
|
int simultaneousProcesses() const;
|
||||||
void setSimultaneousProcesses(int processes);
|
void setSimultaneousProcesses(int processes);
|
||||||
|
|
||||||
int buildBeforeAnalysis() const;
|
bool buildBeforeAnalysis() const;
|
||||||
void setBuildBeforeAnalysis(bool build);
|
void setBuildBeforeAnalysis(bool build);
|
||||||
|
|
||||||
Core::Id diagnosticConfigId() const;
|
Core::Id diagnosticConfigId() const;
|
||||||
|
|||||||
@@ -106,11 +106,6 @@ void ClangDiagnosticConfigsSelectionWidget::refresh(Core::Id id)
|
|||||||
connectToCurrentIndexChanged();
|
connectToCurrentIndexChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangDiagnosticConfigsSelectionWidget::showLabel(bool show)
|
|
||||||
{
|
|
||||||
m_label->setVisible(show);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClangDiagnosticConfigsSelectionWidget::connectToClangDiagnosticConfigsDialog(QPushButton *button)
|
void ClangDiagnosticConfigsSelectionWidget::connectToClangDiagnosticConfigsDialog(QPushButton *button)
|
||||||
{
|
{
|
||||||
connect(button, &QPushButton::clicked, [this]() {
|
connect(button, &QPushButton::clicked, [this]() {
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ public:
|
|||||||
|
|
||||||
void refresh(Core::Id id);
|
void refresh(Core::Id id);
|
||||||
|
|
||||||
void showLabel(bool show);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentConfigChanged(const Core::Id ¤tConfigId);
|
void currentConfigChanged(const Core::Id ¤tConfigId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user