forked from qt-creator/qt-creator
Beautifier: Avoid QObject parent in options page
Change-Id: I7e1162802fb6d7d7dffe143dbcdf6d85dc18d56f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -103,7 +103,17 @@ public:
|
||||
ClangFormat::ClangFormat clangFormatBeautifier;
|
||||
Uncrustify::Uncrustify uncrustifyBeautifier;
|
||||
|
||||
QList<BeautifierAbstractTool *> m_tools;
|
||||
BeautifierAbstractTool *m_tools[3] {
|
||||
&artisticStyleBeautifier,
|
||||
&uncrustifyBeautifier,
|
||||
&clangFormatBeautifier
|
||||
};
|
||||
|
||||
GeneralOptionsPage optionsPage {{
|
||||
artisticStyleBeautifier.id(),
|
||||
uncrustifyBeautifier.id(),
|
||||
clangFormatBeautifier.id()
|
||||
}};
|
||||
};
|
||||
|
||||
static BeautifierPluginPrivate *dd = nullptr;
|
||||
@@ -126,15 +136,7 @@ void BeautifierPlugin::extensionsInitialized()
|
||||
}
|
||||
|
||||
BeautifierPluginPrivate::BeautifierPluginPrivate()
|
||||
: m_tools({&artisticStyleBeautifier, &uncrustifyBeautifier, &clangFormatBeautifier})
|
||||
{
|
||||
QStringList toolIds;
|
||||
toolIds.reserve(m_tools.count());
|
||||
for (BeautifierAbstractTool *tool : m_tools)
|
||||
toolIds << tool->id();
|
||||
|
||||
new GeneralOptionsPage(toolIds, this);
|
||||
|
||||
updateActions();
|
||||
|
||||
const Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
@@ -173,9 +175,9 @@ void BeautifierPluginPrivate::autoFormatOnSave(Core::IDocument *document)
|
||||
|
||||
// Find tool to use by id and format file!
|
||||
const QString id = generalSettings.autoFormatTool();
|
||||
auto tool = std::find_if(m_tools.constBegin(), m_tools.constEnd(),
|
||||
auto tool = std::find_if(std::begin(m_tools), std::end(m_tools),
|
||||
[&id](const BeautifierAbstractTool *t){return t->id() == id;});
|
||||
if (tool != m_tools.constEnd()) {
|
||||
if (tool != std::end(m_tools)) {
|
||||
if (!(*tool)->isApplicable(document))
|
||||
return;
|
||||
const TextEditor::Command command = (*tool)->command();
|
||||
|
||||
@@ -66,8 +66,7 @@ void GeneralOptionsPageWidget::apply()
|
||||
settings->save();
|
||||
}
|
||||
|
||||
GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds, QObject *parent) :
|
||||
IOptionsPage(parent)
|
||||
GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds)
|
||||
{
|
||||
setId(Constants::OPTION_GENERAL_ID);
|
||||
setDisplayName(tr("General"));
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
namespace Beautifier {
|
||||
namespace Internal {
|
||||
|
||||
class GeneralOptionsPage : public Core::IOptionsPage
|
||||
class GeneralOptionsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
GeneralOptionsPage(const QStringList &toolIds, QObject *parent);
|
||||
explicit GeneralOptionsPage(const QStringList &toolIds);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user