CompilerExplorer: Use ActionBuilder

Change-Id: Id5692fdec9194482f0276274d5d772a00eb1994c
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-12-13 16:45:31 +01:00
parent 7b4c531f69
commit 348ac80f4a

View File

@@ -23,6 +23,7 @@
#include <QMenu> #include <QMenu>
using namespace Core; using namespace Core;
using namespace Utils;
namespace CompilerExplorer::Internal { namespace CompilerExplorer::Internal {
@@ -36,28 +37,27 @@ public:
{ {
static CompilerExplorer::EditorFactory ceEditorFactory; static CompilerExplorer::EditorFactory ceEditorFactory;
auto action = new QAction(Tr::tr("Open Compiler Explorer"), this); FileIconProvider::registerIconForMimeType(QIcon(":/compilerexplorer/logos/ce.ico"),
connect(action, &QAction::triggered, this, [] {
QString name("Compiler Explorer $");
Core::EditorManager::openEditorWithContents(Constants::CE_EDITOR_ID,
&name,
settings().defaultDocument().toUtf8());
});
Utils::FileIconProvider::registerIconForMimeType(QIcon(":/compilerexplorer/logos/ce.ico"),
"application/compiler-explorer"); "application/compiler-explorer");
ProjectExplorer::JsonWizardFactory::addWizardPath(":/compilerexplorer/wizard/"); ProjectExplorer::JsonWizardFactory::addWizardPath(":/compilerexplorer/wizard/");
const Id menuId = "Tools.CompilerExplorer";
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mCompilerExplorer = ActionManager::createMenu("Tools.CompilerExplorer"); ActionContainer *mCompilerExplorer = ActionManager::createMenu(menuId);
QMenu *menu = mCompilerExplorer->menu(); QMenu *menu = mCompilerExplorer->menu();
menu->setTitle(Tr::tr("Compiler Explorer")); menu->setTitle(Tr::tr("Compiler Explorer"));
mtools->addMenu(mCompilerExplorer); mtools->addMenu(mCompilerExplorer);
Command *cmd = ActionManager::registerAction(action, ActionBuilder openAction(this, "CompilerExplorer.CompilerExplorerAction");
"CompilerExplorer.CompilerExplorerAction"); openAction.setText(Tr::tr("Open Compiler Explorer"));
mCompilerExplorer->addAction(cmd); openAction.addToContainer(menuId);
openAction.addOnTriggered(this, [] {
QString name = "Compiler Explorer $";
Core::EditorManager::openEditorWithContents(Constants::CE_EDITOR_ID,
&name,
settings().defaultDocument().toUtf8());
});
} }
}; };