| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | 
|---|---|
| 2 | // | 
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later | 
| 4 | |
| 5 | #include "symbol.h" | 
| 6 | #include "mainframe/symbolkeeper.h" | 
| 7 | #include "mainframe/symboltreeview.h" | 
| 8 | #include "common/common.h" | 
| 9 | #include "base/abstractmenu.h" | 
| 10 | #include "base/abstractaction.h" | 
| 11 | #include "base/abstractcentral.h" | 
| 12 | #include "base/abstractwidget.h" | 
| 13 | #include "services/window/windowservice.h" | 
| 14 | #include "services/symbol/symbolservice.h" | 
| 15 | |
| 16 | #include <QProcess> | 
| 17 | #include <QAction> | 
| 18 | #include <QLabel> | 
| 19 | #include <QTreeView> | 
| 20 | |
| 21 | using namespace dpfservice; | 
| 22 | void Symbol::initialize() | 
| 23 | { | 
| 24 | QProcess process; | 
| 25 | process.start( "pip3 show esprima"); | 
| 26 | process.waitForFinished(); | 
| 27 | |
| 28 | QString output = process.readAllStandardOutput(); | 
| 29 | if(output.isEmpty()) { | 
| 30 | process.start( "pip3 install esprima"); | 
| 31 | process.waitForFinished(); | 
| 32 | } | 
| 33 | } | 
| 34 | |
| 35 | bool Symbol::start() | 
| 36 | { | 
| 37 | auto &ctx = dpfInstance.serviceContext(); | 
| 38 | WindowService *windowService = ctx.service<WindowService>(WindowService::name()); | 
| 39 | if (windowService) { | 
| 40 | if (windowService->addWidgetWorkspace) { | 
| 41 | auto view = new AbstractWidget(SymbolKeeper::instance()->treeView()); | 
| 42 | windowService->addWidgetWorkspace(MWCWT_SYMBOL, view); | 
| 43 | } | 
| 44 | } | 
| 45 | return true; | 
| 46 | } | 
| 47 | |
| 48 | dpf::Plugin::ShutdownFlag Symbol::stop() | 
| 49 | { | 
| 50 | return Sync; | 
| 51 | } | 
| 52 | 
