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:
@@ -41,7 +41,7 @@ add_qtc_plugin(ClangTools
|
|||||||
executableinfo.cpp executableinfo.h
|
executableinfo.cpp executableinfo.h
|
||||||
filterdialog.cpp filterdialog.h
|
filterdialog.cpp filterdialog.h
|
||||||
runsettingswidget.cpp runsettingswidget.h runsettingswidget.ui
|
runsettingswidget.cpp runsettingswidget.h runsettingswidget.ui
|
||||||
settingswidget.cpp settingswidget.h settingswidget.ui
|
settingswidget.cpp settingswidget.h
|
||||||
tidychecks.ui
|
tidychecks.ui
|
||||||
virtualfilesystemoverlay.cpp virtualfilesystemoverlay.h
|
virtualfilesystemoverlay.cpp virtualfilesystemoverlay.h
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ QtcPlugin {
|
|||||||
"runsettingswidget.ui",
|
"runsettingswidget.ui",
|
||||||
"settingswidget.cpp",
|
"settingswidget.cpp",
|
||||||
"settingswidget.h",
|
"settingswidget.h",
|
||||||
"settingswidget.ui",
|
|
||||||
"tidychecks.ui",
|
"tidychecks.ui",
|
||||||
"virtualfilesystemoverlay.cpp",
|
"virtualfilesystemoverlay.cpp",
|
||||||
"virtualfilesystemoverlay.h",
|
"virtualfilesystemoverlay.h",
|
||||||
|
|||||||
@@ -3,79 +3,76 @@
|
|||||||
|
|
||||||
#include "settingswidget.h"
|
#include "settingswidget.h"
|
||||||
|
|
||||||
#include "ui_settingswidget.h"
|
|
||||||
|
|
||||||
#include "clangtoolsconstants.h"
|
#include "clangtoolsconstants.h"
|
||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
|
#include "runsettingswidget.h"
|
||||||
|
|
||||||
#include <cppeditor/clangdiagnosticconfigsmodel.h>
|
#include <cppeditor/clangdiagnosticconfigsmodel.h>
|
||||||
#include <cppeditor/clangdiagnosticconfigsselectionwidget.h>
|
#include <cppeditor/clangdiagnosticconfigsselectionwidget.h>
|
||||||
|
|
||||||
#include <debugger/analyzer/analyzericons.h>
|
#include <debugger/analyzer/analyzericons.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static SettingsWidget *m_instance = nullptr;
|
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()
|
SettingsWidget *SettingsWidget::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsWidget::SettingsWidget()
|
SettingsWidget::SettingsWidget()
|
||||||
: m_ui(new Ui::SettingsWidget)
|
: m_settings(ClangToolsSettings::instance())
|
||||||
, m_settings(ClangToolsSettings::instance())
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
m_ui->setupUi(this);
|
|
||||||
|
|
||||||
//
|
resize(400, 300);
|
||||||
// Group box "Executables"
|
|
||||||
//
|
|
||||||
|
|
||||||
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
||||||
FilePath path = m_settings->clangTidyExecutable();
|
FilePath path = m_settings->clangTidyExecutable();
|
||||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||||
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
||||||
setupPathChooser(m_ui->clangTidyPathChooser,
|
m_clangTidyPathChooser = new PathChooser;
|
||||||
tr("Clang-Tidy Executable"),
|
m_clangTidyPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||||
placeHolderText,
|
m_clangTidyPathChooser->setPromptDialogTitle(tr("Clang-Tidy Executable"));
|
||||||
path,
|
m_clangTidyPathChooser->setDefaultValue(placeHolderText);
|
||||||
"ClangTools.ClangTidyExecutable.History");
|
m_clangTidyPathChooser->setFilePath(path);
|
||||||
|
m_clangTidyPathChooser->setHistoryCompleter("ClangTools.ClangTidyExecutable.History");
|
||||||
|
|
||||||
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
||||||
path = m_settings->clazyStandaloneExecutable();
|
path = m_settings->clazyStandaloneExecutable();
|
||||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||||
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
||||||
setupPathChooser(m_ui->clazyStandalonePathChooser,
|
m_clazyStandalonePathChooser = new PathChooser;
|
||||||
tr("Clazy Executable"),
|
m_clazyStandalonePathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||||
placeHolderText,
|
m_clazyStandalonePathChooser->setPromptDialogTitle(tr("Clazy Executable"));
|
||||||
path,
|
m_clazyStandalonePathChooser->setDefaultValue(placeHolderText);
|
||||||
"ClangTools.ClazyStandaloneExecutable.History");
|
m_clazyStandalonePathChooser->setFilePath(path);
|
||||||
|
m_clazyStandalonePathChooser->setHistoryCompleter("ClangTools.ClazyStandaloneExecutable.History");
|
||||||
|
|
||||||
//
|
m_runSettingsWidget = new RunSettingsWidget;
|
||||||
// Group box "Run Options"
|
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()
|
void SettingsWidget::apply()
|
||||||
@@ -85,11 +82,11 @@ void SettingsWidget::apply()
|
|||||||
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
||||||
|
|
||||||
// Run options
|
// Run options
|
||||||
m_settings->setRunSettings(m_ui->runSettingsWidget->toSettings());
|
m_settings->setRunSettings(m_runSettingsWidget->toSettings());
|
||||||
|
|
||||||
// Custom configs
|
// Custom configs
|
||||||
const CppEditor::ClangDiagnosticConfigs customConfigs
|
const CppEditor::ClangDiagnosticConfigs customConfigs
|
||||||
= m_ui->runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
= m_runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
||||||
m_settings->setDiagnosticConfigs(customConfigs);
|
m_settings->setDiagnosticConfigs(customConfigs);
|
||||||
|
|
||||||
m_settings->writeSettings();
|
m_settings->writeSettings();
|
||||||
@@ -102,12 +99,12 @@ SettingsWidget::~SettingsWidget()
|
|||||||
|
|
||||||
FilePath SettingsWidget::clangTidyPath() const
|
FilePath SettingsWidget::clangTidyPath() const
|
||||||
{
|
{
|
||||||
return m_ui->clangTidyPathChooser->rawFilePath();
|
return m_clangTidyPathChooser->rawFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath SettingsWidget::clazyStandalonePath() const
|
FilePath SettingsWidget::clazyStandalonePath() const
|
||||||
{
|
{
|
||||||
return m_ui->clazyStandalonePathChooser->rawFilePath();
|
return m_clazyStandalonePathChooser->rawFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClangToolsOptionsPage
|
// ClangToolsOptionsPage
|
||||||
@@ -124,5 +121,4 @@ ClangToolsOptionsPage::ClangToolsOptionsPage()
|
|||||||
setWidgetCreator([] { return new SettingsWidget; });
|
setWidgetCreator([] { return new SettingsWidget; });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // ClangTools::Internal
|
||||||
} // namespace ClangTools
|
|
||||||
|
|||||||
@@ -9,12 +9,14 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace Utils { class FilePath; }
|
namespace Utils {
|
||||||
|
class FilePath;
|
||||||
|
class PathChooser;
|
||||||
|
} // Utils
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
namespace Ui { class SettingsWidget; }
|
class RunSettingsWidget;
|
||||||
|
|
||||||
class SettingsWidget : public Core::IOptionsPageWidget
|
class SettingsWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
@@ -32,8 +34,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
void apply() final;
|
void apply() final;
|
||||||
|
|
||||||
std::unique_ptr<Ui::SettingsWidget> m_ui;
|
|
||||||
ClangToolsSettings *m_settings;
|
ClangToolsSettings *m_settings;
|
||||||
|
|
||||||
|
Utils::PathChooser *m_clangTidyPathChooser;
|
||||||
|
Utils::PathChooser *m_clazyStandalonePathChooser;
|
||||||
|
RunSettingsWidget *m_runSettingsWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClangToolsOptionsPage final : public Core::IOptionsPage
|
class ClangToolsOptionsPage final : public Core::IOptionsPage
|
||||||
@@ -42,5 +47,4 @@ public:
|
|||||||
ClangToolsOptionsPage();
|
ClangToolsOptionsPage();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // ClangTools::Internal
|
||||||
} // namespace ClangTools
|
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ClangTools::Internal::SettingsWidget</class>
|
|
||||||
<widget class="QWidget" name="ClangTools::Internal::SettingsWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Executables</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clang-Tidy:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="Utils::PathChooser" name="clangTidyPathChooser" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="clazyStandaloneLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clazy-Standalone:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="Utils::PathChooser" name="clazyStandalonePathChooser" native="true"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="ClangTools::Internal::RunSettingsWidget" name="runSettingsWidget" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>183</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::PathChooser</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">utils/pathchooser.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>ClangTools::Internal::RunSettingsWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>clangtools/runsettingswidget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user