TextEditor: Use new setup pattern for BookmarkView

Change-Id: I934f1bd6cb3889c4199176cf8d15beaee805f86c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2024-01-17 15:21:25 +01:00
parent b7d646644d
commit c8bb7897f5
3 changed files with 22 additions and 28 deletions

View File

@@ -1010,19 +1010,29 @@ BookmarkManager &bookmarkManager()
// BookmarkViewFactory
BookmarkViewFactory::BookmarkViewFactory()
class BookmarkViewFactory final : public INavigationWidgetFactory
{
public:
BookmarkViewFactory()
{
setDisplayName(Tr::tr("Bookmarks"));
setPriority(300);
setId("Bookmarks");
setActivationSequence(QKeySequence(useMacShortcuts ? Tr::tr("Alt+Meta+M") : Tr::tr("Alt+M")));
}
}
NavigationView BookmarkViewFactory::createWidget()
{
private:
NavigationView createWidget() final
{
auto view = new BookmarkView;
view->setActivationMode(Utils::DoubleClickActivation); // QUESTION: is this useful ?
return {view, view->createToolBarWidgets()};
}
};
void setupBookmarkView()
{
static BookmarkViewFactory theBookmarkViewFactory;
}
} // TextEditor::Internal

View File

@@ -116,14 +116,6 @@ private:
BookmarkManager &bookmarkManager();
void setupBookmarkManager(QObject *guard);
class BookmarkViewFactory : public Core::INavigationWidgetFactory
{
public:
BookmarkViewFactory();
private:
Core::NavigationView createWidget() override;
};
void setupBookmarkView();
} // Bookmarks::Internal

View File

@@ -83,7 +83,6 @@ public:
void createStandardContextMenu();
BookmarkFilter m_bookmarkFilter;
BookmarkViewFactory m_bookmarkViewFactory;
TextEditorSettings settings;
@@ -136,24 +135,16 @@ void TextEditorPluginPrivate::requestContextMenu(TextEditorWidget *widget,
bookmarkManager().requestContextMenu(widget->textDocument()->filePath(), lineNumber, menu);
}
static class TextEditorPlugin *m_instance = nullptr;
class TextEditorPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TextEditor.json")
public:
TextEditorPlugin()
{
m_instance = this;
}
~TextEditorPlugin() final
{
delete d;
d = nullptr;
m_instance = nullptr;
}
ShutdownFlag aboutToShutdown() final;
@@ -178,6 +169,7 @@ void TextEditorPlugin::initialize()
setupLineNumberFilter(); // Goto line functionality for quick open
setupBookmarkManager(this);
setupBookmarkView();
d = new TextEditorPluginPrivate;