ClangTools: Inline settingswidget.ui

Change-Id: Iab93fe772a2f851a2008133ad8f7aae974e6881e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-09-26 16:08:37 +02:00
parent b72ae58629
commit 3fdc5ca61f
5 changed files with 52 additions and 133 deletions

View File

@@ -41,7 +41,7 @@ add_qtc_plugin(ClangTools
executableinfo.cpp executableinfo.h
filterdialog.cpp filterdialog.h
runsettingswidget.cpp runsettingswidget.h runsettingswidget.ui
settingswidget.cpp settingswidget.h settingswidget.ui
settingswidget.cpp settingswidget.h
tidychecks.ui
virtualfilesystemoverlay.cpp virtualfilesystemoverlay.h
)

View File

@@ -74,7 +74,6 @@ QtcPlugin {
"runsettingswidget.ui",
"settingswidget.cpp",
"settingswidget.h",
"settingswidget.ui",
"tidychecks.ui",
"virtualfilesystemoverlay.cpp",
"virtualfilesystemoverlay.h",

View File

@@ -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

View File

@@ -9,12 +9,14 @@
#include <memory>
namespace Utils { class FilePath; }
namespace Utils {
class FilePath;
class PathChooser;
} // Utils
namespace ClangTools {
namespace Internal {
namespace ClangTools::Internal {
namespace Ui { class SettingsWidget; }
class RunSettingsWidget;
class SettingsWidget : public Core::IOptionsPageWidget
{
@@ -32,8 +34,11 @@ public:
private:
void apply() final;
std::unique_ptr<Ui::SettingsWidget> m_ui;
ClangToolsSettings *m_settings;
Utils::PathChooser *m_clangTidyPathChooser;
Utils::PathChooser *m_clazyStandalonePathChooser;
RunSettingsWidget *m_runSettingsWidget;
};
class ClangToolsOptionsPage final : public Core::IOptionsPage
@@ -42,5 +47,4 @@ public:
ClangToolsOptionsPage();
};
} // namespace Internal
} // namespace ClangTools
} // ClangTools::Internal

View File

@@ -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>