WingHexExplorer2/TestPlugin/testplugin.h

83 lines
3.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*==============================================================================
** Copyright (C) 2024-2027 WingSummer
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
** THE SOFTWARE.
** =============================================================================
*/
#ifndef TESTPLUGIN_H
#define TESTPLUGIN_H
#include "iwingplugin.h"
class TestPlugin final : public WingHex::IWingPlugin {
Q_OBJECT
// 可选:用于自定义插件唯一标帜,请不要随意取名,否则很可能会和其他插件冲突导致无法加载
// 如果不注明,则是插件的类名作为唯一标帜,所以也不要随意给插件类起名字
// 当然,你可以在构造函数中,使用 setProperty("puid", yourID) 来实现自定义
Q_PROPERTY(QString puid READ getPuid CONSTANT FINAL)
// 这两行是必须,只有后面的 "TestPlugin.json" 你根据需要修改,
// 具体可见 QT 文档,剩下直接 CV 大法
Q_PLUGIN_METADATA(IID "com.wingsummer.iwingplugin" FILE "TestPlugin.json")
Q_INTERFACES(WingHex::IWingPlugin)
public:
explicit TestPlugin();
virtual ~TestPlugin();
// IWingPlugin interface (必须)
public:
virtual int sdkVersion() const override;
virtual const QString signature() const override;
virtual bool init(const std::unique_ptr<QSettings> &set) override;
virtual void unload(std::unique_ptr<QSettings> &set) override;
virtual const QString pluginName() const override;
virtual const QString pluginAuthor() const override;
virtual uint pluginVersion() const override;
virtual const QString pluginComment() const override;
// IWingPlugin interface (可选)
public:
// 有关注册开头register 开头)的函数,插件系统不保证有且只调用一次
// 所以最好不要为了偷懒,在实现里面 new 和做相应操作
virtual QList<WingHex::WingDockWidgetInfo>
registeredDockWidgets() const override;
virtual QMenu *registeredHexContextMenu() const override;
virtual QList<WingHex::WingRibbonToolBoxInfo>
registeredRibbonTools() const override;
virtual QHash<WingHex::SettingPage *, bool>
registeredSettingPages() const override;
virtual QList<WingHex::PluginPage *> registeredPages() const override;
virtual QList<WingHex::WingEditorViewWidget *>
registeredEditorViewWidgets() const override;
virtual QHash<QString, ScriptFnInfo> registeredScriptFn() override;
private:
QString getPuid() const;
private:
QDialog *_tform = nullptr;
QMenu *_tmenu = nullptr;
const QString puid;
QList<WingHex::WingRibbonToolBoxInfo> _rtbinfo;
};
#endif // TESTPLUGIN_H