TextEditor: Move some functions from the plugin pimpl to the plugin

Since the plugin class is in the .cpp now pimpling is not really
useful, this goes a step into the direction of removing it.

Change-Id: Ia55d60749372d868a94884337f0e0f52ec2cc1b5
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2024-01-26 14:03:07 +01:00
parent bc145f2d36
commit 994e83b839

View File

@@ -67,15 +67,6 @@ const char kCurrentDocumentWordUnderCursor[] = "CurrentDocument:WordUnderCursor"
class TextEditorPluginPrivate : public QObject class TextEditorPluginPrivate : public QObject
{ {
public: public:
void updateActions(bool enableToggle, int stateMask);
void extensionsInitialized();
void updateSearchResultsFont(const FontSettings &);
void updateSearchResultsTabWidth(const TabSettings &tabSettings);
void updateCurrentSelection(const QString &text);
void createStandardContextMenu();
BookmarkFilter m_bookmarkFilter; BookmarkFilter m_bookmarkFilter;
TextEditorSettings settings; TextEditorSettings settings;
@@ -106,6 +97,12 @@ public:
void initialize() final; void initialize() final;
void extensionsInitialized() final; void extensionsInitialized() final;
void updateSearchResultsFont(const FontSettings &);
void updateSearchResultsTabWidth(const TabSettings &tabSettings);
void updateCurrentSelection(const QString &text);
void createStandardContextMenu();
TextEditorPluginPrivate *d = nullptr; TextEditorPluginPrivate *d = nullptr;
}; };
@@ -174,7 +171,7 @@ void TextEditorPlugin::initialize()
SnippetProvider::registerGroup(Constants::TEXT_SNIPPET_GROUP_ID, SnippetProvider::registerGroup(Constants::TEXT_SNIPPET_GROUP_ID,
Tr::tr("Text", "SnippetProvider")); Tr::tr("Text", "SnippetProvider"));
d->createStandardContextMenu(); createStandardContextMenu();
#ifdef WITH_TESTS #ifdef WITH_TESTS
addTestCreator(createCodeAssistTests); addTestCreator(createCodeAssistTests);
@@ -182,7 +179,7 @@ void TextEditorPlugin::initialize()
#endif #endif
} }
void TextEditorPluginPrivate::extensionsInitialized() void TextEditorPlugin::extensionsInitialized()
{ {
connect(FolderNavigationWidgetFactory::instance(), connect(FolderNavigationWidgetFactory::instance(),
&FolderNavigationWidgetFactory::aboutToShowContextMenu, &FolderNavigationWidgetFactory::aboutToShowContextMenu,
@@ -193,25 +190,18 @@ void TextEditorPluginPrivate::extensionsInitialized()
} }
}); });
connect(&settings, connect(&d->settings, &TextEditorSettings::fontSettingsChanged,
&TextEditorSettings::fontSettingsChanged, this, &TextEditorPlugin::updateSearchResultsFont);
this,
&TextEditorPluginPrivate::updateSearchResultsFont);
updateSearchResultsFont(TextEditorSettings::fontSettings()); updateSearchResultsFont(TextEditorSettings::fontSettings());
connect(TextEditorSettings::codeStyle(), &ICodeStylePreferences::currentTabSettingsChanged, connect(TextEditorSettings::codeStyle(), &ICodeStylePreferences::currentTabSettingsChanged,
this, &TextEditorPluginPrivate::updateSearchResultsTabWidth); this, &TextEditorPlugin::updateSearchResultsTabWidth);
updateSearchResultsTabWidth(TextEditorSettings::codeStyle()->currentTabSettings()); updateSearchResultsTabWidth(TextEditorSettings::codeStyle()->currentTabSettings());
connect(ExternalToolManager::instance(), &ExternalToolManager::replaceSelectionRequested, connect(ExternalToolManager::instance(), &ExternalToolManager::replaceSelectionRequested,
this, &TextEditorPluginPrivate::updateCurrentSelection); this, &TextEditorPlugin::updateCurrentSelection);
}
void TextEditorPlugin::extensionsInitialized()
{
d->extensionsInitialized();
MacroExpander *expander = Utils::globalMacroExpander(); MacroExpander *expander = Utils::globalMacroExpander();
@@ -276,7 +266,7 @@ ExtensionSystem::IPlugin::ShutdownFlag TextEditorPlugin::aboutToShutdown()
return SynchronousShutdown; return SynchronousShutdown;
} }
void TextEditorPluginPrivate::updateSearchResultsFont(const FontSettings &settings) void TextEditorPlugin::updateSearchResultsFont(const FontSettings &settings)
{ {
if (auto window = SearchResultWindow::instance()) { if (auto window = SearchResultWindow::instance()) {
const Format textFormat = settings.formatFor(C_TEXT); const Format textFormat = settings.formatFor(C_TEXT);
@@ -304,13 +294,13 @@ void TextEditorPluginPrivate::updateSearchResultsFont(const FontSettings &settin
} }
} }
void TextEditorPluginPrivate::updateSearchResultsTabWidth(const TabSettings &tabSettings) void TextEditorPlugin::updateSearchResultsTabWidth(const TabSettings &tabSettings)
{ {
if (auto window = SearchResultWindow::instance()) if (auto window = SearchResultWindow::instance())
window->setTabWidth(tabSettings.m_tabSize); window->setTabWidth(tabSettings.m_tabSize);
} }
void TextEditorPluginPrivate::updateCurrentSelection(const QString &text) void TextEditorPlugin::updateCurrentSelection(const QString &text)
{ {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) { if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) {
const int pos = editor->position(); const int pos = editor->position();
@@ -330,7 +320,7 @@ void TextEditorPluginPrivate::updateCurrentSelection(const QString &text)
} }
} }
void TextEditorPluginPrivate::createStandardContextMenu() void TextEditorPlugin::createStandardContextMenu()
{ {
ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_STANDARDCONTEXTMENU); ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_STANDARDCONTEXTMENU);
contextMenu->appendGroup(Constants::G_UNDOREDO); contextMenu->appendGroup(Constants::G_UNDOREDO);