2022-11-18 23:47:32 +00:00
|
|
|
|
#ifndef APPCORE_H
|
|
|
|
|
#define APPCORE_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <libConfig.h>
|
2022-11-22 03:42:48 +00:00
|
|
|
|
#include <libParse.h>
|
|
|
|
|
#include <libProjectManager.h>
|
|
|
|
|
|
2022-11-22 04:00:53 +00:00
|
|
|
|
class MainWindow;
|
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
|
namespace MakeTools {
|
|
|
|
|
class StoryTool;
|
|
|
|
|
class SensitiveCore;
|
|
|
|
|
}
|
2022-11-18 23:47:32 +00:00
|
|
|
|
|
|
|
|
|
namespace Core {
|
2022-11-25 01:18:54 +00:00
|
|
|
|
class Extension;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
class AppCore;
|
2022-11-18 23:47:32 +00:00
|
|
|
|
|
|
|
|
|
enum class Scale
|
|
|
|
|
{
|
|
|
|
|
Global,
|
|
|
|
|
Project,
|
|
|
|
|
File,
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-25 01:26:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 功能拓展生成入口
|
|
|
|
|
*/
|
2022-11-25 07:30:33 +00:00
|
|
|
|
class ExtensionFactory
|
|
|
|
|
{
|
2022-11-22 03:42:48 +00:00
|
|
|
|
public:
|
2022-11-25 01:18:54 +00:00
|
|
|
|
virtual ~ExtensionFactory() = default;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 生成新插件内容实例
|
|
|
|
|
* @param core
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-11-25 01:18:54 +00:00
|
|
|
|
virtual Extension* newInstance(AppCore *core) = 0;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 获取所有指定的配置端口类型
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
virtual QList<Core::Scale> configs() const = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief getPanel 获取配置面板,配置内容
|
|
|
|
|
* @param config
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
virtual QWidget* getNewPanel(Config::Configration* config) = 0;
|
|
|
|
|
|
2022-11-25 07:30:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 拓展插件名称
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-11-22 03:42:48 +00:00
|
|
|
|
virtual QString extensionName() const = 0;
|
2022-11-25 01:18:54 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-11-25 01:26:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 功能拓展基类
|
|
|
|
|
*/
|
2022-11-25 01:18:54 +00:00
|
|
|
|
class Extension
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~Extension() = default;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 获取唯一的关联工厂类
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
virtual ExtensionFactory* factory() const = 0;
|
|
|
|
|
|
2022-11-25 07:30:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 通过后缀名设置处理模式
|
|
|
|
|
* @param suffix
|
|
|
|
|
*/
|
|
|
|
|
virtual void resetProcsType(const QString &suffix) = 0;
|
|
|
|
|
|
2022-11-25 01:18:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 载入指定的配置端口实例
|
|
|
|
|
* @param configs
|
|
|
|
|
*/
|
2022-11-29 03:47:12 +00:00
|
|
|
|
virtual void reloadConfigrations(QList<Config::Configration*> configs) = 0;
|
2022-11-25 01:18:54 +00:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-25 01:26:52 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief 文件相关功能拓展
|
|
|
|
|
*/
|
2022-11-25 01:18:54 +00:00
|
|
|
|
class FileExtensionFactory : public ExtensionFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~FileExtensionFactory() = default;
|
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 可以处理的文件类型
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2022-11-25 01:32:42 +00:00
|
|
|
|
virtual QList<QString> suffixPeers() const = 0;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AppCore : public QObject
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-11-22 04:00:53 +00:00
|
|
|
|
AppCore(MainWindow *win, QObject *parent = nullptr);
|
2022-11-18 23:47:32 +00:00
|
|
|
|
virtual ~AppCore() = default;
|
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
|
void save();
|
|
|
|
|
|
|
|
|
|
Config::Configration * globalConfig() const;
|
|
|
|
|
|
|
|
|
|
void setCurrentProject(Project::ProjectManager *project);
|
|
|
|
|
Project::ProjectManager* currentProject() const;
|
2022-11-18 23:47:32 +00:00
|
|
|
|
QList<Config::Configration*> getConfigs(QList<Scale> types) const;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
Parse::Result::ParseCore * parseCore() const;
|
|
|
|
|
|
|
|
|
|
QList<Core::FileExtensionFactory*> extensions(const QString &suffix = QString()) const;
|
|
|
|
|
|
|
|
|
|
MakeTools::StoryTool *getMake_tool() const;
|
|
|
|
|
|
|
|
|
|
MakeTools::SensitiveCore *getFramework() const;
|
|
|
|
|
|
2022-11-22 04:00:53 +00:00
|
|
|
|
|
|
|
|
|
void openTextDocument(const QString &src, const QString &name);
|
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
|
private:
|
2022-11-29 03:47:12 +00:00
|
|
|
|
MainWindow *const views_holder;
|
2022-11-22 03:42:48 +00:00
|
|
|
|
Config::Configration *const global_config;
|
|
|
|
|
Project::ProjectManager * current_project;
|
|
|
|
|
QList<Core::FileExtensionFactory*> extensions_list;
|
|
|
|
|
Parse::Result::ParseCore *const parse_core;
|
2022-11-18 23:47:32 +00:00
|
|
|
|
|
2022-11-22 03:42:48 +00:00
|
|
|
|
MakeTools::StoryTool *const make_tool;
|
|
|
|
|
MakeTools::SensitiveCore *const framework;
|
2022-11-18 23:47:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // APPCORE_H
|