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;
|
ClangFormat::ClangFormat clangFormatBeautifier;
|
||||||
Uncrustify::Uncrustify uncrustifyBeautifier;
|
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;
|
static BeautifierPluginPrivate *dd = nullptr;
|
||||||
@@ -126,15 +136,7 @@ void BeautifierPlugin::extensionsInitialized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BeautifierPluginPrivate::BeautifierPluginPrivate()
|
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();
|
updateActions();
|
||||||
|
|
||||||
const Core::EditorManager *editorManager = Core::EditorManager::instance();
|
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!
|
// Find tool to use by id and format file!
|
||||||
const QString id = generalSettings.autoFormatTool();
|
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;});
|
[&id](const BeautifierAbstractTool *t){return t->id() == id;});
|
||||||
if (tool != m_tools.constEnd()) {
|
if (tool != std::end(m_tools)) {
|
||||||
if (!(*tool)->isApplicable(document))
|
if (!(*tool)->isApplicable(document))
|
||||||
return;
|
return;
|
||||||
const TextEditor::Command command = (*tool)->command();
|
const TextEditor::Command command = (*tool)->command();
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ void GeneralOptionsPageWidget::apply()
|
|||||||
settings->save();
|
settings->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds, QObject *parent) :
|
GeneralOptionsPage::GeneralOptionsPage(const QStringList &toolIds)
|
||||||
IOptionsPage(parent)
|
|
||||||
{
|
{
|
||||||
setId(Constants::OPTION_GENERAL_ID);
|
setId(Constants::OPTION_GENERAL_ID);
|
||||||
setDisplayName(tr("General"));
|
setDisplayName(tr("General"));
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
namespace Beautifier {
|
namespace Beautifier {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GeneralOptionsPage : public Core::IOptionsPage
|
class GeneralOptionsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeneralOptionsPage(const QStringList &toolIds, QObject *parent);
|
explicit GeneralOptionsPage(const QStringList &toolIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user