From 505bb25c0ed75c03800a6fd6e6dfb6850c29235e Mon Sep 17 00:00:00 2001 From: zinface Date: Tue, 25 Apr 2023 23:50:37 +0800 Subject: [PATCH] =?UTF-8?q?cmake-plugin:=20=E8=B0=83=E6=95=B4=20external-p?= =?UTF-8?q?lugin=20=E6=8F=92=E4=BB=B6=E9=80=82=E9=85=8D=E5=8F=AF=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E5=AE=8F=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin/external-plugin/CMakeLists.txt | 8 ++++++++ src/plugin/external-plugin/plugin.cpp | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/plugin/external-plugin/CMakeLists.txt b/src/plugin/external-plugin/CMakeLists.txt index a6dc471..a3110ad 100644 --- a/src/plugin/external-plugin/CMakeLists.txt +++ b/src/plugin/external-plugin/CMakeLists.txt @@ -7,6 +7,9 @@ # external-plugin -> your plugin name set(LOCAL_PLUGIN_NAME "external-plugin") +set(LOCAL_PLUGIN_VERSION "0.1") + +configure_file(${CMAKE_SOURCE_DIR}/cmake/modules/config.h.in plugin-config.h @ONLY) # external-plugin 核心构建 # 在模块化构建中,这个部分代表着构建 external-plugin 插件 @@ -55,6 +58,11 @@ endif(TRUE) # ----------------- external-plugin 构建宏支持相关 ----------------- # +target_compile_definitions(${LOCAL_PLUGIN_NAME} + # 构建插件时,自动引入的插件配置 + PRIVATE + NOTEPAD_PLUGIN_DECLARE_PLUGIN_CONFIG) + if(WIN32 AND NOTEPAD_BUILD_BY_SHARED) # 在 Windows 中构建时,需要关注此库的构建形式,QScintilla 应该以何种方式编译 target_compile_definitions(${LOCAL_PLUGIN_NAME} diff --git a/src/plugin/external-plugin/plugin.cpp b/src/plugin/external-plugin/plugin.cpp index d672d69..853dc3c 100644 --- a/src/plugin/external-plugin/plugin.cpp +++ b/src/plugin/external-plugin/plugin.cpp @@ -6,6 +6,20 @@ #include "ndd_plugin_implement.h" -NOTEPAD_PLUGIN_METADATA_IDENTIFY_V1(u8"外部插件扩展测试", "0.1", "zinface", u8"基于 QMainWindow Ui 的插件", ""); +NOTEPAD_PLUGIN_METADATA_IDENTIFY_1 { + USE_IDENTIFY_VARIABLES -NOTEPAD_PLUGIN_METADATA_IMPLEMENT_V1(NddPluginImplement, false); + NOTEPAD_PLUGIN_METADATA(u8"外部插件扩展测试", PLUGIN_VERSION, "zinface", u8"基于 QMainWindow Ui 的插件", "") + + return true; +} + +NOTEPAD_PLUGIN_METADATA_IMPLEMENT_1 { + USE_IMPLEMENT_VARIABLES + + auto imp = new NddPluginImplement(s_pNotepad, s_getCurEdit()); + imp->setCurrentEditFunc(s_getCurEdit); + imp->setMenuActions(s_pProcData.m_rootMenu); + + return 0; +}