1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "reversedebugplugin.h" |
6 | #include "base/abstractmenu.h" |
7 | #include "base/abstractwidget.h" |
8 | #include "services/window/windowservice.h" |
9 | #include "common/actionmanager/actionmanager.h" |
10 | #include "reversedebuggermgr.h" |
11 | |
12 | #include <QMenu> |
13 | |
14 | using namespace dpfservice; |
15 | using namespace ReverseDebugger::Internal; |
16 | |
17 | void ReverseDebugPlugin::initialize() |
18 | { |
19 | } |
20 | |
21 | bool ReverseDebugPlugin::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 | auto actionInit = [&](QAction *action, QString actionID, QKeySequence key, QString iconFileName){ |
31 | ActionManager::getInstance()->registerAction(action, actionID, action->text(), key, iconFileName); |
32 | AbstractAction *actionImpl = new AbstractAction(action); |
33 | windowService->addAction(dpfservice::MWM_TOOLS, actionImpl); |
34 | }; |
35 | |
36 | auto reverseDbgAction = new QAction(tr("Reverse debug" )); |
37 | QMenu * = new QMenu(); |
38 | reverseDbgAction->setMenu(menu); |
39 | actionInit(reverseDbgAction, "Tool.Reverse" , {}, "" ); |
40 | |
41 | auto recoredAction = new QAction(tr("Record" )); |
42 | auto replayAction = new QAction(tr("Replay" )); |
43 | |
44 | menu->addAction(recoredAction); |
45 | menu->addAction(replayAction); |
46 | |
47 | reverseDebug = new ReverseDebuggerMgr(this); |
48 | connect(recoredAction, &QAction::triggered, reverseDebug, &ReverseDebuggerMgr::recored); |
49 | connect(replayAction, &QAction::triggered, reverseDebug, &ReverseDebuggerMgr::replay); |
50 | |
51 | windowService->addContextWidget(tr("R&everse Debug" ), new AbstractWidget(reverseDebug->getWidget()), "Reverse" ); |
52 | |
53 | return true; |
54 | } |
55 | |
56 | dpf::Plugin::ShutdownFlag ReverseDebugPlugin::stop() |
57 | { |
58 | return Sync; |
59 | } |
60 | |