File indexing completed on 2024-12-15 04:01:20

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 #include <QObject>
0009 #include <QSet>
0010 #include <QString>
0011 #include <QAction>
0012 #include <QIcon>
0013 
0014 #include "app/settings/setting.hpp"
0015 
0016 namespace glaxnimate::plugin {
0017 
0018 class PluginScript
0019 {
0020     Q_GADGET
0021 public:
0022     QString module;
0023     QString function;
0024     app::settings::SettingList settings;
0025 
0026     bool valid() const
0027     {
0028         return !module.isEmpty() && !function.isEmpty();
0029     }
0030 };
0031 
0032 enum class ServiceType
0033 {
0034     Action,
0035     IoFormat,
0036 };
0037 
0038 
0039 class Plugin;
0040 
0041 class PluginService : public QObject
0042 {
0043 public:
0044     virtual ~PluginService() = default;
0045 
0046     virtual ServiceType type() const = 0;
0047     virtual QString name() const = 0;
0048     virtual void enable() = 0;
0049     virtual void disable() = 0;
0050     virtual QIcon service_icon() const = 0;
0051 
0052     Plugin* plugin() const { return owner; }
0053     void set_plugin(Plugin* plugin) { owner = plugin; }
0054 
0055 private:
0056     Plugin* owner = nullptr;
0057 };
0058 
0059 } // namespace glaxnimate::plugin