1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "codeportingplugin.h"
6#include "codeportingmanager.h"
7#include "configwidget.h"
8#include "base/abstractmenu.h"
9#include "base/abstractwidget.h"
10#include "services/window/windowservice.h"
11#include "common/actionmanager/actionmanager.h"
12
13#include <QMenu>
14
15using namespace dpfservice;
16
17void CodePortingPlugin::initialize()
18{
19}
20
21bool CodePortingPlugin::start()
22{
23 auto &ctx = dpfInstance.serviceContext();
24 windowService = ctx.service<WindowService>(WindowService::name());
25 if (!windowService) {
26 qCritical() << "Failed, can't found window service";
27 abort();
28 }
29
30 // Add code porting item in tool menu.
31 QAction *action = new QAction(tr("Code Porting"));
32 ActionManager::getInstance()->registerAction(action, "Tool.CodePorting", action->text(),QKeySequence(),
33 ":/codeporting/images/code_port.png");
34 connect(action, &QAction::triggered, CodePortingManager::instance(), &CodePortingManager::slotShowConfigWidget);
35
36 AbstractAction *actionImpl = new AbstractAction(action);
37 windowService->addAction(MWM_TOOLS, actionImpl);
38
39 // Add output pane
40 windowService->addContextWidget(tr("C&ode Porting"), new AbstractWidget(CodePortingManager::instance()->getOutputPane()), "Porting");
41
42 // Add report pane
43 windowService->addContextWidget(tr("Porting &Report"), new AbstractWidget(CodePortingManager::instance()->getReportPane()), "Porting");
44
45 return true;
46}
47
48dpf::Plugin::ShutdownFlag CodePortingPlugin::stop()
49{
50 return Sync;
51}
52