forked from qt-creator/qt-creator
TextEditor: Hide plugin class definition in .cpp
Change-Id: Ib796333a0c46311fbead63de0e4562918d14a59f Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -188,7 +188,7 @@ void TextEditorActionHandlerPrivate::createActions()
|
|||||||
registerAction(SELECTALL,
|
registerAction(SELECTALL,
|
||||||
[] (TextEditorWidget *w) { w->selectAll(); }, true);
|
[] (TextEditorWidget *w) { w->selectAll(); }, true);
|
||||||
registerAction(GOTO, [](TextEditorWidget *) {
|
registerAction(GOTO, [](TextEditorWidget *) {
|
||||||
LocatorManager::showFilter(TextEditorPlugin::lineNumberFilter());
|
LocatorManager::showFilter(lineNumberFilter());
|
||||||
});
|
});
|
||||||
m_modifyingActions << registerAction(PRINT, [](TextEditorWidget *widget) {
|
m_modifyingActions << registerAction(PRINT, [](TextEditorWidget *widget) {
|
||||||
widget->print(ICore::printer());
|
widget->print(ICore::printer());
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include "markdowneditor.h"
|
#include "markdowneditor.h"
|
||||||
#include "outlinefactory.h"
|
#include "outlinefactory.h"
|
||||||
#include "plaintexteditorfactory.h"
|
#include "plaintexteditorfactory.h"
|
||||||
#include "snippets/snippet.h"
|
|
||||||
#include "snippets/snippetprovider.h"
|
#include "snippets/snippetprovider.h"
|
||||||
#include "tabsettings.h"
|
#include "tabsettings.h"
|
||||||
#include "textdocument.h"
|
#include "textdocument.h"
|
||||||
@@ -43,6 +42,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -263,22 +263,35 @@ void TextEditorPluginPrivate::requestContextMenu(TextEditorWidget *widget,
|
|||||||
menu->addAction(&m_editBookmarkAction);
|
menu->addAction(&m_editBookmarkAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextEditorPlugin *m_instance = nullptr;
|
static class TextEditorPlugin *m_instance = nullptr;
|
||||||
|
|
||||||
TextEditorPlugin::TextEditorPlugin()
|
class TextEditorPlugin final : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_instance, return);
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TextEditor.json")
|
||||||
|
|
||||||
|
public:
|
||||||
|
TextEditorPlugin()
|
||||||
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorPlugin::~TextEditorPlugin()
|
~TextEditorPlugin() final
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
d = nullptr;
|
d = nullptr;
|
||||||
m_instance = nullptr;
|
m_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorPlugin *TextEditorPlugin::instance()
|
ShutdownFlag aboutToShutdown() final;
|
||||||
|
|
||||||
|
void initialize() final;
|
||||||
|
void extensionsInitialized() final;
|
||||||
|
|
||||||
|
TextEditorPluginPrivate *d = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
QObject *pluginInstance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
@@ -439,7 +452,7 @@ void TextEditorPlugin::extensionsInitialized()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
|
LineNumberFilter *lineNumberFilter()
|
||||||
{
|
{
|
||||||
return &m_instance->d->lineNumberFilter;
|
return &m_instance->d->lineNumberFilter;
|
||||||
}
|
}
|
||||||
@@ -532,3 +545,5 @@ void TextEditorPluginPrivate::createStandardContextMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TextEditor::Internal
|
} // namespace TextEditor::Internal
|
||||||
|
|
||||||
|
#include "texteditorplugin.moc"
|
||||||
|
@@ -3,33 +3,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <QObject>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class LineNumberFilter;
|
class LineNumberFilter;
|
||||||
|
LineNumberFilter *lineNumberFilter();
|
||||||
|
|
||||||
class TextEditorPlugin final : public ExtensionSystem::IPlugin
|
QObject *pluginInstance();
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TextEditor.json")
|
|
||||||
|
|
||||||
public:
|
} // TextEditor::Internal
|
||||||
TextEditorPlugin();
|
|
||||||
~TextEditorPlugin() final;
|
|
||||||
|
|
||||||
static TextEditorPlugin *instance();
|
|
||||||
static LineNumberFilter *lineNumberFilter();
|
|
||||||
|
|
||||||
ShutdownFlag aboutToShutdown() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize() final;
|
|
||||||
void extensionsInitialized() final;
|
|
||||||
|
|
||||||
class TextEditorPluginPrivate *d = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace TextEditor
|
|
||||||
|
@@ -493,7 +493,7 @@ bool TextMarkRegistry::remove(TextMark *mark)
|
|||||||
TextMarkRegistry *TextMarkRegistry::instance()
|
TextMarkRegistry *TextMarkRegistry::instance()
|
||||||
{
|
{
|
||||||
if (!m_instance)
|
if (!m_instance)
|
||||||
m_instance = new TextMarkRegistry(TextEditorPlugin::instance());
|
m_instance = new TextMarkRegistry(pluginInstance());
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user