CompilerExplorer: Inline compilerexplorerplugin.h

Makes adding unwanted functionality in this place harder.

Change-Id: I2b36414b4bf6a58deff3c565936d433ebcdc9d5f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-08-17 18:18:17 +02:00
parent c9a9dbc96b
commit 519a95ce5b
4 changed files with 32 additions and 54 deletions

View File

@@ -17,7 +17,6 @@ add_qtc_plugin(CompilerExplorer
compilerexploreraspects.cpp compilerexploreraspects.cpp
compilerexploreraspects.h compilerexploreraspects.h
compilerexplorerplugin.cpp compilerexplorerplugin.cpp
compilerexplorerplugin.h
compilerexplorertr.h compilerexplorertr.h
compilerexplorereditor.cpp compilerexplorereditor.cpp
compilerexplorereditor.h compilerexplorereditor.h

View File

@@ -30,7 +30,6 @@ QtcPlugin {
"compilerexploreroptions.cpp", "compilerexploreroptions.cpp",
"compilerexploreroptions.h", "compilerexploreroptions.h",
"compilerexplorerplugin.cpp", "compilerexplorerplugin.cpp",
"compilerexplorerplugin.h",
"compilerexplorersettings.cpp", "compilerexplorersettings.cpp",
"compilerexplorersettings.h", "compilerexplorersettings.h",
"compilerexplorertr.h", "compilerexplorertr.h",

View File

@@ -1,8 +1,6 @@
// Copyright (C) 2023 The Qt Company Ltd. // Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "compilerexplorerplugin.h"
#include "compilerexplorerconstants.h" #include "compilerexplorerconstants.h"
#include "compilerexplorereditor.h" #include "compilerexplorereditor.h"
#include "compilerexplorersettings.h" #include "compilerexplorersettings.h"
@@ -18,39 +16,45 @@
#include <QMenu> #include <QMenu>
namespace CompilerExplorer { #include <extensionsystem/iplugin.h>
namespace Internal {
CompilerExplorerPlugin::CompilerExplorerPlugin() {} using namespace Core;
CompilerExplorerPlugin::~CompilerExplorerPlugin() {} namespace CompilerExplorer::Internal {
void CompilerExplorerPlugin::initialize() class CompilerExplorerPlugin : public ExtensionSystem::IPlugin
{ {
static CompilerExplorer::EditorFactory ceEditorFactory; Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CompilerExplorer.json")
auto action = new QAction(Tr::tr("Open Compiler Explorer"), this); public:
connect(action, &QAction::triggered, this, [] { CompilerExplorerPlugin();
CompilerExplorer::Settings settings; ~CompilerExplorerPlugin() override;
const QString src = settings.source(); void initialize() override
QString name("Compiler Explorer"); {
Core::EditorManager::openEditorWithContents(Constants::CE_EDITOR_ID, &name, src.toUtf8()); static CompilerExplorer::EditorFactory ceEditorFactory;
});
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); auto action = new QAction(Tr::tr("Open Compiler Explorer"), this);
Core::ActionContainer *mCompilerExplorer = Core::ActionManager::createMenu( connect(action, &QAction::triggered, this, [] {
"Tools.CompilerExplorer"); CompilerExplorer::Settings settings;
QMenu *menu = mCompilerExplorer->menu();
menu->setTitle(Tr::tr("Compiler Explorer"));
mtools->addMenu(mCompilerExplorer);
Core::Command *cmd const QString src = settings.source();
= Core::ActionManager::registerAction(action, "CompilerExplorer.CompilerExplorerAction"); QString name("Compiler Explorer");
mCompilerExplorer->addAction(cmd); EditorManager::openEditorWithContents(Constants::CE_EDITOR_ID, &name, src.toUtf8());
} });
void CompilerExplorerPlugin::extensionsInitialized() {} ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mCompilerExplorer = ActionManager::createMenu("Tools.CompilerExplorer");
QMenu *menu = mCompilerExplorer->menu();
menu->setTitle(Tr::tr("Compiler Explorer"));
mtools->addMenu(mCompilerExplorer);
} // namespace Internal Command *cmd = ActionManager::registerAction(action, "CompilerExplorer.CompilerExplorerAction");
} // namespace CompilerExplorer mCompilerExplorer->addAction(cmd);
}
};
} // CompilerExplorer::Internl
#include "compilerexplorerplugin.moc"

View File

@@ -1,24 +0,0 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <extensionsystem/iplugin.h>
namespace CompilerExplorer::Internal {
class CompilerExplorerPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CompilerExplorer.json")
public:
CompilerExplorerPlugin();
~CompilerExplorerPlugin() override;
void initialize() override;
void extensionsInitialized() override;
};
} // namespace CompilerExplorer::Internal