1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "recentreceiver.h"
6#include "common/common.h"
7
8RecentReceiver::RecentReceiver(QObject *parent)
9 : dpf::EventHandler (parent)
10 , dpf::AutoEventHandlerRegister<RecentReceiver> ()
11{
12
13}
14
15dpf::EventHandler::Type RecentReceiver::type()
16{
17 return dpf::EventHandler::Type::Sync;
18}
19
20QStringList RecentReceiver::topics()
21{
22 return { recent.topic };
23}
24
25void RecentReceiver::eventProcess(const dpf::Event &event)
26{
27 if (event.data() == recent.saveOpenedProject.name) {
28 QString kitName = event.property(recent.saveOpenedProject.pKeys[0]).toString();
29 QString language = event.property(recent.saveOpenedProject.pKeys[1]).toString();
30 QString workspace = event.property(recent.saveOpenedProject.pKeys[2]).toString();
31 if (QDir(workspace).exists())
32 RecentProxy::instance()->saveOpenedProject(kitName, language, workspace);
33 } else if (event.data() == recent.saveOpenedFile.name) {
34 QString filePath = event.property(recent.saveOpenedFile.pKeys[0]).toString();
35 if (QFileInfo(filePath).exists())
36 RecentProxy::instance()->saveOpenedFile(filePath);
37 }
38}
39
40RecentProxy *RecentProxy::instance()
41{
42 static RecentProxy ins;
43 return &ins;
44}
45