2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2019-08-27 16:09:39 +02:00
|
|
|
#include "settingswidget.h"
|
|
|
|
|
|
2019-08-28 08:56:22 +02:00
|
|
|
#include "clangtoolsconstants.h"
|
2023-01-19 18:42:01 +01:00
|
|
|
#include "clangtoolstr.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtoolsutils.h"
|
2022-09-26 16:08:37 +02:00
|
|
|
#include "runsettingswidget.h"
|
2015-03-03 11:08:26 +01:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
#include <cppeditor/clangdiagnosticconfigsmodel.h>
|
|
|
|
|
#include <cppeditor/clangdiagnosticconfigsselectionwidget.h>
|
2019-09-25 15:46:15 +02:00
|
|
|
|
2020-02-03 09:18:49 +01:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
2019-09-25 15:46:15 +02:00
|
|
|
|
2023-01-10 15:51:31 +01:00
|
|
|
using namespace CppEditor;
|
2021-08-12 09:19:55 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
namespace ClangTools::Internal {
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2019-10-21 14:59:57 +02:00
|
|
|
static SettingsWidget *m_instance = nullptr;
|
|
|
|
|
|
|
|
|
|
SettingsWidget *SettingsWidget::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 17:45:16 +01:00
|
|
|
SettingsWidget::SettingsWidget()
|
2022-09-26 16:08:37 +02:00
|
|
|
: m_settings(ClangToolsSettings::instance())
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2019-10-21 14:59:57 +02:00
|
|
|
m_instance = this;
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
resize(400, 300);
|
2019-08-28 08:56:22 +02:00
|
|
|
|
2023-01-10 16:53:12 +01:00
|
|
|
auto createPathChooser = [this](ClangToolType tool)
|
|
|
|
|
{
|
|
|
|
|
const QString placeHolderText = toolShippedExecutable(tool).toUserOutput();
|
|
|
|
|
FilePath path = m_settings->executable(tool);
|
|
|
|
|
if (path.isEmpty() && placeHolderText.isEmpty()) {
|
|
|
|
|
path = tool == ClangToolType::Tidy ? FilePath(Constants::CLANG_TIDY_EXECUTABLE_NAME)
|
|
|
|
|
: FilePath(Constants::CLAZY_STANDALONE_EXECUTABLE_NAME);
|
|
|
|
|
}
|
|
|
|
|
PathChooser *pathChooser = new PathChooser;
|
|
|
|
|
pathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
2023-01-19 18:42:01 +01:00
|
|
|
pathChooser->setPromptDialogTitle(tool == ClangToolType::Tidy ? Tr::tr("Clang-Tidy Executable")
|
|
|
|
|
: Tr::tr("Clazy Executable"));
|
2023-01-10 16:53:12 +01:00
|
|
|
pathChooser->setDefaultValue(placeHolderText);
|
|
|
|
|
pathChooser->setFilePath(path);
|
|
|
|
|
pathChooser->setHistoryCompleter(tool == ClangToolType::Tidy
|
|
|
|
|
? QString("ClangTools.ClangTidyExecutable.History")
|
|
|
|
|
: QString("ClangTools.ClazyStandaloneExecutable.History"));
|
|
|
|
|
return pathChooser;
|
|
|
|
|
};
|
|
|
|
|
m_clangTidyPathChooser = createPathChooser(ClangToolType::Tidy);
|
|
|
|
|
m_clazyStandalonePathChooser = createPathChooser(ClangToolType::Clazy);
|
2022-09-26 16:08:37 +02:00
|
|
|
|
|
|
|
|
m_runSettingsWidget = new RunSettingsWidget;
|
|
|
|
|
m_runSettingsWidget->fromSettings(m_settings->runSettings());
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Group {
|
2023-01-19 18:42:01 +01:00
|
|
|
title(Tr::tr("Executables")),
|
2022-09-26 16:08:37 +02:00
|
|
|
Form {
|
2023-01-19 18:42:01 +01:00
|
|
|
Tr::tr("Clang-Tidy:"), m_clangTidyPathChooser, br,
|
|
|
|
|
Tr::tr("Clazy-Standalone:"), m_clazyStandalonePathChooser
|
2022-09-26 16:08:37 +02:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
m_runSettingsWidget,
|
|
|
|
|
st
|
|
|
|
|
}.attachTo(this);
|
2019-09-13 10:49:14 +02:00
|
|
|
}
|
2018-05-07 15:40:14 +02:00
|
|
|
|
2019-09-13 10:49:14 +02:00
|
|
|
void SettingsWidget::apply()
|
|
|
|
|
{
|
2019-10-01 16:53:01 +02:00
|
|
|
// Executables
|
2023-01-10 15:51:31 +01:00
|
|
|
m_settings->setExecutable(ClangToolType::Tidy, clangTidyPath());
|
|
|
|
|
m_settings->setExecutable(ClangToolType::Clazy, clazyStandalonePath());
|
2019-10-01 16:53:01 +02:00
|
|
|
|
|
|
|
|
// Run options
|
2022-09-26 16:08:37 +02:00
|
|
|
m_settings->setRunSettings(m_runSettingsWidget->toSettings());
|
2018-05-07 15:40:14 +02:00
|
|
|
|
2019-10-01 16:53:01 +02:00
|
|
|
// Custom configs
|
2023-01-10 15:51:31 +01:00
|
|
|
const ClangDiagnosticConfigs customConfigs
|
2022-09-26 16:08:37 +02:00
|
|
|
= m_runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
2019-10-01 16:53:01 +02:00
|
|
|
m_settings->setDiagnosticConfigs(customConfigs);
|
|
|
|
|
|
2019-09-13 10:49:14 +02:00
|
|
|
m_settings->writeSettings();
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-21 14:59:57 +02:00
|
|
|
SettingsWidget::~SettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
m_instance = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
FilePath SettingsWidget::clangTidyPath() const
|
2019-10-21 14:59:57 +02:00
|
|
|
{
|
2022-09-26 16:08:37 +02:00
|
|
|
return m_clangTidyPathChooser->rawFilePath();
|
2019-10-21 14:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
FilePath SettingsWidget::clazyStandalonePath() const
|
2019-10-21 14:59:57 +02:00
|
|
|
{
|
2022-09-26 16:08:37 +02:00
|
|
|
return m_clazyStandalonePathChooser->rawFilePath();
|
2019-10-21 14:59:57 +02:00
|
|
|
}
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2020-02-03 09:18:49 +01:00
|
|
|
// ClangToolsOptionsPage
|
|
|
|
|
|
|
|
|
|
ClangToolsOptionsPage::ClangToolsOptionsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::SETTINGS_PAGE_ID);
|
2023-01-19 18:42:01 +01:00
|
|
|
setDisplayName(Tr::tr("Clang Tools"));
|
2020-02-03 09:18:49 +01:00
|
|
|
setCategory("T.Analyzer");
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
|
|
|
|
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
|
|
|
|
setWidgetCreator([] { return new SettingsWidget; });
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
} // ClangTools::Internal
|