1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "core.h"
6#include "mainframe/windowkeeper.h"
7#include "mainframe/windowtheme.h"
8#include "services/window/windowservice.h"
9
10#include <framework/framework.h>
11#include "common/common.h"
12
13#include <QStatusBar>
14#include <QApplication>
15#include <QMainWindow>
16#include <QMenuBar>
17#include <QFileDialog>
18
19using namespace dpfservice;
20
21void Core::initialize()
22{
23 qInfo() << Q_FUNC_INFO;
24 QString errStr;
25
26 // 发布窗口服务
27 auto &ctx = dpfInstance.serviceContext();
28 if (!ctx.load(WindowService::name(), &errStr)) {
29 qCritical() << errStr;
30 abort();
31 }
32}
33
34bool Core::start()
35{
36 qInfo() << "set Application Theme";
37 qInfo() << __FUNCTION__;
38 auto &ctx = dpfInstance.serviceContext();
39 WindowService *windowService = ctx.service<WindowService>(WindowService::name());
40
41 if (windowService) {
42 using namespace std::placeholders;
43
44 if (!windowService->addOpenProjectAction) {
45 windowService->addOpenProjectAction = std::bind(&WindowKeeper::addOpenProjectAction,
46 WindowKeeper::instace(), _1, _2);
47 }
48 }
49
50 WindowKeeper::instace();
51 WindowTheme::setTheme(":/dark.css");
52
53 QObject::connect(&dpf::Listener::instance(), &dpf::Listener::pluginsStarted, [=] {
54 ActionManager::getInstance()->readUserSetting();
55 navigation.doSwitch(MWNA_RECENT);
56 });
57
58 return true;
59}
60
61dpf::Plugin::ShutdownFlag Core::stop()
62{
63 delete WindowKeeper::instace();
64 return Sync;
65}
66