forked from qt-creator/qt-creator
ClangTools: Move run settings to projects mode
Make the global run settings available per project in project mode and thus remove the diagnostic config selection from the selectable-files-dialog: * Extract the classes RunSettings and RunSettingsWidget instead of duplicating stuff. * Ensure to pick up the old settings * Add some convenience buttons/links in projects mode allowing to restore the global settings, to open the global settings and to navigate (back) to the analyzer mode. Change-Id: I1b91b6f8e58a87a025774e4643c46e176b2a8885 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -26,8 +26,12 @@
|
||||
#include "clangtoolsprojectsettingswidget.h"
|
||||
#include "ui_clangtoolsprojectsettingswidget.h"
|
||||
|
||||
#include "clangtidyclazytool.h"
|
||||
#include "clangtoolsconstants.h"
|
||||
#include "clangtoolsprojectsettings.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
@@ -56,12 +60,46 @@ private:
|
||||
SuppressedDiagnosticsList m_diagnostics;
|
||||
};
|
||||
|
||||
enum { UseGlobalSettings, UseCustomSettings }; // Values in sync with m_ui->globalCustomComboBox
|
||||
|
||||
ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_ui(new Ui::ProjectSettingsWidget)
|
||||
, m_projectSettings(ClangToolsProjectSettingsManager::getSettings(project))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// Use global/custom settings
|
||||
const int globalOrCustomIndex = m_projectSettings->useGlobalSettings() ? UseGlobalSettings
|
||||
: UseCustomSettings;
|
||||
m_ui->globalCustomComboBox->setCurrentIndex(globalOrCustomIndex);
|
||||
onGlobalCustomChanged(globalOrCustomIndex);
|
||||
connect(m_ui->globalCustomComboBox,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&ProjectSettingsWidget::onGlobalCustomChanged);
|
||||
|
||||
// Restore global settings
|
||||
connect(m_ui->restoreGlobal, &QPushButton::clicked, this, [this]() {
|
||||
m_ui->runSettingsWidget->fromSettings(ClangToolsSettings::instance()->runSettings());
|
||||
});
|
||||
|
||||
// Links
|
||||
connect(m_ui->gotoGlobalSettingsLabel, &QLabel::linkActivated, [](const QString &){
|
||||
Core::ICore::showOptionsDialog(ClangTools::Constants::SETTINGS_PAGE_ID);
|
||||
});
|
||||
|
||||
connect(m_ui->gotoAnalyzerModeLabel, &QLabel::linkActivated, [](const QString &){
|
||||
ClangTidyClazyTool::instance()->selectPerspective();
|
||||
});
|
||||
|
||||
// Run options
|
||||
m_ui->runSettingsWidget->fromSettings(m_projectSettings->runSettings());
|
||||
connect(m_ui->runSettingsWidget, &RunSettingsWidget::changed, [this]() {
|
||||
m_projectSettings->setRunSettings(m_ui->runSettingsWidget->toSettings());
|
||||
});
|
||||
|
||||
// Suppressed diagnostics
|
||||
auto * const model = new SuppressedDiagnosticsModel(this);
|
||||
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
||||
connect(m_projectSettings, &ClangToolsProjectSettings::suppressedDiagnosticsChanged,
|
||||
@@ -86,6 +124,14 @@ ProjectSettingsWidget::~ProjectSettingsWidget()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ProjectSettingsWidget::onGlobalCustomChanged(int index)
|
||||
{
|
||||
const bool useGlobal = index == UseGlobalSettings;
|
||||
m_ui->runSettingsWidget->setEnabled(!useGlobal);
|
||||
m_ui->restoreGlobal->setEnabled(!useGlobal);
|
||||
m_projectSettings->setUseGlobalSettings(useGlobal);
|
||||
}
|
||||
|
||||
void ProjectSettingsWidget::updateButtonStates()
|
||||
{
|
||||
updateButtonStateRemoveSelected();
|
||||
|
||||
Reference in New Issue
Block a user