forked from qt-creator/qt-creator
ClangTools: Inline settingswidget.ui
Change-Id: Iab93fe772a2f851a2008133ad8f7aae974e6881e Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -3,79 +3,76 @@
|
||||
|
||||
#include "settingswidget.h"
|
||||
|
||||
#include "ui_settingswidget.h"
|
||||
|
||||
#include "clangtoolsconstants.h"
|
||||
#include "clangtoolsutils.h"
|
||||
#include "runsettingswidget.h"
|
||||
|
||||
#include <cppeditor/clangdiagnosticconfigsmodel.h>
|
||||
#include <cppeditor/clangdiagnosticconfigsselectionwidget.h>
|
||||
|
||||
#include <debugger/analyzer/analyzericons.h>
|
||||
|
||||
#include <optional>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
namespace ClangTools::Internal {
|
||||
|
||||
static SettingsWidget *m_instance = nullptr;
|
||||
|
||||
static void setupPathChooser(PathChooser *const chooser,
|
||||
const QString &promptDiaglogTitle,
|
||||
const QString &placeHolderText,
|
||||
const FilePath &pathFromSettings,
|
||||
const QString &historyCompleterId)
|
||||
{
|
||||
chooser->setPromptDialogTitle(promptDiaglogTitle);
|
||||
chooser->setDefaultValue(placeHolderText);
|
||||
chooser->setFilePath(pathFromSettings);
|
||||
chooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
chooser->setHistoryCompleter(historyCompleterId);
|
||||
}
|
||||
|
||||
SettingsWidget *SettingsWidget::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
SettingsWidget::SettingsWidget()
|
||||
: m_ui(new Ui::SettingsWidget)
|
||||
, m_settings(ClangToolsSettings::instance())
|
||||
: m_settings(ClangToolsSettings::instance())
|
||||
{
|
||||
m_instance = this;
|
||||
m_ui->setupUi(this);
|
||||
|
||||
//
|
||||
// Group box "Executables"
|
||||
//
|
||||
resize(400, 300);
|
||||
|
||||
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
||||
FilePath path = m_settings->clangTidyExecutable();
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
||||
setupPathChooser(m_ui->clangTidyPathChooser,
|
||||
tr("Clang-Tidy Executable"),
|
||||
placeHolderText,
|
||||
path,
|
||||
"ClangTools.ClangTidyExecutable.History");
|
||||
m_clangTidyPathChooser = new PathChooser;
|
||||
m_clangTidyPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||
m_clangTidyPathChooser->setPromptDialogTitle(tr("Clang-Tidy Executable"));
|
||||
m_clangTidyPathChooser->setDefaultValue(placeHolderText);
|
||||
m_clangTidyPathChooser->setFilePath(path);
|
||||
m_clangTidyPathChooser->setHistoryCompleter("ClangTools.ClangTidyExecutable.History");
|
||||
|
||||
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
||||
path = m_settings->clazyStandaloneExecutable();
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
||||
setupPathChooser(m_ui->clazyStandalonePathChooser,
|
||||
tr("Clazy Executable"),
|
||||
placeHolderText,
|
||||
path,
|
||||
"ClangTools.ClazyStandaloneExecutable.History");
|
||||
m_clazyStandalonePathChooser = new PathChooser;
|
||||
m_clazyStandalonePathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||
m_clazyStandalonePathChooser->setPromptDialogTitle(tr("Clazy Executable"));
|
||||
m_clazyStandalonePathChooser->setDefaultValue(placeHolderText);
|
||||
m_clazyStandalonePathChooser->setFilePath(path);
|
||||
m_clazyStandalonePathChooser->setHistoryCompleter("ClangTools.ClazyStandaloneExecutable.History");
|
||||
|
||||
//
|
||||
// Group box "Run Options"
|
||||
//
|
||||
m_runSettingsWidget = new RunSettingsWidget;
|
||||
m_runSettingsWidget->fromSettings(m_settings->runSettings());
|
||||
|
||||
m_ui->runSettingsWidget->fromSettings(m_settings->runSettings());
|
||||
using namespace Layouting;
|
||||
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Executables")),
|
||||
Form {
|
||||
tr("Clang-Tidy:"), m_clangTidyPathChooser, br,
|
||||
tr("Clazy-Standalone:"), m_clazyStandalonePathChooser
|
||||
}
|
||||
},
|
||||
m_runSettingsWidget,
|
||||
st
|
||||
}.attachTo(this);
|
||||
}
|
||||
|
||||
void SettingsWidget::apply()
|
||||
@@ -85,11 +82,11 @@ void SettingsWidget::apply()
|
||||
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
||||
|
||||
// Run options
|
||||
m_settings->setRunSettings(m_ui->runSettingsWidget->toSettings());
|
||||
m_settings->setRunSettings(m_runSettingsWidget->toSettings());
|
||||
|
||||
// Custom configs
|
||||
const CppEditor::ClangDiagnosticConfigs customConfigs
|
||||
= m_ui->runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
||||
= m_runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
||||
m_settings->setDiagnosticConfigs(customConfigs);
|
||||
|
||||
m_settings->writeSettings();
|
||||
@@ -102,12 +99,12 @@ SettingsWidget::~SettingsWidget()
|
||||
|
||||
FilePath SettingsWidget::clangTidyPath() const
|
||||
{
|
||||
return m_ui->clangTidyPathChooser->rawFilePath();
|
||||
return m_clangTidyPathChooser->rawFilePath();
|
||||
}
|
||||
|
||||
FilePath SettingsWidget::clazyStandalonePath() const
|
||||
{
|
||||
return m_ui->clazyStandalonePathChooser->rawFilePath();
|
||||
return m_clazyStandalonePathChooser->rawFilePath();
|
||||
}
|
||||
|
||||
// ClangToolsOptionsPage
|
||||
@@ -124,5 +121,4 @@ ClangToolsOptionsPage::ClangToolsOptionsPage()
|
||||
setWidgetCreator([] { return new SettingsWidget; });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangTools
|
||||
} // ClangTools::Internal
|
||||
|
||||
Reference in New Issue
Block a user