summaryrefslogtreecommitdiff
path: root/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2019-09-13 10:49:14 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2019-09-27 11:46:35 +0000
commit4750969c2b0c5574ed4d4ae23d5c69b5d97e1a87 (patch)
tree3a00b9f0a06563f83bff0d5f075ad1c62e5046bc /src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp
parentbdea56794fdb43e6eab3daf32012b8e04345a0b7 (diff)
downloadqt-creator-4750969c2b0c5574ed4d4ae23d5c69b5d97e1a87.tar.gz
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>
Diffstat (limited to 'src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp')
-rw-r--r--src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp b/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp
index 3e380aa9af..765cd34012 100644
--- a/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp
+++ b/src/plugins/clangtools/clangtoolsprojectsettingswidget.cpp
@@ -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();