diff options
author | hjk <[email protected]> | 2023-11-10 15:23:16 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2023-11-13 07:48:43 +0000 |
commit | 65bb9e35052ab8dc10ddcfb331f847c156ff0c37 (patch) | |
tree | fc07e7b83a0cac063742e8527841a95ded28918e /src | |
parent | d74a85bbac5b488975960fc548d16fb7c545c011 (diff) |
Macros: Move plugin class definition to .cpp
Change-Id: I7ac41e64dd4b3b52876aaafd77218c330e220f67
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/macros/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/plugins/macros/macros.qbs | 1 | ||||
-rw-r--r-- | src/plugins/macros/macrosplugin.cpp | 114 | ||||
-rw-r--r-- | src/plugins/macros/macrosplugin.h | 26 |
4 files changed, 63 insertions, 80 deletions
diff --git a/src/plugins/macros/CMakeLists.txt b/src/plugins/macros/CMakeLists.txt index 564a602f542..fa611f17784 100644 --- a/src/plugins/macros/CMakeLists.txt +++ b/src/plugins/macros/CMakeLists.txt @@ -11,7 +11,7 @@ add_qtc_plugin(Macros macrooptionspage.cpp macrooptionspage.h macros.qrc macrosconstants.h - macrosplugin.cpp macrosplugin.h + macrosplugin.cpp macrotextfind.cpp macrotextfind.h macrostr.h texteditormacrohandler.cpp texteditormacrohandler.h diff --git a/src/plugins/macros/macros.qbs b/src/plugins/macros/macros.qbs index 66e92375a0b..45060f9032c 100644 --- a/src/plugins/macros/macros.qbs +++ b/src/plugins/macros/macros.qbs @@ -30,7 +30,6 @@ QtcPlugin { "macros.qrc", "macrosconstants.h", "macrosplugin.cpp", - "macrosplugin.h", "macrostr.h", "macrotextfind.cpp", "macrotextfind.h", diff --git a/src/plugins/macros/macrosplugin.cpp b/src/plugins/macros/macrosplugin.cpp index c87686fea3c..947c5151d3d 100644 --- a/src/plugins/macros/macrosplugin.cpp +++ b/src/plugins/macros/macrosplugin.cpp @@ -1,16 +1,12 @@ // Copyright (C) 2016 Nicolas Arnaud-Cormos // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include "macrosplugin.h" - #include "macrolocatorfilter.h" #include "macromanager.h" #include "macrooptionspage.h" #include "macrosconstants.h" #include "macrostr.h" -#include <texteditor/texteditorconstants.h> - #include <coreplugin/coreconstants.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actioncontainer.h> @@ -18,14 +14,17 @@ #include <coreplugin/icore.h> #include <coreplugin/icontext.h> +#include <extensionsystem/iplugin.h> + +#include <texteditor/texteditorconstants.h> + #include <QAction> #include <QKeySequence> #include <QMenu> -namespace Macros { -namespace Internal { +namespace Macros::Internal { -class MacrosPluginPrivate +class MacrosPluginPrivate final { public: MacroManager macroManager; @@ -33,50 +32,61 @@ public: MacroLocatorFilter locatorFilter; }; -MacrosPlugin::~MacrosPlugin() +class MacrosPlugin final : public ExtensionSystem::IPlugin { - delete d; -} + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Macros.json") -void MacrosPlugin::initialize() -{ - d = new MacrosPluginPrivate; - - Core::Context textContext(TextEditor::Constants::C_TEXTEDITOR); - - // Menus - Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); - Core::ActionContainer *mmacrotools = Core::ActionManager::createMenu(Constants::M_TOOLS_MACRO); - QMenu *menu = mmacrotools->menu(); - menu->setTitle(Tr::tr("Text Editing &Macros")); - menu->setEnabled(true); - mtools->addMenu(mmacrotools); - - QAction *startMacro = new QAction(Tr::tr("Record Macro"), this); - Core::Command *command = Core::ActionManager::registerAction(startMacro, Constants::START_MACRO, textContext); - command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Ctrl+[") : Tr::tr("Alt+["))); - mmacrotools->addAction(command); - connect(startMacro, &QAction::triggered, &d->macroManager, &MacroManager::startMacro); - - QAction *endMacro = new QAction(Tr::tr("Stop Recording Macro"), this); - endMacro->setEnabled(false); - command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO); - command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Ctrl+]") : Tr::tr("Alt+]"))); - mmacrotools->addAction(command); - connect(endMacro, &QAction::triggered, &d->macroManager, &MacroManager::endMacro); - - QAction *executeLastMacro = new QAction(Tr::tr("Play Last Macro"), this); - command = Core::ActionManager::registerAction(executeLastMacro, Constants::EXECUTE_LAST_MACRO, textContext); - command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+R") : Tr::tr("Alt+R"))); - mmacrotools->addAction(command); - connect(executeLastMacro, &QAction::triggered, &d->macroManager, &MacroManager::executeLastMacro); - - QAction *saveLastMacro = new QAction(Tr::tr("Save Last Macro"), this); - saveLastMacro->setEnabled(false); - command = Core::ActionManager::registerAction(saveLastMacro, Constants::SAVE_LAST_MACRO, textContext); - mmacrotools->addAction(command); - connect(saveLastMacro, &QAction::triggered, &d->macroManager, &MacroManager::saveLastMacro); -} - -} // Internal -} // Macros +public: + ~MacrosPlugin() final + { + delete d; + } + + void initialize() final + { + d = new MacrosPluginPrivate; + + Core::Context textContext(TextEditor::Constants::C_TEXTEDITOR); + + // Menus + Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); + Core::ActionContainer *mmacrotools = Core::ActionManager::createMenu(Constants::M_TOOLS_MACRO); + QMenu *menu = mmacrotools->menu(); + menu->setTitle(Tr::tr("Text Editing &Macros")); + menu->setEnabled(true); + mtools->addMenu(mmacrotools); + + QAction *startMacro = new QAction(Tr::tr("Record Macro"), this); + Core::Command *command = Core::ActionManager::registerAction(startMacro, Constants::START_MACRO, textContext); + command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Ctrl+[") : Tr::tr("Alt+["))); + mmacrotools->addAction(command); + connect(startMacro, &QAction::triggered, &d->macroManager, &MacroManager::startMacro); + + QAction *endMacro = new QAction(Tr::tr("Stop Recording Macro"), this); + endMacro->setEnabled(false); + command = Core::ActionManager::registerAction(endMacro, Constants::END_MACRO); + command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Ctrl+]") : Tr::tr("Alt+]"))); + mmacrotools->addAction(command); + connect(endMacro, &QAction::triggered, &d->macroManager, &MacroManager::endMacro); + + QAction *executeLastMacro = new QAction(Tr::tr("Play Last Macro"), this); + command = Core::ActionManager::registerAction(executeLastMacro, Constants::EXECUTE_LAST_MACRO, textContext); + command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? Tr::tr("Meta+R") : Tr::tr("Alt+R"))); + mmacrotools->addAction(command); + connect(executeLastMacro, &QAction::triggered, &d->macroManager, &MacroManager::executeLastMacro); + + QAction *saveLastMacro = new QAction(Tr::tr("Save Last Macro"), this); + saveLastMacro->setEnabled(false); + command = Core::ActionManager::registerAction(saveLastMacro, Constants::SAVE_LAST_MACRO, textContext); + mmacrotools->addAction(command); + connect(saveLastMacro, &QAction::triggered, &d->macroManager, &MacroManager::saveLastMacro); + } + +private: + MacrosPluginPrivate *d = nullptr; +}; + +} // Macros::Internal + +#include "macrosplugin.moc" diff --git a/src/plugins/macros/macrosplugin.h b/src/plugins/macros/macrosplugin.h deleted file mode 100644 index da7daf3ec60..00000000000 --- a/src/plugins/macros/macrosplugin.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 Nicolas Arnaud-Cormos -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <extensionsystem/iplugin.h> - -namespace Macros { -namespace Internal { - -class MacrosPlugin final : public ExtensionSystem::IPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Macros.json") - -public: - ~MacrosPlugin() final; - - void initialize() final; - -private: - class MacrosPluginPrivate *d = nullptr; -}; - -} // namespace Internal -} // namespace Macros |