From 0e531fa4537cda01423e3dc93baf64ab031191dc Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 29 Jan 2024 16:44:21 +0100 Subject: [PATCH] Meson: Use setup function for MesonActionsManager Remove the now-empty MesonProjectPluginPrivate. Change-Id: I58d9d9338a2ad96d574daa407e35cf8f26843719 Reviewed-by: Jarek Kobus --- .../mesonactionsmanager.cpp | 28 ++++++++++++++++--- .../mesonprojectmanager/mesonactionsmanager.h | 27 ++---------------- .../mesonprojectplugin.cpp | 20 ++----------- 3 files changed, 29 insertions(+), 46 deletions(-) diff --git a/src/plugins/mesonprojectmanager/mesonactionsmanager.cpp b/src/plugins/mesonprojectmanager/mesonactionsmanager.cpp index 221199470ee..5d04cddfcb2 100644 --- a/src/plugins/mesonprojectmanager/mesonactionsmanager.cpp +++ b/src/plugins/mesonprojectmanager/mesonactionsmanager.cpp @@ -17,8 +17,24 @@ #include -namespace MesonProjectManager { -namespace Internal { +namespace MesonProjectManager::Internal { + +class MesonActionsManager : public QObject +{ +public: + MesonActionsManager(); + + Utils::Action buildTargetContextAction{ + Tr::tr("Build"), + Tr::tr("Build \"%1\""), + Utils::Action::AlwaysEnabled /*handled manually*/ + }; + QAction configureActionMenu; + QAction configureActionContextMenu; + + void configureCurrentProject(); + void updateContextActions(); +}; MesonActionsManager::MesonActionsManager() : configureActionMenu(Tr::tr("Configure")) @@ -93,5 +109,9 @@ void MesonActionsManager::updateContextActions() buildTargetContextAction.setVisible(targetNode); } -} // namespace Internal -} // namespace MesonProjectManager +void setupMesonActions() +{ + static MesonActionsManager theMesonActionsManager; +} + +} // MesonProjectManager::Internal diff --git a/src/plugins/mesonprojectmanager/mesonactionsmanager.h b/src/plugins/mesonprojectmanager/mesonactionsmanager.h index 81c3df9fbb5..25842ee19e8 100644 --- a/src/plugins/mesonprojectmanager/mesonactionsmanager.h +++ b/src/plugins/mesonprojectmanager/mesonactionsmanager.h @@ -3,29 +3,8 @@ #pragma once -#include +namespace MesonProjectManager::Internal { -#include +void setupMesonActions(); -namespace MesonProjectManager { -namespace Internal { - -class MesonActionsManager : public QObject -{ - Q_OBJECT - Utils::Action buildTargetContextAction{ - QCoreApplication::translate("QtC::MesonProjectManager", "Build"), - QCoreApplication::translate("QtC::MesonProjectManager", "Build \"%1\""), - Utils::Action::AlwaysEnabled /*handled manually*/ - }; - QAction configureActionMenu; - QAction configureActionContextMenu; - void configureCurrentProject(); - void updateContextActions(); - -public: - MesonActionsManager(); -}; - -} // namespace Internal -} // namespace MesonProjectManager +} // Internal::MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp b/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp index 423a38eddb3..7c33685b609 100644 --- a/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp +++ b/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp @@ -12,7 +12,6 @@ #include -#include #include #include @@ -22,28 +21,13 @@ using namespace Utils; namespace MesonProjectManager::Internal { -class MesonProjectPluginPrivate -{ -public: - MesonActionsManager m_actions; -}; - class MesonProjectPlugin final : public ExtensionSystem::IPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "MesonProjectManager.json") -public: - ~MesonProjectPlugin() final - { - delete d; - } - -private: void initialize() final { - d = new MesonProjectPluginPrivate; - setupToolsSettingsPage(); setupToolsSettingsAccessor(); @@ -54,13 +38,13 @@ private: setupMesonRunConfiguration(); setupMesonRunAndDebugWorkers(); + setupMesonActions(); + ProjectManager::registerProjectType(Constants::Project::MIMETYPE); FileIconProvider::registerIconOverlayForFilename(Constants::Icons::MESON, "meson.build"); FileIconProvider::registerIconOverlayForFilename(Constants::Icons::MESON, "meson_options.txt"); } - - class MesonProjectPluginPrivate *d = nullptr; }; } // MesonProjectManager::Internal