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::BookmarkViewFactory() class BookmarkViewFactory final : public INavigationWidgetFactory
{ {
setDisplayName(Tr::tr("Bookmarks")); public:
setPriority(300); BookmarkViewFactory()
setId("Bookmarks"); {
setActivationSequence(QKeySequence(useMacShortcuts ? Tr::tr("Alt+Meta+M") : Tr::tr("Alt+M"))); 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()
{ {
auto view = new BookmarkView; static BookmarkViewFactory theBookmarkViewFactory;
view->setActivationMode(Utils::DoubleClickActivation); // QUESTION: is this useful ?
return {view, view->createToolBarWidgets()};
} }
} // TextEditor::Internal } // TextEditor::Internal

View File

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

View File

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